annotate 1-Ruby/day1.rb @ 76:5860845f5dac

Create module with synchronous translation and notes on how to run
author IBBoard <dev@ibboard.co.uk>
date Sat, 03 Feb 2018 20:25:47 +0000
parents 3e4ea3d47880
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 #! /usr/bin/env ruby
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 puts 'Hello, World'
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 puts 'Hello, Ruby'.index('Ruby')
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 i = 1
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 while i <= 10
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 puts "This is sentence number #{i}"
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 i = i + 1
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 end
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 randNum = rand(10)
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 guess = 11
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 until guess == 'q' or guess.to_i == randNum
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 puts 'Guess the number (0-9) or "q" to quit'
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 guess = gets.strip
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 end
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19
3e4ea3d47880 Add day 1 exercises
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 puts "Well done! The number was #{randNum}" unless guess == 'q'