Cody

Problem 43754. Lah Numbers

Solution 1077745

Submitted on 8 Dec 2016 by Kensuke Fujita
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 = 8; y_correct = [1,0,0,0,0,0,0,0,0;2,1,0,0,0,0,0,0,0;6,6,1,0,0,0,0,0,0;24,36,12,1,0,0,0,0,0;120,240,120,20,1,0,0,0,0;720,1800,1200,300,30,1,0,0,0;5040,15120,12600,4200,630,42,1,0,0;40320,141120,141120,58800,11760,1176,56,1,0;362880,1451520,1693440,846720,211680,28224,2016,72,1]; assert(isequal(lah(x),y_correct))

y = 1 y = 1 2 y = 1 0 2 1 y = 1 0 2 1 6 0 y = 1 0 2 1 6 6 y = 1 0 0 2 1 0 6 6 1 y = 1 0 0 2 1 0 6 6 1 24 0 0 y = 1 0 0 2 1 0 6 6 1 24 36 0 y = 1 0 0 2 1 0 6 6 1 24 36 12 y = 1 0 0 0 2 1 0 0 6 6 1 0 24 36 12 1 y = 1 0 0 0 2 1 0 0 6 6 1 0 24 36 12 1 120 0 0 0 y = 1 0 0 0 2 1 0 0 6 6 1 0 24 36 12 1 120 240 0 0 y = 1 0 0 0 2 1 0 0 6 6 1 0 24 36 12 1 120 240 120 0 y = 1 0 0 0 2 1 0 0 6 6 1 0 24 36 12 1 120 240 120 20 y = 1 0 0 0 0 2 1 0 0 0 6 6 1 0 0 24 36 12 1 0 120 240 120 20 1 y = 1 0 0 0 0 2 1 0 0 0 6 6 1 0 0 24 36 12 1 0 120 240 120 20 1 720 0 0 0 0 y = 1 0 0 0 0 2 1 0 0 0 6 6 1 0 0 24 36 12 1 0 120 240 120 20 1 720 1800 0 0 0 y = 1 0 0 0 0 2 1 0 0 0 6 6 1 0 0 24 36 12 1 0 120 240 120 20 1 720 1800 1200 0 0 y = 1 0 0 0 0 2 1 0 0 0 6 6 1 0 0 24 36 12 1 0 120 240 120 20 1 720 1800 1200 300 0 y = 1 0 0 0 0 2 1 0 0 0 6 6 1 0 0 24 36 12 1 0 120 240 120 20 1 720 1800 1200 300 30 y = 1 0 0 0 0 0 2 1 0 0 0 0 6 6 1 0 0 0 24 36 12 1 0 0 120 240 120 20 1 0 720 1800 1200 300 30 1 y = 1 0 0 0 0 0 2 1 0 0 0 0 6 6 1 0 0 0 24 36 12 1 0 0 120 240 120 20 1 0 720 1800 1200 300 30 1 5040 0 0 0 0 0 y = 1 0 0 0 0 0 2 1 0 0 0 0 6 6 1 0 0 0 24 36 12 1 0 0 120 240 120 20 1 0 720 1800 1200 300 30 1 5040 15120 0 0 0 0 y = 1 0 0 0 0 0 2 1 0 0 0 0 6 6 1 0 0 0 24 36 12 1 0 0 120 240 120 20 1 0 720 1800 1200 300 30 1 5040 15120 12600 0 0 0 y = 1 0 0 0 0 0 2 1 0 0 0 0 6 6 1 0 0 0 24 36 12 1 0 0 120 240 120 20 1 0 720 1800 1200 300 30 1 5040 15120 12600 4200 0 0 y = 1 0 0 0 0 0 2 1 0 0 0 0 6 6 1 0 0 0 24 36 12 1 0 0 120 240 120 20 1 0 720 1800 1200 300 30 1 5040 15120 12600 4200 630 0 y = 1 0 0 0 0 0 2 1 0 0 0 0 6 6 1 0 0 0 24 36 12 1 0 0 120 240 120 20 1 0 720 1800 1200 300 30 1 5040 15120 12600 4200 630 42 y = 1 0 0 0 0 0 0 2 1 0 0 0 0 0 6 6 1 0 0 0 0 24 36 12 1 0 0 0 120 240 120 20 1 0 0 720 1800 1200 300 30 1 0 5040 15120 12600 4200 630 42 1 y = 1 0 0 0 0 0 0 2 1 0 0 0 0 0 6 6 1 0 0 0 0 24 36 12 1 0 0 0 120 240 120 20 1 0 0 720 1800 1200 300 30 1 0 5040 15120 12600 4200 630 42 1 40320 0 0 0 0 0 0 y = 1 0 0 0 0 0 0 2 1 0 0 0 0 0 6 6 1 0 0 0 0 24 36 12 1 0 0 0 120 240 120 20 1 0 0 720 1800 1200 300 30 1 0 5040 15120 12600 4200 630 42 1 40320 141120 0 0 0 0 0 y = 1 0 0 0 0 0 0 2 1 0 0 0 0 0 6 6 1 0 0 0 0 24 36 12 1 0 0 0 120 240 120 20 1 0 0 720 1800 1200 300 30 1 0 5040 15120 12600 4200 630 42 1 40320 141120 141120 0 0 0 0 y = 1 0 0 0 0 0 0 2 1 0 0 0 0 0 6 6 1 0 0 0 0 24 36 12 1 0 0 0 120 240 120 20 1 0 0 720 1800 1200 300 30 1 0 5040 15120 12600 4200 630 42 1 40320 141120 141120 58800 0 0 0 y = 1 0 0 0 0 0 0 2 1 0 0 ...

2   Pass
x = 1; y_correct = [1,0;2,1]; assert(isequal(lah(x),y_correct))

y = 1 y = 1 2 y = 1 0 2 1

3   Pass
x = 3; y_correct = [1,0,0,0;2,1,0,0;6,6,1,0;24,36,12,1]; assert(isequal(lah(x),y_correct))

y = 1 y = 1 2 y = 1 0 2 1 y = 1 0 2 1 6 0 y = 1 0 2 1 6 6 y = 1 0 0 2 1 0 6 6 1 y = 1 0 0 2 1 0 6 6 1 24 0 0 y = 1 0 0 2 1 0 6 6 1 24 36 0 y = 1 0 0 2 1 0 6 6 1 24 36 12 y = 1 0 0 0 2 1 0 0 6 6 1 0 24 36 12 1

4   Pass
x = 10; y_correct = [1,0,0,0,0,0,0,0,0,0,0;2,1,0,0,0,0,0,0,0,0,0;6,6,1,0,0,0,0,0,0,0,0;24,36,12,1,0,0,0,0,0,0,0;120,240,120,20,1,0,0,0,0,0,0;720,1800,1200,300,30,1,0,0,0,0,0;5040,15120,12600,4200,630,42,1,0,0,0,0;40320,141120,141120,58800,11760,1176,56,1,0,0,0;362880,1451520,1693440,846720,211680,28224,2016,72,1,0,0;3628800,16329600,21772800,12700800,3810240,635040,60480,3240,90,1,0;39916800,199584000,299376000,199584000,69854400,13970880,1663200,118800,4950,110,1]; assert(isequal(lah(x),y_correct))

y = 1 y = 1 2 y = 1 0 2 1 y = 1 0 2 1 6 0 y = 1 0 2 1 6 6 y = 1 0 0 2 1 0 6 6 1 y = 1 0 0 2 1 0 6 6 1 24 0 0 y = 1 0 0 2 1 0 6 6 1 24 36 0 y = 1 0 0 2 1 0 6 6 1 24 36 12 y = 1 0 0 0 2 1 0 0 6 6 1 0 24 36 12 1 y = 1 0 0 0 2 1 0 0 6 6 1 0 24 36 12 1 120 0 0 0 y = 1 0 0 0 2 1 0 0 6 6 1 0 24 36 12 1 120 240 0 0 y = 1 0 0 0 2 1 0 0 6 6 1 0 24 36 12 1 120 240 120 0 y = 1 0 0 0 2 1 0 0 6 6 1 0 24 36 12 1 120 240 120 20 y = 1 0 0 0 0 2 1 0 0 0 6 6 1 0 0 24 36 12 1 0 120 240 120 20 1 y = 1 0 0 0 0 2 1 0 0 0 6 6 1 0 0 24 36 12 1 0 120 240 120 20 1 720 0 0 0 0 y = 1 0 0 0 0 2 1 0 0 0 6 6 1 0 0 24 36 12 1 0 120 240 120 20 1 720 1800 0 0 0 y = 1 0 0 0 0 2 1 0 0 0 6 6 1 0 0 24 36 12 1 0 120 240 120 20 1 720 1800 1200 0 0 y = 1 0 0 0 0 2 1 0 0 0 6 6 1 0 0 24 36 12 1 0 120 240 120 20 1 720 1800 1200 300 0 y = 1 0 0 0 0 2 1 0 0 0 6 6 1 0 0 24 36 12 1 0 120 240 120 20 1 720 1800 1200 300 30 y = 1 0 0 0 0 0 2 1 0 0 0 0 6 6 1 0 0 0 24 36 12 1 0 0 120 240 120 20 1 0 720 1800 1200 300 30 1 y = 1 0 0 0 0 0 2 1 0 0 0 0 6 6 1 0 0 0 24 36 12 1 0 0 120 240 120 20 1 0 720 1800 1200 300 30 1 5040 0 0 0 0 0 y = 1 0 0 0 0 0 2 1 0 0 0 0 6 6 1 0 0 0 24 36 12 1 0 0 120 240 120 20 1 0 720 1800 1200 300 30 1 5040 15120 0 0 0 0 y = 1 0 0 0 0 0 2 1 0 0 0 0 6 6 1 0 0 0 24 36 12 1 0 0 120 240 120 20 1 0 720 1800 1200 300 30 1 5040 15120 12600 0 0 0 y = 1 0 0 0 0 0 2 1 0 0 0 0 6 6 1 0 0 0 24 36 12 1 0 0 120 240 120 20 1 0 720 1800 1200 300 30 1 5040 15120 12600 4200 0 0 y = 1 0 0 0 0 0 2 1 0 0 0 0 6 6 1 0 0 0 24 36 12 1 0 0 120 240 120 20 1 0 720 1800 1200 300 30 1 5040 15120 12600 4200 630 0 y = 1 0 0 0 0 0 2 1 0 0 0 0 6 6 1 0 0 0 24 36 12 1 0 0 120 240 120 20 1 0 720 1800 1200 300 30 1 5040 15120 12600 4200 630 42 y = 1 0 0 0 0 0 0 2 1 0 0 0 0 0 6 6 1 0 0 0 0 24 36 12 1 0 0 0 120 240 120 20 1 0 0 720 1800 1200 300 30 1 0 5040 15120 12600 4200 630 42 1 y = 1 0 0 0 0 0 0 2 1 0 0 0 0 0 6 6 1 0 0 0 0 24 36 12 1 0 0 0 120 240 120 20 1 0 0 720 1800 1200 300 30 1 0 5040 15120 12600 4200 630 42 1 40320 0 0 0 0 0 0 y = 1 0 0 0 0 0 0 2 1 0 0 0 0 0 6 6 1 0 0 0 0 24 36 12 1 0 0 0 120 240 120 20 1 0 0 720 1800 1200 300 30 1 0 5040 15120 12600 4200 630 42 1 40320 141120 0 0 0 0 0 y = 1 0 0 0 0 0 0 2 1 0 0 0 0 0 6 6 1 0 0 0 0 24 36 12 1 0 0 0 120 240 120 20 1 0 0 720 1800 1200 300 30 1 0 5040 15120 12600 4200 630 42 1 40320 141120 141120 0 0 0 0 y = 1 0 0 0 0 0 0 2 1 0 0 0 0 0 6 6 1 0 0 0 0 24 36 12 1 0 0 0 120 240 120 20 1 0 0 720 1800 1200 300 30 1 0 5040 15120 12600 4200 630 42 1 40320 141120 141120 58800 0 0 0 y = 1 0 0 0 0 0 0 2 1 0 0 ...

Suggested Problems

More from this Author11

Community Treasure Hunt

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

Start Hunting!