All Questions
Tagged with combinatorics java
110 questions
2
votes
1
answer
178
views
Java program for calculating probabilities of die combinations in Yatzy
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 ...
3
votes
2
answers
129
views
Buy units of a good - If you buy them together, you get a discount - Find the cheapest way to purchase all goods available
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 ...
1
vote
0
answers
69
views
Video Poker with luck modifier
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 ...
0
votes
0
answers
114
views
Generating group permutations: an extended Heap's algorithm in Java
Suppose we have a sequence of sequences <1, 2> <3, 4>. There, we have two groups: <1, 2> and ...
3
votes
1
answer
163
views
String Permutation Implemention
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
...
1
vote
1
answer
227
views
Creates all possible permutations of a string and its substrings
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, ...
2
votes
0
answers
124
views
Iterating over all simple unique cycles in an undirected graph in Java - brute-force approach
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 ...
3
votes
1
answer
111
views
Building a tree containing all permutations of arithmetic expressions given some numbers
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 ...
4
votes
1
answer
615
views
Find all combinations of numbers of a set that add up to a given target - avoid for loops
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'...
1
vote
1
answer
237
views
Generating all variations of M*N matrix containing boolean values
I've implemented an algorithm that generates all variations of a matrix of size \$M*N\$. My approach is that I see a matrix as a list where the position of elements can be calculated from the position ...
5
votes
1
answer
138
views
Calculating every possible answer given a set of formulas
Problem
Given a set of formulas (AKA "Rules"), get a list containing every possible answer that does not break any formula.
Formula variables can have a maximum equal to the number of characters. ...
2
votes
3
answers
265
views
Mapping words to letters which contains
Given sentence for example: ala ma kota, kot koduje w Javie kota I should to every letter occurring in the sentence I should map every string that this letter ...
7
votes
5
answers
736
views
String combinations of 0 and 1
I was asked this question in an interview:
Given a string s consisting of 0, 1 and ...
5
votes
5
answers
1k
views
Checking if an integer permutation is cyclic in Java
A an integer permutation array[] is said to be cyclic if and only if we can choose an arbitrary element at position i, move it ...
3
votes
2
answers
1k
views
Print out all possible letter combinations a given phone number can represent
I am working on a problem in which given a 7 digit telephone number, we need to print out all possible combinations of letters that each number could represent.
I came up with below code and I was ...