Alex Grad @grad.dev · Dec 12

I've completed day 12 of #AdventOfTypeScript. Spent 40 minutes mostly trying to figure out NaughtyOrNice. In the end, I hardcoded the rating by name. If hardcoding is the only solution, then this task is just nonsense. adventofts.com/events/2024/12

17 likes 7 replies

?

Replies

Muhammad Khan · Dec 13

I checked the discord, apparently it was this condition. If the name had odd number of letters then `nice` else `naughty`.

Matthijs · Dec 12

I went for index%10 === 0 to mean naughty. But it could be anything. Did allow for a typescript-y solution though, so at least I learned something :)

ArttX · Dec 12

I figured out `NaughtyOrNice`! From first, I also did not find way to separate these records. But found, that in tests, there are comments, that tells what to do. ``` // even number of characters in the name get 'naughty' // odd number of characters in the name get 'nice' ``` So this is my solution:

Johann Haeger · Dec 12

Looking at the given tests I chose to base NaughtyOrNice on length of name: <5 ⇒ naughty ≥ 5 ⇒ nice But only Santa will know the truth 🤭

Andy Young · Dec 12

I didn't see any good pattern for determining naughty or nice either. I hardcoded too.

Etienne · Dec 12

Hardcoded the naughty/nice too, I couldn't find any logic. Just assumed it was a given list by some reinder…

Trevor · Dec 12

This might be where I tap out. I’ll see how I feel in the morning.