def stigespill(kast, stiger): pos = 0 for oyne in kast: pos += oyne if pos in stiger: pos = stiger[pos] return pos #print(stigespill([5,4,2,2],{5:12, 18:7})) def hvilke_tre_kast(slutt_rute,stiger): terninger = [1,2,3,4,5,6] passende_kast = [] for kast1 in terninger: for kast2 in terninger: for kast3 in terninger: mine_kast = [kast1, kast2, kast3] if stigespill(mine_kast, stiger) == slutt_rute: passende_kast.append(mine_kast) return passende_kast print(hvilke_tre_kast(5, {3:15, 17:4}) )