Find Chess960 starting position identifier: Difference between revisions
Find Chess960 starting position identifier (view source)
Revision as of 12:32, 8 May 2023
, 1 year ago→{{header|Java}}
Line 599:
}
List<Integer> rookKing
if ( ! (
▲ List.of(aPosition.indexOf('R'), aPosition.indexOf('K'), aPosition.lastIndexOf('R'));
▲ if ( ! ( rookAndKing.get(0) < rookAndKing.get(1) && rookAndKing.get(1) < rookAndKing.get(2) ) ) {
throw new AssertionError("The king must be between the two rooks.");
}
Line 622 ⟶ 621:
private static String retainIf(String aText, Predicate<Character> aPredicate) {
return aText.chars(
.mapToObj( i -> (char) i )
.map(String::valueOf).reduce("", String::concat);▼
.filter(aPredicate)
.map(String::valueOf)
}
|