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.
Vincoli
0 ≤ length of text ≤ 10,000
Esempi
Esempio 1
Input:
text = "programming"
Output atteso:
expected = "pormig"
Input:
std::string text = "programming";
Output atteso:
std::string expected = "pormig";
Input:
string text = "programming";
Output atteso:
string expected = "pormig";
Spiegazione
Positions 0, 2, 4, 6, 8, 10 give p, o, r, m, i, g: "pormig".
Esempio 2
Input:
text = "a"
Output atteso:
expected = "a"
Input:
std::string text = "a";
Output atteso:
std::string expected = "a";
Input:
string text = "a";
Output atteso:
string expected = "a";
Spiegazione
Only position 0 exists: "a".
Riferimenti
Questa sfida è adattata per CodeUtility. Segui la traccia e i vincoli sopra.