use of io.vavr.collection.CharSeq in project javaslang by javaslang.
the class Euler36Test method isDoubleBasePalindrome.
private static boolean isDoubleBasePalindrome(int x) {
final CharSeq seq = CharSeq.of(Integer.toString(x));
final CharSeq rev = CharSeq.of(Integer.toBinaryString(x));
return isPalindrome(seq) && isPalindrome(rev);
}
use of io.vavr.collection.CharSeq in project javaslang by javaslang.
the class AbstractValueTest method shouldConvertToCharSeq.
@Test
public void shouldConvertToCharSeq() {
final Value<Integer> value = of(1, 2, 3);
final CharSeq charSeq = value.toCharSeq();
final CharSeq expected = CharSeq.of(of(1, 2, 3).iterator().mkString());
assertThat(charSeq).isEqualTo(expected);
}
use of io.vavr.collection.CharSeq in project javaslang by javaslang.
the class Euler43Test method tenDigitPandigitalsWithProperty.
private static Seq<Long> tenDigitPandigitalsWithProperty() {
final CharSeq ALL_DIGITS = CharSeq.of("0123456789");
final List<Integer> DIVISORS = List.of(2, 3, 5, 7, 11, 13, 17);
return ALL_DIGITS.combinations(2).flatMap(CharSeq::permutations).flatMap(firstTwoDigits -> DIVISORS.foldLeft(List.of(firstTwoDigits), (accumulator, divisor) -> accumulator.flatMap(digitsSoFar -> ALL_DIGITS.removeAll(digitsSoFar).map(nextDigit -> digitsSoFar.append(nextDigit))).filter(digitsToTest -> digitsToTest.takeRight(3).parseInt() % divisor == 0))).map(tailDigitsWithProperty -> tailDigitsWithProperty.prepend(ALL_DIGITS.removeAll(tailDigitsWithProperty).head())).map(CharSeq::parseLong);
}
Aggregations