Created
June 14, 2018 03:57
-
-
Save davemenninger/e3dec3591be85b49024d52f7658ccdab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def position( speed: , time:) | |
(speed * time) % 576 | |
end | |
planets = [ | |
{ name: "A", speed: 24, }, | |
{ name: "B", speed: 15, }, | |
{ name: "C", speed: 9, }, | |
{ name: "D", speed: 6, }, | |
{ name: "E", speed: 4, }, | |
{ name: "F", speed: 3, }, | |
{ name: "G", speed: 2, }, | |
] | |
(1..576).each do |t| | |
line = "t: #{t}\t" | |
last_planet_pos = 0 | |
was_good = 0 | |
planets.each do |planet| | |
line << planet[:name] + "\t" | |
this_planet_pos = position( speed: planet[:speed], time: t ) | |
line << "#{this_planet_pos}" | |
jump_dist = 5 | |
if ( last_planet_pos - jump_dist <= this_planet_pos && this_planet_pos <= last_planet_pos + jump_dist ) | |
color_code = 33 | |
line << "\e[#{color_code}m*\e[0m" | |
was_good = 1 | |
end | |
line << "\t" | |
last_planet_pos = this_planet_pos | |
end | |
if ( was_good == 1 ) | |
puts line | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment