Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
28
Task/Odd-word-problem/Python/odd-word-problem-3.py
Normal file
28
Task/Odd-word-problem/Python/odd-word-problem-3.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from sys import stdin, stdout
|
||||
|
||||
def char_in(): return stdin.read(1)
|
||||
def char_out(c): stdout.write(c)
|
||||
|
||||
def odd():
|
||||
a = char_in()
|
||||
if a.isalpha():
|
||||
r = odd()
|
||||
char_out(a)
|
||||
return r
|
||||
|
||||
# delay printing terminator until later, in the shape of a closure
|
||||
def clos():
|
||||
char_out(a)
|
||||
return a != '.'
|
||||
|
||||
return clos
|
||||
|
||||
def even():
|
||||
while True:
|
||||
c = char_in()
|
||||
char_out(c)
|
||||
if not c.isalpha(): return c != '.'
|
||||
|
||||
e = False
|
||||
while odd()() if e else even():
|
||||
e = not e
|
||||
Loading…
Add table
Add a link
Reference in a new issue