#P2657. Count Windy Numbers
Count Windy Numbers
Count Windy Numbers
A windy number is defined as a positive integer which does not have any leading zeros and for which the absolute difference between any two adjacent digits is at least \(2\). Given two positive integers \(a\) and \(b\), count how many windy numbers exist in the range \([a, b]\), inclusive.
More formally, let a number be represented as \(d_1d_2\dots d_k\) where \(d_1\) is non-zero. The number is windy if for every \(i=1,2,\dots,k-1\), the following holds:
[ |d_i - d_{i+1}| \ge 2 ]
Calculate the total number of windy numbers between \(a\) and \(b\) (both inclusive).
inputFormat
The input consists of a single line containing two space-separated positive integers \(a\) and \(b\), where \(1 \leq a \leq b\).
outputFormat
Output a single integer: the count of windy numbers in the range \([a, b]\).
sample
1 10
9