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 collections import Counter | |
from functools import reduce | |
from time import monotonic | |
from typing import Any, Generator, Sequence, TypeVar | |
T = TypeVar("T") | |
def step(n: int) -> int: | |
return sum(i * i for i in map(int, str(n))) |
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
#SingleInstance Force | |
; | |
; Detect Hangul/English Langugage | |
; for AHK v2 | |
; Cache the imm32.dll for better performance | |
immModule := DllCall("LoadLibrary", "Str", "imm32.dll", "Ptr") | |
IMECheckHangul() | |
{ |
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
// NSScanner+Swift.swift | |
// A set of Swift-idiomatic methods for NSScanner | |
// | |
// (c) 2015 Nate Cook, licensed under the MIT license | |
import Foundation | |
extension NSScanner { | |
// MARK: Strings |
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
# 200만 이하의 소수의 합 | |
# 에라토스테네스의 체로 구한다. | |
@time let n = 2000000 | |
s = trues(n) | |
s[1] = false | |
for i=2:n | |
if s[i] | |
s[i+i:i:end] = falses((n-i) ÷ i) | |
end |
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
# 코루틴을 이용해서 피보나치 수열을 만들기 | |
begin | |
# 코루틴을 생성한다. | |
# f = (chnl) -> ... 이고 | |
# c = Channel(f) 인데 | |
# 이것을 하나의 구문으로 합친다. | |
# fib는 사실상 Channel이다. | |
fib = Channel() do c |
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
## 파일크기가 같은 파일에서 1개씩남 남기고 모두 제거하기 | |
import glob, pathlib, os | |
files = (pathlib.Path(x) for x in glob.glob('*')) | |
info = {} | |
for file in files: | |
s = file.stat().st_size | |
info.setdefault(s, []).append(file) | |
for fs in info.values(): |
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
Show hidden characters
{ | |
"cmd": ["swift", "$file"], | |
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", | |
"working_dir": "${file_path}", | |
"selector": "source.swift" | |
} |
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 Foundation | |
func timeit(_ f: () -> ()) { | |
let s = Date() | |
f() | |
print("time: \(s.timeIntervalSinceNow * -1000)ms") | |
} | |
func isPrime(_ n: Int) -> Bool { | |
if n < 2 { 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
// | |
// main.swift | |
// Euler-47 | |
// | |
// Created by sooop on 2017. 8. 25.. | |
// Copyright © 2017년 sooop. All rights reserved. | |
// | |
import Foundation |
NewerOlder