# Tagged Questions

An algorithm is a sequence of well-defined steps that defines in abstract the solution to a problem.

937 views

### An inverted pyramid

I want to draw a pyramid approximately like this ...
706 views

### Splitting strings into letter keys and integers

I have strings of the following form: string = "ABC123DEFG456HI89UZXX1"; Letter keys of variable lengths are followed by (positive) integers. I want to get this ...
721 views

### Coalition Games

Suppose an election produces the following result: result = {{"a", 120}, {"b", 80}, {"c", 50}, {"d", 30}}; Letters are parties and numbers seats. To form a ...
579 views

### How to generate a blank crossword sheet?

I attempted to generate a blank crossword sheet. My method is by combining the rows and columns as shown on the graph below. However, some of the across and ...
370 views

### Replacing matrix values

I want to find the n largest values in a matrix and replace all others with zero. The solution I found uses ReplaceAll and becomes very slow as the size of ...
339 views

### Extracting values with multiple keys

I want to extract sorted data from a huge database based upon two (or more) keys in a very timely manner. Here is a reproducible toy example for two keys only: ...
151 views

### How to make a case insensitive sorted list and rename the file names of a given folder?

Suppose I had about 500 .JPG and .jpg files in my folder "c:\images\". How to ask ...
291 views

### How to build a game board [duplicate]

I have - rather lazily - constructed a chessboard like this: ...
634 views

### Implementing an algorithm for finding the largest circle that contains a single point in a set (and no other point)

This question concerns the implementation of an algorithm proposed by Rahul Narain on a former question of mine that was migrated to math.stackexchange: http://math.stackexchange.com/questions/483845/...
66 views

### Speeding up ReplaceRepeated while truncating to desired order

I need to program in an algorithm that recursively makes algebraic replacements which leads to an utterly complicated algebraic function of $x$, but whose final result is only needed at fixed order in ...
2k views

### How to get actual triangles from DelaunayTriangulation[]?

The ComputationalGeometry package has a DelaunayTriangulation[] function. It returns a list of points connected to each point, ...
805 views

### “Indexing” a vector

I need to "index" a vector according to the first occurence of its distinct elements. I have written ...
685 views

### Faster way to test if an expression equals zero

I want to test if expressions (mix of variables, functions and numbers) are zero valued, as fast as possible, and PossibleZeroQ is sometimes very slow. One solution ...
3k views

### Mathematica Implementations of the Random Forest algorithm

Is anyone aware of Mathematica use/implementation of Random Forest algorithm?
3k views

### Machine learning. SVM algorithm

I want to work with machine learning in Mathematica. Are there any SVM algorithms implemented in Mathematica anywhere? Or any other algorithms for machine learning? With positive and negative database ...
1k views

### Ragged Diamonds

diamond[n_Integer] := Table[1, {#}] & /@ (Range[n]~ Join~Range[n - 1, 1, -1]) diamond[5] // MatrixForm How could a more functional, "tablefree", solution ...
580 views

### Find intersection points with V10

My question departs from this one: Find intersection of pairs of straight lines but now I want to find the points with the new V10 Region-functions. ...
217 views

### Multivariate Polynomial Manipulation

I have a large homogenous multivariate polynomial in, say, 5 variables $a,b,c,d,e$. As an example take the polynomial $$a^4+2abcd+a^2 b^2+e^4+cde^2.$$ Now I would like to replace $k$-th power of any ...
293 views

### All possible pairs of two items

I have 4 different items {1, 2, 3, 4}. I want to obtain all possible pairs of two of the items. I have written: ...
208 views

### Optimization Algorithm: ideas wanted

EDIT: Lets assume a random matrix: ...
165 views

...
766 views

### Replace interior of matrix with zeros

I have f.e. the following square matrix: ...
337 views

### Write a number as the product of its two largest divisors

For even n >= 10 && n <= 98 I want to write n as the product of its two largest divisors (excluding ...
157 views

### What's a non-trivial Mathematica program involving conscious choice of stack vs. queue data structure?

In a typical computer science algorithms course, much attention is given to the discussion of queues vs. stacks as a data structure programmers need to consciously choose from to achieve algorithmic ...
301 views

### What is the underlying algorithm for GroupElementToWord?

What algorithm is Mathematica 9 using for GroupElementToWord[group, g]?
7k views

### Plotting a set of trajectories (not a vector field) in 3D

Consider a set of trajectories in 3D space, that possibly converge. By visualizing trajectories as arrows the result will look crowded as each arrowhead will be placed where the attractor is. In 2D, ...
204 views

### Implementing Kane's Subset Sum Algorithm

In the following paper, D. Kane describes an algorithm for subset sum that runs in logspace: http://arxiv.org/pdf/1012.1336v2.pdf. I am trying to implement it ...
244 views

### Can Mathematica solve $x^{b^2} + ax^b -1 = 0$ for $x$ with $a>0$, $b>1$?

I have a problem that I can't seem to solve neither analytically nor with Mathematica. Namely, I have the expression $$x^{b^2} + ax^b - 1= 0,$$ which I want to solve for $x$ with $a>0$, $b>1$. ...
202 views

### How do I find the all valid pairings between two sets?

I have a pretty hard problem to solve here, and I have no idea how to start. I have X kind of fruits and 5 colors (let's say Red, Green, Yellow, Blue and Purple). Each fruit can be available in ...
1k views

### Detecting patterns of black and white stones on a 2D board

I'm writing a program to play a game of Pente, and I'm struggling with the following question: What's the best way to detect patterns on a two-dimensional board? For example, in Pente a pair of ...
94 views

### How write this Function with many arguments? [duplicate]

F[x1_,x2_,...,x99_]:=expr How to write this Function in mathematica whithout complete write it?
52 views

### How to determine three last bindings made to a variable when evaluating an expression?

How can I create a list of bindings made to a certain variable when evaluating an expression? I want to determine three bindings made.
391 views

### Generating the set of all strings within a fixed edit distance of a initial string?

Provided a starting string initialString, and a particular alphabet of allowed characters {"A","B","C","D","E",...}, how can I ...
1k views

### Bresenham's line algorithm

Bresenham's line algorithm is producing discretized line for given two points for purpose of plotting for example. Like that: I have to stress that I'm interested in positions, not a plot. ...
206 views

### Challenge: Speeding up MaxDetect for application in 3D blob detection

In image segmentation it is a common problem that objects appear clustered and are therefore undistinguishable from each other when using simple algorithms. Based on this post I obtained efficient ...
559 views

### A* algorithm for finding shortest path in a graph

FindShortestPath finds the shortest path between two vertices in an edge-weighted graph, allowing a choice between the Dijkstra and Bellman-Ford algorithms. In my (limited) understanding, both of ...
142 views

### Algorithm in RandomChoice[{w1,w2,…}->{e1,e2,…},n]?

I wonder if someone happens to know the actual algorithm implemented in the particular overload of RandomChoice that handles explicitly presented discrete ...
1k views

### Efficient backtracking with Mathematica

Backtracking is a general algorithm for finding all (or some) solutions to some computational problem, that incrementally builds candidates to the solutions, and abandons each partial candidate c ("...
315 views

### Generate encoding from nested list

Taking reference of Huffman code algorithm, ...
308 views

### Generated Numbers under a constraint?

Let's say I have five four dimensional vectors $p_i^\mu=(p_i^1,p_i^2,p_i^3,p_i^4)$ with $i=1,2,3,4,5$. Now, I want to fill the entries of these vectors ($4\cdot5=20$ in total) with some numbers, but ...
371 views

### Creating a function with integral zeroes of the 0th, 1st, and 2nd derivatives

I would like to be able to randomly generate functions, each of which satisfies $f : [-10, 10] \rightarrow [-10, 10]$ All the zeroes, critical points, and inflection points have an integral $x$-...