Flip a coin (advanced)
Hello, I came up with solution below, it gives result around ~1350
I keep getting this error which I dont really understand.
File "/usr/local/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
yield
File "/usr/local/lib/python3.8/unittest/case.py", line 676, in run
self._callTestMethod(testMethod)
File "/usr/local/lib/python3.8/unittest/case.py", line 633, in _callTestMethod
method()
File "/app/test/test_main.py", line 23, in test_answer
self.assertGreaterEqual(main(p0), I0[0], lowerErrorMessage)
File "/app/tmc/utils.py", line 10, in fail
raise AssertionError(err)
Error: src.main.main does not exist!Can somebody help ?
Thank you
import numpy as np
import regex as re
def generate(p1):
# change this so that it generates 10000 random zeros and ones
# where the probability of one is p1
seq = np.random.choice([0,1], p=[1-p1, p1], size=10000)
return seq
def count(seq):
# insert code to return the number of occurrences of 11111 in the sequence
# Convert the sequence to a string for easy pattern matching
sequence_str = ''.join(map(str, seq))
count= len(re.findall("11111", sequence_str, overlapped=True))
return count
def main(p1):
seq = generate(p1)
return count(seq)
print(main(2/3))