Skip to main content

Questions tagged [combinatorics]

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

Filter by
Sorted by
Tagged with
4 votes
1 answer
228 views

I decided to practice by modeling some simple, hand-solvable problems using z3py. Below is an example: ...
Flint's user avatar
  • 43
0 votes
0 answers
20 views

Reference: arXiv:2504.04233 Example 2.12: 4-vertex cycle graph Structure: Square graph with 4 vertices Flooding cascade sets: 7 total (2 of size 2, 4 of size 3, 1 of size 4) Key insight: Opposite ...
138 Aspen's user avatar
  • 469
0 votes
0 answers
15 views

The implementation successfully demonstrates all key findings from the research paper arXiv:2509.12756, including the disproof of the original conjecture and the establishment of the correct formula ...
138 Aspen's user avatar
  • 469
0 votes
0 answers
28 views

I'd like to use Mathematica to demonstrate the expansion of the Rasala polynomials for symmetric group character degrees accroding to arXiv 2509.13190 The code is as follows. You may try it online! <...
138 Aspen's user avatar
  • 469
0 votes
0 answers
18 views

I ported C++ implementation of Lempel method for constructing Costas arrays to Mathematica. How to fix my code? Thanks in advance. ...
138 Aspen's user avatar
  • 469
2 votes
0 answers
34 views

I ported C++ implementation of Welch method for constructing Costas arrays to Mathematica. Any feedback would be appreciated. ...
138 Aspen's user avatar
  • 469
4 votes
1 answer
194 views

So, this is improved code from my previous attempt to implement the permutations algorithm in PicoBlaze assembly language. You can see it live here: ...
FlatAssembler's user avatar
4 votes
1 answer
304 views

You can see it live here: ...
FlatAssembler's user avatar
2 votes
1 answer
194 views

Yatzy Yatzy is a dice rolling game where players aim to get particular die combinations. This program counts probability of each such combinations. They are: All five ones, All five twos, Same for ...
coderodde's user avatar
  • 32.3k
3 votes
2 answers
148 views

The problem is as follows: A user needs to be able to purchase goods. He has a total of five distinct goods available: I've called them '1', '2', '3', '4', and '5', If the user buys them in sets, he ...
Andrew Bailey's user avatar
3 votes
1 answer
102 views

About exercise 2.2 Place N queens on N*N board, 1 queen per line, so that all queens are safe. Use permutation to improve the provided implementation from book. The ...
Eric's user avatar
  • 151
1 vote
1 answer
137 views

This is a problem from a previous semester that I am trying to upsolve. I am trying to solve a problem involving the total number of ways of decomposing a number using only repdigits. A repdigit is a ...
Lesserrafim's user avatar
3 votes
2 answers
235 views

Two partitions of a set have a greatest lower bound (meet) and a least upper bound (join). See here: Meets and joins in the lattice of partitions (Math SE) The meet is easy to calculate. I am trying ...
Watchduck's user avatar
  • 230
3 votes
1 answer
103 views

Problem set This is somewhat a generalization of the famous partition of integer n into k parts. Given two integers ...
linuxbeginner's user avatar
4 votes
1 answer
149 views

This is a simple multiset coefficient calculator in python, that will calculate both standard multiset coefficients, as well as multiset coefficients with repetition limits, used initially as part of ...
Lee Davis-Thalbourne's user avatar
2 votes
1 answer
169 views

I wrote this code to get all possible arrangements for an array containing 3 elements: ...
John's user avatar
  • 59
1 vote
0 answers
75 views

While grinding for coins on the GTA San Andreas casino poker machines I started to wonder how exactly one might implement a luck modifier to a video poker game without it being completely obvious to ...
TorbenPutkonen's user avatar
0 votes
0 answers
124 views

Suppose we have a sequence of sequences <1, 2> <3, 4>. There, we have two groups: <1, 2> and ...
coderodde's user avatar
  • 32.3k
6 votes
2 answers
122 views

My sister is organizing a Majong tournament. She wants to set up a set of round-robin rounds. There will be 16 players at 4 tables; 4 players per table. Players will play 5 rounds. She wants every ...
JDT's user avatar
  • 81
2 votes
1 answer
185 views

The problem involves the fastest possible method to generate a list of combinations which repeats from all the possible combinations with repetition allowed. I know there needs to be a way to ...
Reptorian's user avatar
3 votes
1 answer
189 views

The objective is simple: List all possible permutations for a given a String. I looked at some implementations from popular sources. I decided to build this to the flow: The Code for Review ...
Amal Krishnan's user avatar
1 vote
1 answer
241 views

