GJam: 2013 China Event: Name Sorting - MATLAB Cody - MATLAB Central

Problem 1876. GJam: 2013 China Event: Name Sorting

Difficulty:|Rate

This Challenge is derived from GJam 2013 China Moist. The problem is Codified by making the input a cell array of names.

The Challenge involves a serial card sorting machine that places card (i+1) in its best position, 1 thru i, if the name on card (i+1) is lexicographically greater than the name on card (i). The machine continues thru the end of the deck. The machine then restarts at card 1 until the order is correct. The output to return is the number of card insertions. The character values follow ascii codes with Space < A:Z < a:z. A shorter name is less than an extended name (Ab<Abe)

Input: names ( cell array of names )

Output: Insertions (count of card insertions required)

Competition Summary: Best Time 6 minutes, 793/1049 correct

Example:

names={'Stuart Beckingham' 'Rinata Araslanova' 'Jeremy Abbott' 'Daniil Barantsev' };

Clearly takes 3 card insertions. Start (SRJD) moves [(RSJD) (JRSD) (DJRS)]

Solution Stats

61.11% Correct | 38.89% Incorrect
Last Solution submitted on Oct 03, 2020

Solution Comments

Show comments
MATLAB EXPO 2025 Registration is Now Open! November 12 – 13, 2025
Registration is now open for MathWorks annual virtual event MATLAB EXPO 2025...
0

Problem Recent Solvers10

Suggested Problems

More from this Author308

Community Treasure Hunt

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

Start Hunting!