Closed fijam closed 2 years ago
doodling:
from itertools import cycle
charset_list = ['katakana', 'uppercase', 'lowercase', 'numbers']
initial_set = charset_list[0]
charset_loop = cycle(charset_list) # generator to keep track of current charset
next(charset_loop) # start the thing on [0]
def enter_correct_set(wanted_set, times_to_press, initial_set):
#if -(len(set_common)) < times_to_press < 0:
#if recorder r55: return charset_list[0]
#else: return initial
if times_to_press < 0:
# we will end up one set sooner
index_of_wanted_set = charset_list.index(wanted_set)
wanted_set = charset_list[index_of_wanted_set-1]
if wanted_set == initial_set:
print(f"Pressing pause {len(charset_list)} times")
return initial_set
else:
for count, step in enumerate(charset_loop):
if step == wanted_set:
print(f"pressing Pause {count+3} times")
return wanted_set
if times_to_press > 0:
if wanted_set == initial_set:
print("Pressing pause 1 time")
return initial_set
else:
for count, step in enumerate(charset_loop):
if step == wanted_set:
print(f"pressing Pause {count+2} times")
return wanted_set
while True:
wanted_set = input('wanted set:' )
times_to_press = int(input('TTP results is:'))
initial_set = enter_correct_set(wanted_set, times_to_press, initial_set)
print(f'new initial set is: {initial_set}')
meh
def change_set_moves(current_set, wanted_set):
if current_set == wanted_set:
return 1
for step in charset_loop:
print(step)
if step == current_set:
for count, step in enumerate(charset_loop):
print(count,step)
if step == wanted_set:
return count+2
nah
charset_list = ['katakana', 'uppercase', 'lowercase', 'numbers']
initial_set = charset_list[0]
def change_set_moves(current_set, wanted_set):
d = charset_list.index(wanted_set) - charset_list.index(current_set)
return (d + 1) if d >= 0 else (d + 1 + len(charset_list))
somewhat fixed, still not 100% happy with it
The distance finding is fine, but the surrounding tracking of stepping through charsets is (perhaps) needlessly complicated.
Investigate generators for tracking current/wanted character set.