I want to improve this code to efficiently create all possible permutations/combinations of a string. For example, if I have the string "abc", the result would be the list [ab, ac, ba, bc, ...
themightye's user avatar
1 vote
1 answer
154 views

Could you please help with speeding-up this code? Input: UTF-8 text (encoded 1-3 times from known pool of encodings). Every time was encoded and decoded by random encoding from pool. Original was koi8-...
Kir S's user avatar
  • 11
7 votes
2 answers
1k views

I came up with a suitable solution to a HackerRank problem that failed because the execution took longer than 10 seconds on lists that were of very large size. The problem: Given a list ...
NFeruch - FreePalestine's user avatar
8 votes
2 answers
976 views

the aim of the code below is to print all balanced sequences with equal number of 'A' and 'B'. A sequence is balanced if every prefix of length \$\geqslant 4\$ is balanced. A prefix is balanced if the ...
kodkod's user avatar
  • 441
3 votes
0 answers
63 views

I have a question about how to check if two tableaux are compatible (will define below). Here we only consider tableaux of rectangular shape. A tableau is called semistandard if its rows are weakly ...
Jianrong Li's user avatar
2 votes
0 answers
132 views

This post is about an Iterator iterating over simple loops of an undirected graph. In the above graph, the cycle \$\langle 1, 2, 3, 4, 5, 3, 1 \rangle\$ is not ...
coderodde's user avatar
  • 32.3k
1 vote
1 answer
107 views

For dummy's sake, let's say that I have a database with columns text, ind and sentid. You ...
Bram Vanroy's user avatar
1 vote
1 answer
109 views

I am working on a code that will minimize the number of ingredients necessary to make some dishes. Each dish can be prepared in an arbitrary large number of ways, with combinations of two ingredients. ...
adrienlucca.net's user avatar
2 votes
1 answer
174 views

Given a boolean expression consisting of the symbols 0 (false), 1 (true), & (AND), | (OR), and ^ (XOR), and a desired boolean result value result, implement a function to count the number of ways ...
Andrei Rost's user avatar
1 vote
3 answers
164 views

Given a positive integer n, I would like to randomly output n non negative integers that sum to ...
Simd's user avatar
  • 231
1 vote
1 answer
414 views

I was trying to to print all subarrays of an array in quadratic time. Here is my code: ...
Vaibhav Vishal Singh's user avatar
2 votes
2 answers
834 views

You are given an array A of length N (where N is as large as 2×105). All elements of the array are positive integers less than or equal to N. Determine the count of subarrays (contiguous subsequences) ...
Vaibhav Vishal Singh's user avatar
3 votes
2 answers
463 views

I have solved the pascal's triangle problem. I am not good at writing efficient programs, hence any suggestions/ comments shall be welcomed. ...
Zainab Saad's user avatar
1 vote
1 answer
165 views

Subset Product is an NP-complete problem and is my favorite problem. So, I've written a slightly smarter way of solving the problem. Will performance impact matter if I use multi-cpus and my GPU? Do ...
The T's user avatar
  • 491
5 votes
2 answers
2k views

I have the following task: Let us have a list (denoted by L, and for simplicity, the elements come from the interval [0,1]). We are given a parameter (denoted by C), and we want to find as many pairs ...
Atvin's user avatar
  • 153
5 votes
2 answers
295 views

I need to find the number of five-digit octal numbers in which all digits are different and no two odd or even digits are adjacent. My code below gives the correct answer, but I'm not satisfied. Can ...
o0o0o's user avatar
  • 53
5 votes
1 answer
251 views

I wrote this code in 4 days, I want to see if I can optimize this code some more, and have some suggestion on what can I improve. This code takes in any number of points then naming them ...
pockspocky's user avatar
2 votes
1 answer
179 views

I have an array with integer labels in [0, n-1], say arr1=[1, 0, 3, 2] with n = 3. And then I have another array again with integer labels in [0, n-1], say arr2=[0, 0, 2, 3]. How can I find the ...
ApPs's user avatar
  • 23
1 vote
1 answer
791 views

Context: My question comes from needing to iterate different np.arange arrays. The main motivation is to calculate all the possible combinations between the arrays, ...
nuwe's user avatar
  • 163
1 vote
1 answer
195 views

https://www.hackerrank.com/challenges/absolute-permutation/problem I know that if you work out the math and logic first, the algorithm can be simplified greatly (shifting indices), but is that the ...
No Name's user avatar
  • 147
2 votes
1 answer
253 views

I am trying to learn rust and as such have been redoing some of the challenges on project Rosalind. This one relates to the challenge Enumerating Gene Orders. ...
mega_creamery's user avatar
4 votes
1 answer
1k views

I am learning Haskell and I implemented a recursive function that generates possible strings by length and array (e.g. ['a'..'z']): ...
Vlad Havriuk's user avatar
1 vote
1 answer
83 views

I have a dataframe of cases that score 0-1 on a group of binary attributes. What I want to do is extract all possible ombinations of attribute triplets (e.g. A/B/C, A/B/D... out of A-E) and then sum ...
Fnguyen's user avatar
  • 173
2 votes
1 answer
268 views

To divide 9 persons into 3 groups, when the ordering of groups is not important can be done in (9C3 * 6C3 * 3C3) / (3!) = 280 ways Here, we divide by (3!) because the ordering of 3 groups is not ...
Prateek Thapa's user avatar
2 votes
0 answers
52 views

My goal is to look for nearest neighbours in a Boolean-assigned mapping (a Python dictionary). For this purpose I'm looping through the candidates, starting from those with the closest distance. The ...
Felix Emanuel's user avatar
3 votes
3 answers
1k views

The goal of the function below is to generate all subsets of a given set, i.e. a collection of sets that contain all possible combinations of the elements in the set. Note that for my application I do ...
Alexandre Bintz's user avatar
3 votes
1 answer
119 views

Given any series of numbers, for example 1,2,3,4,5 and given the arithmetic operands + - * / including parenthesis, what would be the most optimal way to build a tree that contains all permutations ...
Mihael Keehl's user avatar
4 votes
1 answer
628 views

I am thinking about the following problem: Consider a 3-numbers lock, i.e. a lock which has three little number wheels that opens whenever the sum of these three numbers equals 75. I know, this doesn'...
Luk's user avatar
  • 141

1
2 3 4 5
11