Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def huinja(alg1,hype1,puhkus1,alg2,hype2,puhkus2):
- vastus = 0; # ???
- tmpPuhkus1 = puhkus1;
- tmpPuhkus2 = puhkus2;
- algVahe = abs(alg1 - alg2);
- #initial hype..
- alg1+=hype1;
- alg2+=hype2;
- while True:
- if (alg1 == alg2):
- vastus=alg1;
- break;
- tmpVahe = abs(alg1-alg2);
- maxHype = max(hype1, hype2);
- if (algVahe < tmpVahe - hype1 or (tmpVahe == algVahe and hype1 == hype2)):
- vastus = -1;
- break;
- if (tmpPuhkus1 > 1):
- tmpPuhkus1-=1;
- else:
- alg1+=hype1;
- tmpPuhkus1 = puhkus1;
- if (tmpPuhkus2 > 1):
- tmpPuhkus2-=1;
- else:
- alg2+=hype2;
- tmpPuhkus2 = puhkus2;
- print vastus;
- huinja(1,2,1,2,1,1); # 3
- huinja(1,2,3,4,5,5); # -1
- huinja(10,7,7,5,8,6); # 45
- huinja(100,7,4,300,8,6); # 940 ???????????
- huinja(1,7,1,15,5,1); # 50
- huinja(0,1,1,1,1,1); # -1
- huinja(1,1,1,0,2,2); # 2
- huinja(0,3,3,0,6,6); # 6
- huinja(0,6,6,0,3,3); # 6
- huinja(0,100,100,0,1,1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement