Created
October 3, 2012 02:25
-
-
Save scottchiang/3824577 to your computer and use it in GitHub Desktop.
Richard's pseudocode
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
# Script: Covert sentences | |
# | |
# GET a sentence from user input. | |
# IF the sentence length is greater than 20, randomize the sentence | |
# ELSE take the 2nd letter of each word and change it to the letter P | |
# ENDIF | |
# PRINT the new sentence | |
def pseudocode | |
puts "Type in a sentence:" | |
user_input = gets.chomp | |
temp = [] | |
if user_input.length > 20 | |
input_array = user_input.split(' ') | |
puts input_array.sort_by { rand }.join(' ') | |
else | |
user_input.split(' ').map do |x| | |
x[1] = 'P' | |
temp << x | |
end | |
p temp.join(' ') | |
end | |
end | |
pseudocode | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment