Miscellaneous scripts
This repository contains miscellaneous scripts that does not fit in one repository, yet I will use them sometimes for my personal use. Note that some of the scripts might contain hardcoded paths and opinionated presets, and you are advised to inspect them before actually using.
Loading...
Searching...
No Matches
longestrep.py
Go to the documentation of this file.
1file = open("pi_million_digits.txt", "r").read()
2
3Q3_out = {}
4sequence = ""
5
6for char in file:
7 if char in sequence:
8 sequence += char
9 else: # put the sequence into the dict
10 # workaround for initially sequence being empty
11 if sequence:
12 Q3_out[sequence] = Q3_out.setdefault(sequence, 0) + 1
13 sequence = char
14
15print(Q3_out)