We've recently reached the threshold of 10,000 questions on PPCG. Hooray! Let's celebrate this with a simple challenge.
Input
Two integers \$A\$ and \$B\$, both in \$[1..9999]\$, such that \$A+B<10000\$.
Task
Your task is to add one single digit to one of these integers or one single digit to both of them such that \$A+B=10000\$. If adding a digit to both \$A\$ and \$B\$, it need not necessarily be the same digit.
The new digit can be added at the beginning, at the end or anywhere in the middle of the original integer. However, you can't add a leading zero.
Example:
For \$A=923\$, the following transformations are valid:
$$\color{red}1923\\92\color{red}73\\923\color{red}8$$
But these ones are invalid:
$$\color{red}{0}923\\\color{red}{10}923\\9\color{red}{4}2\color{red}{7}3$$
Given \$A=923\$ and \$B=72\$, there are two possible solutions:
$$923\color{red}8 + 7\color{red}62 = 10000\\92\color{red}73 + 72\color{red}7 = 10000$$
Output
You must print or output a list of all possible solutions.
For the above example, the expected output would be [[9238,762],[9273,727]]
.
Rules
- I/O can be processed in any reasonable, unambiguous format. You may use strings, lists of digits, etc. instead of integers.
- The input is guaranteed to have at least one solution.
- You are allowed not to deduplicate the output. However, it would be appreciated if the test code is deduplicating it with some post-processing, for instance in the footer section of TIO.
- This is a code-golf challenge.
Test cases
Input --> Output
934, 654 --> [[9346,654]]
737, 628 --> [[7372,2628]]
9122, 88 --> [[9122,878]]
923, 72 --> [[9238,762],[9273,727]]
998, 3 --> [[9968,32],[9987,13]]
900, 10 --> [[9900,100],[9090,910]] NB: solutions such as [9000,1000] are NOT valid
(more than one digit added to 10)
363, 632 --> [[3673,6327],[3638,6362]]
288, 711 --> [[2881,7119],[2882,7118],[2883,7117],[2884,7116],[2885,7115],[2886,7114],
[2887,7113],[2888,7112],[2889,7111]]
365, 635 --> [[365,9635],[1365,8635],[2365,7635],[3365,6635],[4365,5635],[5365,4635],
[6365,3635],[7365,2635],[8365,1635],[9365,635],[3065,6935],[3165,6835],
[3265,6735],[3465,6535],[3565,6435],[3665,6335],[3765,6235],[3865,6135],
[3965,6035],[3605,6395],[3615,6385],[3625,6375],[3635,6365],[3645,6355],
[3655,6345],[3675,6325],[3685,6315],[3695,6305],[3650,6350]]
output a list of all possible solutions
Oh bummer. That'd be difficult for my Runic language. I could probably write a program that could output a solution! \$\endgroup\$