diff options
author | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2017-08-03 03:06:23 +0700 |
---|---|---|
committer | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2017-08-03 03:06:23 +0700 |
commit | 5cfeec0f11dbcff922fe5b1a1a17bccf4812852e (patch) | |
tree | c866745d54978d860f93acbff14e7ca1d1d2db59 /others/other/lang.py | |
parent | 44f9d4b8e63d4f7f1b447744124e95f22c8ce296 (diff) | |
download | cp-5cfeec0f11dbcff922fe5b1a1a17bccf4812852e.tar.gz |
[others] Move other/colorec.* to mHoang and add other/{defrac,lang}.py
Diffstat (limited to 'others/other/lang.py')
-rwxr-xr-x | others/other/lang.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/others/other/lang.py b/others/other/lang.py new file mode 100755 index 0000000..9c9f144 --- /dev/null +++ b/others/other/lang.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +def lang(index): + global unused + if index < len(unused) and unused[index]: + unused[index] = False + for i in commands[index]: lang(i) + + +commands = [] +with open('LANG.INP') as f: + for index, line in enumerate(f): + l = line.split() + if l[0] == 'NEXT': + commands.append((index + 1,)) + elif len(l) == 2: + commands.append((int(l[1]) - 1,)) + else: + commands.append((int(l[1]) - 1, int(l[3]) - 1)) + +unused = [True] * len(commands) +lang(0) +with open('LANG.OUT', 'w') as f: + print(sum(unused), file=f) + print(*(i + 1 for i, b in enumerate(unused) if b), sep='\n', file=f) |