From 5cfeec0f11dbcff922fe5b1a1a17bccf4812852e Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Thu, 3 Aug 2017 03:06:23 +0700 Subject: [others] Move other/colorec.* to mHoang and add other/{defrac,lang}.py --- others/other/lang.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 others/other/lang.py (limited to 'others/other/lang.py') 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) -- cgit 1.4.1