2018-03-01から1日間の記事一覧

Jupyterを外部サーバに設置してアクセスする方法

以下の設定で可能。 In [1]: from notebook.auth import passwd In [2]: passwd() Enter password: <パスワードを入力> Verify password: <パスワードを再入力> Out[2]: 'sha1:<ハッシュ化されたパスワード>' $ vim ~/.jupyter/jupyter_notebook_config.py ~…

UnionFind木のpythonでの実装

UnionFind木で同じグループのものを判定する class UnionFind(object): def __init__(self, size): self.parent = [i for i in range(size)] self.rank = [0 for _ in range(size)] def find(self, x): if self.parent[x] == x: return x else: return self.…

PriorityQueueの確認

PriorityQueueをPythonで表してみる。 こんなんで大きい順に出せるのかと思った。 class PriorityQueue(object): def __init__(self): self.l = [] def push(self, x): self.l.append(x) sz = len(self.l) i = sz - 1 while i > 0: p = (i - 1) // 2 if self…