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.
Thank you for your comment. I do agree with what you pointed out. Yes X should of been a const. Old habits from another language. I use Switch statements as much as possible. I believe them to be the easiest way to read code.
I don't think you need that fatalError in there as you'll probably never need to have it. The days should always be between 1 and any allowed number in the Integer type. The switch case looks pretty clean - I like the same line for case and result. First case should probably have been 1...2 ..because there will never be 0 rental days and I checked ...they're not using zero base. The next case probably could have been 3...6 and then finally just default as seen in psmilliorn's solution which would be discount (or descount as you've spelled it) = 50. Could have also used the switch case return design pattern to save on lines of code too, but it all still works. I hope my feedback was useful. Thanks for sharing your solution.
There's a lot going on in this solution that could have been commented on and you just wanted to point out their misspelling? To each their own..
I feel like this one looks nice in terms of readability, but the number of lines seems bulky for the job it's doing. Could probably shorten it up by putting the returns on the same line as the cases. x should be a constant (let x = 40). Other than that it looks great. I'm glad I got to see it done this way because in many ways it makes sense and if I find myself thinking this way on a problem I hope I remember how cleanly you did it.
Feels like a good clean approach that maintains readability and optimization. I like it. I had gone for the nested ternary option, but sometimes I feel like nested ternaries are barf ugly.
Beautiful. I forgot about those techniques. Thanks for the reminder.