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
#!/bin/python | |
import math | |
def smartsub(N, k): | |
if k == 0: | |
return 1 | |
""" k > 1 """ | |
d, m = divmod(N, 10**k) |
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
{ | |
init: function(elevators, floors) { | |
var A = elevators[0]; | |
A.on("idle", function() { | |
A.goToFloor(0); | |
}); | |
A.on("floor_button_pressed", function(floorNum) { | |
if (A.currentFloor < floorNum) { | |
A.goingUpIndicator(true) |
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
package main | |
import ( | |
"crypto/rand" | |
"encoding/base64" | |
"encoding/binary" | |
"fmt" | |
"github.com/seehuhn/mt19937" | |
) |
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
package main | |
import ( | |
"crypto/rand" | |
"encoding/base64" | |
"fmt" | |
) | |
func main() { |
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
#/usr/bin/python | |
# coding: utf-8 | |
from sqlalchemy.engine import create_engine | |
from sqlalchemy.engine import create_engine | |
from sqlalchemy.orm.session import sessionmaker | |
from sqlalchemy.sql.expression import and_ | |
from sqlalchemy.schema import Column | |
from sqlalchemy.dialects.postgresql import DATE, VARCHAR, DOUBLE_PRECISION, BIGINT, INTEGER, NUMERIC | |
from sqlalchemy.dialects.postgresql import TIMESTAMP |
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
nori@Nagato:~/.go/src/github.com/bgnori/npoker$ /usr/local/go/bin/go run main.go | |
18.849115秒 | |
3 players, 1000000 trials | |
player 0 has J♠,J♣, won 0.189, won eq of 186.78. | |
player 1 has A♠,A♥, won 0.714, won eq of 708.11. | |
player 2 has K♦,A♦, won 0.111, won eq of 105.10. | |
nori@Nagato:~/.go/src/github.com/bgnori/npoker$ /usr/local/go/bin/go run main.go | |
49.913845秒 |
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
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"os" | |
) | |
type LINEContent struct { | |
ToType int `json:"toType"` |
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
#!/usr/bin/python | |
import re | |
import requests | |
import json | |
source = "https://trello.com/docs/api/index.html" | |
pattern = re.compile( | |
r" (?P<method>[A-Z]+) /(?P<version>\d+)/boards/\[board_id\]/?(?P<entity>[^/]*)/?(?P<params>.*)") |
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
#!/usr/bin/python | |
# -*- coding=utf8 -*- | |
""" | |
kana notation: usint | for bind of monad, flatMap in Scala. | |
see http://labs.timedia.co.jp/2011/05/monad-in-python.html | |
need monad law test | |
a. Associativity | |
(m flatMap f) flatMap g == m flatMap (f flatMap g) |
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
source = list(range(10)) | |
stack = [] | |
expected = [6, 5, 4, 3, 2, 1, 0, 7, 8, 9] | |
while expected: | |
while not stack or stack[0] != expected[0]: | |
stack.insert(0, source.pop(0)) | |
print("push", stack[0]) |