Skip to content

Instantly share code, notes, and snippets.

@relyks
Created December 1, 2022 01:34
Show Gist options
  • Save relyks/a9caa8cbb40dc114a9124143733ce836 to your computer and use it in GitHub Desktop.
Save relyks/a9caa8cbb40dc114a9124143733ce836 to your computer and use it in GitHub Desktop.
My Solution to Shopify’s Day 2 Challenge at RubyConf 2022
# Please fill in the method definition below:
def Organizer(c)
c.select{String===_1&&/^.{,5}$|^tomatoes$/!~_1}
end
# Modify the solution above. Emojis are free.
# Code below will check correctness.
example_collection = [
'apples',
33,
nil,
'hat',
'tomatoes',
'toothbrush',
'laptop'
]
collection_two = [
'my best friend gary',
Array,
'hairbrush',
'drawers',
99
]
collection_three = [
'tomatillos',
'tin',
'table',
'mother-in-law'
]
raise unless Organizer(example_collection) == ["apples", "toothbrush", "laptop"]
raise unless Organizer(collection_two) == ["my best friend gary", "hairbrush", "drawers"]
raise unless Organizer(collection_three) == ["tomatillos", "mother-in-law"]
puts 'It works!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment