Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#Ruby 196#

Ruby 196

#Ruby 196#

Ruby 196

edited body
Source Link
Level River St
  • 28.8k
  • 4
  • 40
  • 112

Finally, to comply with the random requirement, the pattern can be shifted diagonally by a random number 0..98 so there are 9 possible boards that can be generated.

Finally, to comply with the random requirement, the pattern can be shifted diagonally by a random number 0..9 so there are 9 possible boards that can be generated.

Finally, to comply with the random requirement, the pattern can be shifted diagonally by a random number 0..8 so there are 9 possible boards that can be generated.

added 198 characters in body
Source Link
Level River St
  • 28.8k
  • 4
  • 40
  • 112

The astute will have noticed that we cannot simply write a 2-digit number across each tile, because the edges will not match. What is needed is a sequence of (at least) 255 digits where all combinations are unique. From this we can pick a pair of digits (e.g. 1 and 2) for the first tile , then follow naturally on to the next, where the last number of one tile becomes the first of the next (e.g. 2 and 3).

I use a sequence containing just the hexadecimal digits 0-9A-F because the hexadecimal number representation is more golfable than some other arbitrary base. Therefore I need a 256 digit sequence where every one of the possible 2-digit combinations appears exactly once. Such a sequence is known as a De Bruijn sequence.

The astute will have noticed that we cannot simply write a 2-digit number across each tile, because the edges will not match. What is needed is a sequence of (at least) 255 digits where all combinations are unique. I use a sequence containing just the hexadecimal digits 0-9A-F because the hexadecimal number representation is more golfable than some other arbitrary base. Therefore I need a 256 digit sequence where every one of the possible 2-digit combinations appears exactly once. Such a sequence is known as a De Bruijn sequence.

The astute will have noticed that we cannot simply write a 2-digit number across each tile, because the edges will not match. What is needed is a sequence of (at least) 255 digits where all combinations are unique. From this we can pick a pair of digits (e.g. 1 and 2) for the first tile , then follow naturally on to the next, where the last number of one tile becomes the first of the next (e.g. 2 and 3).

I use a sequence containing just the hexadecimal digits 0-9A-F because the hexadecimal number representation is more golfable than some other arbitrary base. Therefore I need a 256 digit sequence where every one of the possible 2-digit combinations appears exactly once. Such a sequence is known as a De Bruijn sequence.

Source Link
Level River St
  • 28.8k
  • 4
  • 40
  • 112
Loading

AltStyle によって変換されたページ (->オリジナル) /