Ad
  • Default User Avatar

    I just want to point out that:
    bits.replaceAll("^0+", "").replaceAll("0+$", "");

    Can be shortened to: bits.replaceAll("^0+|0+$", "").
    The "or" operator is a handy sign~

  • Default User Avatar

    Nice one :)
    As a little improvements :

    • The "number > 99" test is done up to 5 times (one time for each predicate), it can be done outside the stream.
    • I'm not of fan of Integer.paseInt(Integer.toString(number)), but I guess it's a compromise for readability to have all the predicates on strings.
  • Default User Avatar

    In the "finder" method, you might be checking multiple times the same number to know if it is a prime number or not.
    Example : gap(6, 2, 20), you will check 2 and 8 (x = 2), then 3 and 9 (x = 3), then 4 (x = 4), then 5 and 11 plus 6 and 7 (between 5 and 11 until a prime is found) (x = 5), then 6 (x = 6), then 7 and 13 (x = 7), etc. In that example, 6 and 7 have already been checked twice.