Created
April 23, 2015 21:38
-
-
Save eddroid/7989f46616fe58b85364 to your computer and use it in GitHub Desktop.
C5 Pair Programming: Rinse & Repeat
This file contains 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
uppers = "A".."Z" | |
lowers = "a".."z" | |
letters = uppers.to_a + lowers.to_a | |
numbers = ("0".."9") | |
#### | |
## 1st question | |
#### | |
all_letters = false | |
until all_letters | |
puts "What's your name?" | |
name = gets | |
exit if name.nil? | |
name = name.chomp | |
name_array = name.split('') | |
all_letters = name_array.all? do |char| | |
letters.include? char | |
end | |
end | |
#### | |
## 2nd question | |
#### | |
all_numbers = false | |
until all_numbers | |
puts "How old are you?" | |
age = gets | |
exit if age.nil? | |
age = age.chomp | |
age_array = age.split('') | |
all_numbers = age_array.all? do |char| | |
numbers.include? char | |
end | |
end | |
p age |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment