Various utilities, data structures, and algorithms written in Java for solving coding puzzles like Advent of Code.
However, Java is not the best language for coding puzzles. Consider using Kotlin instead. :)
Compatibility: Java 21+
This section lists a few notable utilities of the JDK and the Guava library, which can be practical for solving coding puzzles (besides the tools provided in this library).
- Language features
- lambdas
 var(Java 11+)- records (Java 14+)
 - switch expressions (Java 14+)
 
 - Collections
- sequenced collections: first/last element and reversed view (Java 21+)
 List.of,Set.of,Map.ofLinkedHashSet,LinkedHashMapNavigableSet(e.g.TreeSet)Collections.rotate(List, int)
 - Streams
- stream API
 toListmethod ofStream(Java 16+)
 - Other
Math.clamp,Math.floorDiv,Math.floorModArrays.mismatch,Arrays.setAll
 
Ints,Longs, etc. - utils for (arrays of) primitivesListspartition(List, int)cartesianProduct(List...)
Setsintersection(Set, Set),union(Set, Set)difference(Set, Set),symmetricDifference(Set, Set)combinations(Set, int),powerSet(Set)cartesianProduct(Set...)
- Multisets, multimaps
Multiset,HashMultiset,LinkedHashMultiset,TreeMultisetMultimap,MultimapBuilder, e.g.:MultimapBuilder.hashKeys().arrayListValues().build()MultimapBuilder.linkedHashKeys().hashSetValues().build()
Multimaps,Multisets- related utils (collectors, filtering, etc.)
 - Other
BiMap,HashBiMapRangeRangeSetTable,HashedBasedTable,TreeBasedTable
 LongMath(orIntMath)gcd(long, long)- greatest common divisorbinomial(int, int)factorial(int)isPrime(long)isPowerOfTwo(long)