Challenge description
Let's take a positive integer n, reverse its digits to get rev(n) and get the absolute value of the difference of these two numbers: |n - rev(n)| (or abs(n - rev(n))).
Example:
n = 5067
rev(n) = 7605
|n - rev(n)| = |5067 - 7605| = |-2538| = 2538
After repeating this op...
Python, 101 bytes
Tortoise and hare algorithm.
Truthy is any value in loop, falsey is 0.
g=lambda n:abs(n-int(str(n)[::-1]))
def r(n):
t=h=g(n)
h=g(h)
while t-h:h=g(g(h));t=g(t)
return h
Ideone it!
Time-bomb similator
code-golfinteger
Input:
Two integers in the range of >= 0 (excluding both being 0)
Output:
Print a countdown starting from the larger integer until we've reached the smaller integer (in which case we've defused the bomb). If the ending integer is below 5, we add a "phew....
Python, 101 bytes
Tortoise and hare algorithm.
Truthy is any value in loop, falsey is 0.
g=lambda n:abs(n-int(str(n)[::-1]))
def r(n):
t=h=g(n)
h=g(h)
while t-h:h=g(g(h));t=g(t)
return h
Ideone it!
@DrGreenEggsandIronMan 3 to 5 Gb in 1080p60 but 9 to 10 Gb when I upsample to 4k. Though Youtube does its own processing so the thing being downloaded is a lot smaller.
@DrGreenEggsandIronMan Well a perfect, uncompressed 1920x1080 24-bit color, 20 min, 60fps video would take up 1920*1080*24*60*60*20 bits or about 448 Gb (which is surprisingly large o_O)
@HelkaHomba Wow. There was one time I was recording terraria with some friends of mine and I didn't turn the settings down at all. We lost track of time and played for like 2 hours, so it filled every single byte on my hard drive, and my computer just went kaput.
A cyclic tag system is a tiny, Turing-complete computational model consisting of a two-symbol alphabet (I'll use {0,1}), a finite, nonempty cyclic list of productions that consist of those two symbols, and an unbounded word which also consists of those two symbols.
At each step:
the first ele...
Making stderr go to /dev/null doesn't work, because I need everything from the default logger be thrown away before the default logger gets a chance to output.