Fully working program

This commit is contained in:
KikooDX 2020-02-09 11:58:34 +01:00
parent a42a119408
commit bd420e7548
1 changed files with 46 additions and 0 deletions

46
main.py Normal file
View File

@ -0,0 +1,46 @@
from math import ceil
import locate2
def crible(max):
result = [i for i in range(2, max) if i%2 and i%5]
step = 0
while step != len(result):
div = result[step]
if div**2 > result[-1]:
break
result = [i for i in result if i%div or i==div]
step += 1
#insert 2 & 5 if needed
if max > 2:
result.insert(0, 2)
if max > 5:
result.insert(2, 5)
return result
#list browser
def explore(provided_list):
scr = locate2.Screen(21, 7) #app screen, w:21 h:7
pos = 0
max_pos = ceil(len(provided_list) / 7) - 1
key = " "
while key != "0":
scr.fill()
scr.locate_v(21, 1, "^4||1v") #sidebar
status = "{}/{}".format(pos, max_pos)
scr.locate(20 - len(status), 1, status)
for i in range(7):
try:
scr.locate(1, i+1, provided_list[pos*7+i])
except:
break
uin = scr.refresh(fancy=True)[-1:] #only keep the last char entered
key = uin if uin else key
power = 10 ** "123".find(key)
if power != 0.1 and pos + power <= max_pos:
pos += power
power = 10 ** "456".find(key)
if power != 0.1 and pos - power >= 0:
pos -= power
result = crible(int(input("max>")))
explore(result)