Skip to content

Instantly share code, notes, and snippets.

Created August 25, 2017 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/08cd1a2d18e636af29d3c7682ede480b to your computer and use it in GitHub Desktop.
Save anonymous/08cd1a2d18e636af29d3c7682ede480b to your computer and use it in GitHub Desktop.
Goal column is the target sum - length of code / what the digits have to add up to.
After generating the first ten primes for that goal, "origLen" column is how many bytes it takes to print them.
The other columns are repeating digit patterns - how short does that text get, if you string-replace that repeating pattern with one char?
e.g. for the goal of 5, printing the primes takes 38 chars.
There's no way to shrink that text below 5 by hitting any of those repeating patterns, so all the rows are - for no answer.
by 71 characters, printing the primes takes 95 characters.
- Replacing the pattern 999 with one char brings it down to 63 characters.
Now it's lower than the goal, you can embed this in the code with (8) spare bytes for the unpack code.
- The best option is 73 characters, where replacing 89999 makes the most room for unpacking code (10) spare bytes.
goal origLen 99 999 9999 8999 89999 99998
---- ------- -- --- ---- ---- ----- -----
4 45 - - - - - -
5 38 - - - - - -
7 35 - - - - - -
8 36 - - - - - -
10 36 - - - - - -
11 36 - - - - - -
13 38 - - - - - -
14 38 - - - - - -
16 37 - - - - - -
17 38 - - - - - -
19 39 - - - - - -
20 39 - - - - - -
22 43 - - - - - -
23 45 - - - - - -
25 48 - - - - - -
26 49 - - - - - -
28 49 - - - - - -
29 49 - - - - - -
31 49 - - - - - -
32 54 - - - - - -
34 59 - - - - - -
35 58 - - - - - -
37 59 - - - - - -
38 59 - - - - - -
40 59 - - - - - -
41 59 - - - - - -
43 65 - - - - - -
44 67 - - - - - -
46 69 - - - - - -
47 69 - - - - - -
49 69 - - - - - -
50 69 - - - - - -
52 76 - - - - - -
53 78 - - - - - -
55 79 - - - - - -
56 79 - - - - - -
58 79 - - - - - -
59 79 - - - - - -
61 85 - - - - - -
62 88 - - - - - -
64 89 - - - - - -
65 89 - 65 (0) - - - -
67 89 - - - - - -
68 89 - - - - - -
70 99 - - - - - -
71 95 68 (3) 63 (8) 71 (0) 71 (0) - -
73 99 - 71 (2) 69 (4) 72 (1) 63 (10) -
74 99 - 73 (1) - - - -
76 99 75 (1) - 75 (1) - - -
77 99 72 (5) 75 (2) 75 (2) - - -
79 106 78 (1) 76 (3) 76 (3) - 78 (1) -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment