設計によるセレンディピティ

"The most powerful force in the universe is compound interest."

とてもわかりやすいプログラミングの本を見つけた

『10才からはじめるプログラミング図鑑』という本がとても良い本だったので, この本で学ぶ子供,親向けに,Python のコードを写経する. 詰んだ時などに参考にしてもらえたら嬉しい.

10才からはじめるプログラミング図鑑:たのしくまなぶスクラッチ&Python超入門

10才からはじめるプログラミング図鑑:たのしくまなぶスクラッチ&Python超入門

ちなみに,表紙の見た目からは,スクラッチPythonの入門書に見えるが, それ以外にも,

等についてもわかりやすく書かれていて驚いた.10才のころに読みたかったし,この本から学ぶことができる子供達がとても羨ましい.もちろん,ステマではない.

では早速,写経する.

3 パイソンで遊ぼう

プロジェクト4 : ゆうれいゲーム

# p.96 ゆうれいゲーム
# Ghost Game

from random import randint
print('ゆうれいゲーム')
feeling_brave = True
score = 0
while feeling_brave:
    ghost_door = randint(1, 3)
    print('ドアが3つある。')
    print('そのうち1つのドアの向こうにゆうれいがいる。')
    print('さあ、何番のドアを開ける?')
    door = input('1、2、それとも3?')
    door_num = int(door)
    if door_num == ghost_door:
        print('ゆうれいだ!')
        feeling_brave = False
    else:
        print('ゆうれいはいなかった!')
        print('となりの部屋に入れたよ。')
        score = score + 1
print('逃げろ!')
print('ゲームオーバー! スコアは', score, 'です。')

分岐

# p.121 いくつかの処理のうち1つを選ぶ

a = int(input('a = '))
b = int(input('b = '))
op = input('たす/ひく/かける/わる:')
if op == 'たす':
    c = a + b
elif op == 'ひく':
    c = a - b
elif op == 'かける':
    c = a * b
elif op == 'わる':
    c = a / b
else:
    c = 'エラー'
print('答え = ',c)

パイソンでのくり返し

# p.122 パイソンでのくり返し

from turtle import *
forward(100)
right(120)
forward(100)
right(120)
forward(100)
right(120)
for i in range(3):
    forward(100)
    right(120)
# p.123 入れ子構造 (ネスティング)のループ

n = 3
for a in range(1, n + 1):
    for b in range(1, n + 1):
        print(b, 'x', a, '=', b * a)

関数

# p.130 関数の作り方とよび出し方

def greeting():
    print('こんにちは!')

greeting()
# p.131 関数にデータをわたす

def height(m, cm):
    total = (100 * m) + cm
    print(total, 'センチの高さだね')

height(1,45)
# p.131 関数からデータを返す

def num_input(prompt):
    typed = input(prompt)
    num = int(typed)
    return num

a = num_input('a を入力して下さい')
b = num_input('b を入力して下さい')
print('a + b =', a + b)

プロジェクト5 : 自動作文マシン

# pp.132-133 自動作文マシン

# 文章を自動的に作る
name = ['タカシが', 'ニュートンが', 'パスカルが']
noun = ['ライオンを', '自転車を', '飛行機を']
verb = ['買う', '乗り回す', 'たたく']

from random import randint
def pick(words):
    num_words = len(words)
    num_picked = randint(0, num_words - 1)
    word_picked = words[num_picked]
    return word_picked

print(pick(name), pick(noun), pick(verb), end='。\n')
#  文章を作り続ける
while True:
    print(pick(name), pick(noun), pick(verb), end='。\n')
    input()

プロジェクト6 : 作図マシン

# p.140

from turtle import *
reset()
left(90)
forward(100)
right(45)
forward(70)
right(90)
forward(70)
right(45)
forward(100)
right(90)
forward(100)

関数「turtle_controller」

# p.142 

from turtle import *
def turtle_controller(do, val):
    do = do.upper()
    if do == 'F':
        forward(val)
    elif do == 'B':
        backward(val)
    elif do == 'R':
        right(val)
    elif do == 'L':
        left(val)
    elif do == 'U':
        penup()
    elif do == 'D':
        pendown()
    elif do == 'N':
        reset()
    else:
        print('不明な命令がありました')
