Skip to content

Instantly share code, notes, and snippets.

View shiracamus's full-sized avatar

@shiracamus shiracamus

View GitHub Profile
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):
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
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from itertools import product
class Group:
def __init__(self, missionaries, cannibals):
self.missionaries = missionaries
@shiracamus
shiracamus / lyrics_converter.py
Created January 13, 2018 22:04
convert lyrics data in mp3 files to lrc text files
#!/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
@shiracamus
shiracamus / yhpg_doukaku_F09.py
Last active February 2, 2018 01:48
オフラインリアルタイムどう書く F09 のPython実装例 https://qiita.com/Nabetani/items/61e13fa5cf0abe5979be
#!/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):
@shiracamus
shiracamus / yhpg_doukaku_F09.c
Last active February 2, 2018 10:13
オフラインリアルタイムどう書く F09 のC言語実装例 https://qiita.com/Nabetani/items/61e13fa5cf0abe5979be
#include <stdio.h>
#include <string.h>
typedef char Digit;
typedef struct {
Digit digits[3];
} Row;
typedef union {
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <random>
#include <vector>
class Maze {
int start_x,
start_y;
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
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)
#!/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 # 最初のベット額