Advent of Code 2024 - DAY 1: Where is the Chief Historian? (Java solution)

Поділитися
Вставка
  • Опубліковано 3 гру 2024

КОМЕНТАРІ • 1

  • @avalagum7957
    @avalagum7957 2 дні тому

    Well, looking at the solutions in other languages, the Java solution has a very bad presentation:
    - lines 29 - 31: the lack of a Tuple type makes this very ugly. It'll be nice if Java has a method to split by multiple consecutive blank characters (space, tab) so that we don't have to use regex.
    - List is used to store 2 lists of long numbers. In other languages, it is a tuple of 2 lists: much easier to understand.
    - Collections.sort(list), to me, is not as nice as list.sort()
    - the for loop from line 62 - 66 can be replaced with stream, group by ... so it's not bad here
    - the for loop from 68 - 71 can be replaced with stream, map, sum ... so it's not bad either