練習問題

基本文法

奇数・偶数判定

スカラー a と b の和が偶数かどうかを判定するプログラムを書け。

In [0]:
a = 12
b = 8

s = a + b
print(s)

if s % 2 == 0:
  print('even')
else:
  print('odd')
20
even

リストの最大値・最小値

リストの要素のうち、最大値および最小値を求めよ。

In [0]:
a = [5, 2, 9, 4, 3, 3]
MAX = -100000
MIN = 100000
for w in a:
  if w > MAX:
    MAX = w
  if w < MIN:
    MIN = w

print(MIN)
print(MAX)
2
9

リストから重複要素除去

リスト中の重複要素を取り除き、重複要素のないリストを作成せよ。ただし、集合を使わないこと。

In [0]:
a = [2, 2, 9, 6, 3, 3]
z = []
for w in a:
  n = 0
  for u in a:
    if w == u:
      n = n + 1
  
  if n == 1:
    z.append(w)
  else:
        
    has_w = 0
    
    for zi in z:
      if zi == w:
        has_w = 1
        
    if has_w == 0:
      z.append(w)
    
print(z)
[2, 9, 6, 3]

確率シミュレーション

確率 0.4 で表、確率 0.6 で裏のコインを投げたとき、表が10回出るまでに何回投げればよいのかを調べよ。ただし、0 から 1 までの範囲内で一様乱数を発生する関数として、random.uniform(0, 1) を用いてよい。

In [0]:
import random
# コインを投げた回数
ntry = 0
# 表の回数
n = 0
# 表の回数が 10 回になるまでコインを投げ続ける
while n < 10:
  # 1. コイン投げる
  x = random.uniform(0, 1)
  ntry = ntry + 1
  # 2. 表裏を判定する
  if x < 0.4:
    # 3. 表ならば n に 1 を加える
    n = n + 1

print(n)
print(ntry)
10
36

確率シミュレーション(二項分布)

確率 0.4 で表、確率 0.6 で裏のコインを投げたとき、表が 10 回出るまでに必要な回数を求めるプログラムを作り、そのプログラムを 1000 回実行して得られた 1000 の値の平均値を求めよ。ただし、0 から 1 までの範囲内で一様乱数を発生する関数として、random.uniform(0, 1) を用いてよい。

In [0]:
import random
ntries = []

j = 0
while j < 10000:
  ### ここから ###
  ntry = 0
  n = 0
  while n < 10:
    x = random.uniform(0, 1)
    ntry = ntry + 1
    if x < 0.4:
      n = n + 1
  ### ここまで ###
  ntries.append(ntry)
  j = j + 1
