Advertisement
Guest User

Untitled

a guest
Sep 24th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. def huinja(alg1,hype1,puhkus1,alg2,hype2,puhkus2):
  2.     vastus = 0; # ???
  3.    
  4.     tmpPuhkus1 = puhkus1;
  5.     tmpPuhkus2 = puhkus2;
  6.    
  7.     algVahe = abs(alg1 - alg2);
  8.    
  9.     #initial hype..
  10.     alg1+=hype1;
  11.     alg2+=hype2;
  12.    
  13.     while True:
  14.         if (alg1 == alg2):
  15.             vastus=alg1;
  16.             break;
  17.        
  18.         tmpVahe = abs(alg1-alg2);
  19.         maxHype = max(hype1, hype2);
  20.         if (algVahe < tmpVahe - hype1 or (tmpVahe == algVahe and hype1 == hype2)):
  21.             vastus = -1;
  22.             break;
  23.        
  24.         if (tmpPuhkus1 > 1):
  25.             tmpPuhkus1-=1;
  26.         else:
  27.             alg1+=hype1;
  28.             tmpPuhkus1 = puhkus1;
  29.            
  30.         if (tmpPuhkus2 > 1):
  31.             tmpPuhkus2-=1;
  32.         else:
  33.             alg2+=hype2;
  34.             tmpPuhkus2 = puhkus2;
  35.  
  36.     print vastus;
  37.    
  38. huinja(1,2,1,2,1,1); # 3
  39. huinja(1,2,3,4,5,5); # -1
  40. huinja(10,7,7,5,8,6); # 45
  41. huinja(100,7,4,300,8,6); # 940 ???????????
  42. huinja(1,7,1,15,5,1); # 50
  43. huinja(0,1,1,1,1,1); # -1
  44.  
  45. huinja(1,1,1,0,2,2); # 2
  46. huinja(0,3,3,0,6,6); # 6
  47.  
  48. huinja(0,6,6,0,3,3); # 6
  49.  
  50. huinja(0,100,100,0,1,1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement