-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava.java
More file actions
37 lines (30 loc) · 942 Bytes
/
Java.java
File metadata and controls
37 lines (30 loc) · 942 Bytes
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
public class Java {
public static void main(String[] args) {
String target = "hello world";
int index = 0;
int pointer = 0;
String ans = "";
String chars = "abcdefghijklmnopqrstuvwxyz";
while (true) {
char cur = chars.charAt(index++);
if (target.charAt(pointer) == ' ') {
pointer++;
ans += " ";
}
if (cur == target.charAt(pointer)) {
ans += cur;
pointer++;
}
String toLog = ans + cur;
if (toLog.endsWith("dd")) {
toLog = toLog.substring(0, toLog.length() - 1);
}
System.out.println(toLog);
if (ans.equals(target)) {
System.out.println("Successfully logged Hello World!");
break;
}
if (index >= 26) index = 0;
}
}
}