Skip to content

Instantly share code, notes, and snippets.

@nabn
Created November 29, 2013 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nabn/7711479 to your computer and use it in GitHub Desktop.
Save nabn/7711479 to your computer and use it in GitHub Desktop.
#! /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