Given a ruler length in inches and fractions of an inch, and a granularity in fractions of an inch, output the values of all marks on the ruler, starting from 0, in ascending order.
Input ruler length will be a mixed fraction (integer and proper fraction)
Input granularity will be a proper fraction in the form 1/(2ⁿ)
, where 1 ≤ n ≤ 6
.
Output numbers will all be expressed similarly to the input. For values where the number of inches is a whole number, no fractional part will be expressed. For values where the number of inches is 0 < n < 1
, only the fractional part will be expressed.
If the input granularity is not fine enough to represent the ruler length, then the final number will be the closest representable number below the ruler length.
Examples
Input 1
1/2
would output:
0
1/2
1
Input 2 3/4
1/8
would output:
0
1/8
1/4
3/8
1/2
5/8
3/4
7/8
1
1 1/8
1 1/4
1 3/8
1 1/2
1 5/8
1 3/4
1 7/8
2
2 1/8
2 1/4
2 3/8
2 1/2
2 5/8
2 3/4
Input 2 3/4
1/2
would output:
0
1/2
1
1 1/2
2
2 1/2
2+3/4
? \$\endgroup\$