Created
July 23, 2022 01:01
-
-
Save jabrena/4c94d533f4d7dcb7ca9a37850ff05d64 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; | |
public class XDemo { | |
public static void main(String[] args) { | |
int r = 16; | |
IntStream.rangeClosed(-r, r) | |
.map(Math::abs) | |
.peek(i -> IntStream.rangeClosed(-r, r) | |
.map(Math::abs) | |
// printing a kind of thick circle, | |
// thin circle and cross in the center | |
.mapToObj(j -> i == j && i < r/3 || // cross | |
// outer thick circle | |
Math.abs(i*i + j*j - r*r/1.3) < 4*r || | |
// inner thin circle | |
Math.abs(i*i + j*j - r*r/4) < r | |
// cast to String | |
? "" | |
// two random ASCII punctuation | |
// symbols: !"#$%&'()*+,-./ | |
+ (char) (33 + Math.random() * 15) | |
+ (char) (33 + Math.random() * 15) | |
// two whitespaces | |
: " ") | |
.forEach(System.out::print)) | |
.forEach(i -> System.out.println()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment