Cody

# Problem 44637. Still more miles to go before I sleep

Solution 1533559

Submitted on 18 May 2018 by David Verrelli
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
r=12341;b=4; assert(isequal(miles2(r,b),659))

rTxt = '012400' rTxt = '013000' ans = 659

2   Pass
r=12341;b=2; assert(isequal(miles2(r,b),87659))

rTxt = '020000' rTxt = '0100000' ans = 87659

3   Pass
r=12331;b=4; assert(isequal(miles2(r,b),0))

ans = 0

4   Pass
r=455555;b=5; assert(isequal(miles2(r,b),544445))

rTxt = '0500000' rTxt = '01000000' ans = 544445

5   Pass
r=23907515;b=5; assert(isequal(miles2(r,b),92485))

rTxt = '024000000' ans = 92485

6   Pass
r=23807515;b=8; assert(isequal(miles2(r,b),192485))

rTxt = '024000000' ans = 192485

7   Pass
s=zeros(1,10); for b=2:10 s(b)=miles2(123456789,b); end assert(isequal(sum(s),960219488))

rTxt = '0200000000' rTxt = '01000000000' ans = 876543211 rTxt = '0130000000' rTxt = '0200000000' ans = 76543211 rTxt = '0124000000' rTxt = '0130000000' ans = 6543211 rTxt = '0123500000' rTxt = '0124000000' ans = 543211 rTxt = '0123460000' rTxt = '0123500000' ans = 43211 rTxt = '0123457000' rTxt = '0123460000' ans = 3211 rTxt = '0123456800' rTxt = '0123457000' ans = 211 rTxt = '0123456790' rTxt = '0123456800' ans = 11 ans = 0

8   Pass
s=zeros(200,10); for b=2:10 for r=1:200 s(r,b)=miles2(r,b); end end assert(isequal(sum(s(:)),96940))

