Skip to content

Instantly share code, notes, and snippets.

@rabestro
rabestro / WTF.java
Last active December 14, 2020 09:27
Bad Code Coding Challenge - Print the multiplication table
public class WTF {
public static void main(String[] args) {
Integer W, F=0x2F;
for (int T; (W=T=F)>0 & W==F; ++F)
System.out.printf((W=T-=057)!=0 && 0!=(T%=011) ? "%5d":"%n%5d",(1+W/9)*++T);
}
}
@rabestro
rabestro / Main.java
Last active July 26, 2020 15:54
Check sudoku of any dimension
import java.util.Scanner;
import java.util.stream.IntStream;
import static java.util.stream.IntStream.range;
public class Main {
public static void main(String[] args) {
final var scanner = new Scanner(System.in);
final var n = scanner.nextInt();
@rabestro
rabestro / README.md
Created May 11, 2020 09:13
For loop and ranges → The roots of equation

There are numbers a,b,c,d. Output in ascending order all the integers between 0 and 1000 (inclusively), which are the roots of the equation

a⋅x^3 + b⋅x^2 + c⋅x + d = 0

If a specified interval does not contain any roots of the equation, do not output anything.

@rabestro
rabestro / EnumToString.java
Last active April 21, 2020 14:30
How to convert Enum to String
import java.util.stream.*;
public class EnumToString {
public static void main(String[] args) {
String colors = Stream.of(MyColors.values())
.map(Enum::toString)
.collect(Collectors.joining(", "));
System.out.println(colors);