RosettaCodeData/Task/Combinations-and-permutations/Uiua/combinations-and-permutations.uiua
2026-04-30 12:34:36 -04:00

15 lines
504 B
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

P ← /×+1˜↙⇡⊙¯ # Simple Perm calc.
C ← ÷/×+1⇡⤙P # Simple Comb calc.
# Better version: casts out common factors first.
C ← (
AllFactors ← map⊕(⊃⊢⧻)⊸⊛▽⊸>₁/⊂(°/×)
⊃(+1⇡◌|+1˜↙⇡⊙¯) # Collect numerator, denominator terms.
⍆◴⊂◡∩(⊙◌°map)∩AllFactors # Identify common factors.
/×ⁿ⤚(-∩⌞≡⬚0get⊙¤⊙⊙¤) # Cast out, mult
)
≡⌞P 12 ↘1⇡12
≡⌞C 60 ×10↘1⇡6
P 105 103
P 15000 333
C 900 674