turtle_controller('F' , 100)
turtle_controller('R' , 90)
turtle_controller('F' , 50)

関数「string_artist」を作る

# p.144

program = 'N-L90-F100-R45-F70-R90-F70-R45-F100-R90-F100'
cmd_list = program.split('-')
cmd_list

次のソースコードを142ページのソースコードの下に続けて書こう.

def string_artist(program):
    cmd_list = program.split('-')
    for command in cmd_list:
        cmd_len = len(command)
        if cmd_len == 0:
            continue
        cmd_type = command[0]
        num = 0
        if cmd_len > 1:
            num_string = command[1:]
            num = int(num_string)
        print(command, ':', cmd_type, num)
        turtle_controller(cmd_type, num)
# p.145

string_artist('N-L90-F100-R45-F70-R90-F70-R45-F100-R90-F100')

ユーザー用の入力画面を作る

次のソースコードは、ユーザーが作図命令を入力するポップアップウィンドウを作るためのものだ.「while True」ループでユーザーの入力を待ち続けるんだ.142ページと144ページのソースコードに続けて入力してね.

# p.146

instructions = '''タートルへの指示を入力して下さい:
例 F100-R45-U-F100-L45-D-F100-R90-B50
N = 新しくかき始める
U/D = ペンを下げる / 上げる
F100 = 前方へ100歩進む
B50 = 後方へ50歩進む
R90 = 右へ90度回転する
L45 = 左へ45度回転する'''
screen = getscreen()
while True:
    t_program = screen.textinput('作図マシン', instructions)
    print(t_program)
    if t_program == None or t_program.upper() == 'END':
        break
    string_artist(t_program)

p.147

N-L90-F100-R45-F70-R90-F70-R45-F100-R90-F100- B10-U-R90-F10-D-F30-R90-F30-R90-F30-R90-F3

ちなみに,プロジェクト6 : 作図マシン のコードを続けて書くと

# p.142 関数「turtle_controller」
from turtle import *
def turtle_controller(do, val):
    do = do.upper()
    if do == 'F':
        forward(val)
    elif do == 'B':
        backward(val)
    elif do == 'R':
        right(val)
    elif do == 'L':
        left(val)
    elif do == 'U':
        penup()
    elif do == 'D':
        pendown()
    elif do == 'N':
        reset()
    else:
        print('不明な命令がありました')

# p.144 関数「string_artist」を作る
def string_artist(program):
    cmd_list = program.split('-')
    for command in cmd_list:
        cmd_len = len(command)
        if cmd_len == 0:
            continue
        cmd_type = command[0]
        num = 0
        if cmd_len > 1:
            num_string = command[1:]
            num = int(num_string)
        print(command, ':', cmd_type, num)
        turtle_controller(cmd_type, num)

# p.146 ユーザー用の入力画面を作る
instructions = '''タートルへの指示を入力して下さい:
例 F100-R45-U-F100-L45-D-F100-R90-B50
N = 新しくかき始める
U/D = ペンを下げる / 上げる
F100 = 前方へ100歩進む
B50 = 後方へ50歩進む
R90 = 右へ90度回転する
L45 = 左へ45度回転する'''
screen = getscreen()
while True:
    t_program = screen.textinput('作図マシン', instructions)
    print(t_program)
    if t_program == None or t_program.upper() == 'END':
        break
    string_artist(t_program)

バグとデバッグ

# p.148

top_num = 5
total = 0
for n in range(top_num):
    total = total + n
print('1から', top_num, 'までの合計は', total)
# p.149

top_num = 5
total = 0
for n in range(top_num):
    total = total + n
    print('デバッグ: n=', n, 'total=', total)
    input()
print('1から', top_num, 'までの合計は', total)
# p.149

top_num = 5
total = 0
for n in range(1, top_num + 1):
    total = total + n
    print('デバッグ: n=', n, 'total=', total)
    input()
print('1から', top_num, 'までの合計は', total)

ウィンドウを作る

# p.154 かんたんなウィンドウ

from tkinter import *
window = Tk()
# p.154 ウィンドウにボタンを足す

from tkinter import *
def bAaction():
    print('ありがとう!')
def bBaction():
    print('いたい!ひどいじゃないか!')
window = Tk()
buttonA = Button(window, text='押して!', command=bAaction)
buttonB = Button(window, text='押さないでよ!', command=bBaction)
buttonA.pack()
buttonB.pack()
# p.155 サイコロをふる

from tkinter import *
from random import randint
def roll():
    text.delete(0.0, END)
    text.insert(END, str(randint(1, 6)))
window = Tk()
text = Text(window, width=1, height=1)
buttonA = Button(window, text='ここを押してサイコロをふろう', command=roll)
text.pack()
buttonA.pack()

色と座標

# p.156

from tkinter import *
t = Tk()
colorchooser.askcolor() # なぜか動かなかった
# p.157
from random import *
from tkinter import *
size = 500
window = Tk()
canvas = Canvas(window, width=size, height=size)
canvas.pack()
while True:
    col = choice(['pink', 'orange', 'purple', 'yellow'])
    x0 = randint(0, size)
    y0 = randint(0, size)
    d = randint(0, size/5)
    canvas.create_oval(x0, y0, x0 + d, y0 + d,  fill=col)
    window.update()

図形をかく

# p.158 基本的な図形をかく

>>> from tkinter import *
>>> window = Tk()
>>> drawing = Canvas(window, height=500, width=500)
>>> drawing.pack()
>>> rect1 = drawing.create_rectangle(100, 100, 300, 200)
>>> square1 = drawing.create_rectangle(30, 30, 80, 80)
>>> oval1 = drawing.create_oval(100, 100, 300, 200)
>>> circle1 = drawing.create_oval(30, 30, 80, 80)
# p.158 座標を使ってかく

>>> drawing.create_rectangle(50, 50, 250, 350)
# p.159 図形に色をつける

>>> drawing.create_oval(30, 30, 80, 80, outline='red', fill='blue')
# p.159 エイリアンをかこう

from tkinter import *
window = Tk()
window.title('エイリアン')
c = Canvas(window, height=300, width=400)
c.pack()
body = c.create_oval(100, 150, 300, 250, fill='green')
eye = c.create_oval(170, 70, 230, 130, fill='white')
eyeball = c.create_oval(190, 90, 210, 110, fill='black')
mouth = c.create_oval(150, 220, 250, 240, fill='red')
neck = c.create_oval(200, 150, 200, 130)
hat = c.create_polygon(180, 75, 220, 75, 200, 20, fill='blue')

グラフィックスを変化させる

# p.160 図形を動かす
>>> c.move(eyeball, -10,0)
>>> c.move(eyeball, 10,0)

p.159 のソースコードに続けて入力してね.

# 色を変えてみる
def mouth_open():
    c.itemconfig(mouth, fill='black')
def mouth_close():
    c.itemconfig(mouth, fill='red')
>>> mouth_open()
>>> mouth_close()

p.160 のソースコードに続けて入力してね.

# p.161 図形をかくす
def blink():
    c.itemconfig(eye, fill='green')
    c.itemconfig(eyeball, state=HIDDEN)
def unblink():
    c.itemconfig(eye, fill='white')
    c.itemconfig(eyeball, state=NORMAL)
>>> blink()
>>> unblink()
# p.161 しゃべらせる
words = c.create_text(200, 280, text='私はエイリアンだ!')
def steal_hat():
    c.itemconfig(hat, state=HIDDEN)
    c.itemconfig(words, text='ぼうしをかえしてよ!')
>>> steal_hat()

イベントに反応する

# p.162 マウスのイベント

window.attributes('-topmost', 1)
def burp(event):
    mouth_open()
    c.itemconfig(words, text='げっぷ!')
c.bind_all('<Button-1>', burp)
# p.163 キーボードのイベント

def blink2(event):
    c.itemconfig(eye, fill='green')
    c.itemconfig(eyeball, state=HIDDEN)
def unblink2(event):
    c.itemconfig(eye, fill='white')
    c.itemconfig(eyeball, state=NORMAL)
c.bind_all('<KeyPress-a>', blink2)
c.bind_all('<KeyPress-z>', unblink2)
# p.163 キーの操作で動かす

def eye_control(event):
    key = event.keysym
    if key == "Up":
        c.move(eyeball, 0, -1)
    elif key == "Down":
        c.move(eyeball, 0, 1)
    elif key == "Left":
        c.move(eyeball, -1, 0)
    elif key == "Right":
        c.move(eyeball, 1, 0)
c.bind_all('<Key>', eye_control)

プロジェクト6 : せん水かんゲーム

# p.165 ウィンドウとせん水かんを作る

from tkinter import *
HEIGHT = 500
WIDTH = 800
window = Tk()
window.title('せん水かんゲーム')
c = Canvas(window, width=WIDTH, height=HEIGHT, bg='darkblue')
c.pack()
ship_id = c.create_polygon(5, 5, 5, 25, 30, 15, fill='red')
ship_id2 = c.create_oval(0, 0, 30, 30, outline='red')
SHIP_R = 15
MID_X = WIDTH / 2
MID_Y = HEIGHT / 2
c.move(ship_id, MID_X, MID_Y)
c.move(ship_id2, MID_X, MID_Y)
# p.166 せん水かんを動かす

SHIP_SPD = 10
def move_ship(event):
    if event.keysym == 'Up':
        c.move(ship_id, 0, -SHIP_SPD)
        c.move(ship_id2, 0, -SHIP_SPD)
    elif event.keysym == 'Down':
        c.move(ship_id, 0, SHIP_SPD)
        c.move(ship_id2, 0, SHIP_SPD)
    elif event.keysym == 'Left':
        c.move(ship_id, -SHIP_SPD, 0)
        c.move(ship_id2, -SHIP_SPD, 0)
    elif event.keysym == 'Right':
        c.move(ship_id, SHIP_SPD, 0)
        c.move(ship_id2, SHIP_SPD, 0)
c.bind_all('<Key>', move_ship)
# p.167 「あわ」を用意する

from random import randint
bub_id = list()
bub_r = list()
bub_speed = list()
MIN_BUB_R = 10
MAX_BUB_R = 30
MAX_BUB_SPD = 10
GAP = 100
def create_bubble():
    x = WIDTH + GAP
    y = randint(0, HEIGHT)
    r = randint(MIN_BUB_R, MAX_BUB_R)
    id1 = c.create_oval(x - r, y - r, x + r, y + r, outline='white')
    bub_id.append(id1)
    bub_r.append(r)
    bub_speed.append(randint(1, MAX_BUB_SPD))
# p.168 あわを動かす

def move_bubbles():
    for i in range(len(bub_id)):
        c.move(bub_id[i], -bub_speed[i], 0)
from time import sleep, time
BUB_CHANCE = 10
# メインのループ
while True:
    if randint(1, BUB_CHANCE) == 1:
        create_bubble()
    move_bubbles()
    window.update()
    sleep(0.01)
def get_coords(id_num):
    pos = c.coords(id_num)
    x = (pos[0] + pos[2])/2
    y = (pos[1] + pos[3])/2
    return x, y
# p.169 あわをわる方法

def del_bubble(i):
    del bub_r[i]
    del bub_speed[i]
    c.delete(bub_id[i])
    del bub_id[i]
def clean_up_bubs():
    for i in range(len(bub_id) -1, -1, -1):
        x, y = get_coords(bub_id[i])
        if x < -GAP:
            del_bubble(i)
  • 10 のコードは省略しました.
# p.170 2つの点の間の距離をはかる

from math import sqrt
def distance(id1, id2):
    x1, y1 = get_coords(id1)
    x2, y2 = get_coords(id2)
    return sqrt((x2 - x1)**2 + (y2 - y1)**2)
# あわをわる

def collision():
    points = 0
    for bub in range(len(bub_id)-1, -1, -1):
        if distance(ship_id2, bub_id[bub]) < (SHIP_R + bub_r[bub]):
            points += (bub_r[bub] + bub_speed[bub])
            del_bubble(bub)
    return points
  • 13 のコードは省略しました.
# p.172 ゲームを完成させる

c.create_text(50, 30, text='タイム', fill='white' )
c.create_text(150, 30, text='スコア', fill='white' )
time_text = c.create_text(50, 50, fill= 'white' )
score_text = c.create_text(150, 50, fill='white')
def show_score(score):
    c.itemconfig(score_text, text=str(score))
def show_time(time_left):
    c.itemconfig(time_text, text=str(time_left))
from time import sleep, time
BUB_CHANCE = 10
TIME_LIMIT = 30 # P.172
BONUS_SCORE = 1000 # P.172
score = 0 # p.171
bonus = 0 # P.172
end = time() + TIME_LIMIT  # P.172
# p.173

# メインのループ
while time() < end: # P.173
    if randint(1, BUB_CHANCE) == 1:
        create_bubble()
    move_bubbles()
    clean_up_bubs()  # p.169
    score += collision()  # p.171
    if (int(score / BONUS_SCORE)) > bonus:  # p.173
        bonus += 1  # p.173
        end += TIME_LIMIT  # p.173
    show_score(score)  # p.173
    show_time(int(end - time()))  # p.173
    window.update()
    sleep(0.01)
# p.173
c.create_text(MID_X, MID_Y, \
    text='ゲームオーバー', fill='white', font=('Helvetica', 30))
c.create_text(MID_X, MID_Y + 30, \
              text='スコア'+ str(score),  fill='white')
c.create_text(MID_X, MID_Y + 45,
              text='ボーナスタイム' + str(bonus*TIME_LIMIT),  fill='white')

これで完成です. 下記は完成したプログラムです.

# p.165 ウィンドウとせん水かんを作る

from tkinter import *
HEIGHT = 500
WIDTH = 800
window = Tk()
window.title('せん水かんゲーム')
c = Canvas(window, width=WIDTH, height=HEIGHT, bg='darkblue')
c.pack()

ship_id = c.create_polygon(5, 5, 5, 25, 30, 15, fill='red')
ship_id2 = c.create_oval(0, 0, 30, 30, outline='red')
SHIP_R = 15
MID_X = WIDTH / 2
MID_Y = HEIGHT / 2
c.move(ship_id, MID_X, MID_Y)
c.move(ship_id2, MID_X, MID_Y)

# p.166 せん水かんを動かす

SHIP_SPD = 10
def move_ship(event):
    if event.keysym == 'Up':
        c.move(ship_id, 0, -SHIP_SPD)
        c.move(ship_id2, 0, -SHIP_SPD)
    elif event.keysym == 'Down':
        c.move(ship_id, 0, SHIP_SPD)
        c.move(ship_id2, 0, SHIP_SPD)
    elif event.keysym == 'Left':
        c.move(ship_id, -SHIP_SPD, 0)
        c.move(ship_id2, -SHIP_SPD, 0)
    elif event.keysym == 'Right':
        c.move(ship_id, SHIP_SPD, 0)
        c.move(ship_id2, SHIP_SPD, 0)
c.bind_all('<Key>', move_ship)

# p.167 「あわ」を用意する

from random import randint
bub_id = list()
bub_r = list()
bub_speed = list()
MIN_BUB_R = 10
MAX_BUB_R = 30
MAX_BUB_SPD = 10
GAP = 100
def create_bubble():
    x = WIDTH + GAP
    y = randint(0, HEIGHT)
    r = randint(MIN_BUB_R, MAX_BUB_R)
    id1 = c.create_oval(x - r, y - r, x + r, y + r, outline='white')
    bub_id.append(id1)
    bub_r.append(r)
    bub_speed.append(randint(1, MAX_BUB_SPD))

def get_coords(id_num):
    pos = c.coords(id_num)
    x = (pos[0] + pos[2])/2
    y = (pos[1] + pos[3])/2
    return x, y

# あわを動かす
def move_bubbles():
    for i in range(len(bub_id)):
        c.move(bub_id[i], -bub_speed[i], 0)

# p.169 あわをわる方法

