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
레지스터에는 총 10가지의 종류가 있다!! | |
* 이름없는 레지스터 : "" | |
* 10개의 번호 레지스터 : "0 | |
* 삭제 레지스터 : "- | |
* 26개의 이름이 있는 레지스터 a-z : 대소문자를 구분하지 않음 | |
* 세 종류의 읽기 전용 레지스터 : ":, "., "% | |
* 대체 버퍼 레지스터 : "# | |
* 표현식 레지스터 : "= |
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
{ | |
"_LETTERS_": { | |
"Kiyeok": ["0x3131", "ㄱ"], | |
"Ssangkiyeok": ["0x3132", "ㄲ"], | |
"Kiyeok-Sios": ["0x3133", "ㄳ"], | |
"Nieun": ["0x3134", "ㄴ"], | |
"Nieun-Cieuc": ["0x3135", "ㄵ"], | |
"Nieun-Hieuh": ["0x3136", "ㄶ"], | |
"Tikeut": ["0x3137", "ㄷ"], | |
"Ssangtikeut": ["0x3138", "ㄸ"], |
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 jamodata | |
# 초성 | |
def choseong(c): | |
'''초성의 자모 코드값을 리턴''' | |
v = ord(c) | |
if 0xAC00 <= v <= 0xD7A3: | |
key = (v - 0xac00) // 28 // 21 + 0x1100 | |
name = jamodata.jamo_indices[key] | |
return chr(jamodata.letters[name]) |
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 Data.Char (isDigit, isSpace) | |
newtype Parser a = Parser { runParser :: String -> [(a, String)]} | |
instance Functor Parser where | |
fmap f p = Parser $ \str -> | |
case runParser p str of | |
[] -> [] | |
[(y, ys)] -> [(f y, ys)] |
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
from multiprocessing import Process | |
import sys | |
import random | |
import zmq | |
import zmq.asyncio | |
import asyncio | |
ctx = zmq.asyncio.Context() |
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 sys | |
import random | |
import asyncio | |
import zmq | |
import zmq.asyncio | |
ctx = zmq.asyncio.Context() | |
async def run_server(port=5556): | |
sock = ctx.socket(zmq.PUB) |
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
@elapsed sum(i for i=1:999 if i % 3 == 0 || i % 5 == 0) |> println | |
## FASTER SOLUTION | |
@time (Set(3:3:999) ∪ Set(5:5:999)) |> sum |> println |
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 reversed_lines(filepath, sep='\n'): | |
token = sep.encode() | |
buffer = bytearray() | |
chunk_size = 1024 | |
c = 0 | |
with open(filepath, 'rb') as f: | |
total_bytes = f.seek(0,2) | |
# 버퍼에 한 번을 읽어들인다. | |
while True: | |
c += 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
def is_prime(n: int) -> bool: | |
if n < 2: return False | |
if n < 4: return True | |
if n % 2 == 0 or n % 3 == 0: | |
return False | |
if n < 9: return True | |
k, l = 5, n ** 0.5 | |
while k <= l: | |
if n % k == 0 or n % (k+2) == 0: | |
return False |
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
private extension String { | |
subscript(i:Int) -> Character { | |
let idx = index(startIndex, offsetBy: i) | |
return self[idx] | |
} | |
} | |
struct Array2D<T> { | |
let width: Int, height: Int |