print(ntries)
print(sum(ntries)/len(ntries))
[30, 14, 38, 28, 37, 22, 21, 33, 28, 31, 22, 19, 28, 36, 17, 28, 24, 26, 29, 29, 22, 26, 24, 21, 25, 22, 22, 29, 31, 20, 22, 29, 26, 16, 18, 35, 14, 16, 33, 15, 30, 34, 20, 15, 19, 16, 18, 24, 21, 17, 20, 27, 20, 35, 20, 31, 27, 26, 23, 17, 17, 29, 21, 40, 25, 17, 21, 21, 19, 24, 34, 21, 29, 26, 25, 25, 22, 29, 20, 26, 22, 22, 17, 26, 28, 19, 27, 22, 24, 15, 18, 21, 21, 24, 25, 15, 19, 26, 25, 32, 27, 22, 17, 28, 24, 22, 23, 16, 26, 33, 31, 35, 19, 23, 28, 36, 22, 19, 34, 23, 27, 25, 24, 29, 29, 14, 25, 20, 27, 32, 22, 25, 20, 16, 31, 35, 31, 18, 38, 23, 33, 24, 15, 26, 18, 28, 24, 22, 20, 23, 29, 22, 31, 34, 19, 29, 12, 25, 29, 29, 23, 21, 22, 20, 37, 29, 22, 22, 22, 29, 30, 24, 26, 19, 23, 24, 18, 18, 23, 21, 28, 25, 17, 23, 22, 24, 27, 32, 27, 25, 18, 19, 19, 25, 21, 30, 16, 17, 29, 27, 28, 19, 23, 34, 23, 33, 22, 28, 25, 36, 23, 37, 23, 24, 16, 25, 27, 26, 20, 31, 21, 26, 24, 20, 17, 28, 26, 32, 33, 21, 19, 28, 31, 30, 19, 17, 25, 23, 14, 19, 21, 23, 20, 25, 25, 49, 23, 21, 23, 26, 31, 25, 34, 25, 33, 20, 26, 17, 21, 21, 16, 26, 28, 18, 28, 17, 29, 28, 29, 18, 32, 22, 20, 28, 16, 22, 27, 28, 21, 25, 25, 20, 26, 33, 34, 22, 22, 32, 20, 20, 23, 30, 22, 26, 15, 33, 23, 24, 27, 25, 20, 25, 26, 24, 17, 28, 23, 25, 26, 22, 16, 19, 22, 23, 25, 19, 31, 22, 28, 20, 26, 24, 27, 25, 23, 19, 45, 33, 18, 20, 26, 19, 24, 38, 20, 26, 25, 29, 18, 37, 21, 27, 25, 20, 30, 26, 37, 21, 35, 36, 18, 24, 34, 23, 18, 23, 20, 27, 29, 20, 36, 26, 28, 26, 18, 24, 31, 26, 28, 22, 33, 34, 31, 23, 18, 24, 29, 11, 26, 32, 22, 23, 33, 19, 19, 22, 32, 27, 15, 16, 20, 15, 19, 34, 22, 17, 27, 21, 25, 22, 31, 27, 17, 49, 22, 22, 35, 30, 29, 23, 27, 22, 26, 18, 26, 19, 30, 21, 26, 19, 18, 16, 37, 21, 24, 23, 23, 25, 24, 22, 23, 22, 25, 21, 30, 18, 24, 33, 20, 27, 23, 25, 28, 25, 18, 28, 25, 39, 26, 23, 21, 24, 24, 23, 20, 19, 27, 32, 18, 18, 31, 22, 25, 25, 38, 36, 21, 30, 25, 30, 19, 20, 23, 27, 27, 20, 24, 33, 23, 21, 17, 16, 28, 33, 31, 27, 29, 24, 21, 36, 17, 26, 28, 37, 19, 23, 19, 21, 20, 22, 23, 21, 23, 23, 23, 20, 18, 33, 26, 26, 21, 16, 32, 18, 17, 25, 27, 30, 23, 27, 29, 26, 21, 50, 27, 21, 29, 19, 29, 17, 17, 14, 23, 29, 23, 21, 23, 27, 24, 25, 38, 31, 17, 21, 24, 20, 17, 26, 21, 18, 38, 26, 35, 22, 41, 27, 26, 34, 28, 32, 20, 25, 34, 20, 20, 20, 30, 22, 23, 17, 30, 13, 23, 23, 23, 22, 35, 29, 19, 25, 19, 18, 26, 19, 25, 31, 24, 29, 27, 28, 25, 34, 20, 30, 25, 21, 25, 17, 22, 26, 23, 22, 21, 30, 20, 27, 16, 22, 36, 20, 19, 16, 19, 29, 22, 29, 28, 51, 29, 24, 24, 19, 27, 20, 24, 34, 23, 33, 25, 18, 17, 19, 23, 29, 25, 25, 28, 36, 19, 27, 31, 28, 35, 34, 16, 26, 35, 28, 20, 18, 23, 19, 19, 28, 32, 24, 40, 24, 25, 18, 23, 22, 18, 27, 22, 21, 28, 23, 21, 37, 20, 31, 32, 27, 24, 23, 33, 29, 23, 27, 19, 23, 22, 30, 27, 20, 21, 21, 32, 21, 21, 29, 19, 28, 17, 40, 19, 17, 35, 18, 34, 24, 31, 24, 22, 14, 30, 32, 23, 29, 21, 26, 25, 21, 19, 36, 18, 27, 20, 19, 27, 21, 32, 18, 25, 32, 18, 20, 31, 15, 30, 21, 20, 37, 17, 21, 28, 21, 23, 17, 31, 27, 29, 21, 24, 39, 22, 24, 14, 22, 29, 33, 23, 35, 27, 35, 11, 19, 17, 38, 28, 18, 35, 28, 27, 34, 29, 37, 26, 27, 29, 27, 28, 29, 18, 16, 35, 36, 22, 23, 32, 28, 25, 31, 28, 21, 28, 15, 28, 21, 21, 27, 30, 24, 20, 32, 17, 22, 21, 22, 16, 26, 32, 26, 38, 26, 18, 17, 28, 24, 22, 19, 26, 23, 22, 20, 29, 29, 27, 17, 22, 17, 15, 30, 32, 18, 31, 33, 15, 34, 22, 19, 30, 27, 25, 26, 18, 39, 40, 27, 20, 21, 23, 26, 21, 26, 21, 17, 24, 24, 24, 44, 21, 40, 21, 18, 25, 32, 22, 43, 28, 24, 22, 22, 22, 28, 22, 37, 28, 16, 15, 27, 33, 26, 31, 19, 24, 25, 24, 22, 30, 22, 22, 20, 27, 19, 22, 27, 41, 18, 22, 20, 27, 21, 28, 41, 18, 46, 15, 19, 26, 17, 22, 29, 35, 26, 31, 30, 26, 31, 21, 16, 39, 24, 23, 17, 22, 35, 25, 23, 21, 28, 37, 20, 23, 21, 16, 28, 36, 24, 38, 26, 18, 16, 27, 24, 32, 23, 19, 22, 18, 25, 19, 30, 27, 19, 38, 25, 25, 20, 27, 25, 20, 25, 28, 37, 17, 23, 31, 19, 22, 24, 32, 23, 14, 29, 39, 20, 23, 15, 29, 25, 30, 26, 24, 15, 27, 28, 21, 28, 16, 25, 29, 27, 20, 18, 19, 21, 26, 24, 25, 22, 21, 25, 31, 21, 16, 34, 19, 29, 40, 31, 23, 16, 21, 27, 19, 22, 38, 27, 21, 17, 30, 27, 24, 23, 21, 13, 34, 33, 31, 21, 29, 18, 32, 17, 30, 24, 26, 23, 23, 25, 32, 19, 45, 36, 21, 17, 31, 24, 29, 18, 25, 42, 27, 20, 35, 35, 27, 17, 25, 19, 33, 18, 15, 18, 32, 24, 26, 30, 20, 23, 28, 20, 24, 34, 30, 32, 25, 18, 26, 25, 38, 29, 26, 30, 31, 39, 14, 22, 24, 17, 38, 28, 30, 23, 26, 27, 15, 15, 22, 18, 26, 32, 21, 22, 27, 20, 23, 19, 22, 30, 20, 23, 36, 26, 31, 29, 22, 35, 22, 24, 16, 19, 25, 26, 21, 16, 33, 34, 25, 19, 27, 31, 22, 24, 22, 29, 21, 20, 23, 24, 15, 15, 22, 24, 27, 28, 19, 23, 36, 28, 26, 26, 28, 16, 25, 26, 28, 25, 21, 28, 31, 19, 18, 23, 27, 31, 30, 23, 21, 24, 32, 25, 20, 23, 24, 23, 17, 16, 19, 40, 30, 23, 31, 18, 24, 30, 36, 17, 28, 24, 25, 17, 25, 25, 22, 25, 23, 25, 21, 19, 29, 23, 17, 30, 18, 24, 25, 30, 31, 37, 17, 21, 30, 22, 29, 19, 22, 25, 23, 39, 35, 14, 17, 28, 23, 27, 23, 28, 13, 35, 24, 22, 22, 22, 30, 25, 16, 26, 19, 24, 23, 19, 23, 25, 26, 28, 32, 22, 26, 25, 26, 19, 17, 19, 28, 28, 23, 34, 28, 27, 26, 41, 23, 21, 14, 32, 20, 23, 21, 27, 24, 19, 33, 31, 25, 18, 31, 16, 23, 18, 20, 25, 25, 18, 17, 29, 26, 28, 26, 24, 24, 17, 28, 29, 23, 19, 13, 32, 23, 28, 27, 35, 17, 21, 25, 22, 21, 23, 28, 32, 36, 22, 25, 35, 15, 25, 14, 29, 26, 22, 17, 26, 17, 14, 29, 23, 24, 25, 56, 32, 18, 21, 32, 18, 20, 21, 27, 23, 27, 20, 25, 28, 31, 25, 21, 29, 27, 23, 23, 23, 22, 25, 27, 18, 31, 24, 18, 16, 21, 37, 27, 19, 35, 25, 21, 31, 26, 33, 31, 26, 19, 24, 32, 24, 37, 27, 27, 26, 22, 19, 23, 22, 30, 20, 27, 22, 23, 27, 22, 32, 27, 28, 27, 24, 20, 25, 26, 28, 25, 22, 20, 30, 25, 20, 18, 26, 28, 29, 20, 22, 39, 25, 20, 24, 23, 23, 30, 33, 29, 33, 26, 14, 26, 32, 28, 18, 29, 18, 30, 18, 21, 31, 22, 26, 28, 19, 16, 24, 28, 34, 22, 24, 22, 33, 26, 35, 26, 23, 23, 17, 24, 24, 26, 23, 29, 22, 37, 23, 17, 33, 24, 29, 27, 21, 14, 21, 20, 19, 31, 25, 29, 28, 27, 20, 21, 34, 30, 16, 24, 16, 20, 26, 21, 31, 20, 36, 21, 28, 27, 15, 25, 20, 27, 24, 25, 22, 20, 19, 28, 25, 19, 27, 30, 25, 25, 31, 39, 17, 31, 25, 26, 28, 22, 18, 22, 17, 17, 17, 25, 26, 19, 47, 19, 20, 24, 26, 24, 21, 32, 32, 24, 20, 31, 27, 34, 18, 19, 23, 32, 24, 29, 25, 27, 43, 21, 15, 35, 27, 19, 25, 28, 26, 26, 19, 28, 18, 28, 21, 32, 19, 22, 35, 30, 24, 22, 18, 20, 22, 28, 18, 29, 16, 17, 22, 19, 30, 27, 26, 21, 28, 33, 23, 33, 38, 25, 28, 31, 32, 31, 27, 24, 40, 20, 29, 27, 34, 16, 23, 36, 31, 32, 30, 25, 12, 19, 25, 20, 19, 14, 21, 30, 19, 18, 26, 23, 19, 26, 25, 22, 21, 23, 24, 20, 27, 25, 21, 31, 21, 31, 23, 34, 31, 26, 16, 21, 15, 21, 19, 15, 22, 20, 22, 21, 34, 21, 17, 22, 21, 20, 42, 27, 20, 25, 25, 26, 34, 45, 24, 30, 30, 35, 22, 19, 24, 19, 30, 30, 18, 37, 24, 17, 29, 20, 21, 29, 21, 25, 24, 23, 16, 18, 21, 29, 40, 25, 23, 33, 22, 35, 17, 21, 24, 24, 26, 22, 23, 22, 20, 23, 14, 23, 22, 24, 23, 21, 28, 23, 22, 17, 22, 27, 24, 19, 24, 24, 25, 20, 21, 22, 19, 28, 27, 35, 18, 33, 29, 29, 31, 17, 23, 24, 12, 17, 23, 21, 18, 21, 28, 27, 23, 36, 25, 17, 28, 22, 17, 24, 33, 27, 24, 30, 21, 25, 26, 11, 20, 17, 26, 13, 30, 22, 28, 29, 29, 24, 19, 27, 31, 29, 22, 23, 30, 31, 27, 20, 23, 21, 25, 29, 23, 31, 29, 18, 24, 25, 25, 29, 18, 27, 17, 20, 32, 23, 21, 32, 30, 24, 40, 37, 19, 18, 12, 24, 15, 30, 18, 19, 20, 14, 17, 25, 27, 16, 28, 19, 29, 30, 32, 20, 25, 34, 24, 17, 32, 33, 22, 22, 21, 28, 22, 28, 31, 24, 28, 22, 18, 19, 18, 25, 26, 27, 23, 19, 25, 21, 25, 20, 22, 17, 20, 33, 22, 24, 28, 24, 18, 25, 25, 15, 36, 28, 18, 27, 28, 33, 21, 29, 24, 12, 31, 22, 18, 17, 28, 19, 27, 16, 34, 27, 22, 24, 35, 26, 34, 31, 20, 33, 27, 30, 17, 22, 32, 19, 26, 19, 39, 13, 28, 13, 21, 32, 17, 22, 23, 22, 24, 25, 14, 26, 43, 29, 17, 29, 18, 20, 22, 21, 20, 27, 20, 29, 39, 15, 29, 20, 24, 20, 27, 24, 19, 15, 36, 21, 21, 30, 25, 41, 33, 27, 18, 24, 20, 24, 15, 39, 27, 24, 19, 26, 24, 25, 23, 33, 23, 27, 18, 27, 23, 27, 23, 33, 24, 30, 33, 18, 27, 20, 26, 34, 18, 34, 22, 21, 19, 19, 19, 24, 21, 25, 29, 34, 18, 31, 22, 25, 33, 31, 21, 25, 21, 28, 26, 21, 46, 22, 30, 14, 23, 28, 12, 38, 22, 19, 22, 27, 29, 40, 20, 20, 20, 28, 28, 26, 16, 25, 21, 30, 21, 26, 18, 26, 24, 28, 31, 28, 26, 34, 23, 15, 25, 44, 24, 28, 22, 30, 28, 20, 41, 35, 18, 21, 36, 28, 39, 22, 28, 23, 21, 23, 18, 31, 16, 26, 17, 32, 18, 23, 16, 26, 21, 26, 28, 21, 34, 22, 22, 15, 15, 31, 21, 26, 25, 36, 28, 27, 18, 22, 18, 19, 30, 27, 22, 21, 19, 24, 38, 20, 25, 25, 31, 27, 21, 26, 26, 33, 13, 19, 21, 15, 21, 30, 25, 16, 26, 22, 22, 20, 27, 29, 22, 27, 20, 21, 29, 21, 36, 22, 23, 21, 28, 18, 32, 25, 22, 29, 24, 20, 18, 35, 21, 27, 15, 22, 33, 31, 23, 29, 17, 25, 29, 18, 20, 29, 30, 24, 18, 23, 16, 20, 32, 21, 21, 19, 35, 26, 23, 23, 19, 28, 24, 24, 21, 20, 26, 34, 32, 36, 32, 23, 29, 27, 22, 29, 20, 15, 20, 26, 28, 29, 22, 26, 18, 30, 32, 22, 19, 24, 24, 31, 25, 24, 19, 20, 29, 28, 21, 20, 24, 20, 25, 26, 22, 35, 32, 22, 26, 23, 20, 25, 18, 16, 31, 30, 21, 20, 39, 23, 19, 29, 21, 25, 22, 49, 27, 27, 21, 19, 23, 28, 20, 40, 25, 26, 26, 25, 42, 37, 25, 27, 25, 23, 24, 25, 17, 16, 26, 26, 19, 24, 24, 17, 20, 22, 18, 22, 18, 21, 19, 30, 19, 25, 25, 25, 29, 21, 23, 20, 21, 27, 14, 24, 34, 24, 23, 24, 21, 29, 20, 27, 22, 33, 14, 33, 27, 33, 16, 21, 17, 21, 11, 31, 31, 15, 34, 33, 24, 15, 24, 19, 25, 24, 27, 17, 25, 17, 24, 24, 22, 28, 37, 17, 22, 25, 21, 20, 37, 23, 29, 24, 22, 18, 31, 27, 29, 23, 33, 23, 17, 23, 26, 24, 23, 28, 18, 23, 22, 19, 23, 38, 22, 19, 16, 29, 23, 25, 19, 24, 27, 30, 24, 29, 29, 41, 23, 42, 24, 27, 34, 26, 29, 27, 22, 31, 30, 18, 21, 20, 25, 25, 25, 26, 38, 18, 28, 31, 18, 24, 16, 28, 42, 33, 16, 26, 30, 31, 17, 21, 20, 20, 24, 21, 32, 25, 32, 30, 22, 34, 30, 23, 35, 21, 33, 32, 24, 35, 21, 29, 13, 25, 27, 21, 35, 23, 26, 21, 26, 29, 25, 33, 31, 25, 20, 23, 25, 22, 23, 18, 33, 32, 19, 24, 31, 30, 15, 19, 34, 30, 30, 22, 31, 24, 28, 27, 26, 23, 34, 20, 20, 28, 21, 21, 23, 17, 24, 38, 18, 17, 23, 16, 30, 17, 31, 26, 22, 29, 31, 21, 25, 16, 25, 18, 30, 19, 22, 37, 20, 21, 19, 17, 25, 35, 20, 24, 24, 31, 23, 30, 28, 19, 26, 26, 32, 38, 35, 24, 21, 34, 21, 26, 39, 26, 26, 28, 21, 21, 16, 35, 25, 31, 31, 17, 25, 30, 22, 26, 27, 20, 30, 31, 25, 53, 19, 24, 24, 21, 22, 16, 24, 23, 37, 29, 28, 30, 42, 17, 25, 37, 22, 23, 36, 27, 13, 21, 30, 23, 28, 26, 42, 30, 25, 20, 33, 32, 32, 25, 34, 25, 23, 22, 22, 14, 26, 20, 25, 21, 25, 33, 36, 24, 27, 20, 15, 25, 16, 27, 20, 27, 25, 32, 32, 27, 17, 26, 19, 24, 36, 15, 29, 31, 24, 22, 19, 20, 27, 37, 29, 19, 30, 35, 19, 18, 30, 31, 22, 23, 27, 28, 18, 20, 28, 22, 26, 27, 22, 15, 17, 19, 13, 34, 25, 32, 12, 31, 18, 28, 30, 22, 24, 31, 34, 22, 31, 17, 22, 28, 34, 27, 21, 22, 24, 31, 26, 23, 27, 21, 32, 31, 24, 27, 17, 35, 40, 19, 26, 15, 18, 26, 29, 18, 20, 38, 24, 19, 18, 23, 23, 37, 22, 23, 20, 30, 25, 25, 25, 32, 22, 35, 21, 24, 26, 39, 30, 27, 19, 16, 33, 19, 25, 20, 18, 18, 33, 22, 14, 24, 31, 26, 21, 23, 29, 27, 21, 15, 21, 33, 27, 18, 20, 24, 15, 28, 19, 15, 31, 28, 20, 27, 24, 27, 31, 22, 25, 18, 21, 24, 17, 31, 29, 29, 29, 18, 31, 29, 30, 22, 18, 37, 19, 29, 24, 25, 26, 23, 25, 22, 17, 21, 16, 29, 30, 18, 25, 22, 30, 25, 27, 37, 16, 32, 18, 33, 33, 18, 19, 20, 32, 42, 31, 24, 18, 22, 19, 21, 32, 23, 19, 16, 25, 28, 33, 26, 32, 26, 25, 28, 25, 29, 29, 29, 30, 13, 29, 21, 21, 38, 19, 35, 41, 25, 20, 26, 18, 27, 23, 41, 25, 30, 24, 23, 22, 26, 23, 23, 33, 28, 30, 24, 32, 20, 24, 22, 25, 16, 18, 23, 21, 22, 20, 21, 26, 32, 22, 21, 19, 17, 32, 22, 20, 26, 23, 26, 20, 23, 27, 32, 18, 21, 24, 35, 23, 28, 18, 27, 25, 22, 44, 22, 33, 18, 30, 23, 32, 27, 22, 14, 21, 30, 20, 24, 31, 42, 18, 19, 23, 23, 22, 31, 24, 23, 25, 24, 27, 23, 21, 29, 26, 24, 29, 33, 15, 23, 20, 19, 25, 26, 28, 29, 20, 26, 17, 28, 20, 27, 25, 21, 25, 19, 18, 18, 26, 29, 16, 18, 19, 22, 27, 22, 32, 31, 20, 23, 35, 25, 17, 25, 26, 41, 25, 21, 27, 22, 25, 20, 29, 33, 25, 24, 26, 21, 28, 30, 23, 29, 21, 19, 36, 18, 22, 26, 19, 44, 15, 24, 23, 23, 27, 24, 24, 24, 21, 28, 30, 18, 28, 20, 25, 21, 20, 23, 23, 36, 26, 27, 28, 36, 23, 37, 23, 27, 22, 23, 23, 24, 19, 18, 25, 32, 26, 26, 47, 17, 24, 21, 22, 26, 23, 29, 24, 30, 22, 20, 23, 21, 20, 23, 18, 31, 18, 22, 28, 28, 28, 23, 24, 20, 24, 24, 20, 40, 28, 16, 29, 31, 20, 35, 27, 37, 24, 28, 22, 34, 22, 25, 40, 21, 28, 24, 19, 26, 27, 29, 23, 23, 22, 23, 24, 29, 29, 25, 31, 21, 21, 27, 24, 40, 26, 20, 30, 30, 20, 12, 22, 19, 15, 25, 24, 20, 28, 28, 21, 16, 23, 23, 18, 28, 16, 22, 20, 32, 23, 25, 22, 25, 21, 18, 30, 25, 20, 21, 32, 25, 20, 33, 21, 31, 25, 24, 18, 26, 25, 21, 31, 42, 32, 41, 27, 27, 16, 30, 30, 18, 19, 21, 28, 24, 24, 38, 22, 26, 25, 20, 37, 30, 22, 26, 21, 22, 25, 24, 30, 23, 18, 25, 28, 22, 23, 22, 27, 20, 31, 21, 12, 17, 27, 21, 18, 26, 26, 23, 30, 19, 30, 36, 21, 18, 24, 30, 18, 24, 35, 24, 18, 26, 24, 21, 44, 24, 30, 26, 17, 24, 36, 22, 23, 27, 20, 27, 20, 31, 38, 25, 29, 33, 22, 31, 23, 34, 26, 29, 22, 22, 30, 28, 14, 17, 32, 22, 28, 25, 18, 16, 26, 21, 18, 26, 21, 24, 22, 31, 18, 20, 24, 22, 15, 23, 28, 32, 23, 27, 19, 24, 39, 21, 32, 33, 21, 27, 22, 26, 29, 18, 15, 21, 21, 24, 21, 31, 18, 17, 31, 21, 21, 25, 19, 30, 20, 28, 20, 29, 35, 16, 22, 29, 24, 30, 25, 20, 22, 47, 33, 30, 18, 25, 27, 22, 26, 30, 35, 20, 25, 27, 22, 15, 16, 24, 31, 22, 19, 26, 23, 26, 21, 27, 22, 37, 20, 27, 33, 23, 33, 21, 32, 18, 37, 21, 24, 20, 17, 19, 26, 30, 39, 25, 14, 18, 19, 17, 25, 30, 17, 29, 28, 32, 29, 31, 23, 24, 29, 19, 21, 20, 15, 23, 30, 27, 23, 27, 20, 34, 26, 19, 17, 22, 15, 23, 19, 28, 30, 20, 29, 14, 21, 17, 22, 27, 24, 25, 31, 29, 18, 25, 24, 26, 21, 20, 26, 22, 16, 38, 19, 19, 28, 25, 22, 20, 33, 29, 23, 34, 32, 27, 33, 23, 28, 19, 22, 23, 26, 30, 28, 18, 24, 24, 21, 29, 23, 21, 40, 22, 27, 20, 28, 20, 20, 21, 33, 44, 29, 32, 30, 34, 27, 26, 36, 23, 22, 18, 27, 29, 23, 29, 37, 24, 23, 35, 47, 16, 19, 14, 17, 19, 26, 21, 28, 17, 19, 36, 29, 20, 19, 23, 19, 26, 27, 35, 25, 20, 20, 24, 24, 19, 27, 26, 34, 25, 23, 29, 21, 27, 42, 24, 23, 21, 24, 27, 25, 31, 17, 37, 23, 27, 34, 23, 22, 21, 18, 22, 25, 27, 28, 17, 34, 23, 27, 22, 28, 23, 38, 37, 32, 36, 17, 24, 20, 26, 23, 28, 26, 35, 19, 24, 24, 22, 19, 21, 32, 26, 23, 36, 19, 25, 22, 38, 25, 18, 27, 20, 22, 35, 36, 22, 18, 19, 19, 20, 29, 28, 17, 15, 22, 31, 16, 12, 14, 23, 24, 34, 20, 33, 22, 27, 29, 24, 19, 30, 25, 21, 19, 20, 31, 21, 22, 22, 25, 34, 21, 35, 36, 23, 31, 31, 17, 16, 28, 15, 33, 29, 29, 24, 24, 13, 17, 16, 27, 24, 27, 17, 21, 21, 28, 16, 22, 28, 24, 19, 43, 34, 17, 23, 32, 17, 27, 26, 37, 17, 31, 19, 26, 26, 22, 22, 19, 23, 14, 37, 41, 22, 25, 22, 34, 30, 28, 23, 23, 22, 20, 36, 42, 18, 30, 25, 15, 25, 35, 24, 30, 36, 31, 25, 18, 27, 33, 29, 31, 30, 25, 41, 24, 28, 31, 23, 23, 39, 20, 19, 31, 26, 14, 21, 34, 19, 22, 26, 37, 20, 33, 35, 29, 31, 24, 16, 18, 30, 24, 27, 23, 28, 15, 23, 24, 22, 24, 22, 40, 20, 20, 28, 22, 25, 17, 27, 20, 34, 24, 24, 21, 16, 16, 29, 25, 36, 17, 35, 26, 18, 22, 16, 22, 21, 20, 14, 20, 18, 38, 32, 16, 26, 19, 15, 21, 24, 28, 42, 32, 27, 24, 25, 17, 22, 26, 25, 32, 24, 23, 35, 29, 23, 18, 23, 21, 26, 19, 28, 36, 31, 15, 24, 23, 33, 17, 23, 27, 13, 27, 15, 20, 27, 30, 28, 26, 20, 28, 24, 32, 30, 27, 34, 24, 26, 27, 35, 16, 38, 27, 21, 21, 19, 25, 26, 34, 24, 26, 16, 29, 27, 26, 26, 24, 25, 18, 22, 23, 23, 33, 19, 24, 19, 20, 19, 36, 41, 29, 23, 28, 36, 24, 27, 23, 20, 16, 19, 23, 18, 35, 21, 17, 21, 41, 26, 28, 20, 20, 18, 20, 29, 28, 23, 21, 19, 23, 26, 17, 26, 24, 27, 17, 31, 19, 28, 32, 27, 22, 19, 25, 31, 21, 19, 24, 29, 33, 14, 20, 33, 32, 28, 26, 21, 22, 38, 19, 23, 35, 29, 20, 33, 19, 20, 21, 27, 35, 19, 22, 23, 18, 26, 18, 31, 19, 38, 22, 40, 22, 20, 24, 24, 22, 31, 22, 25, 29, 41, 17, 26, 21, 27, 22, 18, 24, 27, 15, 31, 19, 16, 20, 42, 27, 29, 37, 28, 18, 19, 27, 31, 23, 24, 20, 31, 17, 17, 33, 29, 27, 35, 28, 19, 35, 15, 21, 28, 19, 16, 29, 32, 35, 24, 19, 34, 27, 31, 24, 22, 44, 26, 21, 20, 22, 35, 28, 25, 32, 36, 26, 23, 39, 25, 26, 31, 28, 21, 36, 28, 27, 26, 19, 28, 23, 35, 23, 26, 20, 22, 24, 19, 20, 26, 16, 23, 25, 24, 22, 23, 22, 31, 32, 25, 26, 14, 18, 28, 22, 20, 21, 20, 21, 29, 20, 21, 16, 18, 31, 37, 24, 28, 30, 26, 36, 34, 26, 28, 19, 36, 16, 30, 20, 20, 25, 23, 20, 21, 26, 41, 26, 25, 16, 31, 29, 21, 27, 29, 25, 20, 26, 19, 36, 20, 32, 33, 30, 32, 24, 26, 23, 24, 25, 21, 37, 32, 33, 33, 28, 29, 28, 25, 17, 25, 35, 16, 28, 18, 25, 25, 17, 28, 31, 34, 34, 22, 26, 26, 22, 20, 33, 35, 21, 40, 30, 34, 25, 25, 33, 23, 18, 21, 24, 22, 35, 37, 38, 36, 28, 32, 19, 29, 25, 22, 36, 38, 19, 17, 21, 17, 19, 26, 28, 19, 20, 26, 31, 39, 25, 20, 23, 29, 30, 25, 25, 26, 26, 22, 25, 24, 24, 25, 27, 24, 40, 34, 21, 26, 21, 21, 28, 20, 34, 25, 29, 29, 22, 29, 31, 17, 25, 26, 22, 21, 22, 41, 31, 24, 21, 28, 21, 28, 28, 22, 24, 28, 25, 31, 20, 27, 21, 33, 23, 26, 27, 24, 15, 21, 17, 13, 20, 26, 24, 16, 19, 30, 19, 20, 21, 34, 20, 13, 25, 47, 16, 21, 27, 19, 29, 32, 33, 13, 21, 19, 24, 28, 19, 39, 20, 25, 28, 24, 25, 25, 23, 29, 31, 29, 20, 28, 14, 31, 17, 48, 34, 25, 21, 21, 27, 25, 23, 21, 39, 14, 20, 27, 25, 16, 16, 28, 28, 26, 28, 26, 19, 22, 23, 23, 22, 30, 25, 17, 28, 24, 23, 21, 18, 30, 20, 37, 32, 18, 28, 30, 22, 33, 15, 25, 17, 22, 31, 27, 14, 21, 28, 25, 38, 30, 23, 34, 14, 18, 22, 20, 25, 18, 25, 25, 19, 18, 26, 23, 21, 23, 23, 27, 27, 17, 18, 26, 21, 37, 28, 34, 22, 24, 17, 23, 22, 20, 23, 15, 25, 29, 19, 20, 20, 29, 26, 18, 25, 15, 18, 25, 36, 20, 28, 18, 27, 18, 35, 21, 27, 26, 12, 15, 18, 26, 23, 18, 45, 20, 23, 18, 31, 22, 34, 22, 26, 24, 34, 31, 24, 32, 31, 39, 18, 21, 32, 13, 34, 15, 25, 20, 22, 25, 20, 20, 20, 23, 29, 18, 35, 21, 39, 25, 36, 28, 24, 23, 31, 27, 28, 21, 25, 34, 35, 29, 15, 20, 21, 32, 17, 33, 22, 30, 34, 24, 22, 25, 19, 21, 24, 14, 21, 28, 14, 27, 24, 30, 28, 22, 22, 22, 20, 22, 34, 28, 24, 30, 24, 39, 22, 20, 19, 28, 29, 15, 31, 28, 30, 37, 22, 24, 31, 32, 18, 32, 34, 41, 19, 29, 21, 20, 36, 31, 29, 20, 32, 33, 25, 20, 27, 20, 19, 20, 23, 23, 36, 20, 18, 26, 31, 21, 22, 21, 31, 22, 25, 27, 20, 45, 20, 28, 21, 25, 20, 42, 30, 22, 33, 19, 22, 20, 20, 39, 34, 26, 12, 21, 30, 21, 24, 32, 23, 29, 18, 29, 24, 26, 42, 26, 22, 30, 26, 20, 27, 30, 30, 20, 25, 16, 25, 17, 26, 14, 34, 26, 30, 32, 28, 31, 24, 29, 37, 22, 25, 20, 37, 26, 27, 29, 28, 30, 15, 20, 32, 22, 41, 18, 17, 25, 27, 27, 21, 29, 23, 28, 25, 24, 22, 27, 17, 26, 37, 27, 17, 29, 23, 26, 28, 28, 29, 49, 24, 21, 18, 26, 14, 22, 28, 31, 31, 37, 14, 27, 23, 34, 32, 13, 19, 31, 25, 42, 15, 22, 19, 30, 24, 44, 29, 34, 34, 20, 22, 23, 15, 20, 29, 29, 28, 38, 15, 32, 27, 25, 30, 22, 17, 32, 22, 22, 23, 20, 14, 16, 23, 26, 21, 28, 18, 21, 30, 34, 22, 22, 24, 24, 33, 24, 20, 30, 31, 30, 22, 20, 33, 17, 21, 34, 17, 21, 25, 25, 26, 29, 20, 27, 33, 22, 18, 35, 27, 25, 24, 27, 24, 30, 14, 23, 22, 24, 23, 25, 33, 24, 28, 19, 24, 30, 32, 36, 33, 30, 35, 27, 22, 34, 20, 25, 39, 31, 26, 14, 20, 29, 16, 19, 25, 25, 30, 29, 28, 15, 19, 33, 18, 22, 22, 18, 24, 26, 27, 19, 19, 32, 24, 24, 33, 31, 21, 24, 24, 30, 26, 25, 23, 21, 40, 24, 24, 24, 23, 31, 37, 31, 29, 28, 26, 28, 28, 28, 24, 17, 39, 21, 27, 20, 17, 16, 36, 23, 23, 22, 20, 28, 13, 30, 25, 23, 34, 25, 22, 27, 23, 17, 30, 19, 16, 24, 20, 27, 33, 23, 23, 19, 20, 36, 27, 26, 29, 20, 23, 17, 40, 22, 34, 18, 24, 16, 38, 50, 17, 30, 34, 27, 20, 27, 20, 34, 26, 33, 24, 19, 21, 22, 35, 27, 22, 33, 17, 22, 41, 29, 18, 18, 19, 24, 38, 32, 31, 33, 16, 27, 32, 31, 27, 24, 24, 34, 26, 22, 17, 46, 22, 19, 28, 27, 18, 31, 25, 29, 26, 31, 29, 19, 15, 24, 25, 21, 33, 27, 17, 21, 29, 25, 32, 22, 22, 27, 21, 26, 20, 17, 27, 17, 17, 26, 36, 29, 18, 22, 21, 14, 23, 22, 20, 30, 22, 21, 20, 30, 18, 16, 33, 31, 19, 23, 28, 21, 21, 21, 29, 22, 20, 23, 29, 31, 17, 23, 23, 26, 27, 27, 33, 28, 30, 16, 31, 20, 15, 27, 19, 27, 30, 25, 18, 20, 25, 21, 25, 25, 24, 22, 24, 20, 24, 25, 27, 17, 23, 27, 34, 29, 23, 22, 32, 21, 24, 26, 23, 24, 35, 27, 29, 23, 23, 35, 29, 37, 23, 22, 26, 22, 28, 27, 29, 27, 27, 32, 29, 37, 21, 20, 44, 14, 29, 26, 27, 24, 18, 20, 20, 27, 17, 24, 26, 29, 23, 18, 29, 22, 20, 25, 21, 22, 18, 30, 26, 29, 21, 26, 22, 18, 23, 28, 39, 25, 24, 23, 31, 31, 20, 30, 18, 19, 23, 33, 29, 23, 29, 18, 27, 27, 37, 24, 17, 22, 17, 24, 23, 14, 25, 29, 21, 28, 21, 17, 30, 20, 24, 35, 34, 23, 21, 21, 22, 27, 18, 22, 28, 29, 24, 30, 22, 32, 21, 26, 23, 15, 21, 22, 30, 19, 23, 23, 30, 16, 23, 17, 21, 22, 43, 18, 20, 31, 16, 23, 37, 20, 13, 24, 31, 22, 20, 26, 21, 15, 27, 22, 15, 24, 14, 17, 41, 37, 28, 18, 25, 20, 27, 34, 17, 26, 24, 24, 27, 39, 21, 24, 24, 26, 23, 34, 20, 39, 30, 25, 17, 23, 26, 15, 20, 26, 20, 25, 38, 42, 35, 15, 22, 13, 25, 23, 32, 25, 16, 20, 16, 20, 31, 30, 27, 17, 38, 20, 33, 30, 22, 15, 26, 18, 24, 34, 23, 29, 25, 27, 28, 27, 22, 19, 30, 19, 27, 33, 24, 19, 16, 23, 22, 30, 30, 15, 14, 16, 15, 21, 20, 20, 21, 43, 23, 20, 24, 17, 35, 25, 29, 29, 16, 25, 32, 31, 27, 39, 22, 27, 20, 31, 27, 30, 27, 20, 32, 25, 31, 31, 30, 20, 23, 17, 23, 19, 27, 22, 21, 45, 20, 26, 29, 21, 18, 23, 28, 26, 31, 28, 18, 30, 35, 27, 12, 16, 37, 31, 29, 28, 32, 23, 25, 30, 16, 17, 31, 24, 16, 22, 25, 22, 33, 24, 26, 26, 34, 31, 24, 31, 19, 16, 34, 33, 20, 36, 21, 36, 22, 19, 26, 32, 16, 25, 29, 15, 29, 26, 30, 19, 32, 16, 24, 30, 19, 28, 22, 32, 21, 14, 21, 16, 45, 23, 22, 18, 31, 34, 19, 35, 29, 28, 23, 31, 40, 25, 29, 18, 25, 30, 22, 28, 27, 17, 30, 25, 37, 22, 23, 30, 25, 27, 18, 29, 29, 19, 25, 17, 27, 15, 33, 17, 25, 24, 21, 37, 18, 20, 33, 24, 13, 27, 25, 20, 21, 20, 20, 27, 25, 26, 19, 32, 18, 21, 29, 21, 24, 24, 17, 27, 25, 20, 15, 20, 29, 39, 26, 26, 24, 16, 29, 27, 22, 18, 18, 24, 29, 21, 38, 29, 22, 34, 20, 31, 23, 23, 20, 25, 15, 19, 28, 27, 20, 24, 34, 23, 35, 30, 20, 27, 19, 22, 18, 23, 45, 17, 32, 29, 23, 23, 27, 22, 19, 30, 29, 31, 20, 27, 33, 22, 24, 32, 23, 19, 25, 20, 23, 38, 17, 23, 19, 27, 23, 18, 24, 17, 20, 26, 24, 30, 16, 25, 32, 21, 25, 26, 30, 36, 28, 18, 26, 46, 16, 25, 27, 30, 28, 22, 17, 18, 21, 33, 24, 29, 22, 13, 21, 21, 16, 20, 19, 30, 22, 19, 24, 35, 31, 23, 19, 29, 19, 29, 19, 21, 25, 29, 30, 19, 24, 26, 37, 21, 23, 25, 21, 14, 24, 21, 16, 34, 21, 35, 19, 35, 29, 33, 17, 23, 23, 19, 19, 22, 31, 17, 20, 33, 20, 24, 27, 25, 29, 26, 34, 25, 19, 21, 36, 19, 24, 25, 27, 29, 22, 26, 23, 23, 12, 18, 23, 27, 23, 22, 20, 35, 22, 33, 16, 33, 19, 31, 28, 24, 38, 24, 18, 28, 26, 18, 33, 20, 25, 23, 13, 23, 25, 14, 28, 32, 24, 23, 30, 18, 34, 23, 31, 24, 21, 20, 34, 27, 23, 29, 24, 25, 22, 26, 16, 34, 23, 28, 29, 23, 25, 21, 17, 20, 19, 33, 33, 23, 30, 29, 17, 15, 20, 26, 31, 24, 23, 43, 19, 27, 28, 22, 27, 25, 35, 21, 27, 24, 27, 22, 38, 33, 50, 20, 21, 19, 36, 31, 28, 25, 22, 24, 32, 24, 30, 29, 33, 34, 19, 18, 29, 21, 14, 26, 27, 33, 22, 21, 23, 32, 35, 22, 23, 26, 24, 25, 23, 25, 15, 32, 17, 20, 25, 22, 38, 19, 21, 30, 22, 23, 28, 27, 38, 21, 19, 38, 21, 22, 22, 18, 27, 17, 26, 30, 19, 18, 14, 25, 31, 24, 23, 28, 27, 30, 14, 28, 21, 27, 33, 33, 15, 20, 29, 17, 24, 29, 23, 21, 24, 29, 28, 24, 47, 22, 22, 30, 23, 22, 31, 18, 26, 17, 27, 19, 24, 20, 19, 31, 25, 24, 21, 21, 20, 32, 19, 32, 24, 19, 30, 28, 26, 16, 23, 34, 21, 31, 18, 20, 28, 27, 22, 19, 21, 25, 18, 24, 24, 31, 28, 28, 19, 17, 28, 24, 23, 17, 25, 34, 13, 31, 17, 28, 23, 28, 35, 21, 24, 23, 23, 19, 27, 26, 22, 14, 19, 21, 28, 16, 19, 30, 22, 21, 36, 20, 32, 21, 28, 41, 24, 19, 24, 40, 40, 26, 23, 30, 23, 23, 18, 24, 14, 25, 21, 42, 31, 22, 18, 27, 43, 28, 24, 26, 20, 18, 31, 38, 26, 37, 13, 20, 20, 28, 23, 34, 24, 16, 29, 25, 28, 32, 29, 21, 18, 14, 21, 16, 25, 21, 29, 16, 19, 24, 25, 23, 24, 23, 33, 14, 19, 17, 33, 25, 23, 24, 24, 26, 31, 23, 21, 24, 14, 21, 21, 20, 23, 26, 35, 37, 33, 26, 30, 32, 29, 27, 33, 25, 18, 25, 26, 17, 29, 25, 30, 20, 24, 18, 35, 25, 20, 20, 23, 28, 28, 16, 22, 31, 31, 29, 31, 21, 19, 40, 20, 18, 24, 24, 19, 20, 18, 28, 28, 25, 39, 19, 26, 24, 25, 29, 20, 19, 23, 36, 18, 30, 23, 26, 26, 18, 37, 21, 26, 20, 22, 19, 29, 34, 24, 23, 14, 20, 19, 34, 18, 26, 19, 26, 22, 26, 25, 22, 34, 25, 35, 26, 15, 19, 29, 29, 21, 20, 18, 28, 26, 21, 18, 29, 21, 23, 21, 35, 25, 33, 28, 19, 22, 29, 26, 23, 19, 20, 31, 30, 18, 19, 29, 24, 30, 27, 19, 26, 26, 21, 37, 35, 21, 15, 24, 30, 22, 18, 25, 27, 29, 18, 30, 36, 18, 23, 24, 28, 27, 31, 24, 32, 23, 26, 19, 20, 32, 20, 30, 17, 16, 24, 21, 30, 23, 23, 31, 15, 19, 18, 25, 24, 26, 29, 38, 16, 26, 18, 19, 31, 23, 20, 35, 26, 35, 25, 24, 21, 22, 13, 29, 21, 30, 22, 29, 17, 34, 20, 29, 21, 24, 35, 18, 26, 18, 27, 21, 16, 22, 26, 24, 28, 26, 29, 22, 24, 19, 22, 21, 33, 23, 35, 31, 25, 33, 26, 26, 26, 19, 23, 22, 28, 27, 30, 18, 16, 27, 24, 22, 25, 20, 24, 19, 20, 29, 13, 22, 22, 14, 34, 21, 27, 28, 22, 22, 24, 21, 27, 39, 28, 23, 15, 27, 24, 30, 27, 24, 31, 25, 18, 22, 28, 23, 15, 24, 20, 18, 29, 22, 19, 21, 33, 23, 28, 27, 19, 34, 29, 35, 22, 21, 26, 12, 38, 23, 36, 33, 21, 26, 38, 49, 35, 26, 19, 13, 23, 23, 21, 20, 24, 19, 32, 27, 24, 30, 23, 25, 34, 38, 16, 23, 18, 23, 25, 15, 33, 35, 27, 18, 20, 13, 28, 21, 35, 18, 22, 32, 24, 24, 22, 25, 15, 28, 22, 21, 28, 40, 27, 18, 28, 21, 25, 30, 20, 33, 26, 29, 25, 23, 28, 24, 20, 21, 18, 30, 17, 16, 27, 34, 20, 21, 22, 23, 24, 17, 24, 19, 36, 24, 23, 26, 31, 23, 22, 26, 34, 46, 24, 30, 22, 26, 31, 17, 27, 25, 18, 21, 15, 41, 23, 25, 24, 15, 26, 31, 24, 37, 23, 30, 30, 24, 28, 34, 29, 22, 24, 34, 27, 29, 22, 28, 19, 25, 28, 29, 21, 27, 33, 21, 40, 22, 32, 20, 28, 42, 15, 35, 23, 33, 20, 21, 25, 29, 23, 21, 22, 19, 21, 16, 21, 17, 39, 21, 28, 37, 20, 25, 35, 23, 20, 21, 24, 20, 17, 16, 15, 28, 25, 23, 24, 19, 19, 25, 30, 16, 22, 25, 22, 38, 21, 23, 26, 29, 15, 19, 26, 30, 24, 28, 27, 30, 32, 17, 35, 21, 20, 25, 21, 22, 22, 20, 36, 25, 38, 30, 37, 34, 37, 31, 27, 29, 18, 22, 20, 24, 30, 39, 21, 40, 21, 28, 22, 25, 44, 35, 23, 21, 23, 27, 29, 34, 31, 26, 26, 17, 15, 22, 21, 17, 24, 20, 21, 23, 34, 18, 26, 23, 29, 25, 21, 26, 20, 23, 19, 19, 23, 22, 24, 21, 27, 31, 25, 17, 25, 41, 28, 22, 24, 27, 22, 37, 20, 31, 28, 36, 24, 20, 21, 30, 24, 36, 31, 18, 27, 28, 30, 23, 24, 20, 33, 17, 19, 20, 26, 24, 33, 25, 25, 27, 22, 19, 15, 23, 36, 26, 31, 20, 21, 28, 14, 33, 12, 29, 30, 21, 35, 25, 27, 19, 39, 21, 20, 21, 19, 36, 31, 17, 43, 20, 18, 25, 45, 19, 22, 27, 24, 25, 19, 35, 20, 21, 24, 22, 18, 24, 20, 28, 26, 21, 27, 28, 16, 27, 20, 25, 26, 21, 12, 40, 20, 21, 27, 31, 25, 32, 22, 21, 27, 33, 24, 20, 12, 37, 19, 29, 18, 30, 30, 37, 29, 29, 28, 29, 20, 20, 21, 33, 25, 28, 23, 32, 20, 23, 23, 27, 18, 15, 29, 22, 24, 20, 19, 27, 15, 20, 20, 13, 26, 32, 32, 33, 17, 34, 22, 17, 25, 28, 19, 29, 24, 29, 20, 21, 20, 25, 22, 29, 21, 27, 15, 14, 33, 25, 28, 22, 23, 20, 27, 22, 23, 23, 18, 18, 29, 23, 35, 22, 26, 29, 26, 16, 33, 25, 25, 23, 18, 33, 35, 20, 17, 19, 15, 28, 25, 20, 24, 23, 22, 29, 31, 22, 21, 19, 29, 22, 22, 13, 23, 23, 19, 30, 28, 23, 29, 21, 21, 30, 20, 32, 22, 35, 37, 14, 25, 22, 31, 24, 25, 34, 26, 13, 17, 28, 19, 21, 30, 35, 12, 33, 14, 21, 29, 28, 20, 33, 23, 14, 17, 23, 27, 27, 29, 33, 20, 17, 30, 18, 19, 42, 27, 20, 22, 20, 25, 40, 23, 36, 28, 24, 22, 18, 19, 20, 28, 35, 27, 26, 30, 19, 34, 19, 20, 24, 16, 20, 31, 21, 37, 26, 21, 21, 26, 39, 25, 28, 16, 19, 25, 21, 28, 32, 22, 23, 24, 34, 29, 23, 26, 25, 22, 12, 26, 36, 27, 24, 14, 23, 22, 22, 17, 19, 22, 20, 19, 31, 21, 25, 23, 28, 27, 27, 23, 24, 36, 34, 32, 21, 31, 29, 24, 18, 22, 29, 33, 26, 16, 25, 30, 24, 14, 36, 20, 30, 19, 24, 18, 24, 23, 31, 26, 24, 21, 19, 29, 19, 33, 38, 30, 18, 32, 20, 23, 18, 26, 39, 20, 27, 33, 20, 31, 26, 32, 20, 26, 24, 25, 23, 23, 23, 33, 31, 21, 35, 22, 19, 22, 29, 31, 15, 23, 24, 27, 28, 34, 26, 24, 27, 25, 40, 21, 25, 27, 25, 20, 50, 38, 22, 25, 18, 17, 21, 29, 14, 16, 32, 20, 23, 32, 24, 24, 17, 17, 29, 25, 35, 22, 31, 21, 18, 19, 26, 20, 21, 36, 27, 26, 28, 29, 34, 36, 21, 31, 24, 15, 21, 17, 24, 30, 24, 23, 43, 39, 39, 20, 35, 37, 35, 28, 28, 21, 15, 27, 20, 24, 24, 17, 24, 27, 27, 19, 20, 35, 30, 22, 21, 24, 16, 19, 32, 23, 19, 19, 25, 22, 31, 29, 24, 22, 29, 27, 26, 20, 21, 31, 20, 31, 27, 21, 21, 18, 28, 22, 24, 28, 20, 34, 29, 22, 15, 20, 25, 16, 17, 26, 32, 22, 19, 36, 23, 22, 17, 28, 23, 31, 23, 21, 24, 33, 24, 24, 26, 17, 20, 24, 24, 22, 24, 20, 24, 21, 25, 23, 32, 21, 27, 18, 28, 27, 21, 16, 31, 22, 19, 25, 24, 24, 31, 24, 24, 24, 40, 41, 17, 36, 29, 25, 24, 33, 33, 25, 21, 30, 33, 24, 28, 17, 21, 18, 33, 23, 28, 24, 41, 19, 18, 24, 24, 24, 20, 28, 20, 19, 32, 28, 27, 19, 29, 27, 27, 25, 22, 27, 20, 26, 25, 23, 19, 23, 24, 29, 21, 20, 30, 27, 23, 32, 19, 28, 20, 31, 17, 31, 21, 22, 19, 43, 22, 30, 34, 19, 23, 22, 18, 19, 27, 22, 21, 36, 32, 18, 33, 27, 30, 27, 20, 21, 26, 33, 34, 30, 18, 15, 21, 39, 21, 44, 25, 31, 30, 36, 24, 31, 25, 32, 25, 19, 27, 21, 16, 26, 25, 47, 30, 19, 23, 26, 22, 16, 24, 37, 24, 24, 19, 33, 30, 28, 30, 29, 21, 24, 29, 32, 35, 19, 31, 26, 22, 24, 20, 28, 37, 28, 22, 33, 35, 19, 46, 18, 27, 20, 20, 20, 26, 29, 26, 39, 22, 18, 19, 37, 20, 23, 30, 21, 19, 19, 22, 27, 21, 39, 26, 27, 29, 28, 19, 34, 27, 29, 25, 26, 25, 17, 23, 31, 26, 30, 30, 22, 18, 15, 36, 19, 24, 23, 28, 21, 37, 28, 23, 25, 20, 19, 29, 26, 25, 30, 17, 20, 25, 25, 23, 23, 28, 22, 26, 22, 37, 23, 31, 16, 27, 25, 34, 21, 25, 19, 42, 13, 26, 22, 22, 23, 30, 30, 28, 28, 30, 18, 23, 22, 25, 21, 27, 22, 21, 18, 22, 31, 43, 19, 17, 28, 26, 34, 23, 21, 25, 21, 28, 22, 35, 17, 22, 36, 16, 24, 24, 18, 17, 17, 22, 25, 23, 24, 21, 26, 21, 21, 19, 27, 18, 23, 34, 22, 31, 28, 25, 14, 15, 30, 34, 30, 19, 25, 21, 40, 21, 24, 18, 16, 24, 26, 24, 24, 28, 30, 22, 19, 27, 31, 26, 25, 29, 23, 25, 24, 33, 25, 51, 23, 23, 17, 18, 29, 32, 22, 17, 23, 15, 32, 21, 28, 29, 15, 21, 27, 26, 26, 25, 34, 25, 22, 28, 25, 22, 23, 21, 23, 20, 21, 21, 34, 37, 30, 20, 18, 24, 20, 28, 16, 30, 15, 25, 20, 23, 19, 17, 18, 25, 38, 33, 28, 25, 25, 22, 19, 25, 29, 25, 23, 20, 32, 14, 20, 26, 21, 29, 13, 21, 28, 24, 32, 25, 18, 28, 35, 29, 20, 31, 31, 21, 31, 16, 26, 29, 23, 25, 27, 26, 30, 33, 39, 27, 16, 28, 25, 22, 26, 24, 28, 23, 19, 14, 15, 32, 30, 24, 38, 40, 24, 21, 28, 27, 37, 21, 22, 19, 22, 15, 19, 26, 22, 25, 21, 27, 22, 32, 20, 26, 26, 24, 18, 27, 31, 19, 32, 23, 33, 20, 27, 19, 22, 20, 34, 26, 22, 36, 27, 23, 23, 18, 32, 26, 25, 19, 31, 25, 22, 21, 36, 22, 18, 28, 29, 22, 36, 17, 21, 20, 16, 34, 17, 26, 33, 25, 21, 32, 25, 17, 29, 30, 23, 29, 23, 22, 24, 20, 20, 23, 14, 20, 33, 13, 27, 32, 27, 24, 23, 36, 24, 17, 24, 15, 33, 22, 16, 30, 23, 29, 22, 21, 32, 30, 21, 24, 21, 22, 27, 25, 12, 21, 28, 20, 23, 48, 22, 28, 32, 19, 27, 27, 24, 19, 22, 26, 15, 25, 31, 27, 23, 16, 27, 20, 29, 17, 20, 19, 26, 25, 17, 18, 27, 21, 30, 34, 36, 28, 39, 40, 23, 29, 19, 24, 33, 17, 20, 30, 31, 27, 23, 20, 34, 29, 23, 25, 20, 29, 39, 23, 24, 29, 33, 22, 19, 26, 32, 25, 27, 14, 31, 22, 21, 22, 22, 24, 35, 29, 22, 30, 33, 24, 28, 29, 33, 23, 21, 24, 20, 36, 22, 20, 36, 24, 27, 20, 24, 23, 21, 22, 32, 30, 24, 16, 19, 24, 24, 23, 24, 24, 24, 20, 23, 31, 32, 31, 29, 38, 29, 21, 29, 30, 20, 27, 19, 19, 24, 34, 20, 25, 22, 15, 26, 25, 17, 24, 19, 23, 22, 21, 35, 25, 28, 21, 21, 24, 44, 26, 25, 25, 29, 31, 31, 21, 34, 26, 22, 32, 23, 27, 31, 31, 28, 16, 31, 44, 22, 24, 23, 26, 35, 40, 25, 22, 28, 35, 30, 21, 33, 17, 28, 27, 24, 24, 19, 29, 32, 36, 24, 20, 22, 26, 21, 20, 23, 26, 19, 19, 27, 25, 35, 18, 24, 25, 24, 29, 36, 24, 30, 34, 29, 25, 24, 25, 23, 24, 16, 34, 32, 13, 27, 18, 13, 18, 24, 22, 30, 38, 34, 31, 20, 26, 23, 32, 26, 37, 25, 27, 27, 26, 20, 30, 25, 24, 27, 48, 26, 20, 30, 17, 21, 18, 24, 25, 30, 25, 29, 19, 53, 23, 23, 26, 31, 13, 17, 28, 24, 29, 21, 34, 29, 27, 31, 16, 18, 30, 23, 23, 21, 27, 23, 21, 15, 18, 18, 28, 25, 28, 30, 21, 26, 22, 33, 25, 20, 23, 14, 26, 23, 33, 22, 37, 21, 29, 26, 26, 19, 19, 42, 32, 34, 39, 25, 27, 29, 25, 17, 19, 30, 17, 23, 14, 32, 16, 27, 30, 25, 29, 22, 19, 27, 27, 22, 22, 17, 14, 28, 26, 27, 32, 28, 23, 18, 28, 23, 21, 27, 23, 22, 39, 24, 15, 29, 34, 29, 24, 23, 23, 36, 30, 25, 28, 22, 32, 33, 34, 29, 19, 22, 29, 30, 34, 33, 26, 47, 18, 20, 32, 29, 25, 24, 17, 22, 23, 26, 23, 24, 25, 21, 24, 22, 26, 23, 35, 20, 27, 22, 21, 15, 25, 18, 32, 17, 26, 20, 23, 36, 30, 19, 41, 18, 35, 21, 27, 31, 22, 26, 29, 20, 26, 34, 24, 20, 16, 17, 25, 18, 27, 15, 27, 28, 20, 23, 20, 24, 33, 30, 30, 20, 18, 47, 31, 45, 14, 21, 23, 25, 35, 13, 35, 30, 25, 26, 28, 21, 17, 28, 20, 19, 24, 32, 25, 24, 16, 22, 32, 25, 40, 28, 26, 22, 29, 21, 22, 25, 29, 18, 22, 18, 25, 15, 27, 25, 23, 18, 24, 17, 26, 27, 31, 21, 26, 21, 17, 15, 20, 12, 23, 19, 24, 21, 19, 37, 26, 31, 19, 35, 34, 23, 31, 17, 27, 30, 23, 20, 28, 26, 25, 30, 29, 32, 22, 26, 20, 27, 20, 20, 23, 22, 27, 20, 21, 24, 30, 24, 24, 31, 22, 23, 28, 29, 15, 22, 28, 20, 27, 23, 26, 20, 40, 20, 27, 21, 13, 26, 27, 19, 22, 29, 26, 19, 35, 25, 20, 17, 27, 39, 24, 21, 26, 14, 23, 16, 28, 19, 23, 45, 21, 20, 33, 33, 24, 17, 19, 22, 35, 16, 26, 15, 22, 47, 20, 21, 24, 18, 25, 18, 19, 27, 30, 17, 18, 21, 24, 19, 28, 18, 27, 30, 20, 14, 23, 24, 30, 18, 29, 22, 31, 32, 27, 23, 28, 24, 39, 29, 23, 23, 23, 34, 15, 20, 13, 24, 20, 19, 29, 17, 36, 26, 25, 32, 26, 24, 17, 29, 15, 29, 25, 36, 27, 23, 31, 23, 31, 24, 25, 31, 26, 26, 25, 23, 23, 20, 35, 28, 24, 27, 26, 39, 21, 34, 19, 17, 23, 14, 21, 35, 40, 22, 28, 21, 17, 31, 20, 27, 29, 31, 35, 25, 18, 28, 30, 25, 37, 21, 33, 18, 28, 30, 31, 29, 22, 17, 18, 21, 33, 31, 29, 27, 22, 24, 31, 23, 20, 31, 35, 27, 26, 23, 22, 25, 22, 18, 22, 31, 29, 32, 27, 30, 23, 22, 25, 22, 22, 26, 32, 16, 23, 23, 34, 21, 24, 33, 24, 24, 20, 29, 29, 22, 20, 23, 39, 19, 19, 25, 24, 23, 15, 20, 19, 20, 18, 22, 21, 28, 19, 19, 24, 22, 31, 25, 18, 32, 32, 53, 24, 21, 24, 27, 29, 27, 30, 16, 26, 38, 20, 23, 31, 17, 18, 26, 21, 24, 19, 33, 27, 21, 38, 26, 22, 23, 26, 28, 18, 20, 13, 18, 32, 15, 34, 21, 22, 17, 19, 22, 21, 27, 18, 19, 24, 25, 35, 20, 33, 20, 40, 27, 31, 23, 22, 41, 23, 35, 26, 34, 26, 17, 23, 16, 30, 28, 30, 21, 31, 23, 18, 38, 20, 20, 25, 31, 18, 23, 16, 23, 19, 27, 15, 28, 25, 22, 22, 22, 32, 20, 27, 30, 16, 17, 27, 35, 25, 21, 20, 29, 32, 22, 20, 18, 16, 35, 28, 29, 31, 22, 22, 26, 29, 28, 25, 22, 43, 27, 46, 32, 22, 29, 26, 18, 22, 23, 22, 28, 20, 23, 31, 23, 25, 27, 21, 33, 15, 23, 19, 20, 27, 22, 28, 24, 26, 27, 24, 32, 22, 24, 14, 23, 28, 34, 25, 38, 25, 31, 19, 21, 25, 21, 31, 35, 19, 24, 21, 23, 21, 29, 28, 25, 15, 22, 19, 26, 39, 24, 27, 21, 25, 21, 31, 20, 22, 30, 31, 21, 32, 19, 20, 18, 20, 33, 26, 24, 26, 14, 15, 17, 25, 34, 27, 30, 26, 23, 20, 24, 28, 30, 19, 19, 34, 24, 27, 19, 27, 20, 14, 18, 19, 17, 23, 23, 19, 17, 44, 43, 36, 20, 27, 26, 36, 28, 21, 20, 36, 29, 41, 17, 30, 20, 26, 13, 22, 25, 21, 20, 24, 20, 26, 32, 18, 38, 24, 29, 32, 19, 16, 21, 25, 26, 29, 19, 27, 23, 25, 17, 20, 36, 20, 21, 25, 29, 20, 23, 21, 46, 30, 26, 34, 19, 21, 26, 34, 32, 35, 27, 14, 22, 27, 30, 25, 14, 20, 21, 15, 20, 19, 21, 25, 21, 19, 28, 39, 27, 17, 27, 27, 29, 31, 24, 38, 36, 32, 17, 20, 20, 23, 22, 32, 23, 25, 31, 25, 21, 26, 23, 19, 23, 29, 19, 30, 15, 20, 22, 26, 24, 17, 25, 17, 33, 18, 18, 31, 27, 25, 22, 23, 29, 32, 15, 25, 26, 23, 36, 21, 23, 20, 28, 39, 27, 33, 30, 27, 30, 17, 30, 23, 24, 32, 31, 32, 20, 21, 11, 31, 26, 22, 19, 18, 34, 29, 30, 25, 29, 15, 19, 20, 38, 16, 26, 38, 29, 18, 30, 28, 16, 21, 25, 19, 35, 22, 30, 19, 21, 22, 19, 40, 14, 26, 22, 18, 29, 27, 21, 21, 24, 30, 20, 21, 24, 26, 18, 38, 15, 23, 18, 16, 26, 17, 18, 30, 27, 41, 29, 29, 27, 22, 22, 32, 27, 21, 31, 17, 38, 28, 19, 23, 19, 32, 26, 25, 18, 23, 23, 19, 23, 23, 18, 30, 22, 24, 28, 29, 22, 20, 19, 31, 30, 27, 33, 31, 29, 38, 22, 20, 43, 20, 29, 31, 49, 29, 38, 28, 35, 23, 21, 31, 33, 25, 31, 19, 23, 20, 29, 28, 25, 33, 24, 18, 25, 16, 31, 18, 20, 23, 23, 21, 39, 30, 24, 23, 24, 23, 23, 27, 21, 22, 28, 26, 21, 25, 22, 31, 23, 28, 22, 24, 31, 28, 21, 21, 60, 20, 30, 22, 27, 34, 25, 46, 34, 23, 22, 31, 29, 31, 29, 22, 34, 29, 31, 30, 21, 25, 27, 36, 26, 23, 18, 29, 25, 25, 28, 30, 28, 22, 39, 24, 23, 33, 23, 28, 22, 27, 29, 27, 22, 34, 31, 43, 37, 25, 24, 25, 22, 33, 13, 29, 28, 20, 22, 20, 32, 36, 26, 30, 31, 22, 26, 20, 35, 31, 40, 19, 26, 28, 21, 22, 21, 24, 29, 21, 33, 19, 29, 25, 23, 26, 25, 30, 23, 16, 27, 18, 26, 14, 21, 19, 37, 18, 26, 25, 25, 16, 21, 34, 18, 28, 31, 24, 32, 24, 12, 29, 30, 28, 16, 23, 15, 28, 33, 27, 32, 28, 31, 20, 23, 30, 16, 26, 14, 26, 19, 28, 14, 30, 23, 23, 29, 42, 34, 25, 30, 19, 24, 19, 22, 20, 23, 27, 25, 27, 25, 18, 24, 25, 29, 24, 17, 26, 27, 26, 27, 25, 28, 24, 24, 24, 29, 26, 26, 18, 19, 26, 50, 17, 20, 29, 22, 38, 18, 24, 30, 24, 21, 31, 28, 26, 24, 34, 25, 26, 15, 19, 31, 22, 21, 26, 27, 21, 22, 30, 18, 25, 23, 22, 27, 22, 28, 35, 32, 28, 37, 45, 17, 18, 27, 27, 23, 22, 27, 25, 20, 15, 23, 19, 29, 22, 24, 18, 27, 30, 22, 16, 16, 34, 29, 30, 35, 22, 22, 34, 16, 16, 23, 31, 31, 31, 14, 20, 16, 14, 26, 31, 27, 30, 28, 20, 20, 30, 22, 20, 25, 25, 23, 30, 31, 25, 24, 26, 14, 18, 23, 37, 34, 32, 25, 28, 27, 21, 25, 26, 23, 30, 35, 19, 18, 29, 24, 27, 30, 24, 20, 21, 20, 24, 18, 18, 23, 19, 29, 23, 32, 30, 15, 26, 14, 25, 21, 28, 17, 30, 23, 15, 24, 34, 17, 32, 18, 19, 32, 23, 24, 23, 22, 28, 20, 24, 19, 21, 25, 34, 33, 19, 33, 35, 25, 19, 18, 27, 18, 16, 21, 35, 28, 30, 20, 33, 26, 17, 23, 38, 26, 26, 41, 17, 14, 21, 35, 35, 29, 27, 21, 22, 21, 14, 27, 20, 29, 25, 18, 24, 22, 30, 32, 34, 19, 20, 24, 19, 20, 24, 17, 21, 21, 27, 16, 18, 26, 39, 31, 20, 20, 38, 28, 24, 30, 26, 38, 31, 26, 27, 35, 42, 26, 30, 33, 27, 23, 33, 24, 17, 25, 20, 27, 22, 31, 31, 18, 18, 33, 28, 26, 22, 36, 19, 26, 16, 23, 26, 31, 24, 18, 28, 24, 22, 29, 30, 48, 26, 32, 25, 24, 31, 12, 29, 31, 17, 36, 33, 28, 25, 24, 24, 32, 27, 21, 29, 23, 25, 26, 21, 26, 27, 26, 21, 27, 25, 39, 23, 28, 31, 29, 27, 18, 30, 17, 24, 25, 27, 21, 32, 22, 22, 24, 22, 36, 23, 26, 17, 19, 32, 25, 36, 17, 21, 20, 22, 23, 30, 28, 43, 31, 27, 18, 19, 28, 33, 20, 24, 22, 26, 21, 25, 32, 21, 31, 15, 23, 28, 16, 21, 30, 15, 22, 20, 23, 18, 26, 19, 23, 32, 22, 19, 17, 29, 20, 26, 22, 26, 20, 21, 36, 20, 24, 46, 22, 21, 23, 16, 27, 32, 22, 25, 23, 23, 18, 31, 25, 26, 35, 24, 30, 29, 24, 23, 28, 20, 24, 28, 24, 31, 24, 20, 26, 33, 25, 27, 29, 26, 22, 23, 20, 31, 20, 28, 19, 33, 37, 18, 26, 34, 13, 21, 18, 25, 21, 26, 27, 31, 27, 25, 32, 24, 14, 21, 26, 27, 26, 16, 19, 23, 36, 20, 36, 12, 42, 20, 25, 25, 26, 33, 28, 30, 26, 30, 23, 27, 24, 19, 17, 23, 29, 24, 17, 34, 38, 36, 24, 26, 26, 32, 27, 31, 28, 25, 15, 31, 19, 34, 19, 28, 17, 32, 31, 18, 23, 22, 30, 18, 15, 21, 16, 21, 24, 39, 23, 25, 38, 30, 37, 31, 28, 24, 39, 34, 24, 28, 22, 24, 25, 38, 21, 19, 23, 15, 19, 26, 18, 17, 27, 29, 26, 21, 21, 18, 32, 29, 20, 22, 34, 27, 24, 17, 30, 32, 21, 41, 20, 24, 24, 27, 23, 20, 23, 29, 20, 32, 25, 16, 17, 31, 16, 23, 16, 17, 23, 25, 35, 17, 30, 26, 37, 35, 35, 23, 30, 26, 23, 21, 21, 24, 24, 21, 31, 23, 29, 27, 35, 37, 30, 19, 22, 35, 24, 41, 32, 19, 19, 27, 29, 39, 24, 21, 24, 20, 22, 30, 22, 21, 25, 18, 19, 20, 21, 33, 26, 19, 26, 20, 22, 27, 26, 30, 14, 21, 26, 25, 31, 27, 22, 26, 22, 15, 23, 20, 19, 25, 21, 21, 17, 38, 25, 30, 14, 34, 24, 28, 25, 29, 18, 17, 22, 19, 26, 17, 18, 23, 27, 30, 15, 41, 13, 31, 29, 21, 14, 23, 24, 31, 20, 26, 36, 20, 14, 17, 33, 23, 30, 21, 28, 25, 19, 20, 27, 25, 26, 25, 18, 24, 24, 27, 29, 20, 33, 24, 36, 17, 19, 34, 30, 31, 30, 16, 23, 21, 30, 27, 16, 35, 25, 16, 18, 34, 28, 29, 40, 34, 25, 34, 27, 28, 24, 28, 28, 31, 29, 23, 27, 31, 26, 32, 15, 25, 28, 26, 43, 24, 34, 18, 32, 30, 23, 32, 26, 39, 21, 18, 22, 27, 24, 26, 20, 28, 24, 17, 21, 18, 17, 26, 17, 26, 23, 24, 23, 23, 21, 18, 17, 31, 34, 25, 31, 23, 32, 27, 23, 41, 17, 14, 20, 22, 18, 17, 24, 30, 27, 21, 23, 20, 24, 38, 23, 29, 34, 27, 25, 24, 21, 23, 19, 31, 21, 23, 32, 24, 20, 25, 26, 16, 24, 28, 35, 22, 42, 35, 18, 21, 18, 14, 34, 15, 17, 18, 17, 27, 23, 26, 28, 31, 20, 42, 26, 22, 23, 29, 37, 31, 19, 22, 40, 12, 17, 39, 23, 26, 25, 26, 15, 31, 19, 29, 25, 28, 26, 24, 26, 22, 16, 27, 23, 22, 24, 27, 23, 13, 19, 20, 35, 18, 18, 18, 20, 15, 38, 29, 23, 25, 28, 17, 26, 27, 39, 18, 22, 24, 25, 25, 26, 25, 26, 27, 21, 23, 24, 17, 35, 22, 32, 23, 21, 27, 27, 36, 25, 20, 22, 22, 28, 27, 17, 21, 31, 19, 22, 22, 24, 31, 23, 21, 26, 25, 22, 42, 22, 16, 24, 31, 24, 39, 27, 26, 23, 25, 19, 28, 21, 23, 27, 26, 19, 20, 24, 23, 24, 21, 16, 18, 23, 37, 36, 16, 37, 26, 21, 23, 21, 23, 24, 40, 16, 25, 28, 20, 27, 23, 27, 24, 25, 23, 20, 23, 33, 16, 22, 28, 20, 15, 30, 16, 24, 25, 32, 17, 27, 19, 15, 24, 23, 23, 18, 35, 26, 25, 27, 29, 24, 15, 27, 29, 24, 25, 23, 30, 28, 14, 38, 30, 21, 30, 35, 24, 20, 21, 29, 27, 34, 23, 31, 17, 35, 26, 17, 30, 31, 26, 24, 23, 25, 15, 31, 26, 24, 22, 15, 21, 27, 23, 23, 24]
25.0064

乱数を利用した円周率の計算

一様分布を利用して xy 平面上の -1 ≤ x ≤ 1 かつ -1 ≤ y ≤ 1 の領域に乱数を散らばせて、円周率πを求めよ。ただし、面積 S、半径 r および円周率πについて、S = πr2 の関係を証明なしに用いて良い。

In [0]:
x = []
y = []

# 1000 個の乱数を発生させて x 座標とする
# 1000 個の乱数を発生させて y 座標とする
j = 0
while j < 1000000:
  _x = random.uniform(-1, 1)
  _y = random.uniform(-1, 1)
  x.append(_x)
  y.append(_y)
  j = j + 1
n_square = len(x)
n_circle = 0
# 点が単位円の中に入っているかどうかを 1 つずつチェックする
for px, py in zip(x, y):
  r = px * px + py * py
  if r <= 1:
    n_circle = n_circle + 1

# pi : 4 = n_circle : n_squre
pi = 4 * n_circle / n_square
print(pi)
3.143068

数値微分

$f(x) = x^2 + 2x - 1$ の関数を Python の関数で定義せよ。次に、f(x) を x = a で微分したときに得られる値を計算する関数も Python で定義せよ。ただし、微分の定義式は次の通りである。必要であれば、h=0.001 とおいてよい。

$$ f'(a) = \lim_{h\to 0} \frac{f(a + h) - f(a)}{h} $$
In [0]:
def f(x):
  y = x * x + 2 * x - 1
  return y

a = 2
h = 0.00000000001

fa = f(a)
fah = f(a + h)
fprimea = (fah - fa) / h

print(fprimea)
6.000000496442226

二次関数の極値

$f(x) = x^2 + 2x - 1$ の最小値およびその最小値を与える x の値を求めよ。

  1. f(x) はしたに凸の二次関数であるから、その一次導関数 f'(x) が f'(a)=0 を満たすとき、f(a) が f(x) の最小値となる。

  2. a に初期値を与えて、f'(a) を計算する。f'(a) が負の値ならば、a = a + r として、f'(a) が正の値ならば、a = a - rとして、もう一度 f'(a) を求める。r = 0.001 と小さめな値にする。

  3. 2 の操作を無限回繰り返すことで f'(a) = 0 となる a が求められる。ただし、プログラムで計算する場合は、正確に f'(a) = 0 となる点を正確に求められないので、例えば f'(a) < 0.0001 ならば終了するなどの制御を入れる。

In [0]:
import random

# 関数 f(x) の定義
def f(x):
  y = x * x + 2 * x - 1
  return y


# 微分関数の定義(関数 g(x) に対して、g'(a) を計算する関数)
def diff(g, a):
  h = 0.001
  fa = g(a)
  fah = g(a + h)
  fprimea = (fah - fa) / h
  return fprimea


# ランダムな値を 1 つ決める
a = random.uniform(-1, 1)

# f'(a) を求める
error = diff(f, a)  


# f'(a) が 0.0001 未満になるまで次の処理を繰り返す
while error > 0.0001:
  
  if error > 0:
    # 微分係数がプラスならば、a を左に 0.001 動かす
    a = a - 0.01
    
  elif error < 0:
    # 微分係数がマイナスならば、a を右に 0.001 動かす
    a = a + 0.01
  
  # 新しい a の値で微分係数を求める。
  error = diff(f, a)
  
  

# 最小値を与える x(人が数学的に計算した場合は -1)
print(a)

# 最小値(人が数学的に計算した場合は -2)
print(f(a))
-1.0015148013558286
-1.9999977053768523

テキストファイル処理

リスト要素チェック

右のリスト fh の要素のうち、「>」から始まる要素の個数を求めよ。

In [0]:
fh = ['>1ALK:A', 'TPEMPVL', 'TGQYTHA', 
      '>1ALK:B', 'TPEMPVL', 'TGQYTHA']
n = 0

for line in fh:
  firstchar = line[0:1]
  if firstchar == '>':
    n = n + 1

print(n)
2

ファイル内容チェック

1alk.fa ファイルを読み込んで、「>」から始まる行の行数を求めよ。

In [0]:
f = '1alk.fa'
n = 0

with open(f, 'r') as fh:
  
  # ここでファイルの内容はすべて fh に入っている状態になる
  for line in fh:
    if line[0:1] == '>':
      n = n + 1
      
print(n)
2

FASTAファイル中の配列の長さ

1alk.fa ファイルは FASTA フォーマットと呼ばれるファイルである。このファイルは > から始まる行に核酸配列またはアミノ酸配列の名前が、それ以降の行は配列となっている。これらの配列が遺伝情報となる。1alk.fa の中には 2 つの配列が含まれている。それぞれの配列の長さを求めよ。

In [0]:
n = 0
name = ''


with open('1alk.fa', 'r') as fh:
  
  for line in fh:
    line = line.replace('\n', '')
    
    if line[0:1] == '>':
      if name != '':
        print(name)
        print(n)
      
      name = line
      n = 0
            
    else:
      n = n + len(line)


print(name)
print(n)  
>1ALK:A|PDBID|CHAIN|SEQUENCE
449
>1ALK:B|PDBID|CHAIN|SEQUENCE
449

ACGT出現頻度(single sequence / FASTA)

ft.fa ファイルには 1 つの核酸配列が含まれている。核酸配列は文字 A、C、G、T のいずれかで構成されている。この配列のうち、文字 A、C、G、T それぞれ何回出現したかを調べよ。

