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
## Connect 4 | |
import os | |
import re | |
import time | |
class Screen: | |
""" | |
Uses re module | |
""" | |
def clear(): |
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 json | |
import re | |
LINE_SPLIT = re.compile("^.*?\s(.*?)\s\[(.*?)\].*?$") ## group 1 is the simplified, group 2 is the pinyin | |
TONE_MAP = { | |
"a": ["ā", "á", "ǎ", "à"], | |
"e": ["ē", "é", "ě", "è"], | |
"i": ["ī", "í", "ǐ", "ì"], | |
"o": ["ō", "ó", "ǒ", "ò"], | |
"u": ["ū", "ú", "ǔ", "ù"], |
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
// uses cell range C1:D1 to the last row | |
// saves as "englishWord : chineseWord : source (translate.google.com)" for parser to interpret | |
function saveToTextfile() { | |
var ss = SpreadsheetApp.getActive(); | |
var sh = ss.getActiveSheet(); | |
var rg = sh.getRange(1, 3, sh.getLastRow(), 2); | |
var vs = rg.getValues(); | |
console.log(vs) | |
// format 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
ordered = [ | |
1, 5, 10, 50, 100, 500, 1000 | |
] | |
mapping = { | |
1: "I", | |
5: "V", | |
10: "X", | |
50: "L", | |
100: "C", | |
500: "D", |