-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSolution.java
More file actions
34 lines (28 loc) ยท 887 Bytes
/
Solution.java
File metadata and controls
34 lines (28 loc) ยท 887 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
package programmers.Level0.solution._109_qr_code;
/**
* https://school.programmers.co.kr/learn/courses/30/lessons/181903?language=java
*/
class Solution {
public static void main(String[] args) {
int q = 3;
int r = 1;
String code = "qjnwezgrpirldywt";
String expectedResult = "jerry";
Solution solution = new Solution();
String result = solution.solution(q, r, code);
if (expectedResult.equals(result)) {
System.out.println("Pass");
} else {
System.out.println("Fail");
}
}
public String solution(int q, int r, String code) {
StringBuilder answer = new StringBuilder();
for (int i = 0; i < code.length(); i++) {
if (i % q == r) {
answer.append(code.charAt(i));
}
}
return answer.toString();
}
}