@MartinBüttner Might be wrong, but I think Mathematica or Matlab might make a killing with the normal question, with sqrt(2) * erf^-1(2*random() - 1) where erf is the error function
I dunno, I've taken the day off from Codemon. I'm not sure what you can get out of partials. The timeout thing is weird, though. Both you and Martin seem to have bots timing out randomly, but I haven't figured out why.
@Calvin'sHobbies (re terminating) well that's a shame... I would have had a somewhat nontrivial submission for you ;) (at least one with a score that isn't a power of 95)
@Peter, can you think of a simple wording (for the PRNG range) that would allow languages which don't have such a range (by generating multiple random numbers over a smaller range M and interpreting them as the digits of a base-M number)?
@MartinBüttner "If your available uniform RNG has a smaller range, you must either first build a uniform RNG with a sufficiently large range on top of the built-in one or you must implement your own suitable RNG using the seed. This page may be helpful for that."
///, 6634204313747905 > 958
From
string/.~~~~~/0
to
string/0 /.~
This relies on the program not being required to terminate. I started from a core-range of 958 much like the other solutions, from
string//
to
string//~~~~~~~~
However, in this case, // is not a comment. In...
@Lembik do you know about the Bloom filter? for k-mers it might be useful although the time limit is really tight to do more than 1 hash per strings or chars
Random Golf of the Day
code-golfrandom
Meta: I am running this as a little series of challenges revolving around the topic of randomness - in the form of a 9-hole golf course. I'm maintainingn a leaderboard across all challenges in the series, and offer a large bounty to the person competing in...
does that look good to go?
(@Peter ^)
@Doorknob can you let me know when/if Vim.SE goes public?
@Lembik > I don't yet understand why FUZxxl's new solution takes >6 minutes suffix array takes O(n), step 3 takes O(n*p) where p is the average common prefix of 2 neighbor suffix's
ah yeah, but I don't think I'll really contribute anyway, because I'm not using Vim at the moment... but I'd be interested in browsing a bit... I'm sure you've got some interesting content ;)
@MartinBüttner Hmm. There seems to be a disconnect between (effectively) "you must use a PRNG which can be seeded with S" and "If you do use the built-in RNG, you may also rely on its seeding functionality (if it has one)".
I think requiring a seed and reproducibility is reasonable. But it could be better worded to make it clear that the options are using a seedable built-in or implementing your own PRNG.
hm... I wonder... "you must implement your own suitable RNG using the seed" ... does that need a definition of how good the RNG must be to be "suitable"?
"random"
The term "random" means that you may:
Use your language's built-in random number generator,
Use /dev/random, or
Create a RNG that is equivalent to a standard RNG (such as the Mersenne Twister).
I could start an argument about the meaning of "external" now, but I'm not in the mood
(that being said "This post is meant to be a collection of "standard" definitions that may be assumed in every question, and do not need to be specified within the challenge.")
Oh good. I can remove the bit about explaining how to play Connect Four from my challenge because I can link to a "standard", "official" document explaining how to play.
Is is safe to assume that the official rules of Connect Four apply to Connect Four?
I'm perfectly capable of deciding whether my question is approachable. Whether people will decide to close it for arbitrary reasons is another question.
I don't know... I guess it's a fuzzy question of how much you can expect people to know. We obviously don't need to include the definition of "function" or "ASCII" or "array" in every question, because the target audience knows what you're talking about. Likewise, I doubt that the chess challenges need to outline the entire rules of chess... the few people who don't know chess probably won't enjoy the challenge much if they learn the rules just for that purpose anyway. and in that case including a link for the eventuality seems sufficient.
as for Connect 4, I couldn't tell you if most people know it or not.
I mean "The controller will send you X, and you will respond with Y. Then, it will send your opponent Z, and your opponent will respond with whatever comes after Z. Then [...]"
Connect 4 is very popular among middle school kids in France. I doubt many French people who studied enough to learn programming would need an explanation about it. But that might be different in other parts of the world.
All my challenge will say then is "I will give you the board state. You will respond with a column number. Then I will do the same for your opponent. This will continue until a player wins."
That seems simple no?
It cuts the size of my sandbox post in half if I don't try to reinvent the rules.
Like you said, as long as I/O is well defined, I don't see a problem with a link to the official rules. That said, it's mostly because the rules are so simple and clear (and well known). For something more obscure, technical, or complex, I'd expect at least a basic outline in the challenge itself. This is so that people have a rough grasp of the problem before heading out on a link. I don't think Connect Four has that problem.
You could also argue that since the rules are so simple and clear, it wouldn't be a burden to include them. Judgement call on the asker, but I wouldn't close it either way.
I don't think that something so subjective should be a determinant in whether the question is open or closed. If the rules are technical and complex, but they are at least complete, then downvote. You could, if you felt like it, figure it out on your own. You just don't want to. That's what downvotes exist for.
This attitude is empowering. It allows me, the author, to decide if I want to sacrifice readability to explain something.
@Lembik the example of a shape that can't be made can be narrowed by 4 units (exactly the same shape - just remove a 4 unit wide strip from the middle). That brings the shape down to a length of 40. Any further narrowing allows the shape to be unfolded.
I'm not aware of a shape shorter than 40 that cannot be unfolded, which means so far the first number for which I'm confident your sequence will diverge from OEIS is 40. My code runs out of memory on my machine at 17...
I don't have a proof that 40 is the shortest un-unfoldable shape - I'd like to hear from anyone who can either prove this or provide a counter-example
@randomra I believe that can be converted to other shapes. I don't have an immediate example but my code is taking a while on it so it doesn't look like it is isolated (or else it highlights another bug in my code...)
@randomra Anything under 40 will be great. I'm going to adjust the code so it can give the shapes reachable in one step rather than freezing up trying to look for everything. Then I can test any further suggestions plus @MartinBüttner's suggestion
About the Series
First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You can find the leaderboard along with some more information about the series in the first post.
Hol...
@randomra We can use the existing function neighbours(snake, excluded) to give the immediate neighbours (just leave excluded as () ). Using this, your example has 4 neighbours (reachable with a single bend)
@̡̺̟̹̙̹͎̹̪̟͚̒́͒̀̏ͥ̔̄̂͐ͧ̉ͤ̂ͤ́M̵̷̤͇̺̭̟̣̳͉̭͙̙͋ͧ̎̓̓̇ͭͮ̒̌̽̈̽̐̔̏̒̀̀̀͡â̴̖̺̬͚͇̩̅̈́͛́̒ͤ͌ͮ̌ͯ̈́ͤ͘͝r̢͔̟̦͎͙͔̭̞͕̟͈͈̻̲ͯ̐̈̾̄̒͊ͮt̷̷̜̲͎͚̙̟͕͖̝͙͖̜͉͇̄̀̿ͫ̒́͡͠ͅi̢̦̘̳̺̳͚̗͉̲͂́̐̀͊̅̎͝n̢̨̲̳͙̹̫̙̩̮̫̬ͦ̇ͪ͗̾ͥͭ̔̃̏ͫ͐ͦͯͮ͛͘͠ This works though, I think.
In other words:
for(s=0;s++<n;System.out.println(Math.sqrt(-2*Math.log(nextDouble()))*Math.cos(2*Math.PI*nextDouble()))); // HIS
for(;n-->0;System.out.println(Math.sqrt(-2*Math.log(nextDouble()))*Math.cos(2*Math.PI*nextDouble()))); // MINE
If I had to throw out a random guess I would say that you are probably right. But it might be worth understanding why to see if you can shave characters
> the algorithm you choose must yield a theoretically exact normal distribution (barring limitations of the underlying PRNG or limited-precision data types).
So I guess I'd say that chopping precision off (that's not due to the type limitations) wouldn't be kosher.
"Your implementation should use and return either floating-point numbers (at least 32 bits wide) or fixed-point numbers (at least 24 bits wide) and all arithmetic operations should make use of the full width of the chosen type."
should I include "constants" along with "operations"?
@Rainbolt I talked to Peter about this, and his suggestion was to just make sure people use the necessary precision instead of starting to analyse each output with higher-order statistical features of the result to make sure they really are normal distributions as N -> ∞.
It seems like less work for the challenge author to say "If I run you X times, your distribution must look like Y with Z percent tolerance." where Z is a function of X.
Y is a function, not a shape that you are following with your eyeballs
You know what a perfect distribution looks like. You know that their distribution looks like. How hard is it to produce a number that describes the difference?
anyway, I just went with Peter's suggestion here: chat.stackexchange.com/transcript/message/19901445#19901445 ... it seemed reasonable to me, and I'm not going to change it now. I might think about a different measure if I do a similar challenge again.
@Lembik yeah, looks like that might have worked. I'm not seeing how this would make the spec any clearer.
Charmaine recommended the following list of tests from the NIST suite for use on RANDOM.ORG:
Frequency Test: Monobit Frequency Test: Block Runs Test Test for the Longest Runs of Ones in a Block Binary Matrix Rank Test Discrete Fourier Transform (Spectral Test) Non-Overlapping Template Matching Test Overlapping Template Matching Test Maurer's Universal Statistical Test Linear Complexity Test Serial Test Approximate Entropy Test Cumulative Sums Test Random Excursions Test Random Excursions Variant Test
indeed, one day I was ordering Tea in a Cafe place, and when the guy asked if I wanted milk, I thought he meant more milk that normal, because I'm cultured and all, so I said "no thank you", and I got a Tea without milk
duly, I didn't explain the error, because I'm not like that, and I enjoyed a Tea without milk, and I have never looked back
except now I don't drink any hot beverages, because I don't drink anything except water with or without lemon
I wouldn't dream of putting anything into a lightly fermented Chinese tea, or even an oolong, but a builder's brew can be quite bitter without something to bind the tannins.