interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

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}
4from itertools import product
5from math import comb
6kinds = ["iced", "jam", "plain"]
7# all ordered pairs, keeping those already in non-decreasing order
8for a, b in product(range(3), repeat=2):
9 if a <= b:
10 print(kinds[a], kinds[b])
11n = sum(1 for t in product(range(10), repeat=3) if t[0] <= t[1] <= t[2])
12assert n == comb(10 + 3 - 1, 3)
13print("choices of 3 from 10 kinds:", n)