Given a positive number as a string, multiply the number by 11 and also return it as a string. However, there is a catch:
You are NOT ALLOWED to simply cast the numeric string into an integer!
Now, how is this challenge even possible? Despite this, there is still a way to solve it, and it involves thinking about how someone might multiply by 11 in their head. See the tips below for guidance.
multiplyBy11("11") ➞ "121"
multiplyBy11("111111111") ➞ "1222222221"
multiplyBy11("1213200020") ➞ "13345200220"
multiplyBy11("1217197941") ➞ "13389177351"
multiplyBy11("9473745364784876253253263723") ➞ "104211199012633638785785900953"
There is a simple trick to multiplying any two-digit number by 11 in your head:
// 23 * 11
// Add together 2 and 3 to make 5
// Place 5 between the two digits to make 253
// 77 * 11
// Add together 7 and 7 to make 14
// Place 4 between the two digits to make 747
// Carry the 1 to make 847