# Yet another digit insertion problem

Given a positive number $$\n\$$ we call another (not same as n) positive number $$\m\$$ good if we insert same digits in both n and m and the resulting fractional value is same.

$$m/n = m_{\text{transformed}}/n_{\text{transformed}}$$ $$or$$ $$m*n_{\text{transformed}} = m_{\text{transformed}}*n$$

Clarifications:

• No leading zeros or trailing zero insertion is allowed (you can insert 0 at beginning or end, but this must not be the last digit added in that end),other than this you can insert any digit(same digit and same number of time in both) at any place,i.e you need not insert at same place in n and m.

• At least one insertion is required.

Examples :

Example 1: $$n= 12$$

here m=66 is a good number ,we can obtain it by inserting 1 in m and n such that they become 616 and 112.

Example 2:

$$n=30$$

here m=60 is a good number, we can get 300 and 600 by inserting 0 in middle, as mentioned we cannot insert 0 at end or beginning, but here we inserted it in middle.

Example 3:

$$n=4$$ here 7 is a good number, as we can insert 2 and 1 , making them 124 and 217 respectively, now the fractional value is same.

Example 4:

$$n=11$$ here 2 is a good number, as we can insert 2 and 2 , making them 1221 and 222 respectively, now the fractional value is same.

Example 5:

$$n=4269$$ here 1423 is a good number, as we can insert 0, making them 42069 and 14023 respectively, now the fractional value is same.

Example 6:

$$n=1331$$ here 242 is a good number, as we can insert 2 and 2, making them 123321 and 22422 respectively, now the fractional value is same.

You have to find out smallest good number for a given n (there always exists a good number as pointed out by a user in comments).

This is , so the shortest answer in bytes per language wins.

• If 1 digit is inserted in each, do they have to be in the same position? (ex if n=4 and m=7 is 41 and 17 a valid insertion, I know it's not a solution but just as an example) – ophact Jun 7 at 10:57
• A solution must always exist. Given $n$ choose $m=n\times 10$, now insert a $1$ at the beginning of both numbers (or really do any insertion at the same place relative to the beginning of the number). – Wheat Wizard Jun 7 at 11:30
• Also, 3 is a valid solution for n=12: (12, 3) -> (132, 33), just helping you there – ophact Jun 7 at 12:03
• I'd suggest that you update your testcases such that they show the smallest possible number rather than the current ones which are not necessarily the shortest. – ophact Jun 7 at 15:12
• Also, when we insert 0s, sometimes the result is equivalent to adding 0s at the end, should this one not be allowed too ? For example, if we add two 0s in the middle of 10, we get 1000 which is equivalent to adding the 0s to the end – BrockenDuck Jun 7 at 20:59