Last active
April 16, 2019 15:20
-
-
Save tonybaines/7e8dcb37357bf61e0109913efff4eb5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.stream.IntStream; | |
class Scratch { | |
public static void main(String[] args) { | |
int lowerBound = 100; | |
int upperBound = 999; | |
System.out.println( | |
IntStream.range(lowerBound, upperBound).flatMap(x -> | |
IntStream.range(lowerBound, upperBound).map(y -> x * y) | |
.filter(Scratch::isPalindrome) | |
).max().getAsInt()); | |
} | |
private static boolean isPalindrome(int i) { | |
String forward = Integer.toString(i); | |
String reverse = new StringBuilder(Integer.toString(i)).reverse().toString(); // yuk | |
return forward.equals(reverse); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment