This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
sub find_pair { | |
my ($elems, $target) = @_; | |
my @sums = map { eval } glob join "+", map "{$_}", map join(",", @$_), $elems, $elems; | |
while (my ($i, $s) = each @sums) { | |
next unless $s == $target; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
import datetime | |
import itertools | |
import logging | |
import shelve | |
import requests | |
import requests.adapters | |
import tqdm | |
import urllib3.util.retry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import turtle as t | |
from math import sin, pi, log | |
f = 1 | |
l, r = True, False | |
t.reset() | |
t.speed(0) | |
t.hideturtle() | |
t.bgcolor(0, 0, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
from itertools import product | |
T = int(input()) | |
for t in range(T): | |
N, M = list(map(int, input().split())) | |
grid = [list(map(int, input().split())) for n in range(N)] | |
rowmax = list(map(max, grid)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# find words which are mirror-image palindromes in elian script | |
with open("/usr/share/dict/words", encoding="utf-8", errors="ignore") as fin: | |
words = [word.strip().lower() for word in fin.readlines()] | |
sub = {'i': 'c', 'h': 'b', 'k': 'q', 'j': 'p', 'm': 'm', 'l': 'r', 'o': 'o', 'n': 'n', 'a': 'g', 'c': 'i', 'b': 'h', 'e': 'e', 'd': 'd', 'g': 'a', 'f': 'f', 'y': 's', 'x': 'x', 'z': 't', 'q': 'k', 'p': 'j', 's': 'y', 'r': 'l', 't': 'z', 'w': 'w', 'v': 'v'} | |
for word in words: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# does not work with python 2.x | |
print("".join(map(lambda x: chr((lambda p, x: int(sum(map(lambda i: p[i]*x**(11-i), range(12))) + 0.001))([__import__("struct").unpack('>d', bytes([int(s[8*i:8*i+8], 2) for i in range(8)]))[0] for s in ["1011111101010000111010100110011000001101001100000110010001011111", "0011111110110000000101110100001011100000001010111100100101110011", "1011111111111010101001111000010001111000000111111001101001000100", "0100000000111001001101110000110101000110000001010100001100011000", "1100000001101110000010000010100110101001111010000000111011101101", "0100000010010111011001010111000101110010000010000101010111011100", "1100000010110111111110111100001101011100011011101001111111101100", "0100000011001111101011010010010111011011001011001000001110000011", "1100000011011001100001011001001010011100110001010011010100111001", "0100000011010110010101010110010000110001111011111110011001000111", "1100000010111111100000011000011000100110010110100001000110110110", "0100000001010001111 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# my first solution (lost) in the interactive interpreter used DP, but this | |
# is fast enough | |
fac = lambda x: reduce(lambda a, b: a * b, range(1, x + 1)) | |
R = lambda x: sum(int(c) for c in str(fac(x))) | |
x = 1 | |
while R(x) != 8001: | |
x += 1 | |
print(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
from sys import argv | |
argv[0] = argv[0].split("/")[-1] | |
print " ".join(argv[::-1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2 | |
sudo tar jxvf wkhtmltopdf-0.11.0_rc1-static-i386.tar.bz2 -C /opt | |
sudo rm /usr/bin/wkhtmltopdf | |
sudo ln -s /opt/wkhtmltopdf-amd64 /usr/bin/wkhtmltopdf | |
rm wkhtmltopdf-0.11.0_rc1-static-i386.tar.bz2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Random; | |
public class MinHeap<T extends Comparable<T>> { | |
private ArrayList<T> values; | |
public MinHeap() { | |
values = new ArrayList<T>(); | |
} |
NewerOlder