Cody

Problem 574. Sort numbers by outside digits

Solution 2026591

Submitted on 18 Nov 2019 by Doan Quang Manh
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 = [12368933, 12345931, 68221, 533111, 3819999999999]; y_correct = [12345931, 12368933, 3819999999999, 533111, 68221]; assert(isequal(your_fcn_name(x),y_correct))

b = '12368933' a = 12333 b = '12345931' a = 12333 12331 b = '68221' a = 12333 12331 68221 b = '533111' a = 12333 12331 68221 53311 b = '3819999999999' a = 12333 12331 68221 53311 38199 B = 12331 12333 38199 53311 68221 I = 2 1 5 4 3 y = 1.0e+12 * 0.0000 0.0000 3.8200 0.0000 0.0000

2   Pass
x = [4591023, 37410101, 97516, 888123, 15061789]; y_correct = [15061789, 37410101, 4591023, 888123, 97516]; assert(isequal(your_fcn_name(x),y_correct))

b = '4591023' a = 45923 b = '37410101' a = 45923 37401 b = '97516' a = 45923 37401 97516 b = '888123' a = 45923 37401 97516 88823 b = '15061789' a = 45923 37401 97516 88823 15089 B = 15089 37401 45923 88823 97516 I = 5 2 1 4 3 y = 15061789 37410101 4591023 888123 97516

3   Pass
x = [1110098, 1110197, 1110296, 1110395, 1110494, 1110593, 1110691]; y_correct = fliplr(x); assert(isequal(your_fcn_name(x),y_correct))

b = '1110098' a = 11198 b = '1110197' a = 11198 11197 b = '1110296' a = 11198 11197 11196 b = '1110395' a = 11198 11197 11196 11195 b = '1110494' a = 11198 11197 11196 11195 11194 b = '1110593' a = 11198 11197 11196 11195 11194 11193 b = '1110691' a = 11198 11197 11196 11195 11194 11193 11191 B = 11191 11193 11194 11195 11196 11197 11198 I = 7 6 5 4 3 2 1 y = 1110691 1110593 1110494 1110395 1110296 1110197 1110098

4   Pass
x = [324651, 65432114, 1032464, 21465476, 1232165746561, 12321]; y_correct = [1032464, 12321, 1232165746561, 21465476, 324651, 65432114]; assert(isequal(your_fcn_name(x),y_correct))

b = '324651' a = 32451 b = '65432114' a = 32451 65414 b = '1032464' a = 32451 65414 10364 b = '21465476' a = 32451 65414 10364 21476 b = '1232165746561' a = 32451 65414 10364 21476 12361 b = '12321' a = 32451 65414 10364 21476 12361 12321 B = 10364 12321 12361 21476 32451 65414 I = 3 6 5 4 1 2 y = 1.0e+12 * 0.0000 0.0000 1.2322 0.0000 0.0000 0.0001

Suggested Problems

Community Treasure Hunt

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

Start Hunting!