Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

★ /prog/ challenge No. 666 ★ (Easy)

Name: Anonymous 2013-01-07 12:41

THE CHALLENGE:
Implement ``Tohosort'' (http://www.freewebs.com/tohosort/) 66in Lisp99 in your programming language of choice.

Post the source code of your implementation. It should at least read the input from stdin and print a sorted list after making the comparisons.

Deadline: 2013-01-21 00:00.

The programs will be judged by elegance, speed and number of comparisons made using a random list that will be published the day of the deadline. The winner will be awarded with Ten (10) שקליםSuss (that's Suss-shekels for you goyim), which is enough to pay the fee needed to cross the Sanzu River by ferry.

Name: Anonymous 2013-01-11 12:19

In Ruby. It looks quite fancy -- both the source code (it's remarkably short if you leave out the data) and the interface:

games, touhous = eval DATA.read

selection = case ARGV[0]
  when "-a"
    (0..16).to_a
  when "-c"
    games.each_index.select do |i|
      print "Include games from #{games[i]}? "
      $stdin.gets =~ /y/i
    end
  when '-h'
    puts <<-END
   
    Usage:
      #$0       Sort Touhous from games only
      #$0 -a    Sort all Touhous
      #$0 -c    Custom source selection
      #$0 -h    Show this help
    END
   
    exit
  else
    (0..9).to_a
end

def touhou_cmp(a, b)
  fmt = "\e[31m%30s\e[0m (1) vs. (2) \e[32m%-30s\e[0m ? "
  loop do
    printf fmt, a, b
    case $stdin.gets.chomp
      when "1"; return -1
      when "2"; return  1
    end
  end
end

touhous.reject! { |i| (i[1] & selection).empty? }
puts touhous.map(&:first).sort &method(:touhou_cmp)

__END__
[
  [
    "Embodiment of Scarlet Devil",
    "Perfect Cherry Blossom",
    "Immaterial and Missing Power",
    "Imperishable Night",
    "Phantasmagoria of Flower View",
    "Mountain of Faith",
    "Scarlet Weather Rhapsody",
    "Subterranean Animism",
    "Touhou Hisoutensoku",
    "Undefined Fantastic Object",
    "Books and CDs",
    "The Highly Responsive to Prayers",
    "The Story of Eastern Wonderland",
    "Phantasmagoria of Dim.Dream",
    "Lotus Land Story",
    "Mystic Square",
    "Others",
  ],
  [
    ["Reimu Hakurei",              [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],
    ["Marisa Kirisame",            [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],
    ["Rumia",                      [0, 10]],
    ["Daiyousei",                  [0, 10]],
    ["Cirno",                      [0, 1, 4, 8, 10]],
    ["Hong Meiling",               [0, 2, 8, 10]],
    ["Koakuma",                    [0, 10]],
    ["Patchouli Knowledge",        [0, 2, 6, 8, 10]],
    ["Sakuya Izayoi",              [0, 1, 2, 3, 4, 6, 8, 10]],
    ["Remilia Scarlet",            [0, 2, 3, 6, 8, 10]],
    ["Flandre Scarlet",            [0, 10]],
    ["Letty Whiterock",            [1, 10]],
    ["Chen",                       [1, 2, 6, 8, 10]],
    ["Alice Margatroid",           [1, 2, 3, 6, 8, 10]],
    ["Shanghai Doll",              [1, 2, 3, 6, 8]],
    ["Hourai Doll",                [1, 2, 3, 6, 8]],
    ["Lily White",                 [1, 4, 10]],
    ["Lunasa Prismriver",          [1, 4, 10]],
    ["Merlin Prismriver",          [1, 4, 10]],
    ["Lyrica Prismriver",          [1, 4, 10]],
    ["Youmu Konpaku",              [1, 2, 3, 4, 6, 8, 10]],
    ["Yuyuko Saigyouji",           [1, 2, 3, 6, 8, 10]],
    ["Ran Yakumo",                 [1, 2, 3, 6, 8, 10]],
    ["Yukari Yakumo",              [1, 2, 3, 6, 8, 10]],
    ["Suika Ibuki",                [2, 6, 8, 10]],
    ["Wriggle Nightbug",           [3, 10]],
    ["Mystia Lorelei",             [3, 4, 10]],
    ["Keine Kamishirasawa",        [3, 10]],
    ["Tewi Inaba",                 [3, 4, 10]],
    ["Reisen Udongein Inaba",      [3, 4, 8, 10]],
    ["Eirin Yagokoro",             [3, 10]],
    ["Kaguya Hoiraisan",           [3, 10]],
    ["Kimo-Keine",                 [3]],
    ["Fujiwara no Mokou",          [3, 10]],
    ["Aya Shameimaru",             [4, 6, 8, 10]],
    ["Medicine Melancholy",        [4, 10]],
    ["Yuka Kazami",                [4, 10]],
    ["Komachi Onozuka",            [4, 6, 8, 10]],
    ["Shikieiki Yamaxanadu",       [4, 10]],
    ["Shizuha Aki",                [5]],
    ["Minoriko Aki",               [5]],
    ["Hina Kagiyama",              [5]],
    ["Nitori Kawashiro",           [5]],
    ["Momiji Inubashiri",          [5]],
    ["Sanae Kochiya",              [5, 7, 8, 9]],
    ["Kanako Yasaka",              [5, 8]],
    ["Suwako Moriya",              [5, 7, 8]],
    ["Iku Nagae",                  [6, 8]],
    ["Tenshi Hinanawi",            [6, 8]],
    ["Edo Explosive Pawn",         [6, 8]],
    ["Kisume",                     [7]],
    ["Yamame Kurodani",            [7]],
    ["Parsee Mizuhashi",           [7]],
    ["Yuugi Hoshiguma",            [7]],
    ["Orin (Cat form)",            [7]],
    ["Satori Komeiji",             [7]],
    ["Rin Kaenbyou (Orin)",        [7]],
    ["Zombie Fairy",               [7]],
    ["Utsuho Reiuji (Okuu)",       [7, 8]],
    ["Koishi Komeiji",             [7]],
    ["Goliath Doll",               [8]],
    ["Great Catfish",              [8]],
    ["Nazrin",                     [9]],
    ["Kogasa Tatara",              [9]],
    ["Ichirin Kumoi",              [9]],
    ["Unzan",                      [9]],
    ["Minamitsu Murasa",           [9]],
    ["Shou Toramaru",              [9]],
    ["Byakuren Hijiri",            [9]],
    ["Nue Houjuu",                 [9]],
    ["Sunny Milk",                 [10]],
    ["Luna Child",                 [10]],
    ["Star Sapphire",              [10]],
    ["Sake Insect",                [10]],
    ["Tsuchinoko",                 [10]],
    ["Giant Toad",                 [10]],
    ["Great Tengu of Miyama",      [10]],
    ["Rain Fairy",                 [10]],
    ["Rinnosuke Morichika",        [10]],
    ["Hieda no Akyu",              [10]],
    ["Tokiko",                     [10]],
    ["Reisen",                     [10]],
    ["Watatsuki no Toyohime",      [10]],
    ["Watatsuki no Yorihime",      [10]],
    ["Maribel Hearn",              [10]],
    ["Renko Usami",                [10]],
    ["Mr. Kirisame",               [10]],
    ["Reimu Hakurei (PC-98)",      [11, 12, 13, 14, 15]],
    ["Yin-Yang Orb",               [11]],
    ["Shingyoku",                  [11]],
    ["YuugenMagan",                [11]],
    ["Elis",                       [11]],
    ["Sariel",                     [11]],
    ["Kikuri",                     [11]],
    ["Konngara",                   [11]],
    ["Genjii",                     [11, 12, 13, 14, 15]],
    ["Rika",                       [12]],
    ["Meira",                      [12]],
    ["Marisa Kirisame (PC-98)",    [12, 13, 14, 15]],
    ["Mima",                       [11, 12, 13, 15]],
    ["Ellen",                      [13]],
    ["Kotohime",                   [13]],
    ["Kana Anaberal",              [13]],
    ["Rikako Asakura",             [13]],
    ["Chiyuri Kitashirakawa",      [13]],
    ["Yumemi Okazaki",             [13]],
    ["Ruukoto",                    [13]],
    ["Mimi-chan",                  [13]],
    ["Orange",                     [14]],
    ["Kurumi",                     [14]],
    ["Elly",                       [14]],
    ["Yuka (PC-98)",               [14, 15]],
    ["Mugetu",                     [14]],
    ["Gengetu",                    [14]],
    ["Sara",                       [15]],
    ["Luize",                      [15]],
    ["Alice",                      [15]],
    ["Yuki",                       [15]],
    ["Mai",                        [15]],
    ["Yumeko",                     [15]],
    ["Shinki",                     [15]],
    ["Lily Black",                 [4, 16]],
    ["Scarlet Devil Mansion Maid", [16]],
    ["Eientei Rabbit",             [16]],
    ["Leila Prismriver",           [16]],
    ["Youki Konpaku",              [16]],
    ["Fluff Ball",                 [16]],
  ]
]

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List