def del_bubble(i):
    del bub_r[i]
    del bub_speed[i]
    c.delete(bub_id[i])
    del bub_id[i]

def clean_up_bubs():
    for i in range(len(bub_id) -1, -1, -1):
        x, y = get_coords(bub_id[i])
        if x < -GAP:
            del_bubble(i)

# p.170 2つの点の間の距離をはかる

from math import sqrt
def distance(id1, id2):
    x1, y1 = get_coords(id1)
    x2, y2 = get_coords(id2)
    return sqrt((x2 - x1)**2 + (y2 - y1)**2)

# あわをわる

def collision():
    points = 0
    for bub in range(len(bub_id)-1, -1, -1):
        if distance(ship_id2, bub_id[bub]) < (SHIP_R + bub_r[bub]):
            points += (bub_r[bub] + bub_speed[bub])
            del_bubble(bub)
    return points

# p.172 ゲームを完成させる

c.create_text(50, 30, text='タイム', fill='white' )
c.create_text(150, 30, text='スコア', fill='white' )
time_text = c.create_text(50, 50, fill= 'white' )
score_text = c.create_text(150, 50, fill='white')
def show_score(score):
    c.itemconfig(score_text, text=str(score))
def show_time(time_left):
    c.itemconfig(time_text, text=str(time_left))

from time import sleep, time
BUB_CHANCE = 10
TIME_LIMIT = 30 # P.172
BONUS_SCORE = 1000 # P.172
score = 0 # p.171
bonus = 0 # P.172
end = time() + TIME_LIMIT  # P.172
# メインのループ
while time() < end: # P.173
    if randint(1, BUB_CHANCE) == 1:
        create_bubble()
    move_bubbles()
    clean_up_bubs()  # p.169
    score += collision()  # p.171
    if (int(score / BONUS_SCORE)) > bonus:  # p.173
        bonus += 1  # p.173
        end += TIME_LIMIT  # p.173
    show_score(score)  # p.173
    show_time(int(end - time()))  # p.173
    window.update()
    sleep(0.01)

# p.173
c.create_text(MID_X, MID_Y, \
    text='ゲームオーバー', fill='white', font=('Helvetica', 30))
c.create_text(MID_X, MID_Y + 30, \
              text='スコア'+ str(score),  fill='white')
c.create_text(MID_X, MID_Y + 45,
              text='ボーナスタイム' + str(bonus*TIME_LIMIT),  fill='white')

5 現実の世界でのプログラミング

JavaScriptを使う

// p.210 ユーザーに入力してもらう

<script>
var name = prompt("名前を入れてね ");
var greeting = "こんにちは" + name + "!";
document.write(greeting);
alert("Hello World!");
</script>
// p.211 イベント

<button onclick="tonguetwist()">さあ言ってみよう!</button>
<script>
 function tonguetwist()
 {
  document.write("なまむぎなまごめなまたまご");  
 }
</script>
// p.211 JavaScript でのループ

<script>
for  (var x=0; x<6; x++)
{
 document.write("ループ回数: "+x+"<br>");
}
</script>

10才からはじめるプログラミング図鑑:たのしくまなぶスクラッチ&Python超入門

10才からはじめるプログラミング図鑑:たのしくまなぶスクラッチ&Python超入門

クリエイティブ・コモンズ・ライセンス

アドルノ『啓蒙の弁証法』を読む宣言

1年前くらいだろうか,書店にて
A君「アドルノという哲学者がいて,この人が書いた本は滅茶苦茶難しいんですよ.これ[『啓蒙の弁証法』]ですね.」
と文庫を手に取り,渡してきた.

啓蒙の弁証法―哲学的断想 (岩波文庫)

啓蒙の弁証法―哲学的断想 (岩波文庫)

A君は,ハイデガー存在と時間』で修士論文を書いている.

SEIN UND ZEIT

SEIN UND ZEIT

そんなA君が「難しい」と言うのだから,僕にはより難しいし,興味のある分野では無いため,僕はペラペラ捲って「ふ~ん...」と棚に戻した.

しかし,不思議な縁で『啓蒙の弁証法』を読むことになった.
やりたいことや読みたい本が積まれていくが”縁”を大事にして,読むことにした.