ans = 0 rTxt = '010' ans = 8 rTxt = '010' ans = 7 rTxt = '010' ans = 6 rTxt = '010' ans = 5 rTxt = '010' ans = 4 rTxt = '010' ans = 3 rTxt = '010' ans = 2 rTxt = '010' ans = 1 ans = 0 ans = 0 rTxt = '020' rTxt = '0100' ans = 88 rTxt = '020' rTxt = '0100' ans = 87 rTxt = '020' rTxt = '0100' ans = 86 rTxt = '020' rTxt = '0100' ans = 85 rTxt = '020' rTxt = '0100' ans = 84 rTxt = '020' rTxt = '0100' ans = 83 rTxt = '020' rTxt = '0100' ans = 82 rTxt = '020' rTxt = '0100' ans = 81 rTxt = '0100' ans = 80 rTxt = '0100' ans = 79 rTxt = '0100' ans = 78 rTxt = '0100' ans = 77 rTxt = '0100' ans = 76 rTxt = '0100' ans = 75 rTxt = '0100' ans = 74 rTxt = '0100' ans = 73 rTxt = '0100' ans = 72 rTxt = '0100' ans = 71 rTxt = '0100' ans = 70 rTxt = '0100' ans = 69 rTxt = '0100' ans = 68 rTxt = '0100' ans = 67 rTxt = '0100' ans = 66 rTxt = '0100' ans = 65 rTxt = '0100' ans = 64 rTxt = '0100' ans = 63 rTxt = '0100' ans = 62 rTxt = '0100' ans = 61 rTxt = '0100' ans = 60 rTxt = '0100' ans = 59 rTxt = '0100' ans = 58 rTxt = '0100' ans = 57 rTxt = '0100' ans = 56 rTxt = '0100' ans = 55 rTxt = '0100' ans = 54 rTxt = '0100' ans = 53 rTxt = '0100' ans = 52 rTxt = '0100' ans = 51 rTxt = '0100' ans = 50 rTxt = '0100' ans = 49 rTxt = '0100' ans = 48 rTxt = '0100' ans = 47 rTxt = '0100' ans = 46 rTxt = '0100' ans = 45 rTxt = '0100' ans = 44 rTxt = '0100' ans = 43 rTxt = '0100' ans = 42 rTxt = '0100' ans = 41 rTxt = '0100' ans = 40 rTxt = '0100' ans = 39 rTxt = '0100' ans = 38 rTxt = '0100' ans = 37 rTxt = '0100' ans = 36 rTxt = '0100' ans = 35 rTxt = '0100' ans = 34 rTxt = '0100' ans = 33 rTxt = '0100' ans = 32 rTxt = '0100' ans = 31 rTxt = '0100' ans = 30 rTxt = '0100' ans = 29 rTxt = '0100' ans = 28 rTxt = '0100' ans = 27 rTxt = '0100' ans = 26 rTxt = '0100' ans = 25 rTxt = '0100' ans = 24 rTxt = '0100' ans = 23 rTxt = '0100' ans = 22 rTxt = '0100' ans = 21 rTxt = '0100' ans = 20 rTxt = '0100' ans = 19 rTxt = '0100' ans = 18 rTxt = '0100' ans = 17 rTxt = '0100' ans = 16 rTxt = '0100' ans = 15 rTxt = '0100' ans = 14 rTxt = '0100' ans = 13 rTxt = '0100' ans = 12 rTxt = '0100' ans = 11 rTxt = '0100' ans = 10 rTxt = '0100' ans = 9 rTxt = '0100' ans = 8 rTxt = '0100' ans = 7 rTxt = '0100' ans = 6 rTxt = '0100' ans = 5 rTxt = '0100' ans = 4 rTxt = '0100' ans = 3 rTxt = '0100' ans = 2 rTxt = '0100' ans = 1 ans = 0 ans = 0 rTxt = '0110' ans = 8 rTxt = '0110' ans = 7 rTxt = '0110' ans = 6 rTxt = '0110' ans = 5 rTxt = '0110' ans = 4 rTxt = '0110' ans = 3 rTxt = '0110' ans = 2 rTxt = '0110' ans = 1 ans = 0 ans = 0 rTxt = '0120' rTxt = '0200' rTxt = '01000' ans = 888 rTxt = '0120' rTxt = '0200' rTxt = '01000' ans = 887 rTxt = '0120' rTxt = '0200' rTxt = '01000' ans = 886 rTxt = '0120' rTxt = '0200' rTxt = '01000' ans = 885 rTxt = '0120' rTxt = '0200' rTxt = '01000' ans = 884 rTxt = '0120' rTxt = '0200' rTxt = '01000' ans = 883 rTxt = '0120' rTxt = '0200' rTxt = '01000' ans = 882 rTxt = '0120' rTxt = '0200' rTxt = '01000' ans = 881 rTxt = '0200' rTxt = '01000' ans = 880 rTxt = '0200' rTxt = '01000' ans = 879 rTxt = '0200' rTxt = '01000' ans = 878 rTxt = '0200' rTxt = '01000' ans = 877 rTxt = '0200' rTxt = '01000' ans = 876 rTxt = '0200' rTxt = '01000' ans = 875 rTxt = '0200' rTxt = '01000' ans = 874 rTxt = '0200' rTxt = '01000' ans = 873 rTxt = '0200' rTxt = '01000' ans = 872 rTxt = '0200' rTxt = '01000' ans = 871 rTxt = '0200' rTxt = '01000' ans = 870 rTxt = '0200' rTxt = '01000' ans = 869 rTxt = '0200' rTxt = '01000' ans = 868 rTxt = '0200' rTxt = '01000' ans = 867 rTxt = '0200' rTxt = '01000' ans = 866 rTxt = '0200' rTxt = '01000' ans = 865 rTxt = '0200' rTxt = '01000' ans = 864 rTxt = '0200' rTxt = '01000' ans = 863 rTxt = '0200' rTxt = '01000' ans = 862 rTxt = '0200' rTxt = '01000' ans = 861 rTxt = '0200' rTxt = '01000' ans = 860 rTxt = '0200' rTxt = '01000' ans = 859 rTxt = '0200' rTxt = '01000' ans = 858 rTxt = '0200' rTxt = '01000' ans = 857 rTxt = '0200' rTxt = '01000' ans = 856 rTxt = '0200' rTxt = '01000' ans = 855 rTxt = '0200' rTxt = '01000' ans = 854 rTxt = '0200' rTxt = '01000' ans = 853 rTxt = '0200' rTxt = '01000' ans = 852 rTxt = '0200' rTxt = '01000' ans = 851 rTxt = '0200' rTxt = '01000' ans = 850 rTxt = '0200' rTxt = '01000' ans = 849 rTxt = '0200' rTxt = '01000' ans = 848 rTxt = '0200' rTxt = '01000' ans = 847 rTxt = '0200' rTxt = '01000' ans = 846 rTxt = '0200' rTxt = '01000' ans = 845 rTxt = '0200' rTxt = '01000' ans = 844 rTxt = '0200' rTxt = '01000' ans = 843 rTxt = '0200' rTxt = '01000' ans = 842 rTxt = '0200' rTxt = '01000' ans = 841 rTxt = '0200' rTxt = '01000' ans = 840 rTxt = '0200' rTxt = '01000' ans = 839 rTxt = '0200' rTxt = '01000' ans = 838 rTxt = '0200' rTxt = '01000' ans = 837 rTxt = '0200' rTxt = '01000' ans = 836 rTxt = '0200' rTxt = '01000' ans = 835 rTxt = '0200' rTxt = '01000' ans = 834 rTxt = '0200' rTxt = '01000' ans = 833 rTxt = '0200' rTxt = '01000' ans = 832 rTxt = '0200' rTxt = '01000' ans = 831 rTxt = '0200' rTxt = '01000' ans = 830 rTxt = '0200' rTxt = '01000' ans = 829 rTxt = '0200' rTxt = '01000' ans = 828 rTxt = '0200' rTxt = '01000' ans = 827 rTxt = '0200' rTxt = '01000' ans = 826 rTxt = '0200' rTxt = '01000' ans = 825 rTxt = '0200' rTxt = '01000' ans = 824 rTxt = '0200' rTxt = '01000' ans = 823 rTxt = '0200' rTxt = '01000' ans = 822 rTxt = '0200' rTxt = '01000' ans = 821 rTxt = '0200' rTxt = '01000' ans = 820 rTxt = '0200' rTxt = '01000' ans = 819 rTxt = '0200' rTxt = '01000' ans = 818 rTxt = '0200' rTxt = '01000' ans = 817 rTxt = '0200' rTxt = '01000' ans = 816 rTxt = '0200' rTxt = '01000' ans = 815 rTxt = '0200' rTxt = '01000' ans = 814 rTxt = '0200' rTxt = '01000' ans = 813 rTxt = '0200' rTxt = '01000' ans = 812 rTxt = '0200' rTxt = '01000' ans = 811 rTxt = '0200' rTxt = '01000' ans = 810 rTxt = '0200' rTxt = '01000' ans = 809 rTxt = '0200' rTxt = '01000' ans = 808 rTxt = '0200' rTxt = '01000' ans = 807 rTxt = '0200' rTxt = '01000' ans = 806 rTxt = '0200' rTxt = '01000' ans = 805 rTxt = '0200' rTxt = '01000' ans = 804 rTxt = '0200' rTxt = '01000' ans = 803 rTxt = '0200' rTxt = '01000' ans = 802 rTxt = '0200' rTxt = '01000' ans = 801 rTxt = '01000' ans = 800 ans = 0 ans = 0 rTxt = '010' ans = 7 rTxt = '010' ans = 6 rTxt = '010' ans = 5 rTxt = '010' ans = 4 rTxt = '010' ans = 3 rTxt = '010' ans = 2 rTxt = '010' ans = 1 ans = 0 ans = 0 ans = 0 rTxt = '020' ans = 7 rTxt = '020' ans = 6 rTxt = '020' ans = 5 rTxt = '020' ans = 4 rTxt = '0...