Skip to content

Instantly share code, notes, and snippets.

View y-tag's full-sized avatar

TAGAMI Yukihiro y-tag

View GitHub Profile
@y-tag
y-tag / tsp.py
Created September 4, 2010 11:58
GDD2010Japan DevQuiz Google Maps API
#! /usr/bin/python
# -*- coding: utf-8 -*-
import fileinput
import itertools
import urllib2
import sys
from BeautifulSoup import BeautifulStoneSoup
def get_html(url):
@y-tag
y-tag / oauth.py
Created September 4, 2010 12:28
GDD2010Japan DevQuiz 2-legged OAuth
#! /usr/bin/python
# -*- coding: utf-8 -*-
import base64
import hashlib
import hmac
import httplib
import time
import urllib
@y-tag
y-tag / shiritori.py
Created September 4, 2010 12:30
GDD2010Japan DevQuiz Shiritori
#! /usr/bin/python
# -*- coding: utf-8 -*-
import fileinput
def build_tree(path, se_dict, tree):
sub_tree = tree
for x in path:
se = x[0] + x[-1]
if se not in sub_tree:
@y-tag
y-tag / pacman.py
Created September 4, 2010 12:32
GDD2010Japan DevQuiz PAC-MAN
#! /usr/bin/python
# -*- coding: utf-8 -*-
import fileinput
import sys
import random
class Field:
def __init__(self, field, limit):
self.field = field
@y-tag
y-tag / word_count.cpp
Created February 27, 2011 09:19
simple word count with boost string/tokenizer
#include <boost/algorithm/string.hpp>
#include <boost/tokenizer.hpp>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <map>
int main(int argc, char **argv)
{
@y-tag
y-tag / gist:961240
Created May 8, 2011 09:12
GCJ 2011 QR A.Bot Trust
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
main();
sub main {
@y-tag
y-tag / gist:961242
Created May 8, 2011 09:14
GCJ 2011 QR B.Magicka
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
main();
sub main {
@y-tag
y-tag / gist:961244
Created May 8, 2011 09:17
GCJ 2011 QR C.Candy Splitting
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use List::Util;
main();
@y-tag
y-tag / gist:961246
Created May 8, 2011 09:18
GCJ 2011 QR D.GoroSort
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
main();
sub main {
package DownhillSimplex;
use strict;
use warnings;
use 5.008;
sub simplex {
my ($init_vertices, $params, $coes, $eval_func, $disp_func) = @_;
my $alpha = defined($coes->{alpha}) ? $coes->{alpha} : 1;