-
Notifications
You must be signed in to change notification settings - Fork 126
/
Main.java
executable file
·80 lines (63 loc) · 2.36 KB
/
Main.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
* Hash Mágico
*
* Desafio:
* - O conceito de hash é transformar uma grande quantidade de
* dados em uma pequena quantidade de informações. Nesse algoritmo
* você terá uma entrada com várias linhas, cada uma com uma string.
*
* - O valor de cada caracter é computado como segue:
*
* - Valor = (Posição no alfabeto) + (Elemento de entrada) +
* (Posição do elemento)
*
* - As posições iniciam em zero. 'A' tem posição 0 no alfabeto, ‘C'
* tem posição 2 no alfabeto, ... O cálculo de hash retornado é a soma
* de todos os caracteres da entrada. Por exemplo, se a entrada for:
*
* - CBA
* - DDD
*
* - então cada caractere deverá ser computado como segue:
* 2 = 2 + 0 + 0 : 'C' no elemento 0 posição 0
* 2 = 1 + 0 + 1 : 'B' no elemento 0 posição 1
* 2 = 0 + 0 + 2 : 'A' no elemento 0 posição 2
* 4 = 3 + 1 + 0 : 'D' no elemento 1 posição 0
* 5 = 3 + 1 + 1 : 'D' no elemento 1 posição 1
* 6 = 3 + 1 + 2 : 'D' no elemento 1 posição 2
*
* - O cálculo final de hash será 2+2+2+4+5+6 = 21.
*
* Entrada:
* - A entrada contém vários casos de teste. A primeira linha de entrada
* contém um inteiro N que indica a quantidade de casos de teste. Cada caso
* de teste inicia com um inteiro L (1 ≤ L ≤ 100) que indica a quantidade de
* linhas que vem a seguir. Cada uma destas L linhas contém uma string com até
* 50 let