All Questions
Tagged with optimized-output or optimization
154 questions
18
votes
3
answers
968
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 ...
16
votes
11
answers
2k
views
A million and one constants
When code golfing, it can be useful to write numbers succinctly. This challenge involves using a source language to generate code for a target language. For the submission to be valid, it must ...
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 ...
12
votes
3
answers
580
views
Galton Board optimization
Imagine an infinite symmetrical triangle of pegs, where the rows have size 1, 2, 3, ... (similar to Pascal's Triangle). All the pegs are red apart from k (your ...
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 ...
14
votes
5
answers
747
views
Sum-of-four-squares grid
Output a grid of characters visualizing the decomposition of a number into a sum of four perfect squares.
Challenge
Given a nonnegative integer \$0 \le n \le 2^{30}\$, output a \$2^k \times 2^k\$ ...
0
votes
2
answers
289
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
1
answer
675
views
Which line is best?
Consider an \$n \times n\$ grid of integers. The task is to draw a straight line across the grid so that the part that includes the top left corner sums to the largest number possible. Here is a ...
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 ...
1
vote
0
answers
229
views
DP approach gives TLE [closed]
There is a question to basically find the largest sum in an array, such that no two elements are chosen adjacent to each other. The concept is to recursively calculate the sum, while considering and ...
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 ...
3
votes
0
answers
220
views
I'm really cold and my heating is broken! Please write a rust or python program that will heat my laptop up [closed]
I'm working from home and the heat of my laptop on my lap is the only thing keeping me warm. I have a Dell G3 Laptop with an NVidia GEForce GTX CPU.
I have tried writing a rust program with 5 threads ...
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 ...
4
votes
0
answers
311
views
Find the best character arrangement
You want to write your English essay. However, all characters on your keyboard broke other than the arrow keys and the enter key. You want to find out how to place the characters so you can write your ...
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 ...