Все задачи
Легко Решено: 0 Процент решений: 0%

Every Other Character

Keep the characters at even positions.

Условие

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.

Ограничения

0 ≤ length of text ≤ 10,000

Примеры

Пример 1
Ввод:
text = "programming"

Ожидаемый вывод:
expected = "pormig"
Ввод:
std::string text = "programming";

Ожидаемый вывод:
std::string expected = "pormig";
Ввод:
string text = "programming";

Ожидаемый вывод:
string expected = "pormig";

Пояснение

Positions 0, 2, 4, 6, 8, 10 give p, o, r, m, i, g: "pormig".

Пример 2
Ввод:
text = "a"

Ожидаемый вывод:
expected = "a"
Ввод:
std::string text = "a";

Ожидаемый вывод:
std::string expected = "a";
Ввод:
string text = "a";

Ожидаемый вывод:
string expected = "a";

Пояснение

Only position 0 exists: "a".

Ссылки

Это задание адаптировано для CodeUtility. Следуйте условию и ограничениям выше.

Учитесь у других

Решения сообщества

Пока нет опубликованных решений. Решите задание, чтобы поделиться первым.