Rubyã§ã¯ãé åãã¨ãçµã¿åããããArrayã¯ã©ã¹ã®combinationã¡ã½ããã¨permutationã¡ã½ãããç¨ãããã¨ã§ãç°¡åã«æ±ãããã¨ãã§ãã¾ãã array = [1,2,3,4] p array.combination(3).to_a [[1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4]]combinationã®å¼æ°ã¯é¸ã³åºãè¦ç´ ã®åæ°ãæå®ããã array = [1,2,3] p array.permutation(3).to_a [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]両æ¹ã¨ã便å©ãªã¡ã½ããã§ãã ã¾ããè¦ç´ ã®éè¤ã許å¯ããå ´å㯠repeated_combination ã repeated_permutation ãå©ç¨ã§ãã¾ãã ãªã
{{#tags}}- {{label}}
{{/tags}}