Questions tagged [optimization]
For challenges focusing on the optimization of an aspect not covered by other tags. (not a winning criterion)
154 questions
18
votes
3
answers
993
views
Cancel and minimize game
Here is a game: Start with the set {1,2,3,...,n} of natural numbers. At any turn of the game, you may pick two numbers from this set, a and b, then replace them with their product a*b. Since it is a ...
17
votes
6
answers
2k
views
When is my coworker's next birthday?
inspired by this post.
Consider 2 coworkers who work Monday - Friday, every week of every year, with no breaks or national holidays.
On day n (day, month and year), worker 1 asks worker 2 their ...
22
votes
2
answers
2k
views
Fast leap year check
The task is to find parameters that make a fast leap year check correct for the widest range of years.
We assume the Proleptic Gregorian calendar, which extends the Gregorian calendar backward from ...
0
votes
2
answers
292
views
Smashing Dominoes [closed]
Challenge
This challenge is based on the domino effect:
Initially, each domino is located on one straight line and is in a vertical state. It can be dropped either to the left along the same straight ...
4
votes
5
answers
1k
views
What is the smallest possible binary output you can generate
Here is a challenge:
What is the shortest possible compiled program? Writing one line programs are fun, but they often lean on language libraries that get pulled into the final bits. How lean can you ...
17
votes
19
answers
6k
views
The Dating Game / Secretary Problem
The bots are looking for love. Can you help them?
The rules
The goal of this game is find the bot you have the highest compatibility with. However, robots, who are inexperienced at dating are unable ...
6
votes
2
answers
1k
views
Optimal strategy to defeat the wizard
In this game, you can look inside one box at a time chosen by you. When you do that, you can see how many coins there are in that box.
The wizard has one last twist for you. At any point, you can ...
6
votes
1
answer
2k
views
fastest matrix multiplication on x86
This challenge requires integration with C, so you can stop reading if you're not interested.
Matrix multiplication is a simple operation, but the performance depends a lot on how efficiently the code ...
19
votes
8
answers
2k
views
Optimally break a string into words
Given a string, like potatocarrot, break it into the smallest number of substrings possible. These substrings can consist either be a single character, or one of a ...
15
votes
12
answers
2k
views
Satisfy as many people as possible
There are times when a large number of people need to choose something. They all want to get the stuff they choose, obviously, but it's impossible to please everyone that way, so a usual compromise is ...
22
votes
4
answers
812
views
Egyptian fractions summing to n
An "Egyptian fraction" is a list of distinct fractions with a numerator of \$1\$. For example:
\$
\frac 1 1+ \frac 1 2 + \frac 1 3 + \frac 1 6
\$
The "size" of an Egyptian ...
32
votes
10
answers
5k
views
Who Is Kevin Bacon?
You may know the game The Six Degrees of Kevin Bacon, based on the conjecture that every actor in Hollywood can be connected to Kevin Bacon by no more than 6 "co-star" relations, so Kevin ...
26
votes
27
answers
3k
views
Hunt for discount
Story
My local pizza delivery introduced new discount. You get 50% discount from every second item on your order.
But being greedy capitalists, they forgot to mention that they will rearrange items ...
18
votes
7
answers
1k
views
Square root multiples
This code-challenge is based on OEIS sequence A261865.
\$A261865(n)\$ is the least integer \$k\$ such that some multiple of \$\sqrt{k}\$ is in the interval \$(n,n+1)\$.
The goal of this challenge is ...
2
votes
0
answers
79
views
Find two contiguous subarrays with the greatest difference [closed]
Here's an interview question I've seen on a few sites. People claim that an O(n) solution is possible, but I've been racking my brain these last 2 days and I couldn'...
19
votes
1
answer
1k
views
Gerrymander North Carolina
The challenge
How well can you gerrymander North Carolina into 13 voting districts?
In this challenge, you use the following files to draw different maps for Republicans and Democrats.
File 1: ...
18
votes
1
answer
1k
views
Sort with a neural network
The previous neural net golfing challenges (this and that) inspired me to pose a new challenge:
The challenge
Find the smallest feedforward neural network such that, given any 4-dimensional input ...
18
votes
14
answers
2k
views
Permutations in Disguise
Given a \$n\$-dimensional vector \$v\$ with real entries, find a closest permutation \$p\$ of \$(1,2,...,n)\$ with respect to the \$l_1\$-distance.
Details
If it is more convenient, you can use ...
6
votes
1
answer
712
views
Multiplication in Brainfuck - minimum number of evaluations [closed]
Given two numbers in tape location #0 and tape location #1 in Brainfuck, compute their product into another tape location (specify with answer). Optimize for the least amount of time-units used, where ...
31
votes
2
answers
1k
views
Can a neural network recognize primes?
Background
Recognizing primality seems like a poor fit for (artificial) neural networks. However, the universal approximation theorem states that neural networks can approximate any continuous ...
17
votes
3
answers
1k
views
Plight of the Concorde
Background
The traveling salesman problem (TSP) asks for the shortest circuit that visits a given collection of cities. For the purposes of this question, the cities will be points in the plane and ...
16
votes
3
answers
587
views
Optimize my wings order
This tweet lists the possible orders for Wings of a Chinese restaurant1:
When ordering Pizza I usually calculate what size gives me the best Pizza-price ratio which is a simple calculation. However ...
26
votes
2
answers
1k
views
Optimize Compiler for simple Reverse Polish Notation Programming Language
Description
Imaginary programming language (IPL) uses Polish Reverse Notation. It has the following commands:
i -- input number and push it to the stack
o -- non-destructive output top of the stack (...
21
votes
11
answers
2k
views
Fruit bagging factory
Your mission is to build an algorithm (program or function) that can optimize packing fruit from a conveyor belt into bags to be sent off to retailers, optimizing for a largest number of bags.
Each ...
11
votes
2
answers
598
views
Egg hunting in Collatz style
Inspired by The Great API Easter Egg Hunt!
Summary
Your task is to search for a predetermined integer in the "Collatz space" (to be explained later) using the fewest step possible.
...