Created
April 25, 2017 20:44
-
-
Save ekumachidi/01fef1baa023c4c00de2027479027abf to your computer and use it in GitHub Desktop.
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
# Viking Academy Coding challenge | |
def not_string(input) | |
if input.partition(" ").first == "Not" || input.partition(" ").first =="not" | |
puts input | |
else | |
puts "not #{input}" | |
end | |
end | |
not_string("Hi, this is a string") | |
not_string("not a string here") | |
not_string("nothing strange about this one") | |
def no_dupes(array) | |
cleaned = [] | |
array.each do |number| | |
unless cleaned.include?(number) | |
cleaned << number | |
end | |
end | |
puts cleaned | |
end | |
def flim_flam | |
puts (1..100).collect { |i| (result = [["FLIM"][i % 3], ["FLAM"][i % 5]].compact.join).empty? ? i : result } | |
end | |
no_dupes( [ 1, 4, 2, 7, 3, 1, 2, 8 ] ) | |
no_dupes( [ 100, 32, 44, 44, 23, 32, 44 ] ) | |
flim_flam() | |
puts "end" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment