An algorithm is a sequence of well-defined steps that defines an abstract solution to a problem. Use this tag when your issue is related to algorithm design.
16
votes
7answers
179 views
Is there a way to measure how sorted a list is?
It may sound like a silly question, but I'd like to know if there is a way to measure how sorted a list is.
I mean, it's not about knowing if a list is sorted or not (boolean) but something like a ...
0
votes
2answers
47 views
How to generate all possibilities for triangles from 10 possible dots [closed]
I am trying to think of the solution for this problem:
Generate all possibilities for triangle between 10 dots which are positioned like this:
. . .
. . .
. . .
.
(like a ...
1
vote
2answers
29 views
Removing elements in a functional style
I have been struggling with something that looks like a simple algorithm, but can't find a clean way to express it in a functional style so far. Here is an outline of the problem: suppose I have 2 ...
0
votes
4answers
43 views
weighted boolean value - scaling
I am not sure how to implement this, but here is the description:
Take a number as input in between the range 0-10 (0 always returning false, 10 always returning true)
Take the argument which was ...
4
votes
2answers
55 views
Is there a bug in java.util.Stack's Iterator?
Today I was trying to push in util.Stack class and then use the Iterator to iterate(without using pop) through the items. I was expecting LIFO property but got surprised.
Here is the code that I was ...
0
votes
3answers
51 views
Greater chance to roll 6 with dice in Java
I was wondering how can I program a dice which has a greater chance to roll a 6?
I've tried everything but I just cant figure the algorithm.
The probability of six is given by the user.
I just don't ...
0
votes
0answers
19 views
algorithm to group items (fibre terminals) to best fit container (fibre buffer)
I have an ordered list that represents terminals on a fibre cable where each terminal has a number of ports (e.g. 4, 8, 12). Given a fibre optic cable that will supply a different fibre strand to ...
0
votes
2answers
38 views
Algo to find least amount of items that satisfy a given requirement
I want to implement an algorithm for the following problem. It later on needs to be implemented in T-SQL:
I have a set of providers - lets say shops. Each shop has it set of items it offers. Some ...
1
vote
1answer
33 views
Exponentiation by cyclic shifting
Some other topic here on SO mentioned the paper “Fast Exponentiation with Precomputation” by Brickell et al., which, along with simple concept of precomputation of powers corresponding to binary ...
0
votes
0answers
120 views
Goods reordering algorithm
I have a few warehouses in which I store goods. Unfortunately, some of the goods are in the wrong warehouses, so I need to move them to the correct ones using a truck. Loading and unloading goods ...
1
vote
1answer
55 views
Implementing Karatsuba algorithm in Haskell
I just got to know about Karatsuba Algorithm, and I tried to implement it in Haskell.
Here is my code:
(***) :: Integer -> Integer -> Integer
x *** y
| max x y < ub = x*y
| ...
1
vote
0answers
20 views
Lehmer's extended GCD algorithm implementation
While doing my own BigInteger implementation, I got stuck with the extended GCD algorithm, which is fundamental for finding modular multiplicative inverse. As the well-known Euclidean approach ...
-7
votes
1answer
32 views
Lexical analysis of program [closed]
How to carry out the lexical analysis of the language of the program to compute the sum of squares of the components of the array numbers.
I have a program:
s:=0;
for i := 0 to N-1 do
s := s + ...
1
vote
1answer
44 views
What is a good benchmark for A* (AStar)?
I wrote myself an A*, it works quite well and now comes the time to evaluate its performance (potentially against other solutions to see how it performs).
For both having visual feedback and fun I ...
-1
votes
0answers
18 views
Generating random trading from an equilibrium price [closed]
I'm hoping someone can help me with shedding some light on solving this problem.
Say I have 100 agents. Each agent has a certain amount of money and a certain amount of an asset.
Lets say if an ...