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
words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', 6: 'Six', | |
7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', 11: 'Eleven', | |
12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', 15: 'Fifteen', | |
16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', 19: 'Nineteen', | |
20: 'Twenty', 30: 'Thirty', 40: 'Forty', 50: 'Fifty', 60: 'Sixty', | |
70: 'Seventy', 80: 'Eighty', 90: 'Ninety', 100: 'Hundred', | |
1000: 'Thousand', 1000000: 'Million', 1000000000: 'Billion'} | |
units = sorted(words, reverse=True) | |
def number2word(number): |
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
def divide_file(filePath, chunkSize): | |
def read(): | |
with open(filePath, 'rb') as f: | |
while True: | |
data = f.read(chunkSize) | |
if len(data) == 0: | |
return | |
yield data |
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 python | |
# -*- coding:utf-8 -*- | |
from itertools import product | |
class Group: | |
def __init__(self, missionaries, cannibals): | |
self.missionaries = missionaries |
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 python3 | |
# -*- coding:utf-8 -*- | |
# | |
# Lyrics converter | |
# | |
# version: 2017.4.18 | |
# author: @shiracamus | |
# github: https://github.com/shiracamus/lyrics_converter | |
# | |
# Need to install mutagen module |
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 python3 | |
# -*- coding:utf-8 -*- | |
position = lambda name: { | |
'a':(1, 2, 3), 'd':(7, 4, 1), 'g':(9, 8, 7), 'j':(3, 6, 9), | |
'b':(4, 5, 6), 'e':(8, 5, 2), 'h':(6, 5, 4), 'k':(2, 5, 8), | |
'c':(7, 8, 9), 'f':(9, 6, 3), 'i':(3, 2, 1), 'l':(1, 4, 7), | |
}[name] | |
def solve(data): |
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
#include <stdio.h> | |
#include <string.h> | |
typedef char Digit; | |
typedef struct { | |
Digit digits[3]; | |
} Row; | |
typedef union { |
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
#include <cstdio> | |
#include <cstdlib> | |
#include <ctime> | |
#include <iostream> | |
#include <random> | |
#include <vector> | |
class Maze { | |
int start_x, | |
start_y; |
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
def number2yx(number): | |
b = int((number - 1) ** 0.5) | |
start = b ** 2 + 1 | |
a = min(number - start, start + b * 2 - number) | |
return (a, b) if (b % 2 == 1) ^ (a == number - start) else (b, a) | |
def yx2number(y, x): | |
if y < 0 or x < 0: return '-' | |
a, b = sorted((y, x)) | |
start = b ** 2 + 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
import time | |
from itertools import count | |
def make_gunegune(size): | |
size = (size + 1) | 1 | |
gunegune = [['-'] * size for y in range(size)] | |
number = count(1) | |
for z in range(1, size, 2): | |
for x in range(1, z, +1): gunegune[z][x] = next(number) | |
for y in range(z, 0, -1): gunegune[y][z] = next(number) |
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 python3 | |
# -*- coding: utf-8 -*- | |
import random | |
import matplotlib.pyplot as plt | |
NUM_TRIAL = 500 # 試行回数 | |
ODDS = 2 # オッズ | |
START_MONEY = 100 # 初期資金 | |
START_BET = 1 # 最初のベット額 |
OlderNewer