"""Hypotheses from the January table, in the project formula (D60):
selection rule / word rule / ordering rule, each one Pindar could say aloud; bookend shape stated."""
import sweeplib as S
W=S.WL; I=lambda w: W.index(w)+1

A_pieces = [21,57,129,131,141,189,191,259,268,363,473]
A_printed = ['bean','mistake','alpha','blind','awkward','blue','error','bless','bird','true','false']
A_index   = ['bean','mistake','alpha','blind','awkward','blue','error','bird','bless','true','false']
A_should  = ['action','alpha','alpha','blind','awkward','blue','error','bird','bless','true','false']
A_idxval  = {'bean':157,'mistake':1136,'alpha':57,'blind':191,'awkward':135,'blue':195,'error':615,'bird':181,'bless':190}

H = {}
def fr(name, words): return [(name+"|fwd", list(words)), (name+"|rev", list(words)[::-1])]
H["H1 SetA printed, piece order"] = fr("H1", A_printed)
H["H2 SetA index-corrected, piece order"] = fr("H2", A_index)
nine = sorted([w for w in A_index if w in A_idxval], key=lambda w:A_idxval[w])
H["H3 SetA index-corrected, index order"] = fr("H3end", nine+['true','false']) + fr("H3start", ['true','false']+nine)
H["H4 SetA the words that SHOULD be there, piece order"] = fr("H4", A_should)
H["H6 nine indexed exceptions + bookends"] = fr("H6piece", ['universe']+A_index[:9]+['final']) + fr("H6index", ['universe']+nine+['final'])
ten = sorted(['action','alpha','awkward','bean','blind','blue','mistake','bird','bless','error'], key=I)
H["H11 the ten disturbed WORDS by index + one bookend"] = fr("H11uni", ['universe']+ten) + fr("H11fin", ten+['final'])
# H10: order by the PIECE's index but read the sheet's printed word (keeps the swap): #259(181)->bless, #268(190)->bird
_piece_idx = {'bean':157,'mistake':1136,'alpha':57,'blind':191,'awkward':135,'blue':195,'error':615,'bless':181,'bird':190}
H["H10 SetA printed words in piece-index order"] = fr("H10", sorted(A_printed[:9], key=lambda w:_piece_idx[w])+['true','false'])
H7 = {
 "H7a bookends outside, ten by index": ['universe']+ten+['final'],
 "H7b reversed": (['universe']+ten+['final'])[::-1],
 "H7c all twelve by pure index": sorted(ten+['universe','final'], key=I),
 "H7d reversed": sorted(ten+['universe','final'], key=I)[::-1],
}
TASKS = [(v, w) for lab in H for (v, w) in H[lab]]
