Skip to content

Various utilities, data structures, and algorithms written in Java for solving coding puzzles.

License

Notifications You must be signed in to change notification settings

p-kovacs/java-puzzle-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

0bff019 · Jan 13, 2025
Dec 18, 2024
Jan 13, 2025
Dec 14, 2022
Dec 14, 2022
Oct 13, 2021
Jan 13, 2025
Dec 13, 2024
Dec 18, 2024
Dec 18, 2024
Dec 14, 2022

Repository files navigation

Java Puzzle Utils

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+

Cheat sheet

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).

JDK

  • 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.of
    • LinkedHashSet, LinkedHashMap
    • NavigableSet (e.g. TreeSet)
    • Collections.rotate(List, int)
  • Streams
    • stream API
    • toList method of Stream (Java 16+)
  • Other
    • Math.clamp, Math.floorDiv, Math.floorMod
    • Arrays.mismatch, Arrays.setAll

Guava

  • Ints, Longs, etc. - utils for (arrays of) primitives
  • Lists
    • partition(List, int)
    • cartesianProduct(List...)
  • Sets
    • intersection(Set, Set), union(Set, Set)
    • difference(Set, Set), symmetricDifference(Set, Set)
    • combinations(Set, int), powerSet(Set)
    • cartesianProduct(Set...)
  • Multisets, multimaps
    • Multiset, HashMultiset, LinkedHashMultiset, TreeMultiset
    • Multimap, MultimapBuilder, e.g.:
      • MultimapBuilder.hashKeys().arrayListValues().build()
      • MultimapBuilder.linkedHashKeys().hashSetValues().build()
    • Multimaps, Multisets - related utils (collectors, filtering, etc.)
  • Other
    • BiMap, HashBiMap
    • Range
    • RangeSet
    • Table, HashedBasedTable, TreeBasedTable
  • LongMath (or IntMath)
    • gcd(long, long) - greatest common divisor
    • binomial(int, int)
    • factorial(int)
    • isPrime(long)
    • isPowerOfTwo(long)

About

Various utilities, data structures, and algorithms written in Java for solving coding puzzles.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages