Problema
Build a new string from the characters of text at positions 0, 2, 4, … (every other character, starting with the first).
Implement every_other_character(text).
Input
text: The original text.
Output
Return the characters at even positions, in order.
Restrições
0 ≤ length of text ≤ 10,000
Exemplos
Exemplo 1
Entrada:
text = "programming"
Saída esperada:
expected = "pormig"
Entrada:
std::string text = "programming";
Saída esperada:
std::string expected = "pormig";
Entrada:
string text = "programming";
Saída esperada:
string expected = "pormig";
Explicação
Positions 0, 2, 4, 6, 8, 10 give p, o, r, m, i, g: "pormig".
Exemplo 2
Entrada:
text = "a"
Saída esperada:
expected = "a"
Entrada:
std::string text = "a";
Saída esperada:
std::string expected = "a";
Entrada:
string text = "a";
Saída esperada:
string expected = "a";
Explicação
Only position 0 exists: "a".
Referências
Este desafio foi adaptado para o CodeUtility. Siga o enunciado e as restrições acima.