add tasks starting with a number
This commit is contained in:
parent
9246b988c7
commit
2dd7375f96
204 changed files with 3726 additions and 0 deletions
5
Task/100-doors/Python/100-doors-1.py
Normal file
5
Task/100-doors/Python/100-doors-1.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
doors = [False] * 100
|
||||
for i in xrange(100):
|
||||
for j in xrange(i, 100, i+1):
|
||||
doors[j] = not doors[j]
|
||||
print "Door %d:" % (i+1), 'open' if doors[i] else 'close'
|
||||
3
Task/100-doors/Python/100-doors-2.py
Normal file
3
Task/100-doors/Python/100-doors-2.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for i in xrange(1, 101):
|
||||
root = i ** 0.5
|
||||
print "Door %d:" % i, 'open' if root == int(root) else 'close'
|
||||
1
Task/100-doors/Python/100-doors-3.py
Normal file
1
Task/100-doors/Python/100-doors-3.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
print '\n'.join(['Door %s is %s' % (i, ('closed', 'open')[(i**0.5).is_integer()]) for i in xrange(1, 101)])
|
||||
1
Task/100-doors/Python/100-doors-4.py
Normal file
1
Task/100-doors/Python/100-doors-4.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
print '\n'.join('Door %s is %s' % (i, 'closed' if i**0.5 % 1 else 'open') for i in range(1, 101))
|
||||
4
Task/100-doors/Python/100-doors-5.py
Normal file
4
Task/100-doors/Python/100-doors-5.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
for i in list(range(1, 101)):
|
||||
if i**0.5 % 1: state='open'
|
||||
else: state='close'
|
||||
print ("Door {}:{}".format(i, state))
|
||||
Loading…
Add table
Add a link
Reference in a new issue