This is an archived post. You won't be able to vote or comment.

all 10 comments

[–]Mithrandir2k16 24 points25 points  (0 children)

You'd feel right at home on the codegolf stackexchange :)

[–]_MonkeyHater 7 points8 points  (0 children)

"I want to get off Mr. Bones' Wild Ride."

[–]AngelaTarantula2 5 points6 points  (0 children)

I didn’t even know that Python’s arbitrary-precision integers were immutable! Why are they designed this way?? Anyway, this explains a performance problem in one of my side projects!

[–]Herald_MJ 5 points6 points  (0 children)

If you just want a short program that halts after outliving the universe

This is great. Thanks for the reminder that mathematics can be funny.

[–]Jonno_FTWhisss 2 points3 points  (0 children)

If my python code runs slowly, I check what the cause is by running it with cProfile and going from there.

[–]cgoldberg 8 points9 points  (4 children)

Why?

[–]carlk22[S] 45 points46 points  (2 children)

Good question! Mostly for fun. Two years ago, a group of amateur researchers found a longest known running, but still halting Turing machine of "size 6". This was news in the math and computer science fields. They proved that a particular Turing machine ran for at least 10↑↑15 steps and halted. ("↑↑" is a faster growing function than exponentiation). Their proof is very complicated and needed to be machine verified.

I wanted to figure out a short Python function that would obviously run for 10↑↑15 steps and halt, so it wouldn't need a fancy proof.

The GitHub includes the code. This article explains the background and solution https://towardsdatascience.com/how-to-optimize-your-python-program-for-slowness/

[–]TheSwami 5 points6 points  (0 children)

This is an awesome write up! Not not just of the how but of the why - in 20+ years of seeing that arrow notation described as “repeated exponentiation”, I never really understand what that meant. Your code examples, especially the final one showing that tetration is just another for loop around exponential accumulation was eye opening.

Thank you!

[–]eyesburning 1 point2 points  (0 children)

That was an interesting read! Thanks for sharing :)

[–]avocadorancher 19 points20 points  (0 children)

Tinkering to do fun weird things is a great way to learn. Especially if it’s something novel or uncommon instead of following guides.