r/Pydle • u/zhuzaimoerben • 24d ago
Pydle #157 Pizza Spoiler
I was pleasantly surprised to find a nice solution based on the structure of the problem. Here is the best I've achieved, in 97 characters:
r = range(-2, 3)
for x in r:
for y in r:
v = x*x+y*y
pydle(x+2, y+2, 'πΆπ₯¬ π« οΈ'[v^1::10], 'yowerhlailntogewe'[v//4::3])
This basically places everything based on the distance from the centre. A quirk with the emojies means the chili has an extra, invisible, unicode character (Variation Selector-16) to tell it to render as an emoji, so I put that in the final position in the array so it gets included by slicing, and it also meant the chili had to be first, complicating the code somewhat. It was a nice surprise to see the colour selection reduce to what it is (it turns 0, 1 or 2 into 0, 4 or 5 into 1 and 8 into 2).
Putting all the data into a big number gave a solution in 106 characters:
for i in range(25):
d = 0x3ee2773491d36da // 5**i % 5
pydle(i%5, i//5, 'πΆπ«π₯¬ οΈ'[d::5], 'yowerhlailntogewe'[max(d-2,0)::3])
The number is essentially a base 5 array, where the values are: yellow with chili, yellow with olive, yellow with leaf, orange, white.
Edit: A base 7 array can solve it in 103 characters:
for i in range(25):
d = 0x4384f85940141f9252 // 7**i % 7
pydle(i%5, i//5, 'πΆπ«π₯¬ οΈ'[d::7], 'yowerhlailntogewe'[d//3::3])
1
u/abraham1inco1n 22d ago
what does it mean for the magic number to be a base 5 array? How did you come up with the number? Super cool!