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
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 ...
16 votes
4 answers
2k views

Magic: the Gathering – Scry-sort

Let me start with a formulation of the problem for people who aren't familiar with Magic: the Gathering. You have a stack of distinct cards face-down. You can apply the following actions arbitrarily ...
9 votes
3 answers
862 views

Minimum number of flips needed to fully set a binary string

Source: My school teacher, it was just given as a problem statement. Problem: You are given a binary sequence $S$ of up to $10^6$ bits. You wish to set all the bits in the string to $1$, but the catch ...
1 vote
3 answers
2k views

Is my 5x5 cube in an "illegal" position?

I've never seen this position before. I'm starting to think it's an "illegal" one because I lent it to a friend and he said he had to glue some fallen stickers. Am I missing an algorithm or ...
13 votes
1 answer
1k views

1+3 Towers of Hanoi

There are four pegs in a row; let's call them A, B, C, and D from left to right. Peg A has a stack of $n$ differently sized disks, sorted in size so the smallest disk is at the top. All other pegs are ...
0 votes
0 answers
73 views

Heuristic function for estimating nurikabe puzzle state

I am trying to write a program for solving nurikabe puzzle. I need a method to approximately represent the state of the game in one number, to choose the best way for the algorithm to continue. I can'...
-2 votes
1 answer
172 views

Deciding whether a set of points on a 2D plane has axial symmetry [closed]

The problem to solve: Let's say we have a set of $n$ points on the 2D plane. Determine whether it has axial symmetry. My attempt so far: For n=2 the answer is trivially "yes". For n=3 ...
29 votes
12 answers
13k views

What's the optimal strategy for Wordle?

Wordle is a game by Josh Wardle in which you try to guess a 5-letter word in at most six attempts. After each guess, the letters which are not in the word are highlighted in grey, the letters which ...
-4 votes
2 answers
957 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 ...
2 votes
1 answer
193 views

stuck at robozzle 1251

Can anyone help me solve this robozzle? It is called bigPlus id 1251 http://www.robozzle.com/puzzle.aspx?id=1251
5 votes
0 answers
251 views

Longest Fibonacci word

Fibonacci words are defined as $F_0 = a, F_1 = b, F_{n+2} = F_nF_{n+1}$ where $a, b$ are letters. How can you find the longest Fibonacci sub-word in a given string? Try to solve it in linear time ($O(...
9 votes
3 answers
1k views

Algorithm for creating a "Dot" logic maze

I've been looking at Robert Abbott's logic mazes, in particular his Dot maze, and I'm trying to understand how they can be constructed so I can write an algorithm to do this automatically for ...
1 vote
1 answer
206 views

Reversing a binary string with a restricted Turing Machine

Some malevolent entity (me) asks you to construct a Turing Machine which, given an input on its tape of the form $LbR$ where $b$ is some binary string, changes this to $Lb^{-1}R$ then halts (where $b^{...
9 votes
1 answer
1k views

Cube Scrambling

Take a normal 3x3 rubiks cube (the Classic unmodded cube). I know the WCA method for scrambling is to pick a random (valid) cube state and calculate a sequence of moves to go from solved to that state,...
3 votes
2 answers
823 views

How does a common person solve impossibly hard truthteller/falsifier questions?

How does one solve the World's hardest puzzle, and other questions of the type? Is there a proper approach to such a question, or does one just have to be incredibly smart to do so? And here's an even ...
5 votes
1 answer
334 views

Nuts and screws

Imagine that you are given a box with n nuts and n screws. Each screw have different size (diameter) and on each screw there is ...
6 votes
1 answer
665 views

Cable with mixed wires

Let's say you have a cable that has n wires. Each wire on the left side corresponds to one wire on the right side. However you cannot distinguish between the wires ...
5 votes
2 answers
11k views

Rubiks Cube 4x4x4 Top Layer Issue - One Edge Pair Flipped

I have trouble with that edge. Please give algorithm or images for solutions for turning it up so that I can form a cross.
2 votes
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 ...
6 votes
1 answer
6k 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 ...
1 vote
1 answer
557 views

Solving Robozzle puzzle

I have a problem with solving the "Dispersion V2" puzzle on robozzle.com: The puzzle has a robot that can be moved and turned with a program. The goal of the puzzle is to have the robot ...
user avatar
26 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 ...
1 vote
1 answer
485 views

Help with solving 7x7 sub-centers inside 11x11x11 Rubik's cube -- errors in guide book

[companion question here] I was given an 11x11x11 Rubik's cube as a gift. It came with a guide book that I have been following to solve the cube. After solving four of the 9x9 sub-centers of the cube,...
1 vote
1 answer
143 views

Help with solving 5x5 sub-centers inside 11x11x11 Rubik's cube -- errors in guide book

[companion question here] I was given an 11x11x11 Rubik's cube as a gift. It came with a guide book that I have been following to solve the cube. I have solved four of the 9x9 sub-centers of the cube,...
17 votes
17 answers
2k views

The dessert problem (blind ballot remaining blind if non-unanimous) [closed]

A group of (possibly over-polite) people have just finished their meal at a restaurant. One of them asks, "Does anyone want dessert?" The table goes quiet. Some of the people might want ...
1 vote
1 answer
183 views

Panini Linguistics Olympiad: Genes from Space

Problem: Alien Protein Codes Dr. Muzabique figured out how to manipulate six alien proteins to do three functions: construct, cut, and pack. The alien genetic code used to manipulate the proteins was ...
3 votes
1 answer
189 views

Which sentences in S := {"the number of lies in S is a multiple of n" | n = 1,...,120} are true in every possible non-contradictory case?

Consider the set $S := \{$ "the number of lies in the set $S$ is a multiple of $n$" $|$ $n = 1, 2, 3, ... , 120 \}$. Question: Which elements/sentences in the set $S$ are true in every ...
1 vote
1 answer
237 views

Mastermind algorithm but for unique colors only

I have seen Donald Knuth's Algorithm to guess the correct pattern in maximum 5 tries. However, I want to write a program to find the correct pattern effectively however the code maker can only make a ...
5 votes
1 answer
2k views

Orientate the centers of a Master Pyraminx (Pyraminx 4x4)

I have a very strange state on my 4x4 Pyraminx. The green side is solved and the other sides are almost solved, the problem is, on these 3 remaining sides the centers are not solved. The state looks ...
0 votes
1 answer
214 views

General Fake Coin: k fake coins out of n coins

Considering a general fake coin problem. There are $n$ coins in total and $k$ of them are fake. Fake coins are lighter than the normal ones. You only have a balance to compare two groups of coins (no ...
8 votes
5 answers
2k views

Minimum cells to fill grid without consecutive neighbours

Imagine you have a m x n grid which is initially colored white. you can fill in a cell with black color if and only if there are no immediately neighboring black cells (no black cells to the left/...
8 votes
1 answer
264 views

O princess, where art thou?

In the highest tower of her castle, a princess has N bedrooms which are arranged in a circle. She never sleeps in the same room on two consecutive days. Every morning she moves to another room by ...
16 votes
1 answer
838 views

Exterminating blobs on a grid

On an infinite square grid, some of the squares are occupied by little creatures called blobs. Cute as they are, it is your mission to exterminate all of them! You only have two methods at your ...
10 votes
2 answers
832 views

Two dimensional Mastermind

You have probably played the classic game of Mastermind with 4 pegs and 6 colours. It turns out that the codebreaker can always find the pattern in 5 moves or fewer. Now consider the 2D version of the ...
5 votes
4 answers
593 views

Algorithm to make two scrambled Rubik's cubes be exactly the same on all faces

There are millions of Rubik's cube combinations possible. If I have two 3×3 Rubik's cubes and both are scrambled, I want to make one scrambled cube exactly the same as the other without solving them. ...
2 votes
1 answer
262 views

How can the princess escape the prince?

This is the story of the sister of the princess in this puzzle. I will shamelessly copy-paste some parts of this post. I have no reference to give for this version as I adapted a Computer Science ...
25 votes
3 answers
10k views

A general solution to the decanting problem? (aka jug-pouring, water-pouring)

Take a look at these two questions: - A Set of Water Jug Challenges - Pouring problem Now I'm asking for a generalised solution to that problem. I define the problem as follows: You are required ...
2 votes
2 answers
367 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 ...
4 votes
1 answer
158 views

Copy that solution

This copy machine program prints the solution to a well-known puzzle.  Explanation of the syntax will follow. What solution will be printed for which well-known puzzle?  EXECUTION CODE .--> ...
7 votes
1 answer
356 views

$4\times4\times4$ Rubiks cube Top Layer Issue

The only way i am able to solve is to jumble the whole cube again. If you know the way to solve pls give images or algorithm.
1 vote
1 answer
391 views

Find the hidden message in... this grid

(So I made this puzzle, and I wanted it to be fun rather than difficult! I hope it’s original enough) Given a 5x5 grid as input, here’s an algorithm: randomly select any 3x3 grid within the 5x5 grid ...
11 votes
1 answer
2k views

Worst way to solve Rubik's in one algorithm

If you apply the same algorithm over and over again the cube will be solved. I want to know what algorithm is the worst one (the one with the longest cycle) I have found RU (cycle of 60 times) I have ...
5 votes
1 answer
347 views

Brute-force solver for Gear Octahedron - flawed method?

I am working on a program to brute-force a LanLan Gear Octahedron I bought second-hand (and scrambled). I have no background in "cubing" and just fancied solving the problem. The structure comprises ...
2 votes
1 answer
319 views

Looking for an old Rubiks cube algorithm

I learnt rubiks cube before the YouTube days from a blog. I do not find the algorithm anymore online but it is something like White cross White corners (except one) Second layer corners (except one) ...
3 votes
1 answer
233 views

Reapply *some* stickers on scrambled cube

I have this weird cube which have some pieces printed on the plastic and some are detachable. The cube was scrambled not solved and it fell on the floor being cheap cube almost all detachable faces ...
5 votes
2 answers
2k views

Oriented Rubiks Cube 4x4 re-arrange center pieces

There are a lot solutions for oriented 3x3. They rotate all center pieces. I'm trying to solve oriented 4x4 with GabbasSoft Cube Demo. Luckily blue and green ...
2 votes
1 answer
1k views

What is the next method after 3-style in 3x3 Blindfolded? [closed]

I have been using the method 3-style for over 2 years, 3-style and I have settled in the range of 25-30 seconds. I wish to permanently become sub-20, and for that I am planning to undertake the uphill ...
6 votes
1 answer
432 views

How to discover twisty puzzle algorithms that are not commutators?

I am reasonably competent at using commutators to find my own algorithms on twisty puzzles. Many good tutorials for this exist online. However, there are also algorithms that are not commutators, ...
5 votes
1 answer
18k views

Programmatically solving a math puzzle with four unknowns and four equations

I have this puzzle and I want to solve by code. I wrote simple code trying to brute force but it fail in one condition https://dotnetfiddle.net/cJyu3w How can I solve such problems?
12 votes
1 answer
796 views

Transform each square of a chessboard to zero

Each square of an 8x8 chessboard is marked with a positive integer. The integers can be changed according to the following two rules: (1) all integers in a row are doubled (2) all integers in a column ...