In [0]:
seqnA = 0
seqnC = 0
seqnG = 0
seqnT = 0


with open('ft.fa', 'r') as fh:
  
  for line in fh:
    
    line = line.replace('\n', '')
    
    if line[0:1] == '>':
      print(line)
      
    else:
      for b in line:
        if b == 'A':
          seqnA = seqnA + 1
        elif b == 'C':
          seqnC = seqnC + 1
        elif b == 'G':
          seqnG = seqnG + 1
        elif b == 'T':
          seqnT = seqnT + 1

          
print(seqnA)
print(seqnC)
print(seqnG)
print(seqnT)
>FT|AF152096.1
762
391
407
923

ACGT出現頻度(multiple sequence / FASTA)

sample.fa ファイルには 5 つの配列が含まれている。それぞれの配列に含まれている文字 A、C、G、T の出現回数を求めて、次の出力例に見習って、CSV 形式で out.txt に書き出せ。

id,A,C,G,T
SEQ1,4,1,0,0
SEQ2,1,4,0,0
SEQ3,2,0,0,3
SEQ4,1,2,2,0
SEQ5,1,1,1,2
In [0]:
with open('out.txt', 'w') as outfh:


  with open('sample.fa', 'r') as infh:

    # 初期化
    seqname = ''
    seqnA = 0
    seqnC = 0
    seqnG = 0
    seqnT = 0

    # ファイルの各行に対して処理
    for line in infh:
      line = line.replace('\n', '')
      
      # > から始まる行ならば名前を記録
      if line[0:1] == '>':
        # 前の処理結果を出力
        if seqname != '':
          temp = seqname + ',' + str(seqnA) + ',' + str(seqnC) + ',' + str(seqnG) + ',' + str(seqnT) + '\n'
          outfh.write(temp)

        # 初期化
        seqname = ''
        seqnA = 0
        seqnC = 0
        seqnG = 0
        seqnT = 0 

        seqname = line

      # > から始まる行でなければA, C, G, Tの数を数える
      else:
        # 文字列をリスト皆して、各文字を調べて頻度を計数する
        for b in line:
          if b == 'A':
            seqnA = seqnA + 1
          elif b == 'C':
            seqnC = seqnC + 1
          elif b == 'G':
            seqnG = seqnG + 1
          elif b == 'T':
            seqnT = seqnT + 1


  temp = seqname + ',' + str(seqnA) + ',' + str(seqnC) + ',' + str(seqnG) + ',' + str(seqnT)
  outfh.write(temp)

テキストファイル(行数カウント)

島の数を調べる。ただし # から始まる行は、コメント行である。

In [0]:
f = 'diversity_galapagos.txt'
n = 0

with open(f, 'r') as fh:
  for line in fh:
    
    if (line[0:1] != '#') and (line[0:6] != 'Island'):
      n = n + 1

print(n)
30

テキストファイル(除算処理)

ガラパゴス島の多様性データ diversity_galapagos.txt を読み込んで、各島の面積(Area)当たりの種数(Species)を答えよ。ただし、文字列を実数に変換する場合は float 関数を使用する。

In [0]:
f = 'diversity_galapagos.txt'
ratios = []

with open(f, 'r') as fh:
  for line in fh:
    # # および Island で始まらない行に対して処理を行う
    if (line[0:1] != '#') and (line[0:6] != 'Island'):
      
      # 1 行のデータを split 関数で分割する。
      # このファイルはタブ区切りであることに注意。
      # タブ区切りは、Python では '\t' という 2 文字で表される
      linedata = line.split('\t')
      #print(linedata)
      
      # split 後、2列目Speciesおよび4列目Areaに当たるデータを取得してくる。
      n_species = int(linedata[1])
      n_area = float(linedata[3])
      
      # 割り算を行なって「面積あたりの種数」を求める。
      ratio = n_species / n_area

      print(linedata[0])
      print(ratio)
      

GFFファイル整形

IWGSCv1.1.gff3 ファイル中の全遺伝子(gene)の染色体名、位置番号、および遺伝子 ID を抽出して、次の出力例のように CSV ファイルに書き出せ。ただし、これらの情報は、# 以外の文字から始まる行に記述されている。1 列目に染色体名、3 列目に分子タイプ、4 列目と 5 列目には開始位置と終了位置、9 列目には遺伝子 ID が記述されている。

TraesCS1A02G000100,chr1A,40098,70338
TraesCS1A02G000200,chr1A,70239,89245
TraesCS1A02G000300,chr1A,95906,104903
TraesCS1A02G000400,chr1A,102794,122504
TraesCS1A02G000500,chr1A,149490,154559
TraesCS1A02G000600,chr1A,162313,162609
In [0]:
with open('IWGSCv1.1.gff3', 'r') as fh:
  for line in fh:
    if line[0:1] != '#':
      line_data = line.split('\t')
      col1 = line_data[0]
      col3 = line_data[2]
      col4 = line_data[3]
      col5 = line_data[4]
      col9 = line_data[8].split(';')[0].replace('ID=', '')
      
      if col3 == 'gene':
        print(col9 + ',' + col1 + ',' + col4 + ',' + col5)
  
TraesCS1A02G000100,chr1A,40098,70338
TraesCS1A02G000200,chr1A,70239,89245
TraesCS1A02G000300,chr1A,95906,104903
TraesCS1A02G000400,chr1A,102794,122504
TraesCS1A02G000500,chr1A,149490,154559
TraesCS1A02G000600,chr1A,162313,162609
TraesCS1A02G000700,chr1A,169592,169969
TraesCS1A02G000800,chr1A,180175,180552
TraesCS1A02G000900,chr1A,233818,245051
TraesCS1A02G001100,chr1A,269472,289602
TraesCS1A02G001000,chr1A,270605,272936
TraesCS1A02G001200,chr1A,287697,287957
TraesCS1A02G001400,chr1A,294611,305428
TraesCS1A02G001300,chr1A,297266,297652
TraesCS1A02G001500,chr1A,326099,326518
TraesCS1A02G001600,chr1A,337960,338256
TraesCS1A02G001700,chr1A,403455,403751
TraesCS1A02G001800,chr1A,1144333,1145934
TraesCS1A02G001900,chr1A,1159194,1162830
TraesCS1A02G002000,chr1A,1163485,1167878
TraesCS1A02G002100,chr1A,1170356,1177383
TraesCS1A02G002200,chr1A,1188844,1190864
TraesCS1A02G002300,chr1A,1209721,1212812
TraesCS1A02G002400,chr1A,1228914,1229339
TraesCS1A02G002500,chr1A,1232354,1238469
TraesCS1A02G002700,chr1A,1336841,1348326
TraesCS1A02G002800,chr1A,1565963,1567220
TraesCS1A02G002900,chr1A,1657115,1666923
TraesCS1A02G003000,chr1A,1668949,1670358
TraesCS1A02G003100,chr1A,1689351,1698842
TraesCS1A02G003200,chr1A,1721421,1734947
TraesCS1A02G003300,chr1A,1792119,1815634
TraesCS1A02G003400,chr1A,2161814,2163439
TraesCS1A02G003500,chr1A,2184957,2185397
TraesCS1A02G003546,chr1A,2200978,2203830
TraesCS1A02G003600,chr1A,2229188,2236819
TraesCS1A02G003700,chr1A,2291887,2292891
TraesCS1A02G003800,chr1A,2377713,2379143
TraesCS1A02G003900,chr1A,2391500,2393497
TraesCS1A02G004000,chr1A,2437843,2441540
TraesCS1A02G004100,chr1A,2474575,2481205
TraesCS1A02G004126,chr1A,2490452,2519369
TraesCS1A02G004200,chr1A,2540491,2540958
TraesCS1A02G004300,chr1A,2550647,2569820
TraesCS1A02G004400,chr1A,2642460,2648016
TraesCS1A02G004500,chr1A,2661957,2667052
TraesCS1A02G004600,chr1A,2837094,2843854
TraesCS1A02G004700,chr1A,2847902,2850951
TraesCS1A02G004800,chr1A,2934676,2938176
TraesCS1A02G004900,chr1A,2942044,2945027
TraesCS1A02G005000,chr1A,2975187,2976767
TraesCS1A02G005100,chr1A,2978903,2981121
TraesCS1A02G005200,chr1A,2982629,2986266
TraesCS1A02G005300,chr1A,3013341,3014979
TraesCS1A02G005315,chr1A,3019865,3021011
TraesCS1A02G005368,chr1A,3074492,3075657
TraesCS1A02G005387,chr1A,3094066,3095267
TraesCS1A02G005400,chr1A,3117194,3118502
TraesCS1A02G005500,chr1A,3119378,3122276
TraesCS1A02G005600,chr1A,3255618,3262577

PDB (mmCIF) ファイル処理

