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
[3] pry(main)> true.class | |
=> TrueClass | |
[4] pry(main)> false.class | |
=> FalseClass |
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 vs_pascal(p): | |
max_len = len(l_to_str(p[-1])) | |
for e in p: | |
print(l_to_str(e).center(max_len)) | |
def l_to_str(l, d=" "): | |
return d.join(map(lambda x: str(int(x)), l)) | |
def comb(n, r): |
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
""" | |
fibonacci | |
┌ 1; n = 0 | |
fibo(n) = ┤ 1; n = 1 | |
└ fibo(n-1) + fibo(n-2); n > 1 | |
http://www.geocities.jp/m_hiroi/light/pyalgo01.html | |
""" |
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
# Definiation of factorial | |
# 0! = 1 | |
# n! = n * (n - 1)! | |
# | |
#|Call:1 │->│Call:2 │->│Call:3 │->│Call:4 │->│Call:5 │ | |
#│n:4 │ │n:3 │ │n:2 │ │n:1 │ │n:0 │ | |
#│value : 24│<-│value : 6 │<-│value : 2 │<-│value : 1 │<-│value : 1 │ | |
# | |
#@profile | |
def fact(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
import random | |
def vs_insertion(l, i): | |
n = l.copy() | |
n.insert(i+1, "*") | |
n.insert(i+1, "]") | |
n.insert(0, "[") | |
print(" ".join(map(lambda x: str(x), 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
import random | |
import math | |
def bs_print(elements, low, high, middle): | |
""" | |
visulize binary search process | |
""" | |
es = elements.copy() | |
ms = es[middle] |
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 math | |
""" | |
Given list of integer and find primes | |
""" | |
l = list(range(1, 101)) | |
def is_prime(x): | |
if x == 1: | |
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
from sqlalchemy import create_engine |
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/sh | |
# | |
# Create directories for ansible | |
# . | |
# ├── common-roles/ | |
# │ ├── base/ | |
# │ │ ├── defaults/ | |
# │ │ │ └── main.yml | |
# │ │ ├── files/ | |
# │ │ │ ├── ... |
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
$ brew untap caskroom/versions | |
$ brew tap caskroom/versions | |
$ brew update | |
Already up-to-date. |