Again, first day is nothing to write home about: just iterate and sum, nothing too complicated.
Oh look, another of those "loop over EVERY-FUCKING-COMBINATION" exercises...
Not much we haven't seen last year.
There's something about this "find the most used record" type of exercises that I dislike.
As a programmer, your MUST have used, at least once, the command man ascii
, if only to find the integer value of a specific number. But were you to look specifically at the hexadecimal table, something may have caught your attention: uppercase letters, and their equivalent lowercase values, are all separated by 32 characters. Now, isn't that a nice number that plays VERY WELL with bit masks? Here's a little playground to help you!
At first, I felt like expanding each area one by one, until I realised that just calculating distances was just easier.
I hate everything about time-advancing series calculations...
Trees are one of those things I never know how to handle properly, traverse, balance, etc... I just love good old arrays.
In that case however, despite my first five minutes being puzzled by the absence of a "length" value for each node of the tree, I quickly found out a solution and actually liked the exercise.