Skip to content

Commit 88115d0

Browse files
committed
coolkid
1 parent 2e12bae commit 88115d0

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

p2.py

+18-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
num_tests = int(lines[index].strip())
55
index += 1 #move to blank line
66

7+
ms = list()
78
while index < len(lines):
9+
global ms
810
index += 1 #move past blank line
911
size_strip = float(lines[index].strip())
1012
index += 1 #move past size strip line
@@ -29,8 +31,8 @@
2931
#get new random val
3032
num_empty = sum([1 for x in frequencies if x == 0])
3133
if new_nums == nums:
32-
pos = random() % num_empty
33-
if (random() % 10) == 0:
34+
pos = random_dumb() % num_empty
35+
if (random_dumb() % 10) == 0:
3436
new_value = 4
3537
else:
3638
new_value = 2
@@ -74,7 +76,7 @@ def move_right(nums):
7476
new_nums = [0]*len(size_strip)
7577
inPair = False
7678
pastNum = 0
77-
index = 0
79+
index = len(new_nums)-1
7880
pairs = enumerate(nums)
7981
pairs.reverse()
8082
for i, num in pairs:
@@ -83,14 +85,24 @@ def move_right(nums):
8385
else:
8486
if inPair and pastNum == num:
8587
new_nums[index] = pastNum*2
86-
index += 1
88+
index -= 1
8789
elif inPair and pastNum != num:
8890
new_nums[index] = pastNum
89-
new_nums[index+1] = num
91+
new_nums[index-1] = num
9092
inPair = False
91-
index += 2
93+
index -= 2
9294
elif not inPair:
9395
pastNum = num
9496
inPair = True
97+
ir = 43
98+
last_call_ans = 0
99+
def random_shit():
100+
global ms
101+
global ir
102+
c = 1 if ((ir>=43) and last_call_ans < 0) else 0
103+
ans = (x[ir-22] - x[ir-43] - c) % (2**32)
104+
last_call_ans = ans
105+
ir += 1
106+
return ans
95107

96108

0 commit comments

Comments
 (0)