Created
November 29, 2013 20:27
-
-
Save nabn/7711479 to your computer and use it in GitHub Desktop.
solution for yipl internship application at https://yipl.hackpad.com/Playing-with-the-name-wV7qfcTYksK application: https://docs.google.com/forms/d/1OrVtJlgYxtH0A06o2QIigjowXXx7VIBuw6GoU8oxdFc/viewform
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
#! /usr/bin/ruby | |
# solution for yipl internship application | |
# at https://docs.google.com/forms/d/1OrVtJlgYxtH0A06o2QIigjowXXx7VIBuw6GoU8oxdFc/viewform | |
# https://yipl.hackpad.com/Playing-with-the-name-wV7qfcTYksK | |
# | |
# author: @nabn_ | |
# -------------------------------------------------------------------- | |
puts | |
print "full name: " | |
# remove trailing newline and extra spaces | |
nameStr = gets.chomp.split.join(' ') | |
nameArr = nameStr.split | |
# don't count spaces | |
puts "Length: #{nameArr.join.length}" | |
print "Status: " | |
if nameArr.first.length == nameArr.last.length | |
puts "Good one" | |
else | |
puts "Not bad, though!" | |
end | |
# hungarian | |
hungarianName = ''+ nameArr.first.downcase | |
nameArr[ 1 , nameArr.length ].each do |word| | |
hungarianName += word.capitalize | |
end | |
puts "Hungarian: #{hungarianName}" | |
# counting vowels | |
count = 0 | |
['a', 'e', 'i', 'o', 'u'].each do |vowel| | |
count += nameArr.join.downcase.count vowel | |
end | |
puts "Vowels: " + count.to_s | |
# remove vowels | |
puts "Vowelless: " + nameStr.gsub(/[aeiou\s]/,'') | |
puts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment