Description
The original code does the following:
CG Convert "abcdefghijklmnopqrstuvwxyz" from base 256 to integer, yielding
156490583352162063278528710879425690470022892627113539022649722.
^3y21 Compute 3^(2 * 21).
% Calculate the modulus.
Since 156490583352162063278528710879425690470022892627113539022649722 - 58227066 gives 156490583352162063278528710879425690470022892627113538964422656, which equals 226 × 3 × 7 × 7477 × 381524422711 × 17007550201751761 × 2288745700077000184147, the desired output can be obtained by replacing ^3y21
with something that evaluates to a divisor of this product and is larger than 58227066.
The ^
in the original code suggests that we might use it to calculate a power of 2, the 3 that we could calculate a fitting divisor of the form 3 × 2n.
Both are misleading. Solutions with a Levenshtein distance of 3 (%CG^2 26
, %CG^y2 13
, %CG^4y13
) or 4 (%CG.<3y13
) are readily found, but the solution at distance 2 requires a different approach.
The lowercase alphabet (G
) has 26 letters, so its power set (the set of all strictly increasing sequences of lowercase letters) has 226 elements. By replacing y2
with yG
, we compute this power set.
We can retrieve the set's length by replacing 3
with l
, which leaves us with ^lyG1
, i.e., 226 raised to the first power.
Code
%CG^lyG1
Note that this will only work on a computer with enough available memory (roughly 6.43 GiB, according to time
), so it will not work with the online interpreter.
Here's how you can verify the results from the command line:
$ \time -v pyth -c '%CG^lyG1'
58227066
Command being timed: "pyth/pyth.py -c %CG^lyG1"
User time (seconds): 30.73
System time (seconds): 2.12
Percent of CPU this job got: 100%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:32.85
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 6742564
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 2269338
Voluntary context switches: 1
Involuntary context switches: 58
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0