-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathComputerSciencePrinciples2.java
More file actions
32 lines (32 loc) · 995 Bytes
/
ComputerSciencePrinciples2.java
File metadata and controls
32 lines (32 loc) · 995 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
public class ComputerSciencePrinciples2
{
public static void main(String[] args) {
String inp = "inagzgkpm)Wl&Tg&io";
if (inp.length()!=18) {
System.out.println("Your input is incorrect.");
System.exit(0);
}
inp=shift(shift2(inp));
if (inp.equals("inagzgkpm)Wl&Tg&io")) {
System.out.println("Correct. Your input is the flag.");
}
else {
//System.out.println("Your input is incorrect.");
}
System.out.println(inp);
}
public static String shift(String input) {
String ret = "";
for (int i = 0; i<input.length(); i++) {
ret+=(char)(input.charAt(i)+i);
}
return ret;
}
public static String shift2(String input) {
String ret = "";
for (int i = 0; i<input.length(); i++) {
ret+=(char)(input.charAt(i)-Integer.toString((int)input.charAt(i)).length());
}
return ret;
}
}