Well done everyone for your submissions! We hope you had fun.
On to feedback and "winners," with special thanks to our crack team of @moderators (especially @alexcraig and @factoradic)!
occur < 0. Other than the code being a wee bit (arguably) messy, this was a near-flawless method.
See Tomek's entry and explanation.
@cloudrunner15916 (David Springer) - We really liked this Python solution, all done in one array (so more efficient), and nice use of
any(). In the second loop, we would check if the value is
< 0, in some cases this would result in much faster execution.
See David's entry and explanation.
@devour30 - good approach, chosen lower case letters instead of upper case, doesn't work with spaces
@javiervfa - interesting approach, runs in correct
O(n+m) time (just), novel way of counting each letter, not quite as efficient as other methods
@cdipietro11 - nice solution with lots of error handling, and a nice menu (possibly over-engineered but we like it), runs in correct time, but fails with spaces unfortunately
@ajaxninja40882 - We thought your C++ solution was very nice, similar counting letters approach to some others, making sure they are equal in the two strings, deals with spaces. You decided to allocate some memory in the beginning for the faster execution, and this is something we would do too, especially when the alphabet is so limited! Your solution uses a single array for storing character occurrences… all in all very good code. In the second loop, we would check if the value is
< 0, in some cases this would result in much faster execution. Thank you for posting in C++, even though we don't teach C++ at Codecademy and so this is ineligible to win, we really like the variety.
@netmaster34973 - Very good Python approach! Very close to what we would call a flawless solution. The problem is... you made a simple mistake that you must have overlooked. You use a list of length
23, but there are
26 characters, so you will get an index out of range error if input includes
Z, for example. Furthermore your solution lacks support for spaces. Unfortunately this mistakes keep you from winning, but we did want to say that your approach was fantastic.
@appsco2012_dasancor8 - nice java implementation, but using the numerical value doesn't work. E.g. "AD" and "BC" have the same value but are not anagrams
Thanks again! See May 3rd's challenge here.