Questions tagged [combinatorics]

Combinatorics is a branch of mathematics concerning the study of finite or countable discrete structures.

394 questions
52 views

326 views

Disjoint cycles of a permutation

Given an element of the permutation group, expressed in Cauchy notation, it is often useful to have it expressed in disjoint cycles (for example to apply the permutation to the keys of a dictionary). ...
2k views

Getting all (forward) permutations of a list of strings

I have the following concise-ish (and working) approach to getting all the forward permutations of a list of string. So with the list: w = ["Vehicula", "Sem", "Risus", "Tortor"] the results ...
68 views

Forming all multiples of 3 using the given digits

I'm working on this kata from Codewars. The task is: Given a certain number, how many multiples of three could you obtain with its digits? Supose that you have the number 362. The numbers that ...
148 views

Lattice path from Project Euler with Python solution

I was trying to solve this problem called lattice path from Project Euler: Count the number of unique paths to travel from the top left to the bottom right of a lattice of squares. How many such ...
562 views

n choose k combination in JavaScript

I was asked to solve a problem for $\binom{n}{k}$. I did the following implementation and am wondering if there's any feedback. Input: n = Integer ...
926 views

Recursive implementation of power set in Python

I was doing a recursion problem called power set, and would like to get code review. Here's the problem. ...
3k views

Printing all possible sums of two n-sided dice rolls

For my CS class, we were tasked with writing a program that calculates all the possible results from rolling two n-sided dice. For example, the input of 4 would ...
61 views

Fitter Nearest-Neighbor function with three nested loops

Background Problem Consider a set of students that we want to place into Ng groups each of which contains Ns students. Let's ...