Initial commit

This commit is contained in:
2022-06-01 23:06:18 +02:00
commit 36147d58b3
3 changed files with 40 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
#num = (1<<127) | 1
from time import time_ns
n = 3 #max random number will be (2^n)
def randomNumber(maxN):
num = time_ns()
num = int(format(num, '0127b'), base=2)
array=[]
for i in range(16000):
array.append(num & 1)
new = (num ^ (num >> 1) ^ (num >> 2)^(num >> 7)) & 1
num = (num >> 1) | (new << 127)
i=0
while True:
j = "".join([str(x) for x in array[-15-i:-1-i]])
index = int(j,2)
if index < len(array):
break
else:
i+=1
rnum = int("".join([str(x) for x in array[index-maxN:index]]),2)
return rnum+1
if __name__=="__main__":
paper_num=randomNumber(n)
question_num=randomNumber(n)
print(f"Next exercise is question {question_num} from paper {paper_num}")
+5
View File
@@ -0,0 +1,5 @@
"THE NON-ALCOHOLIC-BEVERAGE-WARE LICENSE":
<xaloc@tutanota.com> wrote this. As long as you retain this notice you can
do whatever you want with this stuff. If we meet some day, and you think this
stuff is worth it, you can buy me a non-alcoholic beverage in return Xaloc
+6
View File
@@ -0,0 +1,6 @@
## ARRARARARARAM
ARnau's Random Access RAndom part of RAndomly generated sequence to Randomly Access Random Access Memory
Nice little script to generate to pseudo random numbers using lfsr and the computer's time as a seed.
You have Allen to thank for this too.