I actually have three task out of which two has been completed now I am really stuck with the last one.
- Check two consecutive 66 (Working)
- Longest sequence of rolls with 6 (Working)
- Want to check the number for most frequent length of 5's and 6's. For example in 5533661656 the 656 is the longest but there is only one series of length three but answer should be 2 as 55, 66 are there. Similarly 456116513656124566 have length of 2 and 3 which are occuring twice. Now program should print the longest length and answer should be 3
here is code
trial = int(randint(1, 500))
print(trial)
result = ''
for i in range(trial):
init_num = str(randint(1, 6))
result += init_num
print(result)
def double_six(result):
last_dice = '0'
counter = 0
for i in range(trial):
if result[i] == '6' and last_dice == '6':
counter += 1
last_dice = '0'
else:
last_dice = result[i]
return counter
print(double_six(result))
def no_six(result):
s = str(result).split('6')
l = 0
for i in s:
if l < len(i):
l = len(i)
if len(i) > l:
l = i
return (l)
print(no_six(result))
#
# def lucky_series(result)