1alk.cif ファイルを読み込んで、タンパク質 1ALK には何個の炭素原子が含まれているのかを調べよ。 ただし、タンパク質の全原子情報は、CIF ファイルの ATOM から始まる行に記載されている。具体的には、ATOM から始まる行の13文字目が C であれば、それが炭素原子であることを示している。

In [0]:
nC = 0

with open('1alk.cif', 'r') as fh:
  
  for line in fh:
    if line[0:4] == 'ATOM':
      s = line[12]
      if s == 'C':
        nC = nC + 1
        
        
        
print(nC)
4084

データ解析

奇数・偶数の数

リストa に含まれている奇数と偶数の数を求めよ。

In [0]:
a = [1, 3, 5, 2, 4, 9]

n_odd = 0
n_even = 0

for x in a:
  if x % 2 == 0:
    n_even = n_even + 1
  else:
    n_odd = n_odd + 1

print(n_odd)
print(n_even)
4
2

リストの結合

リスト b の各要素をリスト a の各要素として追加せよ。

In [0]:
a = [1, 3, 5, 7, 9]
b = [2, 4, 6, 8, 10]
a.extend(b)
print(a)

a = [1, 3, 5, 7, 9]
b = [2, 4, 6, 8, 10]
for w in b:
  a.append(w)
print(a)

# `a` should be:
# [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]
[1, 3, 5, 7, 9, 2, 4, 6, 8, 10]
[1, 3, 5, 7, 9, 2, 4, 6, 8, 10]

リスト中の共通要素

リスト a とリスト b に共通する要素をリスト c に代入せよ。ただし、集合演算用の関数を使わずに、for 文などを使うこと。

In [0]:
a = [2, 4, 6, 8, 10, 12, 14]
b = [3, 6, 9, 12, 15]

c = []

for ai in a:
  n = 0
  for bi in b:
    if ai == bi:
      n = 1
  
  if n == 1:
    c.append(ai)


print(c)
# [6, 12]
[6, 12]

大文字と小文字

"hello world" を "Hello World" のように単語の 1 文字目が大文字となるような変換プログラムを書け。ただし、uppercapitalizetitle 関数等を使わないこと。

In [4]:
s = 'one of these days is none of these days.'

#print(s.upper())
#print(s.capitalize())
#print(s.title())

d = {'a': 'A', 'b': 'B', 'c': 'C', 'd': 'D', 'e': 'E', 'f': 'F',
     'g': 'G', 'h': 'H', 'i': 'I', 'j': 'J', 'k': 'K', 'l': 'L',
     'm': 'M', 'n': 'N', 'o': 'O', 'p': 'P', 'q': 'Q', 'r': 'R',
     's': 'S', 't': 'T', 'u': 'U', 'v': 'V', 'w': 'W', 'x': 'X',
     'y': 'Y', 'z': 'Z'}

t = ''
for ss in s.split(' '):
  t = t + d[ss[0]] + ss[1:] + ' ' 

print(t)
One Of These Days Is None Of These Days. 

公約数

10,000 以下の 19 と 23 の公約数をすべて求めよ。

In [2]:
for i in range(9999):
  n = i + 1
  if n % 19 == 0 and n % 23 == 0:
    print(n)
437
874
1311
1748
2185
2622
3059
3496
3933
4370
4807
5244
5681
6118
6555
6992
7429
7866
8303
8740
9177
9614

素数問題

10,000 以下の素数(1 または自分自身でしか割り切れない数値)を全て求めよ。

In [12]:
n = 10000

pn = []

for m in range(n + 1):
  if m > 1:
    
    n_div = 0
    for k in range(m + 1):
      if k > 1:
        if m % k == 0:
          n_div = n_div + 1
    
    if n_div == 1:
      pn.append(m)

print(pn)
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973]

単位変換

セルシウス度 C とケルビン K との間に K =C + 273.15 の関係が成り立つ。32 セルシウス度を文字列「27C」で表すとき、これを「300.15K」となるように変換するプログラムを作成せよ。

In [13]:
a = '27C'
b = '???K'


degree_c = float(a.replace('C', ''))
degree_k = degree_c + 273.15

b = str(degree_k) + 'K'
print(b)
300.15K

年号変換

昭和 1 年は西暦 1926 年であり、平成 1 年は西暦 1989 年、令和 1 年は西暦 2019 年である。年号から西暦および西暦から年号に変換するプログラムを書け。

例)「H2」を入力したら「1990」を出力し、「S60」を入力したら「1985」を出力し、「2019」を入力したら「R1」を出力する。

In [21]:
s = 'S60'
h = 'H2'
a = '2019'


def change_year(x):
  x_first = x[0:1]
  output = ''
  
  if x_first == 'S':
    output = str(int(x[1:]) + 1925)
  
  elif x_first == 'H':
    output = str(int(x[1:]) + 1988)
    
  elif x_first == 'R':
    output = str(int(x[1:]) + 2018)

  else:
    y = int(x)
    if y >= 2018:
      output = 'R' + str(y - 2018)
    elif y >= 1988:
      output = 'H' + str(y - 1988)
    elif y >= 1925:
      output = 'R' + str(y - 1925)
  
  return output


print(change_year(s))
print(change_year(h))
print(change_year(a))
1985
1990
R1

個体数カウント

trees.txt を読み込み、容積(Volume)が 25.0 以上の木の数とそうでない木の数を求めよ。

In [25]:
n_large = 0
n_small = 0

with open('trees.txt', 'r') as fh:
  for line in fh:
    if line[0:4] !=  'Tree':
      dat = line.split('\t')
      if float(dat[3]) > 25.0:
        n_large = n_large + 1
      else:
        n_small = n_small + 1

print(n_large)
print(n_small)
14
17

個体追跡

pines.txt ファイル中、Hgt90、Hgt96、Hgt97 の列はそれぞれ1990年、1996年、および1997年における各個体の高さを表している。Hgt90 および Hgt96 が実数値であり、Hgt97 が NA となっているとき、その個体が 1997 年前までに枯れたと仮定する。この仮定の元で、1997 年までに枯れた木は、全体の何割を示すのかを求めよ。

In [0]:
# 模範回答なし
# Pandas で解いてみてください。

グラフ作成

棒グラフ

sleep_in_mammals.txt を読み込み、各種(Species)の睡眠時間(TotalSleep)を、棒グラフでわかりやすく示せ。

In [29]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

file = 'https://aabbdd.jp/data/sleep_in_mammals.txt'
d = pd.read_csv(file, comment='#', header=0, sep='\t')

x = d.loc[:, 'Species'].values
y = np.log10(d.loc[:, 'TotalSleep'].values)

# plt.rcParams['figure.figsize'] = (15.0, 5.0)

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.bar(x, y)
ax.set_xticklabels(x, rotation=90)
fig.show()

散布図

sleep_in_mammals.txt を読み込み、各種(Species)の体重(BodyWt)と睡眠時間(TotalSleep)の関係を、散布図でわかりやすく描け。

In [28]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

file = 'https://aabbdd.jp/data/sleep_in_mammals.txt'
d = pd.read_csv(file, comment='#', header=0, sep='\t')

x = d.loc[:, 'TotalSleep']
y = np.log10(d.loc[:, 'BodyWt'])

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.scatter(x, y)
ax.set_xlabel('TotalSleep')
ax.set_ylabel('log10(BodyWt)')
ax.set_xlim(0, max(x) * 1.05)
ax.set_ylim(0, max(y) * 1.05)
fig.show()

散布図(色の塗り分け)

trees.txt を Pandas で読み込み、横軸を高さ(Height)、縦軸を外周長(Girth)として散布図を描け。ただし、容積(Volume)が25.0以上の木とそうでない木を異なる色で描くこと。

In [27]:
import numpy as np 
import pandas as pd
import matplotlib.pyplot as plt

file = 'https://aabbdd.jp/data/trees.txt'
d = pd.read_csv(file, header=0, sep='\t')

is_large = (d.loc[:, 'Volume'] > 25.0)

tall_trees = d.loc[is_large, :]
short_trees = d.loc[~is_large, :]

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)

ax.scatter(tall_trees.loc[:, 'Height'], tall_trees.loc[:, 'Girth'])
ax.scatter(short_trees.loc[:, 'Height'], short_trees.loc[:, 'Girth'])

ax.set_xlabel('Height')
ax.set_ylabel('Girth')
fig.show()

折れ線グラフ

pines.txt ファイルをPandas で読み込み、1990年、1996年、および1997年における各個体の高さ(Hgt90、Hgt96、Hgt97)を線グラフで描け。ただし、1990年の横軸を0、1996年を6、1997年を7とすること。

In [30]:
import numpy as np 
import pandas as pd
import matplotlib.pyplot as plt

file = 'https://aabbdd.jp/data/pines.txt'
d = pd.read_csv(file, header=0, sep='\t')

hgt90 = d.loc[:, 'Hgt90']
hgt96 = d.loc[:, 'Hgt96']
hgt97 = d.loc[:, 'Hgt97']

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)

for i in range(d.shape[0]):
  x = [0, 6, 7]
  y = [hgt90[i], hgt96[i], hgt97[i]]
  ax.plot(x, y)


ax.set_xlabel('Time')
ax.set_ylabel('Height')
fig.show()

メモ

講義中に書いたコードのメモ。

In [0]:
import numpy as np
a = np.array([[0,2,0,1,2,0],
              [1,0,3,0,0,2],
              [3,1,0,2,2,1],
              [2,2,2,1,0,1],
              [1,0,1,3,2,2],
              [0,3,1,0,2,0]])
b = np.array([[1,0,0],
              [0,1,0],
              [0,0,1]])
s = np.full((4, 4), np.nan)

for row_i in range(np.size(a, axis=0) - 2):
  for col_i in range(np.size(a, axis=1) - 2):
    asub = a[row_i:(row_i+3), (col_i):(col_i+3)]
    x = asub * b
    y = np.sum(x)
    s[row_i, col_i] = y

print(s)
[[0. 7. 2. 2.]
 [4. 1. 5. 3.]
 [6. 6. 3. 4.]
 [3. 3. 7. 3.]]
In [0]:
all([True, True, True, False])
Out[0]:
False
In [0]:
import pandas as pd
file = 'iris.txt' 
d = pd.read_csv(file, header=0, sep='\t')

for gname, gdata in d.groupby('Species'):
  sl = gdata.loc[:, 'Sepal.Length']
  sw = gdata.loc[:, 'Sepal.Width']
  pl = gdata.loc[:, 'Petal.Length']
  pw = gdata.loc[:, 'Petal.Width']
  sr = sl / sw
  pr = pl / pw
  sr_mean = sr.mean()
  pr_mean = pr.mean()
  print([gname, sr_mean, pr_mean])
  
['setosa', 1.4701876810227483, 6.9079999999999995]
['versicolor', 2.160402191687831, 3.2428369326751683]
['virginica', 2.230452738894224, 2.7806623384004467]
In [0]:
import pandas as pd 
file = 'rice.txt' 
d = pd.read_csv(file, header=0, sep='\t')

grouping_by = ['variety', 'fert']

for gname, gdata in d.groupby(grouping_by):
  rootwt = gdata.loc[:, 'root_dry_mass']
  shootwt = gdata.loc[:, 'shoot_dry_mass']
  rootwt_mean = rootwt.mean()
  shootwt_mean = shootwt.mean()
  print([gname[0], gname[1], rootwt_mean, shootwt_mean])
  
  
['ANU843', 'F10', 6.0, 7.333333333333333]
['ANU843', 'NH4Cl', 9.166666666666666, 46.583333333333336]
['ANU843', 'NH4NO3', 13.833333333333334, 71.5]
['wt', 'F10', 49.5, 108.33333333333333]
['wt', 'NH4Cl', 12.583333333333334, 50.25]
['wt', 'NH4NO3', 17.333333333333332, 73.33333333333333]
In [0]:
import pandas as pd
file = 'trees.txt' 
d = pd.read_csv(file, header=0, sep='\t')

h = d.loc[:, 'Height']
g = d.loc[:, 'Girth']

lower_than_80 = (h < 80)
higer_eqthan_80 = (h >= 80)

print(g[higer_eqthan_80].mean())
print(g[higer_eqthan_80].var())
print(g[lower_than_80].mean())
print(g[lower_than_80].var())
15.191666666666665
11.649924242424241
12.021052631578948
5.1861988304093565
In [0]:
import pandas as pd 
file = 'pines.txt' 
d = pd.read_csv(file, header=0, sep='\t')

hgt90 = d.loc[:, 'Hgt90']
hgt97 = d.loc[:, 'Hgt97']

diff = hgt97 - hgt90

f_ismax = (diff == diff.max())
d.loc[f_ismax, 'ID']
Out[0]:
723    724
Name: ID, dtype: int64
In [0]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
x = np.array([0, 300])
y = np.array([0, 300])
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot(x, y)
ax.set_xlim(0, 10)
ax.set_ylim(0, 10)
fig.show()
In [0]: