Last active
August 29, 2015 14:17
-
-
Save nateberkopec/981ec2808f0daf20998f to your computer and use it in GitHub Desktop.
rolldie.rb
This file contains hidden or 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
#!/usr/bin/env ruby | |
def roll_die(die_string) | |
num_of_die, die_type = die_string.split("d").map(&:to_i) | |
(1..num_of_die).reduce(0) { |s, i| s + rand(die_type) + 1 } | |
end | |
puts roll_die(ARGV[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment