Programming for Pain

Try this “programming exercise”:

1
2
3
4
5
6
7
[garry@garry-thinkpad] ~ (master) $ irb
irb(main):001:0> i = 0
=> 0
irb(main):002:0> i += 1; r = rand(10); puts "r = #{r}, i = #{i}"
r = 7, i = 1
=> nil
irb(main):003:0>

See the value of “r”? Drop down and do that many push-ups.

Pop back up and hit your favorite key for repeating the last command:

1
2
3
4
irb(main):003:0> i += 1; r = rand(10); puts "r = #{r}, i = #{i}"
r = 3, i = 2
=> nil
irb(main):004:0>

That’s right, drop and do “r” more push-ups.

If you get a “0”, you get to rest for 1 minute.

When “i” reaches 52, you’re done.

This is a variation of “prison push-ups” that I tried because I didn’t have a deck of cards.

This is quite a challenging workout. It might sound easy, depending on how fit you are, but wait until “i” reaches around 20 or so. :)

Homework: Wrap this in a nice script so you just press a key to get the next count, and have it record your time.

Comments