Skip to content

Instantly share code, notes, and snippets.

View Gorbatchevski's full-sized avatar

Gorbatchevski

  • Belarus
View GitHub Profile
@Gorbatchevski
Gorbatchevski / gist:5280623
Last active December 15, 2015 15:19
Translates a word into pig latin
def translate_into_pig_latin(word)
if word[0] == "a"|| word[0]== "e" || word[0] == "i"|| word[0] == "u" || word[0] == "o"
word+"ay"
elsif (word[0] != "a"|| word[0] != "e" || word[0] != "i"|| word[0] != "u") && (word[1] == "a" || word[1] == "o" || word[1] == "e" || word [1] == "i" || word[1] == "u") && word[0..1] != "qu"
word[1..-1]+word[0]+"ay"
elsif (word[0] != "a"|| word[0] != "e" || word[0] != "i"|| word[0] != "u") && (word[1] != "a" || word[1] != "o" || word[1] != "e" || word [1] != "i" || word[1] != "u")
word[2..-1]+word[0..1]+"ay"
elsif word[0..1]="qu"
word[2..-1]+"quay"
else
@Gorbatchevski
Gorbatchevski / gist:5124314
Last active December 14, 2015 17:48
This Ruby text helps to find out if a year is leap or not.
def leap_year?(year)
if year % 4 == 0 && year%100 > 0
true
elsif year%400 == 0
true
else
false
end
end