Skip to content

Instantly share code, notes, and snippets.

@scottchiang
Created October 3, 2012 02:25
Show Gist options
  • Save scottchiang/3824577 to your computer and use it in GitHub Desktop.
Save scottchiang/3824577 to your computer and use it in GitHub Desktop.
Richard's pseudocode
# 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