eval("(lalalalalalalalalalalalalalalalalalalalalalalalalalalalalalalalal("'[1 :37])mbmbmbmbmbmbmbmbmbmbmbmbmbmbmbmbmbmbmbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbm)]73: 1['"(lalalalalalalalalalalalalalalalalal("'[1 : : : : : : : : : : : : : : :37])mbdsdsdsdsds{u,inzp-+for*}<=2#eval("'"'[1 :3:3:3:3:3:3:3:3:3:3:3:3:3:3:37])mbds{s{s{s{s{s{s{s{s{s{s{s{s{s{s{s{s{s{s{sdsdbm)]73: 1['"'"(lave#2=<}*rof+-pzni,u{u{u{u{u{u{u{u{u{u{u{u{u{u{u{u{u{sdbmbmbmbmbmbmbmbmbmbmbmbmbmbmbm)]73: 1['"(l(l(l(l(l(l(l(l(l(l(l(l(l(l(l(l(l(l("'[1[1[1[1[1[1[1[1[1[1[1[1[1[1[1[1[1[1['"(l(l(l(l(l(l(l(l(lave#2=<}*rof+-pzni,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,i,i,i,i,inzp-+for*}<=2#eval("'[1 :37])m)m)m)m)m)m)m)m)m)m)m)m)m)m)m)m)m)m)m)])])])])])]73: 1['"(lave#2=<}*rof+-pzninininininininininininininininininininznznznznznznznznzp-+for*}<=2#eval("'[1 : : : : : : : : : : : :37])mbds{u,inznzp-+for*}<=2#eval("'"'[1 :37])mbds{u,ininininininininininininininininininzpzpzpzpzpzpzpzpzpzni,u{sdbm)]73: 1['"'"(l(l(l(l(l(l(l(lave#2=<}*rof+-pzni,u{sdsdsdsdsdsdsdsdsdsdsdsdsdsdbm)]73: 1[1[1[1[1[1[1[1[1[1[1[1[1[1[1[1[1[1[1 :3:3:3:3:3:3:3:3:3: 1['"(lave#2=<}*rof+-+-+-+-+-+-+-+-+-+-+-+for*}<=2#eval("'[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 :37]7]7]7]7]7]7]7]7]73: 1['"(lave#2=<}*rof+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-pzni,u{sdsdsdsdsdsdsdsdsdsdsdsdsdsdbm)]73: 1[1[1[1[1[1[1[1[1[1[1[1[1[1[1[1[1[1[1[1 1['"'"(lave#2=<}*rof+-pzni,u{sdbm)]73:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:37])])])])])]73: 1['"(lave#2=<}*rof+-pzni,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u{sdsdsdsdsdsdsdsdsdsdsdsdsdsdbm)]73: 1[1[1[1[1[1[1[1[1[1[1[1[1[1[1[1[1[1[1[1 1['"'"(lave#2=<}*rof+-pzni,u{sdbm)]73:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:37])])])])])])])])]73: 1['"(lave#2=<}*rof+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-pzni,u{s{s{s{s{u,inzp-+for*}<=2#eval("'[1 :37])])])])])])])])])]73: 1['"(lave#2=<}*rofofofofofofofofofofofofofofofofofofoforororororororororororororororororororororororororororof+-pzni,u{sdbm)]73: : : : : : : : : : : : : : :37])mbds{u{u{u{u{u{u{u{u{u{u{u{u{u{u{sdbm)]73: : : : : : : : : : : : : :37])mbds{u,inininininininininininininininininininznznznzp-+for*}<=2#eval("'[1 :37])mbds{s{s{s{s{s{s{s{sdbm)]73: 1['"(lave#2=<}*r*r*r*r*r*r*r*r*r*r*r*r*rof+-pzni,u{s{s{s{s{s{s{s{sdbm)]73: 1['"'"(lave#2=<}*}*}*}*}*}*}*}*}*}*rof+-pzni,u{sdbm)])])])])])])])])])])])])])])])])])])])m)m)m)m)m)m)m)m)]73: 1['"(lave#2=<}*rofofofofofofofofofofofofofofofofofofoforororororororororororororororororororororororororororof+-pzni,u{sdbm)]73: : : : 1['"'"(lave#2=<}*rof+-pzni,u{sdbmbmbmbmbds{u,inzp-+for*}<=2#eval("'"'[1 : : : : : : : : : : : : :37])mbds{u,inininininininininininininininininininininininininininzp-+for*}<=2#eval("'[1 : : : : : : : : : : : : : : :37])mbdsdsdsdsdsdsdsdsdsdbm)]73: 1['"(lave#2=<}<}<}<}<}<}<}<}<}<}<}<}<}<}<}<}<}<}<}<=<=<=<=<=<=<=<=<=<=<=<=<=<=<=<=<=<=<=<=<=<=<=<=<=<=<=<=<=<=<}*rof+-pzni,u{u{u{u{u{u{u{u{u{sdbm)]73: 1['"'"(lave#2=2=2=2=2=2=2=2=2=2=2=2=2=2=2=2=2=2=<}*rof+-pzni,u{sdbm)]73: 1['[1 : :37])
Attempt This Online!
D'oh!
How (if you can be bothered)
The long string slices down to
lambda s:{sum([(u,m)in zip(s[:-1]+s[1:],s[1:]+s)for u in{*s}])for m in s}<={2}
It was generated (by computer program) by walking up and down the string
[1 :37])mbds{u,inzp-+for*}<=2#eval(
wasting just the right amount of time to get the right characters at the chosen spacing.
A few more details:
Lets do a small example:
Let's assume our program is
abracadabra
The basic idea is arrange the unique letters in some order, UNQ = abrcd
, say, and then do something like ababrbrcdabrcrbadadadababrbrcda
. Because this was created by walking up and down UNQ every letter has at most two neighbours. Now, if we slice this with step = 3 we recover abracadabra
:
AbaBrbRcdAbrCrbAdaDadAbaBrbRcdA
. Note that in order to break parity we needed UNQ to be of odd length and to wrap around.
With the wrapping around all the spare neighbour slots we might have hoped to harness in the next step are used up. We'll see in a moment that that is a bit of a problem:
We still need to wrap our magic string in an eval
statement and do the slicing.
But if we try something like eval("ababrbrcdabrcrbadadadababrbrcda"[ : :3])
then the characters touching the quotation marks are over-booked. They already had two neighbours, so the quotation mark is one too many.
We can try and solve this by integrating the wrapper code into UNQ:
UNQ = "[ :3])brcdeval(
It almost works, but, of course, the single quotation mark will cause all sorts of problems when wrapping around. We could try a similar trick to the one we have already tacitly used to manage the double colon in the slicing expression: instead of [::3]
(:
has three neighbours) use [ : :3]
. But with the colon we have used up the "neutral" space character already. We could try and use tab
or even newline
but there is one slightly neater way: use two kinds of quotes: single and double. UNQ = "[ :3])brcdeval('
Then at every other wrap-around we have to add one wiggle over the quotes:
"...'"'"....'".....'"'"....'
etc. Python will concatenate this into one single string that contains a few occurrences of the character pair '"
.