Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
28
Task/Odd-word-problem/Python/odd-word-problem-1.py
Normal file
28
Task/Odd-word-problem/Python/odd-word-problem-1.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(prev = lambda: None):
|
||||
a = char_in()
|
||||
if not a.isalpha():
|
||||
prev()
|
||||
char_out(a)
|
||||
return a != '.'
|
||||
|
||||
# delay action until later, in the shape of a closure
|
||||
def clos():
|
||||
char_out(a)
|
||||
prev()
|
||||
|
||||
return odd(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
|
||||
4
Task/Odd-word-problem/Python/odd-word-problem-2.py
Normal file
4
Task/Odd-word-problem/Python/odd-word-problem-2.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$ echo "what,is,the;meaning,of:life." | python odd.py
|
||||
what,si,the;gninaem,of:efil.
|
||||
$ echo "we,are;not,in,kansas;any,more." | python odd.py
|
||||
we,era;not,ni,kansas;yna,more.
|
||||
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
|
||||
33
Task/Odd-word-problem/Python/odd-word-problem-4.py
Normal file
33
Task/Odd-word-problem/Python/odd-word-problem-4.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
from sys import stdin, stdout
|
||||
|
||||
def fwd(c):
|
||||
if c.isalpha():
|
||||
return [stdout.write(c), (yield from fwd((yield f)))][1]
|
||||
else:
|
||||
return c
|
||||
|
||||
def rev(c):
|
||||
if c.isalpha():
|
||||
return [(yield from rev((yield r))), stdout.write(c)][0]
|
||||
else:
|
||||
return c
|
||||
|
||||
def fw():
|
||||
while True:
|
||||
stdout.write((yield from fwd((yield r))))
|
||||
|
||||
def re():
|
||||
while True:
|
||||
stdout.write((yield from rev((yield f))))
|
||||
|
||||
f = fw()
|
||||
r = re()
|
||||
next(f)
|
||||
next(r)
|
||||
|
||||
coro = f
|
||||
while True:
|
||||
c = stdin.read(1)
|
||||
if not c:
|
||||
break
|
||||
coro = coro.send(c)
|
||||
Loading…
Add table
Add a link
Reference in a new issue