Skip to content

Instantly share code, notes, and snippets.

@packrat386
Created December 8, 2021 01:51
Show Gist options
  • Save packrat386/b013cd6ab35c59a35cf0b43c7e7aadc6 to your computer and use it in GitHub Desktop.
Save packrat386/b013cd6ab35c59a35cf0b43c7e7aadc6 to your computer and use it in GitHub Desktop.
[ubuntu-s-1vcpu-1gb-nyc1-01] wtf > cat wtf.rb
hill = 0
speed = 20
gas = 20
puts "hill,speed,gas,diff_hill,diff_speed,diff_gas"
100.times do
new_hill = hill + [1, -1].sample
new_speed = gas - hill
new_gas = 20 + hill
diff_hill = new_hill - hill
diff_speed = new_speed - speed
diff_gas = new_gas - gas
hill, speed, gas = new_hill, new_speed, new_gas
puts "#{hill},#{speed},#{gas},#{diff_hill},#{diff_speed},#{diff_gas}"
end
[ubuntu-s-1vcpu-1gb-nyc1-01] wtf > ruby wtf.rb
hill,speed,gas,diff_hill,diff_speed,diff_gas
-1,20,20,-1,0,0
0,21,19,1,1,-1
1,19,20,1,-2,1
0,19,21,-1,0,1
-1,21,20,-1,2,-1
0,21,19,1,0,-1
1,19,20,1,-2,1
0,19,21,-1,0,1
1,21,20,1,2,-1
2,19,21,1,-2,1
1,19,22,-1,0,1
0,21,21,-1,2,-1
-1,21,20,-1,0,-1
-2,21,19,-1,0,-1
-1,21,18,1,0,-1
0,19,19,1,-2,1
1,19,20,1,0,1
2,19,21,1,0,1
1,19,22,-1,0,1
0,21,21,-1,2,-1
1,21,20,1,0,-1
2,19,21,1,-2,1
3,19,22,1,0,1
4,19,23,1,0,1
5,19,24,1,0,1
4,19,25,-1,0,1
3,21,24,-1,2,-1
4,21,23,1,0,-1
5,19,24,1,-2,1
6,19,25,1,0,1
5,19,26,-1,0,1
6,21,25,1,2,-1
5,19,26,-1,-2,1
6,21,25,1,2,-1
7,19,26,1,-2,1
8,19,27,1,0,1
7,19,28,-1,0,1
8,21,27,1,2,-1
7,19,28,-1,-2,1
6,21,27,-1,2,-1
5,21,26,-1,0,-1
6,21,25,1,0,-1
5,19,26,-1,-2,1
6,21,25,1,2,-1
5,19,26,-1,-2,1
6,21,25,1,2,-1
5,19,26,-1,-2,1
4,21,25,-1,2,-1
5,21,24,1,0,-1
6,19,25,1,-2,1
5,19,26,-1,0,1
6,21,25,1,2,-1
7,19,26,1,-2,1
8,19,27,1,0,1
7,19,28,-1,0,1
8,21,27,1,2,-1
9,19,28,1,-2,1
8,19,29,-1,0,1
9,21,28,1,2,-1
8,19,29,-1,-2,1
9,21,28,1,2,-1
10,19,29,1,-2,1
11,19,30,1,0,1
12,19,31,1,0,1
11,19,32,-1,0,1
10,21,31,-1,2,-1
11,21,30,1,0,-1
10,19,31,-1,-2,1
11,21,30,1,2,-1
10,19,31,-1,-2,1
9,21,30,-1,2,-1
8,21,29,-1,0,-1
9,21,28,1,0,-1
10,19,29,1,-2,1
9,19,30,-1,0,1
10,21,29,1,2,-1
11,19,30,1,-2,1
10,19,31,-1,0,1
11,21,30,1,2,-1
12,19,31,1,-2,1
13,19,32,1,0,1
12,19,33,-1,0,1
13,21,32,1,2,-1
14,19,33,1,-2,1
13,19,34,-1,0,1
14,21,33,1,2,-1
13,19,34,-1,-2,1
14,21,33,1,2,-1
15,19,34,1,-2,1
16,19,35,1,0,1
15,19,36,-1,0,1
16,21,35,1,2,-1
17,19,36,1,-2,1
18,19,37,1,0,1
17,19,38,-1,0,1
16,21,37,-1,2,-1
17,21,36,1,0,-1
18,19,37,1,-2,1
17,19,38,-1,0,1
18,21,37,1,2,-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment