-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugging.java
More file actions
94 lines (71 loc) · 1.95 KB
/
Copy pathDebugging.java
File metadata and controls
94 lines (71 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
*
*/
public class Debugging {
/**
*
INPUT OUTPUT
A B A XOR B
0 0 0
0 1 1
1 0 1
1 1 0
* @param s
* @param t
* @return
*/
public static String stringsXOR(String s, String t) {
StringBuilder res = new StringBuilder();
for ( int i = 0; i < s.length(); i++) {
if( s.charAt(i) == t.charAt(i) ) {
res.append("0");
} else {
res.append("1");
}
}
return res.toString();
}
public static String replaceToken() {
String P42 = "/api/products/imports/{0,number,#}?shop_id={1,number,#}";
String output = java.text.MessageFormat.format(P42, new Object[] {12221222, 12333333});
return output;
}
/**
* Print your Java Xmas tree :)
*
* printTree(5)
*
* *
* @**
* *@***
* *@*@@**
* @*****@*@
* #
*
* Code challenge day #1
*
*/
public static void printTree(int stars) {
stars = stars % 2 == 0 ? stars++ : stars;
int steps = 1;
int whites = stars / 2;
do {
String decorationS = "*".repeat(steps);
char decoration[] = decorationS.toCharArray();
for ( int index = 0; index < (decorationS.length() / 2); index++ ) {
int position = (int) (Math.random() * decorationS.length());
decoration[position] = '@';
}
// Code challenge day #3
System.out.println(" ".repeat(whites) + new String(decoration).replace("*", (char) 27 + "[32m" + "*" ).replace("@", (char)27 + "[91m" + "@"));
steps = steps + 2;
whites--;
} while ( steps <= stars );
System.out.println(" ".repeat((stars / 2)) + new String((char) 27 + "[33m#"));
}
public static void main(String[] args) {
// System.out.println(stringsXOR("01010", "10101"));
// System.out.println(replaceToken());
printTree(10);
}
}