問題
翻訳を表示Count integers from left through right, including both endpoints, that have no equal neighboring digits. Use their usual decimal writing with no leading zeroes. Zero and all other single-digit numbers qualify.
Implement counting_numbers(left, right).
Input
left: The first allowed value.
right: The last allowed value.
Output
Return how many values satisfy the rule.
制約
0 ≤ left ≤ right ≤ 10¹⁸. The range may be too large to inspect each integer individually.
例
入力:
left = 10
right = 15
期待される出力:
expected = 5
入力:
long long left = 10;
long long right = 15;
期待される出力:
long long expected = 5;
入力:
long left = 10;
long right = 15;
期待される出力:
long expected = 5;
解説
Only 11 has equal neighboring digits. The other five numbers qualify.
入力:
left = 0
right = 9
期待される出力:
expected = 10
入力:
long long left = 0;
long long right = 9;
期待される出力:
long long expected = 10;
入力:
long left = 0;
long right = 9;
期待される出力:
long expected = 10;
解説
All ten values have just one digit and therefore no equal neighbors.
参考資料
この課題はCodeUtility用に調整されています。上記の説明と制約に従ってください。