You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
656 B

  1. from fingering import fingers
  2. from itertools import *
  3. def powerset(iterable):
  4. "powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"
  5. s = list(iterable)
  6. return chain.from_iterable(combinations(s, r) for r in range(1,len(s)+1))
  7. ##for i in range(200):
  8. ## print(fingers(i,22)+1)
  9. valves = [2,1,3,5]
  10. dic = {}
  11. altdic = {}
  12. for comb in powerset(valves):
  13. hs = sum(comb)
  14. comb = tuple(map(lambda x: valves.index(x)+1,comb))
  15. try:
  16. dic[hs] += [comb]
  17. except KeyError:
  18. dic[hs] = [comb]
  19. try:
  20. if len(altdic[hs]) > len(comb):
  21. altdic[hs] = comb
  22. except KeyError:
  23. altdic[hs] = comb