Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This does not fulfill the requirements at all.
This comment is hidden because it contains spoiler information about the solution
I think the problem could be defined a bit more thoroughly.
What about strings which contain both dashes and underscores, like
'the_well-known_guy'
? Even though we can safely guess that the result should be'theWell-knownGuy'
, finding a consistent algorithm would be quite difficult. What about strings with a leading underscore? More importantly, what about strings which contain uppercase characters? The sample tests seem to indicate that uppercase letters in the input should be preserved, yet I managed to pass all the tests with a solution which doesn't. For example, that solution would fail on the string'the_UK_guy'
, returning'theUkGuy'
.Do note that I'm not suggesting the Kata be made more difficult, just better defined, no matter if the definition is arbitrary. As it stands, I think it's just encouraging people not to try to learn more about a problem, which is a terrible habit.
You're right, I'm quite surprised that I didn't check for that optimization. I haven't written Haskell in a while, but I know that at the time I loved to fiddle with things and look at the Core, to see what improvements could be made. I guess now I have no choice but to get back into it ;)
[toUpper c] ++ (replicate i $ toLower c)
is justtoUpper c : replicate i $ toLower c
. As the other commenter noted, there are some unecessary statements.This comment is hidden because it contains spoiler information about the solution
This probably accumulates a bunch of costly thunks.
This comment is hidden because it contains spoiler information about the solution
Using list index is a bad idea! Also, many of the guards here should be replaced with case expressions or if/else.
Danger: Heavy use of (!!), errors, and list append is rarely a good idea.
This is definitely overcomplicated, my main goal here was to learn and practice creating larger/more complex programs.
I'm not sure that using the reverse function application operator (&) is a good idea.
"Best practices" should really include a function signature.
The function used to compare directions is also not extensible and would never be used except inside of dirReduce. It should probably be included in a where clause or modified.
Using nub might be a bad idea, see https://www.reddit.com/r/haskellquestions/comments/7f83jl/nub_sort_or_sort_nub/
Improved version of the current top answer.
Loading more items...