FAQ
Why is the answer 20 and not 19?
The digit 9 appears once in the ones place of the numbers 9, 19, 29, ..., 99 (10 numbers) and once in the tens place of the numbers 90, 91, 92, ..., 99 (10 numbers). The number 99 contains a 9 in both places, so it is counted twice. 10 + 10 = 20.
Does H9A count 100?
No. 100 itself contains no digit 9, so it does not affect the count.
What is the maximum range I can use?
There is no hard limit; count_digit() uses a closed-form, per-place formula, so it stays fast even for enormous ranges (for example count_digit(9, 1, 10**12) returns instantly). Results beyond the hundreds of billions place fall back to a numeric place name.
Can I count the digit 0?
Yes: h9a --digit 0 --start 0 --end 9. Note that numbers are not zero-padded, so 5 is a one-digit number and does not contribute a leading zero.
Do I need to install anything?
Yes. H9A depends on rich and pyfiglet, plus Pillow for screenshots. See installation.md.
Why does the program print steps 2, 3, and 4 but not step 1?
The banner step (step 1) is executed but not labeled in the output; the printed steps begin at the calculation step. This is a quirk of the current implementation.
Is there a JSON output?
Yes. h9a --json prints a machine-readable result with digit, start, end, by_position, and total. See usage.md.
Can I use H9A inside my own program?
Yes. from h9a import count_digit gives you the counting logic, and build_lines() / render_text() / generate_screenshot() help you render or screenshot it. See api.md.
How do I regenerate the screenshot?
h9a --screenshot
Requires Pillow. See screenshots.md.
Does H9A work on Windows / macOS / Linux?
Yes, as long as Python 3.8+ and the dependencies are available.