Questions tagged [algorithm]

A puzzle related to algorithms (a main concept in computer science). Puzzles may ask for an algorithm as an answer or require the analysis of a given algorithm.

Filter by
Sorted by
Tagged with
3 votes
2 answers
242 views

Figure out when a data usage cycle restarts

Your cell phone carrier sends you a text message when you have reached your data limit (which you know) for the month, after which you are charged for extra data usage. Question 1: You want to ...
user avatar
11 votes
3 answers
1k views

The Generous Taco stand

There are a group of people standing in line for a taco stand. This taco stand is special in that it's slogan is "The older you are, the more you get!". To make sure though that there isn't any funny ...
0 votes
2 answers
4k views

Measuring volumes with oil drums of 8 and 5 litre [duplicate]

You have two drums of capacity 8 litre and 5 litre and a resource of oil, can you use these two drums to give 1 litre, 2 litre, 3 litre, 4 litre, and 6 litres and 7 litres to any customer? If yes, ...
-4 votes
1 answer
878 views

Sub-30second solving the $3\times3\times3$ Rubik's cube

I just wanna learn cubing under 30 secs. Please help me:( As i've already learned the Beginner's method. Is there any easiest way to learn the CFOP method as i am unable to understand this method. I ...
18 votes
4 answers
2k views

Consecutive Towers of Hanoi

Consider the following variant of the Towers of Hanoi puzzle. There are six pegs. One of the pegs has a stack of $n$ differently sized disks, sorted by size so the smallest disk is at the top. All ...
  • 31.7k
2 votes
1 answer
146 views

How many moves are at least needed to change the order of cubes to a arbitrary order? [closed]

We have several cubes that are ordered as in the picture below: What is the smallest number of moves with which we are able to reach every possible order? Only the order of the cubes in the ...
2 votes
1 answer
228 views

Doubts about algorithm

Hello I came across a really good algorithm perfect for a minigame I'm making. When I was trying to implement the algorithm I stumbled with some doubts and I can't the algorithm right. I'm talking ...
1 vote
1 answer
250 views

When will inverting an algorithm allow it to function the same as the original?

Let's say I have this zperm algorithm: R' U' R U' R U R U' R' U R U R2 U' R' U2 Now, let's suppose I invert it. U2 R U R2 U' R' U' R U R' U' R' U R' U R Assuming the cube is in a state of its pll ...
6 votes
1 answer
5k views

Is it possible to scramble a Rubik's cube so that each face has no more than 2 squares of the same color?

The complete conditions for this scrambled cube can be described alternatively as the following: 1. Each face has less than 3 squares of the same color, which leads to 1a. Each face has 5 or 6 ...
  • 63
0 votes
1 answer
2k views

The swap puzzle

The swap puzzle Place small coins heads up on the squares marked H and tails up on the squares marked T. Swap the positions of the Heads for the Tails in as few moves as possible. There are two ways ...
8 votes
4 answers
2k views

Is there a simple algorithm for solving Kami 2 puzzles?

I'm finding my life has been consumed by Kami 2, partly because I seem to have achieved some "insight" and am able to solve the puzzles reliably, almost always on the first try. The rules are simple: ...
  • 181
3 votes
1 answer
547 views

Algorithm to Solve Puzzle - Advice Needed

Given the following letters arranged in a circular pattern. A B E C D Each letter can merge with any of its opposite letters to form an adjacent ...
13 votes
1 answer
2k views

What is the optimal first move in Mastermind?

For a given number of positions/holes and a given number of colors, which initial guess eliminates the most possibilities for the solution at a minimum? For 4 positions, it's AABB. What is it for 5, ...
2 votes
1 answer
322 views

sort n balls by knowing the lightest in one query

Suppose there are $n$ balls with different weights and let $b$ be an integer between $2$ and $n$. There is a machine which, given a set $S\subset\{1,2,3,\dots,n\}$ of size at most $b$, can tell you ...
0 votes
5 answers
512 views

Pipe and socket problem

Given a set of n pipes of different sizes and n sockets of different sizes. There is a one to ­one mapping between pipes and sockets, meaning that a pipe can fit into only one socket. Match pipes and ...
1 vote
2 answers
2k views

Algorithm for solving the permutation puzzle Tricky Animals

I have developed a game called Tricky Animals where the goal is to reorder the animals in the right order with three permutations: $A = (1,2), X = (2,3,..,n-1), B = (n-1, n)$. The game can be played ...
user avatar
1 vote
2 answers
315 views

Find other swords down the waterfall

This is another old pattern I generated with a 1D cellular automaton: To me it looks like a sword hidden in a waterfall. The neighborhood of a cell looks like this: What is the rule behind this ...
  • 987
16 votes
5 answers
4k views

Can you recreate this fractal I randomly made?

This fractal looks relatively simple, but how would you generate it? On a smaller scale: I made it using a 1D cellular automaton with a four cell neighborhood: ...
  • 987
-4 votes
3 answers
394 views

Bartenders' beer-table error-correction code

At a pub, a friend spotted our table number being 412; there were nowhere near 400 tables. We mused if it could include a checksum so the bartender could tell if customers gave an invalid number. I ...
  • 341
4 votes
3 answers
930 views

What numbers fill the blanks in 3*3 grid? [closed]

I have a puzzle that I did not know how it could be solved Which numbers should be filled on the blank spaces ? I only figure out that 4 + 20 = 24 and 1 + 20 = 21 then 8 + 20 = 28 I am not sure ...
  • 41
19 votes
1 answer
1k views

Mystery operation

In a future not so far way, Earth archaeologists find on a far away planet a fragment from a long lost civilization. This fragment involves an unknown operation *|*...
  • 4,452
12 votes
4 answers
7k views

How do I memorize parity algorithms for higher-order Rubik's cubes?

I know how to solve a Rubik $4\times4\times4$ or $5\times5\times5$ or bigger, but I have problem with a specific algorithm: the parity error. What's the shortest parity algorithm for $n\times n\times ...
  • 685
5 votes
3 answers
484 views

Place 16 queens in a $16\times 16$ board peacefully, also in subboards!

What is the smallest number, $n$ in which $n$ queens can live in a $n\times n$ board peacefully? Of course not more than 8. ☺ (read about the eight queen puzzle) But this was not the question. ...
1 vote
2 answers
533 views

Calculating column number based on Excel alpha column reference [closed]

Here's a super fun brain teaser!!! Can you give me a mathematical equation to calculate the column number of a Microsoft Excel column, given the alphabetic column reference? Let X, Y, & Z ...
  • 23
1 vote
1 answer
10k views

Check sudoku solvability

With a blank grid, I put and number (1-9) any cell, the Sudoku has n solutions. I continue filling any blank cells with numbers that satisfy the constraints, so the Sudoku still has many solutions, ...
  • 127
3 votes
3 answers
2k views

Sorting 4 numbers using "maximum" & "minimum" between 2 numbers

I'm having some trouble solving this thing. You're given an unlimited number of "black boxes" which will return the maximum or the minimum between 2 inputs. The goal is to compare/sort 4 numbers ...
  • 133
-4 votes
2 answers
113 views

Last number in barcode [closed]

Find solution, how work algoritem for last, control number in 8 places barcode. Here is some results: Here we got last number 8 Here we got last number 7: Here we got last number 5 What is last ...
  • 141
10 votes
1 answer
525 views

Half-reverse operation on binary strings

Is there an algorithm that you can apply twice to an input string of $0$s and $1$s in order to reverse it? In other words, is there a function $f : \mathrm B \to \mathrm B$ on the set of binary ...
  • 2,405
1 vote
0 answers
149 views

Rubik's Cube Master Algorithm [duplicate]

I've been thinking about this question for a while, but I have no idea how to approach it. I don't know what the answer is. The question: What is the shortest finite set of moves that, when repeated,...
  • 1,428
6 votes
1 answer
283 views

Placing markers in grid and minimize similarity of rows

Imagine a game on a grid of $m$ rows and $n$ columns. Player One will place a fixed number $r$ of markers in each row. Player Two will select the two rows which maximize the number of columns having ...
  • 1,339
3 votes
1 answer
617 views

How do I solve this F2L case quickly?

I have been unable to find a solution for this F2L case. It takes about 3 seconds to do, and I do it really slowly. Basically, the F2L case is solved, but the edge is inverted. The way I do it right ...
23 votes
2 answers
1k views

Desegregate the Knights

You are given a 3 by 3 chessboard with a knight on each corner, where the knights in the top row are black and in the bottom row are white. On each turn, you may move a knight of either color (the ...
  • 31.7k
31 votes
5 answers
7k views

Switch The Knights

On a small $ 4 \times 3$ chessboard, the top row is filled with black knights and the bottom row with white knights. On each move, you may move one knight (as it moves in chess) to an unoccupied ...
  • 31.7k
26 votes
1 answer
3k views

Is there an algorithm to decide that the nonogram puzzle is unique

A good nonogram puzzle has a unique solution. However, some nonograms do not. For example, this puzzle: ...
  • 584
11 votes
4 answers
307 views

Rank the Fencers

There are five fencers. Each has a particular skill level, all of which are different. When two fencers duel, the one with the higher skill level always wins. How many duels do the fencers need to ...
  • 31.7k
28 votes
7 answers
2k views

23 Clones and Two Lightbulbs

Rise and shine, Mister Bond. James awoke to find himself yet again imprisoned by an evil genius. At least, that's what he presumed. He was alone in a room with a strange device: it consisted of a ...
  • 31.7k
3 votes
2 answers
3k views

Algorithm for a single diagonal on each face of the Rubik's Cube

Right now I am trying to get the following distorted position: On each face only one diagonal is solved and the rest of the cubes are a different colour than the diagonal. For example: If I am ...
  • 133
3 votes
2 answers
1k views

Strategy for getting out of Hedge maze?

I often wonder: suppose I wake up one day and find myself in a maze of Hedges, like the one in "The Shining", what is the best strategy to get out of it? We can assume we have sunlight or a torch if ...
8 votes
2 answers
236 views

How to beat "Strata"?

Recently I purchased a bunch of mobile puzzle games for my iPhone and one of them was the famous top-rated app "Strata" by Graveck. The rules are simple - you begin with an $n \times n$ board, some ...
  • 6,924
12 votes
2 answers
1k views

Let's deal with "Names in Boxes" Safely

I met a puzzle, which is basically well known 100 Prisoners' Names in Boxes , but... it has an algorithm, which gives prisoners 100% chance to survive! This is achieved by a small change in the ...
  • 16k
2 votes
2 answers
323 views

Closing taps (generalisation) [closed]

You have a tanker that can hold any amount of water. You have $n$ taps that either let in or let out water. The rate of flow of water (in $ml/min$) for each tap is given by $f_n$ (positive for inflow, ...
0 votes
1 answer
295 views

This code shouldn't be working [closed]

Today I wrote some C# code to generate all subsets of a set. It all worked correctly but then I realized about I'd made a rookie mistake. The puzzle here is not that the code is not working but rather ...
9 votes
3 answers
411 views

A problem of inequalities

The puzzle Given a set of numbers $\{1,2,\ldots,n\}$ and an expression of inequalities, e.g., $ x_1 > x_2 < \cdots > x_n$. Prove that there always exists a solution such that $x_i \in \{1,2,\...
14 votes
6 answers
2k views

Radioactive Rods

You have 8 identical looking rods, 2 of which are radioactive, though you don't know which. You also have a box which can test for radioactivity, which can hold any number of rods. After the test, the ...
  • 31.7k
7 votes
1 answer
378 views

Avoiding Incest and Intergenerational Mating

On the planet of Caturn, God created $m$ male cats and $f$ female cats, each with zero stripes. At any time, two cats of opposite genders can mate, giving birth to a cat with a gender of the parents' ...
  • 31.7k
12 votes
2 answers
647 views

Maze Solving Robot, More Difficult Variant

You are trying to design a maze solving robot, capable of solving "valid" mazes. A valid maze is an 8 by 8 checkerboard, surrounded by walls, where Between each pair of orthogonally adjacent squares, ...
  • 31.7k
21 votes
4 answers
1k views

Checkerboard Infection: The Aftermath

As in this previous puzzle, we are again playing with our favorite bacteria, C. Coli, whose natural habitat is an 8x8 checkers board. These are very nasty bacteria - once they are in a cell of a ...
  • 7,781
12 votes
2 answers
441 views

Cubical Infection

You may remember the C. Coli bacteria, which infects checkerboard squares. There is a similar disease which plagues cubes, known as cubic lice. Once a cube gets infested with cubic lice, it will be ...
  • 31.7k
22 votes
4 answers
4k views

Checkerboard Infection

There is a dangerous bacteria, Checkerichia Coli, (or C. Coli for short) which lives in the squares of checkerboards. Squares with this bacteria living in their digestive systems are said to have &...
  • 31.7k
23 votes
6 answers
5k views

Maze Solving Robot

Archie the archeologist has discovered an Egyptian temple, and plans to send in a robot to explore it. He uncovered the ancient engineers' papyruses which explain almost everything about the temple's ...
  • 31.7k