-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathJava.java
47 lines (38 loc) · 1.53 KB
/
Java.java
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
38
39
40
41
42
43
44
45
46
47
/****************************************/
/* */
/* CodinGame.com Solutions by pathosDev */
/* */
/* Puzzle: ASCII Art */
/* Difficulty: Easy */
/* Date solved: 08.11.2018 */
/* */
/****************************************/
import java.util.Scanner;
public class Solution
{
public static void main(String[] args)
{
//Read inputs.
Scanner scanner = new Scanner(System.in);
int L = Integer.parseInt(scanner.nextLine());
int H = Integer.parseInt(scanner.nextLine());
String T = scanner.nextLine().toUpperCase();
//Define index for non alphabetic chars.
final int unknownCharIndex = 'Z' - 'A' + 1;
for (int i = 0; i < H; i++)
{
String asciiLine = scanner.nextLine();
for (int j = 0; j < T.length(); j++)
{
//Get ASCII index of current char.
int charIndex = T.charAt(j) - 'A';
int letterIndex = Character.isLetter(T.charAt(j)) ? charIndex : unknownCharIndex;
//Get ASCII line of current char.
String asciiPart = asciiLine.substring(letterIndex * L, (letterIndex + 1) * L);
//Print ASCII line part.
System.out.print(asciiPart);
}
System.out.println();
}
}
}