Modified Kaprekar Numbers
easy⏱ 15 mintypescriptchallengesproblem-solving-basic-
Runs in your browser
- Before starting
- Use a supported browser; initial dependencies may need internet.
- What it proves
- Run shows output; Test checks the authored cases, not every possible input.
- When finished
- Stop active runs when finished. No cloud infrastructure is provisioned by this exercise.
LEARN BY DOINGPut your intuition to work3 steps
Modified Kaprekar Numbers
Use the lesson’s examples and explanation to check your idea.
Personal reflection. Nothing is sent to an AI service.Before you start
Browser lesson checks; review each requirement in Tests.
Catalog level: Easy · Estimated time: 15 min. Your prior experience can change the difficulty.
1 9 45 55 99
Sample case — your program reads stdin and prints to stdout.
Need a hand?
Start with a small test case. Hints progress from an idea to an explanation and, when requested, code.
Starter A modified Kaprekar number n satisfies: square n, split the square into left part l and right part r (where r has exactly d digits, d = number of digits in n), then l + r = n. Find all such numbers in range [p, q].
Example: n=45 → square=2025 → split: l=20, r=25 (r has 2 digits, same as n) → 20+25=45 ✓. If no numbers found, output 'INVALID RANGE'.
Input format
Two integers p and q (p < q), one per line.
Output format
Print all modified Kaprekar numbers in the range, space-separated, or 'INVALID RANGE' if none exist.
Constraints
0 < p < q < 100000