と,宣言しないと諦めてしまいそうなので宣言しておく.
(もし興味があれば誰か一緒に読みましょう.『存在と時間』も面白い本です.)

クリエイティブ・コモンズ・ライセンス

マイク・ホフリンガー『フェイスブック 不屈の未来戦略』がおもしろい

フェイスブック 不屈の未来戦略 (T's BUSINESS DESIGN)

フェイスブック 不屈の未来戦略 (T's BUSINESS DESIGN)

著者が元facebookのエンジニアであり,執られてきた戦略の解説がとても面白い.

人に近い位置にあるiPhone, android, iPad, コンピュータなどのデバイスや通信事業者は、同じカテゴリー内の製品と取り替えても支障はあまりないが,スマホの台頭によりコンテンツを見るサービスやアプリが重要になった.

機能,プロダクト,会社,ミッションの目標ごとの達成までにかかる期間と産み出す価値の総額のグラフも良い.

グロースの数式

facebook のようなサービスの場合,ある特定の期間(例えば1ヶ月)におけるアクティブユーザー数を  t とした場合,下記のような方程式を書くことができる.

{ \displaystyle
Active_{t} = New_{t}+Retained_{t-1}+Resurrected_{t-[n]}-Churned_{t-1}
}

Active: アクティブユーザー
New: 新規ユーザー
Retained: 保持ユーザー
Resurrected: 復活ユーザー
Churned: 解約ユーザー

2015年にザッカーバーグが行った読書の挑戦 Mark Zuckerberg book club で読了した本も紹介されている.以下にリンクを張る.

暴力の人類史 上

暴力の人類史 上

エネルギーの不都合な真実

エネルギーの不都合な真実

国家はなぜ衰退するのか(上):権力・繁栄・貧困の起源 (ハヤカワ・ノンフィクション文庫)

国家はなぜ衰退するのか(上):権力・繁栄・貧困の起源 (ハヤカワ・ノンフィクション文庫)

最底辺のポートフォリオ

最底辺のポートフォリオ

  • 作者: ジョナサン・モーダック,スチュアート・ラザフォード,ダリル・コリンズ,オーランダ・ラトフェン,野上裕生,大川修二
  • 出版社/メーカー: みすず書房
  • 発売日: 2011/12/23
  • メディア: 単行本
  • 購入: 2人 クリック: 18回
  • この商品を含むブログ (9件) を見る

王城夕紀『青の数学』9頁から11頁を栢山と京香凛とともに解く.

王城夕紀『青の数学 (新潮文庫nex)』9頁から11頁を栢山と京香凛とともに解く.

 n x が整数のとき,  2^{n}+7=x^{2} の解をすべて求めよ。

式を展開できるか?

 7 を右辺に移して,因数分解する.(  n が偶数の場合だけでは?)

 \displaystyle
 \begin{eqnarray}
2^{n} &=& x^{2}-7 \\
   &=& (x-\sqrt{7})(x+\sqrt{7})
\end{eqnarray}

 2^{n} を右辺に移して因数分解する.

 \displaystyle
\begin{eqnarray}
7 &=& x^{2}-2^{n}  \\
   &=& (x-2^{\frac{n}{2}})(x+2^{\frac{n}{2}})
\end{eqnarray}

 (x-2^{\frac{n}{2}}),  (x+2^{\frac{n}{2}}) 7 の因数なので

 \displaystyle
\begin{eqnarray}
7 &=& x^{2}-2^{n}\\
   &=& (x-2^{\frac{n}{2}})(x+2^{\frac{n}{2}})\\
   &=& \pm 1 \cdot \pm 7
\end{eqnarray}

栢山の頭で「  -7, -1, 1, 7 という数字が躍る」

次に,栢山がひらめき,彼女が既に検討済みの,法を  2 にした場合の展開
$$2^{n}+7=x^{2} \pmod 2$$

 \displaystyle
\begin{eqnarray}
x^{2}\pmod 2
 =
  \begin{cases}
    7 & (n \gt 0) \\
    8 & (n = 0)
  \end{cases}
\end{eqnarray}

行き止まり

彼女が書き記した法が  4 の場合の展開 $$2^{n}+7=x^{2} \pmod 4$$

 \displaystyle
\begin{eqnarray}
x^{2}\pmod 4
 =
  \begin{cases}
    3 & (n \gt 1) \\
    1 & (n = 1) \\
    0 & (n = 0) \\
  \end{cases}
\end{eqnarray}

 x が偶数 (  2k) ,奇数 ( 2k+1)のときで場合分けする

 \displaystyle
\begin{eqnarray}
x^{2}
 =
  \begin{cases}
    4k^{2}=0\pmod 4 & (x=2k) \\
    4(k^{2}+k)+1=1\pmod 4 & (x=2k+1) \\
  \end{cases}
\end{eqnarray}

よって,  x^{2}=0 \pmod 4 あるいは  1 \pmod 4 でなければならないため,  n=0 あるいは  1

 \displaystyle
\begin{eqnarray}
x^{2}
 =
  \begin{cases}
    8 & (n=0) \\
    9 & (n=1) \\
  \end{cases}
\end{eqnarray}
 \displaystyle
\begin{eqnarray}
x
 =
  \begin{cases}
    \pm 2\sqrt2 & (n=0) \\
    \pm 3 & (n=1) \\
  \end{cases}
\end{eqnarray}

 x が整数のときという条件なので,  n=1,x=\pm3

青の数学 (新潮文庫nex)

青の数学 (新潮文庫nex)

哲学を学ぶ際に使える独和辞典

ドイツ語で書かれた哲学書の原著を読むため、
オススメの独和辞典を研究者に聞き、購入した。

木村・相良 独和辞典 (新訂)

木村・相良 独和辞典 (新訂)

持ち運びしやすいように上の辞典を購入した。
「この辞典以外無い」らしい。
しかし、小さいがゆえに文字がとても見にくい。
多少値段は上がるが同じ編者の下の辞典を購入しても良さそうだった。

大独和辞典

大独和辞典

クリエイティブ・コモンズ・ライセンス

睡眠不足を解消する,ある冴えた1つの方法

結論は,イヤーマフをするとよく眠れる.だ

毎日,夜中に起きてしまい,再び眠ることが難しく悩んでいた.

普段,仕事に集中する際,私は静かな方が捗るので耳栓とイヤーマフをしている.

その経験もあり,耳栓をして寝ているのだが,

実験のつもりで(多少,バカだなぁと思いながら)イヤーマフも試してみたら苦労せずに眠れてとても驚いた.

今まで,イヤーマフのサイズが大きいので装着しては眠りづらいと思っていたことと,

耳栓もしているし,眠れない理由が環境音ではないと思い込み,

試していなかったので効果に驚き,

睡眠で悩んでいる人の参考になればと思いこの記事を書いた.

リンク先のイヤーマフと耳栓は品質と性能を数年かけて個人的に選びに選びぬき,

少なくとも3年間は毎日使っているものだ.

騙されたと思って,是非試してみていただきたい.

私にとっては費用対効果の非常に高い投資になった.

クリエイティブ・コモンズ・ライセンス

カント『純粋理性批判』でわからないこと

純粋理性批判 上 (岩波文庫 青 625-3)

純粋理性批判 上 (岩波文庫 青 625-3)

 59頁1段落の最後,命題『およそ変化はすべてその原因をもつ』は,『変化』という概念が経験からのみ引き出され得るものだから,という理由で,ア・プリオリだが純粋ではない.次に,60頁の1段落で,命題『変化はすべて原因をもたねばならない』は,原因の概念が,必然性と厳密な普遍性という概念を含んでいることを理由に,ア・プリオリな純粋判断の例とする.しかし,なぜ,後者の命題に『変化』の概念が使われても,前者のようには理由にされず,前者の命題に原因の概念が使われても,後者のようには理由にされないのだろうか?

わかる方がいらっしゃいましたらご教示いただけたら幸いです.*1

*1:p.264 からの B 第二の類推 因果律に従う時間的継起の原則 が上記を理解する上で助けになるとカントを研究している方から教えて頂きました