« first day (2841 days earlier)      last day (2004 days later) » 

12:37 AM
I've got a linux question:
when I type ls -al */* it doesn't show dotfiles in subdirectories
why?
 
12:48 AM
Because the shell expands the glob, so it's too late for ls's -a flag to affect anything.
 
oh! So if I were to manually debug ls, I'd see a bunch of parameters after the -al (one for each file in the subdirectories?)
 
1:48 AM
@Dennis Doesn't bash not include dotfiles in globs by default?
Or am I misunderstanding how GLOBIGNORE works
 
You have to set it to something, as an empty GLOBIGNORE uses the default behavior of ignoring all dotfiles. But yes, GLOBIGNORE=: would also have done the job.
 
How would you tell it to ignore nothing then?
oh, ignore me
 
shopt -s dotglob also works, but GLOBIGNORE is useful in other cases as well.
 
0
Q: Spelling Bee Acceptable

NoLongerBreathedInThis is similar to this question. However, I have a different goal in mind: Reduce the wordlist to words that could appear. The easy part is to delete hyphens and similar. The hard part, however: Remove words containing more than seven letters. So, the problem: Given a set of words containing o...

 
2:30 AM
I heard people wanted another MtG question
 
I might. What's an MtG question?
 
Magic the Gathering. Should show up in a second
 
0
Q: Magic: The Gathering, Paying for Spells

VeskahPremise: In Magic: the Gathering, you cast spells by paying their mana cost by tapping lands for the required amount. These lands can produce one of the five colors which are: White (W) Blue (U) Black (B) Red (R) Green (G) The cost is made up of two parts: a number which is the generic ma...

 
There she be
 
2 minutes? That is magic.
 
2:34 AM
Shout out if you see anything obviously janky but I think I covered most bases
 
Great question, at first I thought I could do this in less than 10 bytes but then multitype lands happened
 
Figured I'd give it a twist
 
3:15 AM
I've been playing OverTheWire Wargames. It's a series of security-based challenges where you ssh into a server and try to get the next password.
I highly recommend it if you're interested
 
How far'd ya get?
 
Well, still moving through them. Started today, on bandit11
learning a ton about linux :)
 
 
3 hours later…
6:07 AM
0
Q: Tips for golfing in Scratch

Silas ReelScratch is a visual programming language. For the sake of counting bytes, Scratch is usually written in scratchblocks2 syntax. Post tips that specifically apply to Scratch.

 
 
1 hour later…
7:35 AM
0
A: Sandbox for Proposed Challenges

Vedant KandoiAlginment This is similar to the alignment used in word. Task 3 inputs: A 1 line string, a positive integer k, and direction (left or middle or right) Your job is to insert new lines(\n) and spaces in the string as required by the direction. Rules k is the number of characters on a single l...

 
8:23 AM
0
Q: Tips for golfing in Dart

ElcanDart is an object oriented programming language borrowing from both Java and Javascript. What general tips do you have for golfing in Dart? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Dart (e.g. "remove comments" is not an answ...

 
9:21 AM
0
A: Sandbox for Proposed Challenges

Peter Taylorfloating-point logic-gates atomic-code-golf Toy floating point coprocessor: ceil Summary: implement the ceiling function for 16-bit IEEE 754 floating point numbers in logic gates, using as few gates as you can. 16-bit IEEE 754 floating point For a more detailed description, see Wikipedia:Half...

 
 
1 hour later…
10:45 AM
hi all
 
 
1 hour later…
12:10 PM
1
Q: Through Space and Time

Kevin CruijssenIntroduction: In general we usually speak of four dimensions: three space dimensions for x, y, and z; and one time dimension. For the sake of this challenge however, we'll split the time dimension into three as well: past, present, and future. Input: Two input-lists. One containing integer x,y...

 
 
2 hours later…
1:46 PM
> In general, you mortals usually speak of four dimensions
ftfy
 
Guys are answers in this format allowed, usually they need to be a full function, no?
 
that does look like a snippet
yeah, while I'm not an expert at C#, I think that you do need some sort of boilerplate to make a full program too
 
I commented on it
 
@LiefdeWen yeah that needs to be put in a lambda
it's actually shorter to put it in a lambda
because return$"{a} {b} {c} {c*c}" is shorter than Console.Write("{a} {b} {c} {c*c}") Also with the latter he'd technically also need to include the byte count of using System;
 
2:32 PM
hi all.. can anyone help me improve codegolf.stackexchange.com/questions/175548/… please
 
Hmm.. computing a set of n random unique integers such that the sum of the set is equal to n^2 is uh.. kinda tricky
 
@Skidsdev well.. it may be tricky but I hope its interesting too
 
2:54 PM
@Anush We'll see :P Once I've collected a few examples I'll post it on the sandbox
 
@Skidsdev cool
I need upvotes too :)
 
My current solution is very bruteforcey. Fill a set with n random unique integers, check if their sum is equal to n^2, if not discard and try again. It's gunna get very slow very fast
it can handle n=5 in about 0.5 secs
but I think n=15 might time out
it's random though, so in theory even n=4000 has a chance of getting it right first try
 
@Skidsdev n random integers in what range, precisely? Because it'd definitely be "tricky" if you had to get 5 random unique integers that sum to 25 in the range [0..100000], for instance.
 
@J.Sallé [0..n]
 
Ah that's more feasible.
 
3:07 PM
so n=1 has a 50/50 chance of being right each time
cos it'll either be a 0 or a 1, and a 1 is right
oh sorry
the range is [0..n^2]
 
@Skidsdev I am not sure if you are solving the right problem. You have to check if g(A) is all distinct
 
otherwise n=2 would be impossible
 
@Skidsdev are you computing g(A)?
 
@Anush Oh sorry this isn't for your sandbox post :P This is one I'm working on
 
it is just in need of some love
 
3:09 PM
oh yeah so it isn't
I'll give it a shot after I finish this sandbox post
although I'm not good at fastest-code challenges because my go-to languages are C#, PHP and JS
none of which are known for their speed
fastest-code challenges tend to be dominated by Rust and sometimes C from what I've seen, neither of which I know
 
@Skidsdev sure but in this case any entry at all wins :)
 
Like I said, I'll give it a shot once I've finished trying to compute some n=10 example answers :P
 
@Skidsdev by the way, as long as it's guaranteed that the program will terminate eventually, it doesn't matter if it takes millenia to reach a solution
 
@J.Sallé right, but I need some of the answers so I can have examples in the post
 
Mine's still computing for n=10 for the past like 3 minutes >.>
 
3:12 PM
I'm doing mine in TIO so 60s is my cutoff
surprisingly it can handle n=8 in about 2 secs
CUrrently configured to do a single run of n=8 and output the result
 
Mine's gone to n=10 without issues now
Bigger ns seem to return at least one zero in the solutions
 
Are you using the same method as me? Generate a set of random integers, keep doing so until the sum is correct?
 
probably a coincidence though, but for n=4 onwards all the solutions contain a zero
@Skidsdev yes
 
I feel like with a static n this would also make an interesting fastest-code challenge
@J.Sallé I got [4, 7, 13, 5, 2, 14, 6, 20, 10] for n=9
 
Indeed
@Skidsdev got these for n=2..9 on my latest run
 
3:19 PM
huh, your n=9 didn't contian a 0 either, but all your others above 4 did
 
Yeah as I said, it's probably a coincidence
It might be easier to find the sum with n-1 numbers for larger ns since 0 is basically a no-op here
 
I could make the range [1..n^2] instead
 
Might be better, not sure though
 
I did one n=1 and then 3 of each n=2..5 and the whole thing only took 1.4s, that's with min value being 1
hmm, the max value doesn't need to be n^2 either, because except for n=1, none of the values can be n^2, otherwise all the others would need to be 0
 
I'll adjust my code and check it
 
3:25 PM
realistically the highest value you can use is n^2 - sum([1..n-1])
 
I was about to say that. I think limiting to (n^2)/2 might also work
Although that wouldn't work for n=2 I guess
 
Yeah it'd also need to be rounded up else the range for n=1 would be [1..0.5]
I think leaving the max value at n^2 is fine, if participants find that lowering that range to something else reduces byte count without reducing possible numbers, then they can do that
but realistically having a max range of n^2 as opposed to n^2-1 or n^2 - sum([1..n-1]) won't affect your output, just your speed
hmm.. are there n possible solutions? n=1 has 1, n=2 has 2... how many does n=3 have?
oh more than 3
oh that could be another challenge
given integer n, what is the count of unique sets x such that each set contains unique integers in range [1..n^2] and sum(x) == n^2?
So from this one idea of "Generate random arrays with constraints", I've got 3 possible challenges. This one, one for calculating the number of permutations, and one for fastest-code :D
 
0
A: Sandbox for Proposed Challenges

SkidsdevArbitrary Randomness Randomness is fun. Challenges with no point are fun. Write a function that, given integer input n, will output exactly n random unique integers between 1 and n^2 (inclusive) such that the sum of all integers is equal to n^2 Randomness does not have to be uniform, provided ...

 
I'm done reasoning with irrational angry people.
@Quintec There has been no insult or rant at all. The previous comment is an observation. "And yes, if 5 people with over 1k rep cannot understand the question, it is a good sign that it is unclear.)" Perhaps, as to those users only. What do you say as to the users who have comprehended and answered the question? Are you open to clarifying each part of the question, or are you fixed at "I have no idea what it is supposed to mean"? — guest271314 4 mins ago
(Maybe I'm the one acting irrationally here. If I am then I apologize. But someone else needs to resolve this.)
 
3:42 PM
@Quintec 4 other people voted to close it, and another replied to the meta post agreeing with you. I also agree with you. Guy's being completely irrational
I will also forever know that post as the "Not impossible" post now
How is [tag:fastest-code] usually scored? Is it that the challenge creator runs each entry on their local machine (or some common machine) and times them?

I imagine you can't have the participants time their own code as hardware varies...
 
That would be a fastest-computer challenge.
 
@Skidsdev usually people post the specs of the hardware the codes will be run on
"people" as in whoever's issuing the challenge
and run them on their own machines
 
@J.Sallé gotcha, I'll do that then. Thankfuly I have a moderately beefy machine.
I suppose knowing the specs ahead of time would allow entrants to optimize for that too. For example multithreading better for a CPU with a lot of cores
 
Indeed
 
brb, going to write up a challenge that runs on a 386 with a 387 co-processor and wait for people to optimize for that. ;-)
 
3:52 PM
haha
 
@AdmBorkBork inb4 someone machine-codes the heck out of your challenge
 
I wonder if I should list things like GPU and SSD speed just in case somebody tries to utilize that
@J.Sallé Do you think n=50 is a large enough n for a fastest-code version of the challenge?
 
@Skidsdev well judging by the fact that it took like 10 minutes to get a solution for n=10 by bruteforcing, I'd say yes
 
What was your tester written in?
 
APL
It's interpreted in C though, so it's probably comparable
 
4:01 PM
Ah fair enough
Do you think maybe n=50 is too big?
that's 50 random integers between 1 and 2500, where the sum of the set must equal 2500. Gunna take a while bruteforcing
but also if I make it too small and somebody finds a non-bruteforce solution that could trivialize it
 
@Skidsdev That's the main issue, I think
 
I'm putting it in the sandbox first anyway, so I'll leave it at n=50 for now see what people think, maybe up it or lower it. Frankly I'm not sure if there is a non-bruteforce solution
 
Should probably ask for the opinion of the mathemathicians here, I'm bad with set theory and the like
 
Yeah good idea
 
@Skidsdev Instead of measuring the time for n=50, you could measure the highest n that finishes in a minute.
 
4:05 PM
Oooh that's a good idea
would that still constitute fastest-code?
 
Yes.
Tie breaker would be time consumed for that n.
 
Awesome, I think I'll do that then. Realistically even a non-bruteforce answer should still take longer for larger n
 
I believe that would also work nicely in TIO, right?
 
Oh plus if it's "how fast can you do it in under 60s" I can use TIO
Dennis has an ulterior motive ;)
 
TIO should never be used to time things.
 
4:07 PM
oh wait hold on I'm not sure we can do largest n in under 1 minute
 
Or any shared server, for that matter.
 
the bruteforce solution at least has very variable compute times
it could get it right in 2 tries, it could take 2 million
 
Is it non-deterministic? You could forbid that.
 
I think that's precisely why you could do it like that
 
in theory any program that can fill an array with n random integers in under 60s could do it in one go
@J.Sallé but then how do you determine whether the program can do it in under 60s?
in theory even n=2 could take hours if it doesn't get [3, 1] or [1, 3]
 
4:10 PM
To make matters worse, TIO has multiple servers. While they're identical on paper, speed varies wildly.
 
@Skidsdev that would discourage brute-forcing, is what I meant
 
Yeah I probably wouldn't use TIO, it's too unreliable for timing. I'd do it locally
 
Although that gets us back to the "is it possible to do it without bruteforcing" problem
 
@J.Sallé ah okay. So should I say the program must be able to do it in under 60s every time? What if there isn't a non-bruteforce solution
yeah
I think it should stay in sandbox until I can consult one of PPCG's mathheads
ALso, for both the fastest-code and the code-golf challenges, what are your thoughts on the clause of "Random doesn't mean uniformly random, just that each valid value has a non-zero chance of being selected"? IIRC thats the standard PPCG definition of "Random", but I'm not sure if it just allows potentially cheesing the solution
 
@Skidsdev yeah, that is the standard, and yeah, it can make cheesing the solution much easier
That said, if the solution is "cheesable", I'd say kudos to whoever figures it out
 
4:16 PM
It's kinda required to be able to use, e.g., rand()%17 (or worse, rand()%17) in C.
Which shouldn't be done in production, sure, but is probably good enough for code golf.
 
ALso with a random range of [1..n^2], and "all valid values must have a non-zero chance of being selected", what about values that are in the range, but can't possibly be part of a valid answer? Such as 15 when n=4?
anything higher than 10 would be an invalid value for n=4
 
@Skidsdev I'd say that's where the whole "figuring out how to cheese this" shebang will be focused.
 
My point is, if those values can never appear in a correct answer, are they invalid values and thus exempt from "all valid values must have non-zero chance", despite being within the required range for randomness?
I imagine determining whether their code can select those number but will always discard them is a non-observable criterion
 
Yeah that's most likely non-observable
I was wondering if removing the range entirely would be a bad thing. I mean, "given n, return n positive integers that sum to n^2" sounds good enough?
 
@J.Sallé hmm maybe
for fastest-code people would likely implement a range anyway to improve speed
 
4:24 PM
Yeah exactly
 
Hmm. would the code-golf version be a duplicate of this?
 
0
A: Sandbox for Proposed Challenges

SkidsdevArbitrary Randomness (Speed edition) fastest-code random Related Given integer n, calculate a set of n random unique integers in range 1..n^2 (inclusive) such that the sum of the set is equal to n^2 Random, in this case, does not necessarily mean uniformly random, just that each valid value ha...

 
in that one you take the desired sum as input, in mine the sum is n^2, other than that they're identical I think
oh and also that the range in that one is [0..1] and it expects float values
hmm and values don't need to be unique
 
@Skidsdev yeah I think it's different enough not to be dupe-hammered
 
Hmm yeah, maybe
 
4:28 PM
@NewSandboxedPosts Hm, no, that definition of randomness isn't good enough here. Start with an easily computable array that satisfies the constraints, then flip a coin. If heads, make a random modification to the set that doesn't alter the sum and flip another coin. If tails, output the solution.
 
@Dennis ah, okay. So uniform randomness for both challenges then? (if you haven't seen it, the code-golf version is the same problem, but just output a valid array given n)
 
Uniform over all possible solutions? That would work, I guess, for the fastest-code version.
 
only for the fastest-code version?
Do you think it'll be fine to allow that level of cheese for the code-golf version?
 
It would be fine for languages with a sufficiently potent PRNG library, but very difficult to achieve in others.
 
Ah right yeah, a lot of esolangs especially don't necessarily have uniform PRNG, do they?
I'll allow the cheese for the code-golf version then, but require uniform chance for each valid output for fastest-code
 
4:36 PM
Some don't have RNG at all
 
Well those wouldn't be valid languages to use. If you can't generate random numbers, you can't partake in a random number challenge :P
 
@Skidsdev And even if they do, you still have to de-bias it if it only returns an integer in a fixed range. Possible, but not really fun.
 
I'll leave em both in sandbox for a couple days, hopefully get some more feedback on it
 
5:11 PM
Any idea why this old challenge of mine is getting new answers these days? Has it been linked as related to a recent challenge maybe?
 
It could just be that one user answered it, which bumped it so other users saw it and then answered it too
 
Ah, I hadn't thought of that
 
5:32 PM
I blame mazzy
 
6:03 PM
Just saw a cool statistic, thought I'd share: (American) Football team Kansas City Chiefs has won the coin-flip (to decide who gets the ball first) in 12 consecutive games. Apparently the chances of that happening are less than .025%
 
But what are the odds that would happen to at least one team in all the years of games the NFL has had?
 
That's a good question
By the way, since 2001 (when the NFL began keeping stats on basically everything they didn't before then), the longest streak is 14 consecutive coin-flip wins.
 
6:21 PM
hardcoding answers is a standard loophole right?
 
Why doesn't var work for properties in C#, when the type is provided after new? Is there a workaround? public Dictionary<string, Dictionary<string, Object>> Groups = new Dictionary<string, Dictionary<string, Object>>(); doesn't look very good
 
@SpookClover Properties and fields are class members, they have to be explicitly typed. var can only be used on local variables.
See .NET Core error CS0825: "The contextual keyword 'var' may only appear within a local variable declaration or in script code"
 
@Skidsdev Yeah, I know. I'm asking if there is a more beautiful way than specifying the type 2 times?
 
Personally I don't initialize fields at their definition, but instead in the object's constructor
of course that makes static classes tricky
So I'd have public Dictionary<string, Dictionary<string, Object>> Groups;, then in the ctor I'd have this.Groups = new Dictionary<string, Dictionary<string, Object>>();
 
Looks a bit better, so might be a solution. I'm kinda disappointed there isn't a shorter way.
 
6:28 PM
Welcome to C#
the primary complaint about C# is that it's needlessly verbose
 
Something Java beats some language at :P
 
barely, but yes
 
That's the only longer thing I've seen in C# yet. Otherwise, I'm quite enjoying it.
 
personally I hate Java's @ tag things, whatever they're called, and the fact that you have to explicitly mention that a function throws an exception and then explicitly handle that exception
 
6:40 PM
@J.Sallé The NFL doesn't keep statistics like baseball does ... I remember watching a game a few years ago where they were commenting that the two starting pitchers combined had the longest last names of any two starting pitchers in the history of baseball.
It's like a) that's a weird statistic to keep track of, 2) that's kinda impressive, iii) who really cares
 
@Anush so, taking a crack at your array subarray challenge. I guess for each s-n combination, I have to keep generating new A's either in order or at random until I either find one that has distinct subarray sums, or until I've exhaused all possible arrays for that given s-n combination?
Wait I don't understand how s=3 is n=3. That would result in [1,2,3], but the subarrays of that include [1,2] and [3], which have duplicate sums
oh right, [2,3,1] doesn't have the contigious subarray [1,2] (or [2,1])
 
7:18 PM
@Quintec I find it interesting that you say that at the one thing Java beats C# at :p
@Skidsdev I usually leave the spamming of annotations to the IDE (intellij idea ftw); Javas Exceptions are for kind of often things & really should be handled immediately, you don't want your program crashing if a file doesn't exist, ever. If you want to not have to write throws & catches everywhere, (ab)use Error
 
7:39 PM
@dzaima Right, but in C# for example I might have an InvalidArgumentException in one of my functions, but in one instance of calling that function I might know for certain that my arguments are valid and won't throw, therefore I don't want to have to catch that exception anyway
 
@Skidsdev Javas IllegalArgumentException is a RuntimeError, which, like Error, doesn't force catching. One has to decide whether an error is catch-force worthy or not
and IMO illegal arguments usually should either be checked beforehand manually (as really one should never be often catching exceptions, as they are exceptions and signal of some state being wrong, whether its the file system or your program, and your program shouldn't ever be in a bad state), and never caught, except maybe for a prettyprinted error dialog for users
 
8:11 PM
Another Friday, another challenge :-)
 
2
Q: Draw this diamond pattern

AdmBorkBorkThe below pattern will form the basis of this challenge. /\ \/ /\ / \ / \ /\/ \/\ \/\ /\/ \ / \ / \/ /\ \/ Given an input width and height, each >=1, output the above ASCII art pattern repeated that many times, joining (and overlapp...

 
@NewMainPosts don't think canvas will beat charcoal
 
@dzaima Charcoal's not actually good at that
oh wait it's not as hard as a previous diamond pattern
 
oh huh it ended up shorter than i expected
 
8:40 PM
yay bug doesn't repeat the canvas if the input is bigger than the width
 
9:12 PM
0
A: Sandbox for Proposed Challenges

thisForcing a kernel panic from a mountaintop This is a thought resulting from a curious incident where C# code opening file apparently caused a BSOD. In the conclusion, it was due to a faulty driver, but from that a thought came up --- can one cause a kernel panic (or BSOD) using managed code exclu...

 
9:56 PM
CMC: "AAABBB" -> "ABABAB", "AAABBBCCC" -> "ABCABCABC"
 
@dzaima Excuse me, I prefer my ConcurrentSkipListMap<String, ConcurrentSkipListMap<String, Object>> Groups = new ConcurrentSkipListMap<String, ConcurrentSkipListMap<String, Object>>();
@Mendeleev More detail?
 
^
 
given a list of n elements each repeated m times (any order), return the array collated/interleaved
 
@Mendeleev so we have to figure out m by counting the consecutive runs of characters?
 
9:58 PM
:P
 
is 'AAABBBAAA' valid input? is 'AAAA'? is 'AAAABB'?
 
@dzaima no, the amount of each character has to match
so ABCABCABC is valid, AAAABBBB is valid, AABBBB is not
@DJMcMayhem funny
 
@Mendeleev is that a no to all 3?
 
Jelly, 3 bytes: ŒgZ
 
@dzaima second one is valid but the output is itself
 
10:01 PM
0
Q: What is the best alternative of decorators in python?

Iram ShahI use decorators, which are good but little bit tricky. Is there any alternative to decorators in python?

 
@DJMcMayhem beat me to it
(although, now that I think about it, the actual code shouldn't be much different)
 
@DJMcMayhem invalid, "1234432112344321" returns "1234321234321414" instead of "1234123412341234"
 
Ugh so we have to sort the data first?
 
Not really. I didn't write an answer in APL
 
Same joke though xd
 
10:03 PM
the added sorting should just be one byte in apl-likes
 
@Mendeleev I'm sorry but what now?
 
fixed, that was poorly worded
 
Actually, it would be 4 bytes in Dyalog, but 1 in dzaima and others :P
 
@Mendeleev dzaima/APL, 15 bytes
 
10:21 PM
Yeah, <⍵ and >⍵ are sorting in RAD, and I'm pretty sure the others have a one-byte solution for sorting
 
11:17 PM
0
Q: Dina's Paintings

xemphisDina loves most numbers. In fact, she loves every number that is not a multiple of n (she really hates the number n). For her friends’ birthdays this year, Dina has decided to draw each of them a sequence of n−1 flowers. Each of the flowers will contain between 1 and n−1 flower petals (inclusive)...

 

« first day (2841 days earlier)      last day (2004 days later) »