Mercurial > repos > other > SevenLanguagesInSevenWeeks
diff 1-Ruby/day1.rb @ 13:3e4ea3d47880
Add day 1 exercises
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 03 Jan 2017 20:10:57 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/1-Ruby/day1.rb Tue Jan 03 20:10:57 2017 +0000 @@ -0,0 +1,20 @@ +#! /usr/bin/env ruby + +puts 'Hello, World' +puts 'Hello, Ruby'.index('Ruby') +i = 1 + +while i <= 10 + puts "This is sentence number #{i}" + i = i + 1 +end + + +randNum = rand(10) +guess = 11 +until guess == 'q' or guess.to_i == randNum + puts 'Guess the number (0-9) or "q" to quit' + guess = gets.strip +end + +puts "Well done! The number was #{randNum}" unless guess == 'q' \ No newline at end of file