Created
January 13, 2016 00:24
-
-
Save jennli/c061f6e27d7be871a3a1 to your computer and use it in GitHub Desktop.
permutation
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
#permutation exercise | |
char_array = Array.new | |
loop do | |
puts "Enter three characters separated by a space ' ' " | |
answer = gets.chomp | |
char_array = answer.split (); | |
if(char_array.size != 3) | |
puts "Invalid, plz enter three characters separated by a space ' ' " | |
end | |
break if (char_array.size == 3) | |
end | |
print char_array.permutation.to_a | |
puts "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment