highwind (owner)

Forks

Revisions

  • 0443b4 Timothy... Mon May 18 12:38:25 -0700 2009
  • 62cd8b Timothy... Mon May 18 12:33:11 -0700 2009
  • 56657b Timothy... Mon May 18 12:30:46 -0700 2009
  • 7f5e8c Timothy... Mon May 18 12:27:44 -0700 2009
  • 21169c highwind Mon May 18 00:41:14 -0700 2009
  • bdac5c highwind Mon May 18 00:40:17 -0700 2009
  • 1e986e Timothy... Mon May 18 00:37:50 -0700 2009
  • eeda9a Timothy... Mon May 18 00:34:27 -0700 2009
  • 4781b3 Timothy... Mon May 18 00:27:28 -0700 2009
  • 7e2a8c highwind Sun May 17 23:39:48 -0700 2009
gist: 113331 Download_button fork
public
Description:
청기백기 게임 명령문 Generator
Public Clone URL: git://gist.github.com/113331.git
Embed All Files: show embed
README #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
청기백기 게임 명령문 Generator.
 
So far implemented in ...
- Python 2.5 : 3 lines
- Python 3.0 : 3 lines
- Ruby : 2 lines
- Java : 9 lines
- Perl : 3 lines
 
 
To be implemented in ...
- C
- haskell
- lisp (maybe clojure?)
- objective c
- C#
- D
- Lua
 
 
Q&A
---
Q: What is this?
A: All the programs here outputs list of randomly generated Korean flag game commands.
 
Q: Why?
A: Because I needed it for my church picnic.
 
Q: I mean, why so many languages?
A: Why not? It's kinda fun.
 
Q: Can I suggest a language?
A: Sure.
 
Q: Can implement it in a language?
A: Sure.
 
Q: This Q&A seems pretty pointless.
A: That's not a question.
 
flags.2.5.py #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/python
# This Python file uses the following encoding: utf-8
from sys import argv
import sys, random, re
 
if len(argv) < 2 or not re.match(r"^\d+$", sys.argv[1]):
    sys.stderr.write("Usage: python %s n\n" % sys.argv[0])
    exit(1)
 
#code start
data = [[u"청기", u"백기", u"둘다"], [u"올", u"내"], [u"려",u"려",u"리지마"]]
 
for i in range(int(sys.argv[1])):
    print "".join([random.choice(d) for d in data])
 
flags.3.0.py #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/local/bin/python3.0
from sys import argv
import random, re, sys
 
if len(argv) < 2 or not re.match(r"^\d+$", sys.argv[1]):
    sys.stderr.write("Usage: python %s n\n" % sys.argv[0])
    exit(1)
 
#code start
data = [["청기", "백기", "둘다"], ["올", "내"], ["려","려","리지마"]]
 
for i in range(int(sys.argv[1])):
    print(*[random.choice(d) for d in data], sep='')
 
 
flags.c #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <stdio.h>
#include <stdlib.h>
 
int main(int argc, char const* argv[]) {
    int n;
    if (argc < 2 || (n = strtol(argv[1], NULL, 10)) == 0) {
        perror("Usage: flags n");
    }
    for (n; n > 0; n--) {
 
    }
    
    return 0;
}
 
flags.hs #
1
2
random_choice d = d!!length
 
Flags.java #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.regex.Pattern;
 
public class Flags {
    public static void main (String [] args) {
        if (args.length < 1 || !Pattern.matches("^\\d+$", args[0])) {
            System.err.println("Usage: java Flags n");
            System.exit(1);
        }
 
        //code start
        ArrayList<ArrayList> data = new ArrayList<ArrayList>();
        data.add(new ArrayList<String>(Arrays.asList("청기", "백기", "둘다")));
        data.add(new ArrayList<String>(Arrays.asList("올", "내")));
        data.add(new ArrayList<String>(Arrays.asList("려","려","리지마")));
        Random r = new Random();
        for (int i = 0; i < Integer.parseInt(args[0]); i++) {
            for (ArrayList d : data) {
                System.out.print(d.get(r.nextInt(d.size())));
            }
            System.out.println();
        }
 
    }
}
 
flags.pl #
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/perl
use File::Basename;
 
die "Usage: perl " , basename(__FILE__), " n\n" if (!($ARGV[0] =~ /^\d+$/));
 
#code start
my @data = ([qw/청기 백기 둘다/],[qw/올 내/],[qw/려 려 리지마/]);
 
local $\ = "\n";
print map { @$_[rand @$_] } @data for 1..$ARGV[0];
 
#code credit to aero from KLDP - http://kldp.org/node/105514#comment-488207
 
flags.rb #
1
2
3
4
5
6
7
8
9
10
#!/usr/bin/ruby
 
abort "Usage: ruby #{File.basename(__FILE__)} n" if ARGV[0].to_i == 0
 
#code start
data = [["청기", "백기", "둘다"], ["올", "내"], ["려","려","리지마"]]
 
ARGV[0].to_i.times {puts data.collect {|d| d[rand(d.length)]}.join}