2018-01-14

やってみた。

https://qiita.com/javacommons/items/9cdd4fdbf6e74c7f106b

def check_brackets1(s):
    dc = dict(zip('{}()[]','}{)(]['))
    lst = []
    for c in s:
        if lst and c == dc[lst[-1]]:
            del lst[-1]
        else:
            lst.append(c)
    return not lst
def check_brackets2(s):
    import re
    ptn = re.compile(r'({}|\(\)|\[\])')
    pre = ''
    while pre != s:
        pre = s
        s = ptn.sub('', s)
    return not s
lst = '(){}[] ([{}]) (} [(]) ([{}()]) [({})](]'.split()
for s in lst:
    print(s, check_brackets1(s), check_brackets2(s))

2017-11-09

転職して、Mac,slack,google appなどを使うようになった。

大学ではグラフを無向と有向にわけて教育している。アルゴリズムが異なる場合もあり、しょうがないだろう。それによりnetworkxなどグラフライブラリも無向と有向に分かれたものになっていることが多い。

しかし、利用を念頭に置いた場合、よりよいのは、「グラフの種類は1つ、辺は無向と有向の2つ」である。例えば、道路網は1つで、道ごとに双方向か片方向に分かれている。

私の作成したグラフライブラリは、そのようになっている。

2017-10-03

Ubuntuのdockerのpullやloginで

「Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 127.0.1.1:53: read udp 127.0.0.1:34316->127.0.1.1:53: i/o timeout」

とエラーが出る。

システムツールのネットワークのDNSサーバに「8.8.8.8」を追加したら直った。