Pyth, Dennis, ≤ 8Pyth, Dennis, ≤ 8
V./Tp*FN
Damn that was fun - the hardest part was figuring out how to do it short enough in Pyth.
Analysis
The 1234
at the start hints that we're probably dealing with a list of numbers, printed without a separator. Let's try and split the numbers up in a way that makes sense:
1 2 3 4 4 6 5 8 8 9 6 12 10 12 7 16 16 18 12 15 16 8 24 20 24 14 27 18 20 9 32 32 36 24 30 32 16 36 21 24 25 10
There's a few hints that we're on the right track:
- All numbers have prime factors less than 10
- A lot of numbers are pretty close to their index in the list
However, there are a few peculiarities. The number at index 23 is 24, and is the only case where the number at the index is greater than the index itself. However, the bigger clue is that some numbers are clearly smaller than their neighbours, particularly the 7 at index 15, the 8 at index 22 and the 9 at index 30.
Noting that this forms a 7-8-9 pattern, we can also see that the last number is a 10 at index 42. Given @Dennis' recent question on abelian groups, a quick check on OEIS reveals that 15, 22, 30, 42
is a subsequence of the partition numbers. Pyth has a builtin for partitions, which gives us two of eight characters: ./
But note that the last number is 10, which is suspicious because 10 is a preinitialised variable in Pyth, as T
. ./T
gives a full list of the 42 partitions of the number 10, which looks like it might come in handy.
Now the printing is done without a separator, so this hints at a use of p
. Perhaps we loop through each partition, do something to it, then print with p
? This gives us the following template:
V./Tp??N
where V
is a for loop which loops over an iterable, storing each element in the variable N
.
A quick look at the second last partition (5, 5)
should make it obvious that we want to take a product. The naive way to reduce a list by multiplication is
u*GHd1
where d
is the list in question. However, this is far too long.
Unfortunately, this is where I had to pull out a brute forcer. I haven't kept up with Pyth for a while, so I didn't know many of the newer features. There were only two characters left, which looked entirely doable.
The brute forcer then returned:
V./Tp*FN
where *F
is fold by *
(multiplication). No wonder I didn't find it in my search - I was looking up the keyword "reduce" rather than "fold"!