Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [algorithm]

A puzzle related to algorithmics (a main concept in computer science).

22
votes
8answers
947 views

Wolves and sheep

All the sheep were living peacefully in the Land of Shewo. But suddenly they were struck by a danger. A few wolves dressed up as sheep entered the territory of Shewo and started killing the sheep one ...
15
votes
5answers
625 views

Blindfold Bingo

Congratulations, you have been selected from among the audience to compete in the fabulous Blindfold Bingo challenge! (cue annoying, yet catchy theme music.) Here you see our perfectly ordinary Bingo ...
27
votes
7answers
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 ...
5
votes
2answers
154 views

Find the result of this dual key cipher

I came up with a neat little cipher that I'm calling the dual key cipher. The basic premise is that there are two cipher keys that, when used together can decode the cipher text against a given ...
3
votes
2answers
130 views

The fantastic matrix

Here's another question that I have been asked in an interview lately. Let $M$ be an $n × n$ matrix whose values are $”+”$ and $”-”$. M is called fantastic if it is possible to make all it's values $”...
9
votes
1answer
244 views

Scoring Oracle: Bob easily wins, but how much?

Bob meets a magician with two bags and a chest on a bridge. The magician challenges him with the following enigma: Here is a bag A, holding 5080 pebbles. Here is another bag B. Most of the pebbles ...
4
votes
4answers
253 views

Weighing Counterfeit coins

There are $n=4$ coins and we know exactly $2$ of them are counterfeit. In $2$ weighings, how can we find which of the four coins are the counterfeit ones? Assumptions: the counterfeit coins look ...
7
votes
3answers
104 views

Creating a maze that is traversed by a pair of compasses

Normal mazes require you to move a point-like object from the entrance of the maze to the exit. I am wondering whether a different kind of maze would work as a puzzle: Imagine a maze printed on a ...
5
votes
3answers
208 views

Fill $N$ by $M$ grid with numbers in such a way that any given cells' neighbors are different

Create an $N$ by $M$ grid with numbers in such a way that satisfies following conditions: numbers should be integers that range from $1$ to $r$. for any cell $C$, all its adjacent neighbors (i.e. ...
4
votes
1answer
475 views

Generalisation of Nim

I'm asking for a general formula/algorithm that can be used in such a game. There are $n$ piles, with varying number of pebbles. The number of pebbles in each pile is given by an array from $pile[...
5
votes
1answer
107 views

Shortest path for delivering packages [duplicate]

A version of the Travelling Salesman Problem, but with certain points. We are talking about a town where 8 canals run from the middle boathouse into the city. You can only travel one way on the green ...
9
votes
1answer
225 views

Puzzles like Sokoban?

I am looking for some puzzles like Sokoban or 15-puzzle but more difficult to solve and satisfy the following requirements: The number of possible moves at each step should be limited, let's say < ...
10
votes
2answers
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 ...
13
votes
4answers
345 views

20-Questions on a grid

Posted this on /r/puzzles too, none have given the right strategy as of now :) There is a square grid of width and height $m$. Three facts about the grid: Each cell has a value, and no two cells ...
12
votes
1answer
666 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, ...
76
votes
7answers
17k views

Why does this solution guarantee that the prince knocks on the right door to find the princess?

I found this puzzle online: On the top floor of a castle lives a princess. The floor has 17 bedrooms arranged in a row. Each bedroom has doors connecting to the adjoining bedrooms as well as to the ...
7
votes
1answer
162 views

It's getting harder and harder for my friends to like me

What is the next number in this sequence? 2, 3, 6, 7, 9, 18, 25, 27, 54, 73, 97, 129, 171, 231, 313, 327, 649, 703, ... ? Hint 1 Hint 2 This is my first puzzle and I'm new to PSE, so feedback is ...
8
votes
4answers
412 views

Ten users, three lights but it's a chatroom

This is a variant of the classic problem of m prisoners n lights. (Example may be found here but note that the requirements are not exactly the same) The goal for you, however, is different. You want ...
2
votes
0answers
117 views

Ten users, ten deadly collars and three lights [duplicate]

One day, 10 puzzling.SE users, including you, find yourselves in a horrible prison. Each of you has a deadly collar, presently lethal. It is safe to take off only when all of the 10 collars have been ...
6
votes
1answer
174 views

A couples therapy mixer situation

During couples-group-therapy, where two therapist and multiple couples consisting of two people each are present and we all sit on chairs forming a circle in the middle of the room. We often discuss ...
10
votes
3answers
35k views

What is the Official notation on rubik's revenge(4x4)?

When solving a 4x4 cube you have specific notation to inner and outer lines, like R = Clockwise outer right and r = Clockwise ...
11
votes
3answers
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 ...
3
votes
1answer
86 views

How can these people cross the bridge? [duplicate]

There are 4 people that must cross an old dilapidated bridge at night, All four walk at different speeds: There is a young teenager that can cross the bridge in 1 minute. There is teenager's older ...
22
votes
7answers
5k views

Hacking an electronic keypad

You are a spy trying to break into an enemy facility. The back door is protected by an electronic keypad lock. You know that this particular lock is opened by a four digit code. Any stream of button ...
1
vote
1answer
268 views

Scheduling Meetings

I came across this problem in real life and thought it could be made into an interesting puzzle. I will enjoy seeing how my eventual solution could be improved! Here's the situation. There ...
1
vote
1answer
1k 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 ...
1
vote
1answer
199 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 ...
1
vote
3answers
599 views

Is my 5x5 cube on an “illegal” position?

I've never met this postion before, and i'm starting to think it's an "illegal" one because i lend it to a friend before and he said he had to glue some fallen stickers. Am i missing an alorithm or do ...
1
vote
0answers
204 views

Finding all possible solutions of a japanese sums puzzle

I'm trying to think of an algorithm that gives out all possible solutions to a japanese sums puzzle. It's not an a college assignment or anything, I'm giving puzzles to my cousin for fun, but want to ...
0
votes
1answer
249 views

Is there a name for this Rubik's cube algorithm?

$RUR'U RU2R'$ I use this algorithm to: permute UL and UF edges (messing up corners) orient LL from a fish (possibly using its mirror) orient pairs of LL corners by combining above algorithm with its ...
3
votes
2answers
228 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 ...
-4
votes
2answers
562 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 ...
0
votes
2answers
2k 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, ...
18
votes
4answers
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 ...
2
votes
1answer
129 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
1answer
212 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 ...
4
votes
1answer
2k views

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

So the complete conditions for this scrambled cube can be described alternatively as the following: Each face has less than 3 squares of the same color, which leads to 1a. Each face has 5 or 6 ...
1
vote
1answer
586 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 ...
7
votes
2answers
1k 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: ...
2
votes
1answer
417 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 ...
5
votes
2answers
4k views

Is there an algorithm for the Rubik's 360?

Is there an algorithm to help me solve the Rubik's 360? Usually I just do it at random, but I rarely succeed.
0
votes
5answers
479 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 ...
2
votes
1answer
307 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 ...
1
vote
2answers
274 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 ...
16
votes
5answers
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: ...
-4
votes
3answers
336 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 ...
4
votes
3answers
548 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 ...
10
votes
3answers
4k 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 ...
19
votes
1answer
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 *|*...
20
votes
2answers
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 ...