Engineer as a Lifestyle @tenkoma

What We Find Changes Who We Become -- Peter Morville著『アンビエント・ファインダビリティ 』

AA折れ線グラフ in Python

やるべし!
(plot.py)

def plot(chars):
    h,Max,Min = 0,0,0
    d = {}
    for c,i in zip(chars,range(len(chars))):
        if c == 'R':
            d[h,i]= '/'
            h += 1
            if h > Max:
                Max = h
        elif c == 'F':
            h -= 1
            d[h,i]= '\\'
            if h < Min:
                Min = h
        elif c == 'C':
            d[h,i]= '_'
    for h in range(Max,Min-1,-1):
        line = ''
        for i in range(len(chars)):
            if d.has_key((h,i)): line += d[h,i]
            else: line += ' '
        print line

if __name__ == "__main__":
    import sys
    plot(sys.argv[1])
>python plot.py RCRFCRFFCCRFFRRCRRCCFRFRFF
                  __
                 /  \/\/\
 _/\_/\        _/        \
/      \__/\  /
            \/

うはは,僕のレベルがばれてしまう(笑)*1
でも辞書(ディクショナリ)ってこんな風に使えるって例ぐらいにはなるか?

*1:time:46:02