-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathComputerSciencePrinciples.java
More file actions
34 lines (34 loc) · 1.03 KB
/
ComputerSciencePrinciples.java
File metadata and controls
34 lines (34 loc) · 1.03 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
import java.util.Scanner;
public class ComputerSciencePrinciples
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String inp = sc.nextLine();
if (inp.length()!=18) {
System.out.println("Your input is incorrect.");
System.exit(0);
}
inp=shift2(shift(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;
}
}