Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/tasks/combinations-with-repetitions/oracle.py # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / tasks / combinations-with-repetitions / oracle.py` 13 lines ยท 649 bytes Raw Blame History 1 # Independent reference for "Combinations with repetitions" (Python 3, standard library only). 2 # expected.txt is this program's stdout; omc never produced it. 3 # Cross-check, WolframLanguageEvaluator: {Binomial[3 + 2 - 1, 2], Binomial[10 + 3 - 1, 3]} -> {6, 220} 4 from itertools import product 5 from math import comb 6 kinds = ["iced", "jam", "plain"] 7 # all ordered pairs, keeping those already in non-decreasing order 8 for a, b in product(range(3), repeat=2): 9 if a <= b: 10 print(kinds[a], kinds[b]) 11 n = sum(1 for t in product(range(10), repeat=3) if t[0] <= t[1] <= t[2]) 12 assert n == comb(10 + 3 - 1, 3) 13 print("choices of 3 from 10 kinds:", n)