Wiki: Hole Specific Tips

This page contains spoilers!

You might have more fun figuring out some of these tricks yourself.

I tried to catalogue only the "open secrets" that tend to come up on Discord.

12 Days of Christmas
  • The reason Lisp is so short is it has English formatting for numbers built-in (like Twelve).
  • You'll have to compress the text to win in many languages.
  • You don't have to skip the first argument if it's -- in your language: that's a perfectly fine brainfuck program producing no output.
  • If your language has eval, that's probably the way to go.
Catalan's Constant
  • 1/1 − 1/3² + 1/5² − 1/7² + 1/9² … converges so slowly that it's useless for this problem.
  • You'll have to look around the internet for a faster approach (or do a lot of math) :)
  • You can try a "zero-based" instead of "one-based" procedure instead: modify the formula so that instead of 10 → 5 → 16 → 8 → 4 → 2 → 1 you compute 9 → 4 → 15 → 7 → 3 → 1 → 0 (everything offset down by one). The stopping times are the same, but the loop bounds and halt check might be shorter.
Emirp Numbers
  • There are only 36 numbers to print, so hardcoding them might work.
CSS Colors
  • args is always a complete permutation of all possible inputs.
  • So you can use arg => sorted(args).index(arg) as a perfect hash function.
  • This trick applies to a few more holes on the site...
Evil Numbers, Odious Numbers
  • Always exactly one of {2n, 2n+1} is evil (and the other is odious), so you can hardcode 25 bits.
  • OK, here are some bigger spoilers.
  • There is something shorter than t=a;a=b;b+=t; (you can avoid a temp variable in any language).
Happy Numbers
  • There are only 32 numbers to print, and they all fit in a byte, so you can try a "hardcode" approach.
  • − 10a − 9b − 8c − … − 2i (mod 11) is just a + 2b + 3c + … + 9i (mod 11).
Niven Numbers
  • There is a shorter formula for two-digit numbers, that also happens to work for 100.
Pernicious Numbers
  • Forget primality: you only have to worry about popcount = 2, 3, or 5.
  • In other words, popcount ≠ 1 (mod 3).
  • There is a really short magic formula, using a bitwise operator.
Prime Numbers
  • In some compiled langs you can (sadly) read the source file from /tmp/
λ, π, τ…
  • If your language has bignums, then usually you want to compute floor(10^1000 * π) and then print that but with a decimal point squeezed in.
  • See primo's answer to a question about how to calculate Conway's constant.