Cody

# Problem 1871. Numbers in extended form

Solution 2103711

Submitted on 23 Jan 2020 by Asif Newaz
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
x = 10234; y_correct = '10000+200+30+4'; assert(strcmp(extended_form(x),y_correct))

b1 = 1 b2 = 234 b3 = 10000 y = '10000+' b1 = 2 b2 = 34 b3 = 200 y = '10000+200+' b1 = 3 b2 = 4 b3 = 30 y = '10000+200+30+' b1 = 4 b2 = 0 b3 = 4 y = '10000+200+30+4+'

2   Pass
x=987654321; y_correct='900000000+80000000+7000000+600000+50000+4000+300+20+1'; assert(strcmp(extended_form(x),y_correct))

b1 = 9 b2 = 87654321 b3 = 900000000 y = '900000000+' b1 = 8 b2 = 7654321 b3 = 80000000 y = '900000000+80000000+' b1 = 7 b2 = 654321 b3 = 7000000 y = '900000000+80000000+7000000+' b1 = 6 b2 = 54321 b3 = 600000 y = '900000000+80000000+7000000+600000+' b1 = 5 b2 = 4321 b3 = 50000 y = '900000000+80000000+7000000+600000+50000+' b1 = 4 b2 = 321 b3 = 4000 y = '900000000+80000000+7000000+600000+50000+4000+' b1 = 3 b2 = 21 b3 = 300 y = '900000000+80000000+7000000+600000+50000+4000+300+' b1 = 2 b2 = 1 b3 = 20 y = '900000000+80000000+7000000+600000+50000+4000+300+20+' b1 = 1 b2 = 0 b3 = 1 y = '900000000+80000000+7000000+600000+50000+4000+300+20+1+'

3   Pass
x = 1000; y_correct = '1000'; assert(strcmp(extended_form(x),y_correct))

b1 = 1 b2 = 0 b3 = 1000 y = '1000+'

4   Pass
x = 314159265358979; y_correct = '300000000000000+10000000000000+4000000000000+100000000000+50000000000+9000000000+200000000+60000000+5000000+300000+50000+8000+900+70+9'; assert(strcmp(extended_form(x),y_correct))

b1 = 3 b2 = 1.4159e+13 b3 = 3.0000e+14 y = '300000000000000+' b1 = 1 b2 = 4.1593e+12 b3 = 1.0000e+13 y = '300000000000000+10000000000000+' b1 = 4 b2 = 1.5927e+11 b3 = 4.0000e+12 y = '300000000000000+10000000000000+4000000000000+' b1 = 1 b2 = 5.9265e+10 b3 = 1.0000e+11 y = '300000000000000+10000000000000+4000000000000+100000000000+' b1 = 5 b2 = 9.2654e+09 b3 = 5.0000e+10 y = '300000000000000+10000000000000+4000000000000+100000000000+50000000000+' b1 = 9 b2 = 265358979 b3 = 9.0000e+09 y = '300000000000000+10000000000000+4000000000000+100000000000+50000000000+9000000000+' b1 = 2 b2 = 65358979 b3 = 200000000 y = '300000000000000+10000000000000+4000000000000+100000000000+50000000000+9000000000+200000000+' b1 = 6 b2 = 5358979 b3 = 60000000 y = '300000000000000+10000000000000+4000000000000+100000000000+50000000000+9000000000+200000000+60000000+' b1 = 5 b2 = 358979 b3 = 5000000 y = '300000000000000+10000000000000+4000000000000+100000000000+50000000000+9000000000+200000000+60000000+5000000+' b1 = 3 b2 = 58979 b3 = 300000 y = '300000000000000+10000000000000+4000000000000+100000000000+50000000000+9000000000+200000000+60000000+5000000+300000+' b1 = 5 b2 = 8979 b3 = 50000 y = '300000000000000+10000000000000+4000000000000+100000000000+50000000000+9000000000+200000000+60000000+5000000+300000+50000+' b1 = 8 b2 = 979 b3 = 8000 y = '300000000000000+10000000000000+4000000000000+100000000000+50000000000+9000000000+200000000+60000000+5000000+300000+50000+8000+' b1 = 9 b2 = 79 b3 = 900 y = '300000000000000+10000000000000+4000000000000+100000000000+50000000000+9000000000+200000000+60000000+5000000+300000+50000+8000+900+' b1 = 7 b2 = 9 b3 = 70 y = '300000000000000+10000000000000+4000000000000+100000000000+50000000000+9000000000+200000000+60000000+5000000+300000+50000+8000+900+70+' b1 = 9 b2 = 0 b3 = 9 y = '300000000000000+10000000000000+4000000000000+100000000000+50000000000+9000000000+200000000+60000000+5000000+300000+50000+8000+900+70+9+'

5   Pass
x=540200; y_correct='500000+40000+200'; assert(strcmp(extended_form(x),y_correct))

b1 = 5 b2 = 40200 b3 = 500000 y = '500000+' b1 = 4 b2 = 200 b3 = 40000 y = '500000+40000+' b1 = 2 b2 = 0 b3 = 200 y = '500000+40000+200+'

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!