## Algorithm

Problem Name: 2 AD-HOC - beecrowd | 1986

# The Martian

Por Alex Paixão, UNIME Brazil

Timelimit: 1

In the movie "The Martian," the astronaut Mark Watney is presumed dead after being caught in a storm, which was left behind while the rest of the team plan to evacuate the planet and return to Earth. Watney is so alone and abandoned, with some provisions and his wit, skill and spirit to survive and find a way to send a signal to home, knowing that even if they know that he is alive, it is very vague hypothesis of a rescue.

Watner, still alive, needed to contact NASA to tell he was still alive, but the place where he had no means of communication with Earth, it was then that he remembered the Pathfinder mission that the ship landed on the Red Planet on 4 July 1997 and released a small rover with six wheels, called Sojourner, to study the neighboring land. The mission had a duration of a few weeks but it turned out to last almost three months. The ship reported for the last time with the teams on Earth on 27 September. He analyzing on the map realized that the Pathfinder was near its "station", then the same thought of using it as communication.

However, the only communication that there was it was a camera that rotate 360 degrees on its axis, to register and send photos on Mars for NASA, as the distance from Earth to Mars are 55.76 million square kilometers (it's not exact because it depends on the position of the rotation of the earth as a reference SOL), a message that is sent from Earth to Mars lasts a time of 30 minutes (technology of the time), it is now smaller, and believe me, the message was walking at the speed of light when creating the Fold (Star Trek) this will be quiet.

Watner had an idea, as the camera rotates 360 degrees, he established at each point equidistant in the circle, a hexadecimal value, where the camera would point the desired code, in a split second, and Watner would annotate and check lestra corresponding in his ASCII table, as shown below.

You have been selected to work at NASA and you’ll have to help Watner to survive, make a program that converts into hexadecimal to character to translate the message, the letters are only "az" 26 characters.

Example: n = 3, then we'll have three pairs of hexadecimal "61 6F 6C", and it is found in the table the letters corresponding to the 6F =, 6C = le 61 = a, turning into "hello".

## Input

It will have a number n (1 <= n <= 100) indicating the word length, and "n" times two hexadecimal places, which means a letter.

See the example below:

## Output

Only the translated message

 Input Sample Output Sample 7 73 6F 63 6F 72 72 6F socorro

## Code Examples

### #1 Code Example with C Programming

```Code - C Programming```

``````
#include <stdio.h>

int main (void)
{

unsigned short caractere, mensagemTam;

scanf("%hu", &mensagemTam);

do
{
scanf("%hx", &caractere);

// Verifica se o caractere lido é um espaço;
// Se não for, printa esse caractere com a diretiva %c
// O C converte o código hexa da tabela ASCII
// Para o símbolo correspondente a esse código;
// Como o URI só verifica a saída ao final do programa
// Posso imprimir os caracreres assim que os leio;
if (caractere != ' ')
{
printf("%c", caractere);
mensagemTam--;
}

} while (mensagemTam);

printf("\n");
}
``````
Copy The Code &

### #2 Code Example with Javascript Programming

```Code - Javascript Programming```

``````
const { readFileSync } = require("fs")
const [numCases, ...input] = readFileSync("/dev/stdin", "utf8").split(/\s+/g)

const lostInMarsMsg = (message) => String.fromCharCode(...message)

function main() {
const formattedMessages = input.slice(0, +numCases).map(hex => `0x\${hex}`)
const message = lostInMarsMsg(formattedMessages)

console.log(message)
}

main()
``````
Copy The Code &

### #3 Code Example with Python Programming

```Code - Python Programming```

``````
input()
e = [chr(int(x, 16)) for x in input().split()]
for i in e: print(i, end='')
print()
``````
Copy The Code &