Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [fewest-operations]

Fewest operations measures the number of specified "operations" performed at run time, and not the amount of operations used in the source code.

Filter by
Sorted by
Tagged with
25 votes
7 answers
2k views

Find the Cheese

Update: There are 6 mazes. They are included in the controller. There is a tar.gz of the mazes and their .bmp files here (dropbox). There is also a utility for making more mazes at that link (the ...
Liam's user avatar
  • 3,215
23 votes
2 answers
967 views

Optimize sorting, using "Sub-vector reversals"

This is a fewest-operations challenge where the objective is to sort a vector into ascending order using the fewest reversals. Your algorithm can only sort the vector using "sub-vector reversals"1, ...
Stewie Griffin's user avatar
22 votes
9 answers
5k views

Fastest algorithm to take the product of all subsets

Given n numbers in an array (you can't assume they are integers), I would like to compute the product of all subsets of size n-1....
user avatar
22 votes
3 answers
3k views

Factoring a 64-bit integer

Write a GOLF assembly program that reads an integer from stdin (followed by a trailing newline), and outputs its prime factors seperated by newlines, followed by a trailing newline on stdout. The ...
orlp's user avatar
  • 39.1k
20 votes
4 answers
620 views

Identify a string from its substrings

Introduction I've previously created two challenges where the idea is to reconstruct an object using as few query-type operations as possible; this will be the third. The task Your inputs shall be ...
Zgarb's user avatar
  • 42.7k
18 votes
1 answer
411 views

Know a sequence by its subsequences

Introduction Suppose you and your friend are playing a game. Your friend thinks of some particular sequence of n bits, and your task is to deduce the sequence by ...
Zgarb's user avatar
  • 42.7k
17 votes
1 answer
447 views

Fewest disk writes to defrag multiple files

Introduction A disk is a linear container with blocks indexed 0 through size-1. A file is a named list of block indexes used ...
spraff's user avatar
  • 891
17 votes
0 answers
577 views

GOLF CPU - Implement Arbitrary Precision Integer Division [closed]

This question was inspired this question and @orlp's comment and a lot of the explanation was copied from there. Write a GOLF assembly program that given two arbitrary size decimal integers ...
Maltysen's user avatar
  • 25.7k
16 votes
4 answers
670 views

Testing if a number is a square

Write a GOLF assembly program that given a 64-bit unsigned integer in register n puts a non-zero value into register s if ...
orlp's user avatar
  • 39.1k
16 votes
3 answers
1k views

Reconstruct a Permutation

Introduction Suppose that you are handed a random permutation of n objects. The permutation is sealed in a box, so you have no idea which of the ...
Zgarb's user avatar
  • 42.7k
16 votes
4 answers
1k views

An optimization challenge with strange coins

You have n coins which each weigh either -1 or 1. Each is labelled from 0 to n-1 so you can ...
user avatar
15 votes
2 answers
2k views

Shortest Algorithm* That Generates a Harlequin Pattern

What is the shortest sequence of moves that, from the solved state of the cube, creates a pattern that meets the following criteria: 6 colors on each face at most 2 facelets of the same color no ...
q-l-p's user avatar
  • 293
15 votes
2 answers
713 views

Image Hide-and-Seek

In this challenge, you need to find a specific pixel within an photograph (taken with a real camera). You are passed an (R, G, B) tuple and an image, and you need to return a point (x,y) within the ...
Nathan Merrill's user avatar
14 votes
2 answers
557 views

The GOLF CPU Golfing Challenge: Prime Partitions

This challenge is the first of a series of fewest-operations problems that should be written in the GOLF CPU. You can find the next one here A partition of a number, ...
Nathan Merrill's user avatar
8 votes
3 answers
687 views

Egg dropping contest

Your challenge: You are on the 0th floor of a infinitely tall building. At any floor, you can walk to the window and drop an egg. Your goal is to figure out the highest floor that the egg can ...
Nathan Merrill's user avatar
5 votes
2 answers
335 views

The GOLF CPU Golfing Challenge: Sides of a Cuboid

This challenge is the second of a series of fastest-code problems that should be written in the GOLF CPU. You can find the first here For this problem, you are given the volume of a cuboid (A ...
Nathan Merrill's user avatar
3 votes
4 answers
1k views

Write the smallest possible code in x86-64 to implement the "<=>" operator

Languages, such as C++, have introduced a new comparison operator: <=>. This operator returns -1, 0, or 1† when comparing two items together: −1 means the ...
Alexis Wilke's user avatar