Cody

Solution 1721950

Submitted on 6 Feb 2019 by Alfonso Nieto-Castanon
  • Size: 36
  • This is the leading solution.
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
% Don't hardcode solutions or use test-specific lookup tables of surnames. % (Lookup tables of letters and/or prefixes are allowed, if you want, though.) RE = regexp(fileread('meSortEm.m'), '\w+', 'match'); tabooWords = {'Hölderlin' 'Friedrich' 'Holz' 'Arno' ... 'Hoffmann' 'Josef' 'Hübsch' 'Heinrich' ... 'Grass' 'Günter' 'Grünberg' 'Arnon' 'Strauch' 'Hugo' 'Strauß' 'Botho' ... 'Deutsch' 'Gerti' 'Dietrich' 'Adolf' 'Dücker' 'Eugen'}; testResult = cellfun( @(z) ismember(z, lower(tabooWords)), lower(RE) ); msg = ['Please do not hard-code your ''solution''.' char([10 13]) 'Found: ' strjoin(RE(testResult)) '.' char([10 13])]; assert( ~any( testResult ), msg )

2   Pass
list = {'van Hoddis, Jakob' 'Hölderlin, Friedrich' 'Hofmann, Michael' 'von Hofmannsthal, Hugo' 'Holz, Arno'}; input = {'Hofmann, Michael' 'Hölderlin, Friedrich' 'Holz, Arno' 'van Hoddis, Jakob' 'von Hofmannsthal, Hugo'}; assert( isequal(meSortEm(input), list) )

3   Pass
data = {'Auböck, Maria' 'Behnisch, Günther' 'Böhm, Elisabeth' 'van den Broek, Jo' 'van Campen, Jacob' 'Dudok, Willem Marinus' 'von Erdmannsdorff, Frederick William' 'van Eyck, Aldo' ... 'Gaddi, Taddeo' 'von Gärtner, Friedrich' 'Galilei, Alessandro' 'Gang, Jeanne' 'Gardella, Ignazio' 'Garnier, Charles' 'Gatermann, Dörte' 'Gauzin-Müller, Dominique' ... 'von Gontard, Carl' 'Höger, Fritz' 'Hoffmann, Josef' 'Hübsch, Heinrich' 'Hundertwasser, Friedensreich Regentag Dunkelbunt' 'de Key, Lieven' 'de Keyser, Hendrick' 'von Klenze, Leo' ... 'von Knobelsdorff, Georg Wenzeslaus' 'Mies, Maria Ludwig Michael' 'Mies van der Rohe, Ludwig' 'Pöppelmann, Matthäus Daniel' 'van Ravesteyn, Sybold' 'de Ridder van Groenesteyn, Stefan' 'von Ritter zu Groenesteyn, Caspar Wilhelm' 'von Ritter von Grünstein, Anselm Franz' ... 'Schneider-Esleben, Paul' 'Schütte-Lihotzky, Margarete' 'Staal-Kropholler, Margaret' 'Stowasser, Friedrich' 'van der Vlugt, Leendert' 'Wils, Jan' 'van Winden, Wilfried' 'van Zuuk, René'}; L = length(data); for i = 1 : 20 elsAll = randperm( L ); elsSome = elsAll(1 : 20+randi(L-20)); list = data( sort(elsSome) ); elsInput = randperm( length(list) ); input = list(elsInput); assert( isequal(meSortEm(input), list) ) end;

4   Pass
data = {'von Arnim, Bettina' 'Böll, Heinrich' 'Büchner, Georg' 'Busch, Wilhelm' 'von Doderer, Heimito' 'von Droste-Hülshoff, Annette' 'von Ebner-Eschenbach, Marie' 'von Eichendorff, Joseph' 'von Eschenbach, Wolfram' 'Fleißer, Marieluise' ... 'Gauß, Karl-Markus' 'Görres, Joseph' 'von Goethe, Johann Wolfgang' 'Grass, Günter' 'Grünberg, Arnon' 'Haasse, Hella' 'Härtling, Peter' 'Hamerling, Robert' 'Handke, Peter' 'von Hardenberg, Georg Philipp Friedrich' ... 'de Hartog, Jan' 'Heißenbüttel, Helmut' 'Hochhuth, Rolf' 'Hölderlin, Friedrich' 'Hoffmann, E.T.A.' 'von Hofmannsthal, Hugo' 'Jünger, Ernst' 'Kästner, Erich' 'Kaminer, Wladimir' 'Kehlmann, Daniel' ... 'von Kleist, Heinrich' 'Kofler, Werner' 'Laßwitz, Kurd' 'von Leitner, Karl Gottfried' 'Lenz, Siegfried' 'Lernet-Holenia, Alexander' 'van Loon, Hendrik Willem' 'Nöstlinger, Christine' 'Preußler, Otfried' 'von Pückler-Muskau, Hermann Ludwig Heinrich' ... 'Raabe, Wilhelm' 'Raimund, Ferdinand' 'Rühmkorf, Peter' 'Strätz, Harald' 'Strahl, Manfred' 'Stramm, August' 'von Straßburg, Gottfried' 'Strasser, Charlot' 'Stratz, Rudolph' 'Straub, Maria Elisabeth' ... 'Strauch, Hugo' 'Strauß, Botho' 'von Strauß und Torney, Luise Elisabeth' 'Suchenwirt, Peter' 'Sudermann, Hermann' 'Sülzer, Bernd' 'Süskind, Patrick' 'Süßmann, Christel' 'Süverkrüp, Dieter' 'Sula, Marianne' ... 'Sulzenbacher, Hannes' 'Sulzer, Alain Claude' 'von Suttner, Bertha' 'von Trimberg, Süßkind' 'von der Vogelweide, Walter' 'van den Vondel, Joost' 'Voß, Johann Heinrich' 'de Vries, Anne' 'von Waldenfels, Rudolf' 'Walser, Martin' ... 'von Weißenburg, Otfrid' 'van de Wetering, Janwillem' 'von Wilpert, Gero' 'von Wolkenstein, Oswald' 'von Zatzikhoven, Ulrich'}; data = data'; L = length(data); for i = 1 : 20 elsAll = randperm( L ); elsSome = elsAll(1 : 35+randi(L-35)); list = data( sort(elsSome) ); elsInput = randperm( length(list) ); input = list(elsInput); assert( isequal(meSortEm(input), list) ) end;

5   Pass
% Amended 2018-03-11 to remove duplicate surname. data = {'Albers, Josef' 'Aldenrath, Heinrich Jacob' 'Alexander, William' 'Allers, Christian Wilhelm' 'Daege, Eduard' 'Dähling, Heinrich Anton' 'Dahm, Helen' 'Danckerts, Hendrick' ... 'Danioth, Heinrich' 'Dauerer, Gabriela' 'Decker, Cornelis Gerritsz' 'Degen, Paul' 'van Delen, Dirck' 'Deutsch, Gerti' 'van Diepenbeeck, Abraham' 'Diepraam, Abraham' ... 'Dietrich, Adolf' 'Dietz, Feodor' 'von Diez, Wilhelm' 'van Dijck, Floris Claesz' 'Dill, Ludwig' 'von Dillis, Johann Georg' 'Dinger, Fritz' 'Dinglinger, Georg Friedrich' ... 'Disler, Martin' 'Disteli, Martin' 'Dix, Otto' 'Doepler, Emil' 'Dörbeck, Franz Burchard' 'Doerner, Max' 'Domscheit, Franz' 'Donck, Gerard' ... 'Doomer, Lambert' 'Dou, Gerard' 'Drache, Heinz' 'Dräger, Anton Josef' 'Dreber, Heinrich' 'Dreesen, Willi' 'Droochsloot, Cornelis' ... 'Drost, Willem' 'Dryander, Johann Friedrich' 'Dubbels, Hendrick Jacobsz' 'Dubordieu, Pieter' 'Duck, Jacob' 'Dücker, Eugen' 'Dürer, Albrecht' 'Dufaux, Henri' ... 'Dujardin, Karel' 'Dunker, Balthasar Anton' 'Dusart, Cornelis' 'Duyster, Willem Cornelisz' 'Dyck, Hermann' 'Dziersk, Udo'}; L = length(data); for i = 1 : 20 elsAll = randperm( L ); elsSome = elsAll(1 : 25+randi(L-25)); list = data( sort(elsSome) ); elsInput = randperm( length(list) ); input = list(elsInput); assert( isequal(meSortEm(input), list) ) end;

6   Pass
% Added 2018-03-11 to test handling of hyphenation. data = {'Droste, Udo' 'Droste-Doderer, Heimito' 'von Droste-Hülshoff, Gerti' 'Droste-Strauß, Annette' 'Ebner, Wolfram' 'Ebner-Eichendorff, Willem' 'von Ebner-Eschenbach, Marie' 'Ebner-Nöstlinger, Christine' 'von Gauzin, Carl' 'Gauzin-Gatermann, Dominique' ... 'van Gauzin-Gontard, Dörte' 'Gauzin-Müller, Anton' 'Lernet, Hermann' 'Lernet-Holenia, Willem' 'Lernet-Loon, Hendrik' 'van Lernet-Süßmann, Christel' 'Pückler, Ludwig' 'Pückler-Dauerer, Gabriela' 'von Pückler-Muskau, Otfried' 'Pückler-Preußler, Heinrich'}; L = length(data); for i = 1 : 20 elsAll = randperm( L ); elsSome = elsAll(1 : 10+randi(L-10)); list = data( sort(elsSome) ); elsInput = randperm( length(list) ); input = list(elsInput); assert( isequal(meSortEm(input), list) ) end;