• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Oct 24th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. from math import log2
2. from functools import cmp_to_key
3. from random import randint
4.
5. def computeTower(prev, towerList):
6.     if prev <= 0:
7.         return []
8.     elif towerList == []:
9.         current = log2(prev)
10.         return [current]+computeTower(current, [])
11.     else:
12.         current = towerList[0]*log2(prev)
13.         return [current]+computeTower(current, towerList[1:])
14.
15. def compareTowers(tower1, tower2):
16.     tower1 = computeTower(2,tower1[1])
17.     tower2 = computeTower(2,tower2[1])
18.     size1 = len(tower1)
19.     size2 = len(tower2)
20.     if size1 < size2:
21.         return -1
22.     elif size2 < size1:
23.         return 1
24.     else:
25.         if tower1[-1]<tower2[-1]:
26.             return -1
27.         elif tower1[-1]>tower2[-1]:
28.             print("Here")
29.             return 1
30.         else:
31.             return 0
32.
33. numTowers = int(input())
34. towers = []
35. for i in range(numTowers):
36.     towers.append(input())
37.
38. builtTowers = []
39. for t in towers:
40.     arr = [int(i) for i in t.split("^")]
41.     builtTowers.append((t,arr))
42.
43. print(builtTowers)
44. sorted(builtTowers, key=cmp_to_key(lambda x,y : randint(-1,1)))
45. print(builtTowers)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top