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.

160 questions
Filter by
Sorted by
Tagged with
70 views

Disguising a Rubik's Cube rotation

I'm wondering if there's a way to disguise the total rotation of a Rubik's Cube? For example, if I wanted to rotate the (solved) cube I could obviously just apply a 90 degree yaw rotation. However, I ...
226 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 ...
794 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 ...
• 31.4k
117 views

Balance Puzzle Find at most 2 counterfeit coins out of anywhere from >=3 # of coins

2 fake coins from a pile of 30 coins The real coins all weigh the same, and the fake coins weigh the same. The fake coins weigh less than the real coins. The difference in the one I am trying to solve ...
11k 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 ...
1 vote
182 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 ...
• 183
396 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. ...
129 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 .--> ...
• 21.4k
1 vote
211 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 ...
741 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 ...
• 25.8k
770 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 ...
• 11.5k
263 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 ...
1 vote
130 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 (...
• 111
69 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 ...
• 141
122 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 ...
• 183
145 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' ...
• 121
922 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. ...
• 31
156 views

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$ $\... • 5,557 7 votes 0 answers 186 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 ... • 6,596 12 votes 1 answer 380 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 ... 1 vote 1 answer 122 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 ... • 4,074 2 votes 1 answer 290 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 ... • 1,691 3 votes 1 answer 1k 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 ... • 25.8k 2 votes 1 answer 3k 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 ... • 25.8k 12 votes 3 answers 1k 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 *, ... 2 votes 1 answer 222 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 ... 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. ... • 133 2 votes 2 answers 328 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, ... 13 votes 1 answer 563 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 ... • 133 6 votes 1 answer 159 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? • 291 4 votes 1 answer 229 views Cutting a Rectangular Board There is an$m \times n$rectangular board drawn on a graph paper. You need to cut it into$mn1 \times 1$squares by straight cuts along the grid lines. You are allowed to stack several pieces ... 4 votes 2 answers 205 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 ... • 4,733 4 votes 2 answers 1k 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 ... 9 votes 5 answers 275 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$? ... • 4,733 5 votes 1 answer 787 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 ... 7 votes 3 answers 636 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 ... 4 votes 2 answers 367 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 ... • 2,105 6 votes 2 answers 176 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 -... • 2,105 3 votes 2 answers 367 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 ... • 2,105 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 ... • 2,105 5 votes 1 answer 16k 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? • 53 5 votes 2 answers 151 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 ...
1k views

You are cooking pancakes for your lovely wife. You want to sort the pancakes such that they increase in diameter as you move from the top to the bottom of the stack. The only operation you can perform ...
• 25.8k
1 vote
522 views

Move all the stones into a single cell of a 3x4 grid

A 3x4 grid contains a heavy stone in each cell. Walking from a cell to an adjacent cell (horizontally or vertically) without any stones requires 1 second. Moving one stone from a cell to an adjacent ...
• 25.8k
2k views

Emoji primes - what's the smallest positive integer this doesn't work for?

Driven by a silly conversation at work, here's the puzzle. Slack allows users to send emoji as a reaction to a message. Emoji are listed left to right in chronological order of reaction, and 'stacks' ...
• 247
167 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 ...
193 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) ...
• 185
313 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 ...
• 153
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 ...
• 291