As of May 31, 2023, we have updated our Code of Conduct.

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
6 votes
1 answer
644 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 ...
popcorn's user avatar
  • 211
0 votes
1 answer
234 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
1 vote
1 answer
263 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,...
Abraham's user avatar
  • 141
1 vote
1 answer
101 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,...
Abraham's user avatar
  • 141
1 vote
1 answer
162 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 ...
MeltedStatementRecognizing's user avatar
18 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 ...
Mark Green's user avatar
3 votes
1 answer
186 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 ...
user avatar
1 vote
1 answer
191 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 ...
Mounir Zouhari's user avatar
5 votes
1 answer
790 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 ...
Missing User's user avatar
0 votes
1 answer
191 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 ...
picker's user avatar
  • 1
8 votes
1 answer
246 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 ...
SecretAdmirer's user avatar
15 votes
1 answer
819 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 ...
Mike Earnest's user avatar
  • 31.8k
28 votes
12 answers
12k 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 ...
EphraimRuttenberg's user avatar
1 vote
1 answer
212 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 ...
Nathaniel's user avatar
  • 183
5 votes
4 answers
525 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. ...
Mayur Garde's user avatar
4 votes
1 answer
146 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 .--> ...
humn's user avatar
  • 21.8k
1 vote
1 answer
323 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 ...
numdar335's user avatar
10 votes
2 answers
798 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 ...
Dmitry Kamenetsky's user avatar
12 votes
1 answer
781 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 ...
ThomasL's user avatar
  • 11.8k
4 votes
2 answers
266 views

All possible locations of a robot going from $(x,y)$ to $(x+y, y)$ or $(x,x+y)$ [closed]

Suppose I had a little robot on the coordinate grid that moves according to the following rule. If it's at the point $(x,y)$, it can move to either $(x+y,y)$ or $(x,x+y)$. If the robot starts at the ...
sirpuzzle's user avatar
1 vote
1 answer
152 views

Reverse Engineer Chess Software Calculations

TLDR Just the Puzzle Given a number n and a weight w the function f will result in a weighted number r as follows. f(n, w) = r n can be a number from 0 to 200 w can be a number from -100 to 100 (...
thinktt's user avatar
  • 111
4 votes
0 answers
70 views

Find the strategy: How to order without knowing [duplicate]

Imagine: You have a group of people in a room that is completely dark. Half of the group has red t-shirts and the other half blue t-shirts. The group gets told to think about a strategy to solve the ...
Lazloo Xp's user avatar
  • 141
-4 votes
1 answer
124 views

A simple two-operation calculator. How to obtain any natural number from any other?

Imagine that you possess a very simple electronic calculator. It has a screen and ten buttons from 0 to 9 to enter natural decimal numbers (positive integers). However, it can perform just two unary ...
Alexander's user avatar
  • 233
2 votes
1 answer
196 views

Is it possible to solve the Cube in a Cube in a Cube in a Cube state using its own algorithm on a 4x4?

So, I got curious if I could solve from the cube in a cube in a cube in a cube position to the solved state just using its own algorithm. This is the one I was using: B' 2R2 2L2 U2 2R2 2L2 B F2 R U' ...
Caters's user avatar
  • 121
3 votes
0 answers
2k views

The New York Time's "Letter Boxed" Puzzle (spoiler)

WARNING: I solved this puzzle and posted a solution below. I'm posting this more for muse. Hello! I don't know if anyone's enjoyed this puzzle on The New York Times website, but I find it rather fun. ...
Aaron's user avatar
  • 31
4 votes
1 answer
167 views

Constant puzzle

A constant is hiding behind this puzzle, can you tell which? 4 $\rightarrow$ 2 $\rightarrow$ 1 $\rightarrow$ 1 $\rightarrow$ 1 $\rightarrow$ $\dots$ ? $\rightarrow$ ? $\rightarrow$ ? $\rightarrow$ $\...
JKHA's user avatar
  • 5,971
9 votes
0 answers
209 views

Rolling dice in a box

A box containing identical dice that were arranged to have same orientation has a missing die at the center (see figure). The dice moves to the free space for they can change orientation and ...
TSLF's user avatar
  • 6,616
12 votes
1 answer
388 views

Infection (Information Dissemination) Puzzle

There are 2020 people in a room. One person has COVID. After each minute, each person $\mathrm{P}$ is paired with some other person $\mathrm{Q}$ who was never paired with $\mathrm{P}$ before, and they ...
PoissonSummation's user avatar
1 vote
1 answer
130 views

Minimise battle time in Monster's Den

So there is this excellent flash game, Monster's Den. In order to make a high score, I must complete many battles..this question is about battles with the Legendary Monsters. The target is to reduce ...
George Menoutis's user avatar
2 votes
1 answer
344 views

A robot moving on a grid

In the spirit the question I propose the puzzle: A robot is placed on a vertex of a grid. At each move the robot must take three steps along the edge of the grid. After each step the robot must turn ...
Nick's user avatar
  • 1,701
3 votes
1 answer
2k views

A robot visiting every edge of a 4x4 grid

This is a harder version of this puzzle: A robot visiting every edge of a 3x3 grid A robot is placed on the top-left vertex of a 4x4 grid. At each move the robot can take one step (up, down, left or ...
Dmitry Kamenetsky's user avatar
2 votes
1 answer
4k views

A robot visiting every edge of a 3x3 grid

A robot is placed on the top-left vertex of a 3x3 grid. At each move the robot can take one step (up, down, left or right) along the edge of the grid to the adjacent vertex, but he cannot go outside ...
Dmitry Kamenetsky's user avatar
12 votes
3 answers
2k views

Find Local Maximum in an Integer Sequence

An element of an integer sequence is called a local maximum if it is not smaller than all its neighbors. E.g., all local maximums of the following sequence are bolded. 3, * 4 *, 2, 1, * 3 *, 2, * 8 *, ...
Alexander S. Kulikov's user avatar
2 votes
1 answer
228 views

Based on 9-trains puzzle

Based on this problem, we have got some algorithms that can sort the 9 train cars in a given specific arrangement. But say if the 9 train cars are given in any-arrangement? Say ABC ABC ABC ...
Always Confused's user avatar
3 votes
1 answer
134 views

demystify and paint me!

To demystify me, look and say. Then paint me not with colors but with array. ...
coredump's user avatar
  • 133
2 votes
2 answers
392 views

Missing number in a set of four segment circles

This is a puzzle posted on a social networking site that I have been trying hard since yesterday to solve: My approach has been to find out a mathematical function with the numbers in the yellow, ...
Sharanya Dutta's user avatar
14 votes
1 answer
595 views

GameDev: stuck with first puzzle design, would love resources to study from or algorithm suggestions!

First time posting here and I'm really, really hoping this is the community I've been looking for. I'm developing a game, right now I'm in the middle of designing levels as the core mechanics have ...
Davide's user avatar
  • 143
7 votes
1 answer
213 views

Has Connect Four been solved on arbitrary board sizes?

Victor Allis in his program VICTOR used his algorithm for six by seven connect four, his algorithm has proven to give a sure win. Is it possible to have similar algorithm for x by y board?
pgp1's user avatar
  • 301
4 votes
1 answer
326 views

Cutting a Rectangular Board

There is an $m \times n$ rectangular board drawn on a graph paper. You need to cut it into $mn$ $1 \times 1$ squares by straight cuts along the grid lines. You are allowed to stack several pieces ...
Hassan Ali's user avatar
4 votes
2 answers
208 views

Minimum number of flips required to turn a sequence into alternating A and Bs

You are given this sequence composed of the characters A and B: A B B B A B B A A B A A B A A B A B A A A B B A B B B A At ...
melfnt's user avatar
  • 5,102
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 ...
Sergey Senkov's user avatar
9 votes
5 answers
292 views

An $n$-sided polygon with area $n$

Here is a $10$-sided polygon which area is $23$ (i.e. it contains exactly 23 unit squares). Can you draw a polygon with: $6$ sides and area $6$? $8$ sides and area $8$? $12$ sides and area $12$? ...
melfnt's user avatar
  • 5,102
5 votes
1 answer
830 views

Shift and Sort the Sequence [closed]

Given a permutation of integers 1 through N, we need to determine whether it is possible to sort this list in an increasing order by following certain conditions. The conditions imposed are : We are ...
Jason Todd's user avatar
7 votes
3 answers
704 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 ...
user avatar
4 votes
2 answers
407 views

The Genius Bank Robber

StackVille Bank & Trust - Robbed! The Robbery The bank is being robbed. There are millions in cash in the vault. The lone robber takes the manager to the safe and demands he opens it. The manager ...
John S.'s user avatar
  • 2,115
6 votes
2 answers
187 views

The Balls of Death

You have nightmares about a pool ball with the number 1 on it, and an empty box. Why? Immortality Imagine, if you will, we are 5000 years into the future. Medicine has evolved and we now are immortal -...
John S.'s user avatar
  • 2,115
3 votes
2 answers
380 views

The Marble Game

Johnny vs. Vinny As brothers, these two are competitive in every aspect of life. Just check out some of my other puzzles, and you'll see my brothers in action. Today is a classic Marble Battle! The ...
John S.'s user avatar
  • 2,115
11 votes
2 answers
2k views

Two Cannons - A Beginner's Physics Puzzle

Standoff Let's say we have two cannons aimed directly at one another ( as my horrible attempt shown in the image ). The Angles The cannon on top is aiming down towards the one on bottom right, and ...
John S.'s user avatar
  • 2,115
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?
Amjad's user avatar
  • 53
5 votes
2 answers
175 views

Determine a polynomial with nonnegative integer coefficients with minimum queries

A friend of us makes up a polynomial with nonnegative integer coefficients. Our task is to find it out with a minimum number of queries. For each query we give him a nonnegative integer $L$ and he ...
John Gregory's user avatar