Skip to content

Instantly share code, notes, and snippets.

View shiracamus's full-sized avatar

@shiracamus shiracamus

View GitHub Profile
@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 {
@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 / 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
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from itertools import product
class Group:
def __init__(self, missionaries, cannibals):
self.missionaries = missionaries
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
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):