Problem
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.
Einschränkungen
0 ≤ length of text ≤ 10,000
Beispiele
Eingabe:
text = "programming"
Erwartete Ausgabe:
expected = "pormig"
Eingabe:
std::string text = "programming";
Erwartete Ausgabe:
std::string expected = "pormig";
Eingabe:
string text = "programming";
Erwartete Ausgabe:
string expected = "pormig";
Erläuterung
Positions 0, 2, 4, 6, 8, 10 give p, o, r, m, i, g: "pormig".
Eingabe:
text = "a"
Erwartete Ausgabe:
expected = "a"
Eingabe:
std::string text = "a";
Erwartete Ausgabe:
std::string expected = "a";
Eingabe:
string text = "a";
Erwartete Ausgabe:
string expected = "a";
Erläuterung
Only position 0 exists: "a".
Referenzen
Diese Aufgabe wurde für CodeUtility angepasst. Beachte die oben genannten Vorgaben und Einschränkungen.