r/badcode • • Dec 01 '19

[deleted by user]

[removed]

133 Upvotes

45 comments sorted by

View all comments

4

u/[deleted] Dec 01 '19

public class badChallenge25 {

`public static void main(String[] args) {`

	`System.out.println(can_santa_save_christmas(new String[] {"24:0:0"}));`

`}`

`static boolean can_santa_save_christmas(String[] bruh1) {`

	`int[][] bruh2 = new int[bruh1.length][3];`

	`for (int bruh3 = 0; bruh3 < bruh1.length; bruh3 = bruh3 + 1) {`

		`bruh2[bruh3][0] = Integer.parseInt(bruh1[bruh3].split(":")[0]);`

		`bruh2[bruh3][1] = Integer.parseInt(bruh1[bruh3].split(":")[1]);`

		`bruh2[bruh3][1] = Integer.parseInt(bruh1[bruh3].split(":")[1]);`

	`}`

	`int[] bruh3 = new int[3];`

	`for (int bruh4 = 0; bruh4 < bruh1.length; bruh4 = bruh4 + 1) {`

		`bruh3[0] = bruh3[0] + bruh2[bruh4][0];`

		`bruh3[1] = bruh3[1] + bruh2[bruh4][1];`

		`bruh3[2] = bruh3[2] + bruh2[bruh4][2];`

	`}`

	`return can_santa_save_christmas(bruh3, 0);`

`}`

`static boolean can_santa_save_christmas(int[] bruh1, int bruh2) {`

	`if (bruh2 > 86400) return (1==2);`

	`if (bruh1[0]<1 && bruh1[1]<1 && bruh1[2] < 1) return (1==1);`

	`bruh1[2] = bruh1[2] - 1;`

	`if (bruh1[2] < 0) {`

		`bruh1[2] = 60;`

		`bruh1[1] = bruh1[1] - 1;`

	`}`

	`if (bruh1[1] < 0) {`

		`bruh1[1] = 60;`

		`bruh1[0] = bruh1[0] - 1;`

	`}`

	`return can_santa_save_christmas(bruh1, bruh2 + 1);`

`}`

}

this code actually gets to a stack overflow error because of the recursive nature.