Last active
November 26, 2015 17:15
-
-
Save tecoholic/d717b71e9d2ed6f410ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
import time | |
import random | |
a = 8 | |
b = 0 | |
c = 0 | |
d = 0 | |
def move(a, b): | |
r = random.randint(1, a+1) | |
a = a - r | |
b = b + r | |
return a, b # this function returns two values | |
def check(a): | |
if a >= 10 or a == 1: | |
a = 0 | |
return a # this function returns 1 value | |
if __name__ == "__main__": | |
while True: | |
a = a + (a/2) | |
b = b + (b/2) | |
c = c + (c/2) | |
d = d + (d/2) | |
# the value returned by this function is not stored anywhere | |
# for example | |
# a = check(q) | |
check(a) | |
check(b) | |
check(c) | |
check(d) | |
# the value returned by the move function should be stored | |
# for example | |
# a, b = move(a,b) | |
# | |
# this will move the values in a and b to new `a` and new `b` | |
move(a, b) | |
move(b, c) | |
move(c, d) | |
move(d, a) | |
print "________" | |
print "| %s | %s|" % (a, b) | |
print "--------" | |
print "| %s | %s|" % (d, c) | |
print "________" | |
time.sleep(2) | |
class T1TestCase(unittest.TestCase): | |
def test_move(self): | |
a=10 | |
b=5 | |
move(a, b) | |
a1 = a+b | |
move(b, a) | |
a2 = b+a | |
self.assertEqual(a1, a2) | |
def test_ck(self): | |
f=11 | |
self.assertEqual(check(f),0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@renvasanth See the comments starting with #