Skip to main content

Timeline for Crazy 8s Code Golf

Current License: CC BY-SA 4.0

10 events
when toggle format what by license comment
Feb 10, 2019 at 17:05 history edited 640KB CC BY-SA 4.0
Formatting, remove commentary
Feb 6, 2019 at 13:42 comment added 640KB @JonathanFrech, that's it. I'll update the comment to make it more clear. Thanks for your suggestions!
Feb 6, 2019 at 13:41 history edited 640KB CC BY-SA 4.0
better clarifiy comment
Feb 5, 2019 at 23:39 comment added Jonathan Frech I would think it works like Subtract one from x. If x was less than or equal to 58, subtract a further ten from it., no?
Feb 5, 2019 at 23:19 history edited 640KB CC BY-SA 4.0
added 44 characters in body
Feb 5, 2019 at 23:13 comment added Jonathan Frech I think I know roughly what the Elvis operator does, I just think your comment is misleading.
Feb 5, 2019 at 23:02 comment added 640KB The ternary is just a shortcut to doing it. Basically $x > 58 evaluates to 1, and so we either subtract that or 11 from $x. In the case where it's higher, it's offset by the ASCII values in the rand() statement being one higher. You can see that this generates a uniformly random (as uniform as PHP's rand() is capable of) distribution: tio.run/…
Feb 5, 2019 at 22:53 comment added 640KB @JonathanFrech in other words we want a number that's between 33-47 or 58-127. So we pick a number that's 58 minus the size of the lower range. If the number is below 58 it's just translated down to the lower range by subtracting the difference. Because of course we can't display numbers (ASCII char 48-57)
Feb 5, 2019 at 22:49 comment added Jonathan Frech Yes, my mistake. Regarding $x-= $x > 58 ?: 11; // subtract 11, if x is less than 58 -- could you elaborate?
Feb 5, 2019 at 22:34 history answered 640KB CC BY-SA 4.0