Skip to content

Commit 7aef71a

Browse files
authored
🎉 feat: initial commit for 1048 using java
1 parent d18f801 commit 7aef71a

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import java.io.BufferedReader;
2+
import java.io.IOException;
3+
import java.io.InputStreamReader;
4+
5+
public class Main {
6+
final static char[] arr = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'J', 'Q', 'K'};
7+
public static void main(String[] args) throws IOException {
8+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
9+
String[] str = br.readLine().split(" ");
10+
int len1 = str[0].length();
11+
int len2 = str[1].length();
12+
int max = Math.max(len1, len2);
13+
int min = Math.min(len1, len2);
14+
15+
String res = "";
16+
if (len1 < len2) {
17+
for (int i = 0 ; i < len2 - len1; i++) {
18+
str[0] = '0' + str[0];
19+
}
20+
}else {
21+
for (int i = 0 ; i < len1 - len2; i++) {
22+
str[1] = '0' + str[1];
23+
}
24+
}
25+
char[] c1 = str[0].toCharArray();
26+
char[] c2 = str[1].toCharArray();
27+
for (int i = max - 1; i >= 0; i--) {
28+
int index = max - i;
29+
if (index % 2 == 1) {
30+
res = arr[(c1[i] - '0' + c2[i] - '0') % 13] + res;
31+
}
32+
if (index % 2 == 0) {
33+
res = arr[(((c2[i] - '0') - (c1[i] - '0')) + 10) % 10] + res;
34+
}
35+
}
36+
System.out.println(res);
37+
}
38+
}

0 commit comments

Comments
 (0)