Lonely Numbers

Published by Deep Xavier in

Given a number, insert duplicate digits on both sides of all digits which appear in a group of one.

Examples

numbersNeedFriendsToo(22733) ➞ 2277733
// The number can be split into groups 22, 7, and 33.
// 7 appears on its own.
// Put 7s on both sides to create 777.
// Put the numbers together and return the result.

numbersNeedFriendsToo(4666) ➞ 444666

numbersNeedFriendsToo(544) ➞ 55544

numbersNeedFriendsToo(123) ➞ 111222333

numbersNeedFriendsToo(56657) ➞ 55566555777

numbersNeedFriendsToo(33) ➞ 33

Notes

All tests will include positive integers.

Watch a quick demo on how Edabit works.