Skip to content

Instantly share code, notes, and snippets.

@ZeroPivot
Created December 13, 2020 20:20
Show Gist options
  • Save ZeroPivot/982db2746ba19667989fe2fc78b79001 to your computer and use it in GitHub Desktop.
Save ZeroPivot/982db2746ba19667989fe2fc78b79001 to your computer and use it in GitHub Desktop.
# Step a name from the arity to the finished string, and get the count of that
# 2020-12-12
print "What is the name? "
end_test = gets.chomp
puts
DEBUG = true
MODULO_DEBUG = 1_000_000
def string_arity(string)
string.split('').count
end
finished = false
until (finished)
steps ||= 0
name ||= end_test
compute_string ||= 'a' * string_arity(end_test)
if (compute_string != name)
steps += 1
compute_string.succ!
if (DEBUG && ((steps % MODULO_DEBUG) == 0))
puts "#{compute_string} -> #{steps}"
end
else
puts "Reached the end; number of steps: #{steps}"
finished = true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment