Port of Palermo
Today I'm jumping back into practice problems in Ruby using Exercism.org. Today's challenge is Exercism.org Port of Palermo
This felt like a nice warm-up to dust off the cobwebs. It took me about 45 minutes to solve. Much of the time was spent reading Ruby docs, trying to flex the muscle of reading Ruby documentation while remembering specific method names.
String#slice
which I thought it was anything from trim, substring, chomp, or none of the above. Eventually 💡 I found it.
I also went down a rabbit hole considering how ports of cities with spaces in their name ("San Jose") would impact this challenge. I found a solution, then checked the tests to see no considerations for this edge case!
If I were to improve it, I would add a check for cities with spaces. There are so many cities with "Port" in the name ("Puerto Rico"), so maybe also consider using not that! Plus using a null check for Port::get_terminal
would be helpful to reject ship types that are not known, recognized, or accepted.