All Questions

Filter by
Sorted by
Tagged with
15
votes
18answers
4k views

Floating Point XOR

Your task is pretty simple. Given two floats, bitwise xor the binary representation of them, and output that as a float. For example, ...
13
votes
11answers
761 views

Output Distinct Factor Cuboids

Output Distinct Factor Cuboids Today's task is very simple: given a positive integer, output a representative of each cuboid formable by its factors. Explanations A cuboid's volume is the product ...
8
votes
11answers
709 views

Olympic game scoring [closed]

The challenge is to write a golf-code program that, given n positive real numbers from 0 to 10 (format x.y, y only can be 0 or 5: 0, 0.5, 1, 1.5, 2, 2.5 … 9.5 and 10), discard the lowest and highest ...
16
votes
14answers
1k 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 ...
28
votes
24answers
6k views

Output a Super Mario Image

This is a problem on Luogu OJ. I decided to post it here because on Luogu OJ, many people, including me and my friend, are interested about how to solve this problem within the fewest characters. ...
20
votes
19answers
1k views

Some Prime Peerage

(Randomly inspired by https://mathoverflow.net/q/339890) (Related: 1, 2) Given an input list of distinct prime numbers (e.g., [2, 5, 7]), and a integer ...
17
votes
10answers
1k views

Write a function that returns an iterable object of all valid points 4-directionally adjacent to (x, y)

A very common need in algorithms classes and computer science in general is to iterate 4-directionally over a grid or matrix (such as in BFS or DFS). This seems to often result in a lot of clunky and ...
20
votes
40answers
3k views

Parallel resistance in electric circuits

Introduction: Two resistors, R1 and R2, in parallel (denoted R1 || R2) have a combined ...
3
votes
1answer
310 views

Find minimal set of rows to retain all unique values in each column

Given a matrix, the goal is to ensure all the values in each column occur at least once, while at the same time doing so requiring the least possible amount of rows. Fastest solution wins. Note: a ...
31
votes
29answers
5k views

Double it your way

There have been a couple of challenges involving doubling source code: here and here. The task we have here is a bit harder, but should be doable in almost every language. In this challenge, you will ...
4
votes
1answer
135 views

Wrong keyboard position [duplicate]

You are in fact writing an interpreter for the language "Wrong keyboard position". You can pretend that you are not doing this and just follow the instructions below. I typr re;atively accuratrly, ...
8
votes
7answers
630 views

Interpret Volatile

Interpret Volatile Volatile is a stack-based esolang made by A_ that only has 8 instructions and is turing complete. However, it is also non-deterministic... meaning that programs don't always give ...
4
votes
3answers
236 views

Write an interpreter for simplified 33

33 is a simple esolang I created. You may have seen me use it in a few questions. You're not going to be writing a full interpreter. The interpreter you will be writing is for a simplified version of ...
5
votes
22answers
579 views

Space Cleaners!

A space cleaner is a special character which removes all spaces between it and the first non space character to its left and it is represented by a '!' character. If it reaches the beginning of the ...
14
votes
8answers
1k views

Stage a Coup to become king of the hill!

Leaderboard ...
17
votes
8answers
1k views

Dividing Divisive Divisors

Given a positive integer \$n\$ you can always find a tuple \$(k_1,k_2,...,k_m)\$ of integers \$k_i \geqslant 2\$ such that \$k_1 \cdot k_2 \cdot ... \cdot k_m = n\$ and $$k_1 | k_2 \text{ , } k_2 | ...
31
votes
21answers
6k views

Random point on a sphere

The Challenge Write a program or function that takes no input and outputs a vector of length \$1\$ in a theoretically uniform random direction. This is equivalent to a random point on the sphere ...
21
votes
9answers
2k views

I see your BIDMAS and raise you a BADMIS

I see your BIDMAS and raise you a BADMIS Challenge Given a set of numbers with operators between them: "5 + 4 * 9 / 3 - 8", return all the possible results of the expression for every permutation of ...
0
votes
0answers
115 views

“Know Thyself” Program [duplicate]

Challenge Write a program that takes as input a text and output "That's me!" if the input is equal to the program own source code, and "That's not me!" otherwise. Notes This is codegolf, in each ...
-6
votes
11answers
176 views

Return the nth element of an array even if its out of bound [closed]

The challenge Write a function that returns the nth element of an array even if its out of bound. ...
16
votes
2answers
469 views

43 quintillion permutations

We can represent a Rubik's Cube as a net as follows (when solved): WWW WWW WWW GGGRRRBBBOOO GGGRRRBBBOOO GGGRRRBBBOOO YYY YYY YYY Each letter ...
17
votes
15answers
3k views

I multiply the source, you (probably) multiply the output!

Task The task is to write a program that outputs a consistent but otherwise arbitrary positive integer \$x\$ (so strictly greater than 0). Here's the catch: when the source is repeated \$N\$ times (...
22
votes
19answers
2k views

Bit floating sequence

A bit floats from the LSB to the MSB moving one position each time until it floats to the top of the container: 0000 0001 0010 0100 1000 Once one bit floats to ...
26
votes
17answers
4k views

Infinitely many primes

Since Euclid, we have known that there are infinitely many primes. The argument is by contradiction: If there are only finitely many, let's say \$p_1,p_2,...,p_n\$, then surely \$m:=p_1\cdot p_2\cdot.....
14
votes
16answers
2k views

What's this constructed number's starter?

A number of programming languages construct large integers through 'concatenating' the digit to the end of the existing number. For example, Labyrinth, or Adapt. By concatenating the digit to the end, ...
67
votes
15answers
15k views

Draw the ☣ (Biohazard Symbol)

Draw the Biohazard symbol in an arbitrary colour on a distinctly coloured background. The specific proportions were published in the June 27th 1974 issue of the Federal Register of the US Government. ...
43
votes
6answers
3k views

ASCII Maze Rendering 3000

I don't like typing, so I draw my mazes in a very simple format: # ##### # # # ### # # # # # # # # ##### # Isn't it a-maze-ing? Of course, I think all ...
24
votes
31answers
4k views

Round away from zero

Round away from zero Inspired by Round towards zero. Given a number input via any reasonable method, round the number "away from zero" - positive numbers round up, and negative numbers round down. ...
41
votes
17answers
6k views

First Number to Contain Each Letter

Given a single letter from A to Z (except J and K) as input, output the smallest non-negative integer containing that letter in its written form. Assume numbers never contain the word "and", so ...
5
votes
2answers
427 views

Farkle Fest 2k19: An AI dice game tournament

Farkle Fest 2k19 In this challenge, we will be playing the semi-popular dice game Farkle. Farkle is a dice game that has players selecting to save dice or risk rerolling the die for more points to ...
8
votes
3answers
312 views

Print the full conjugation of a French verb

Given a string ending in either "er", "ir", or "re" (the "infinitive"), output the full conjugation of the string as a French verb in the seven simple tenses. For each tense (in the order given below),...
31
votes
28answers
3k views

Count rook moves 1D

Given a position with a row of rooks and/or empty spaces, output how many different rook moves are possible. A rook can move left or right to an empty space, but not to one that requires passing over ...
1
vote
6answers
427 views

Concatenate the Cats

There is a sentence with many cats: ...
16
votes
12answers
5k views

Divide Numbers by 0

We've all been told at some point in our lives that dividing by 0 is impossible. And for the most part, that statement is true. But what if there was a way to perform the forbidden operation? Welcome ...
3
votes
0answers
132 views

Golfed “User-pinging” [closed]

In this task, given a user's display name(e.g. Display Name) from which the first space has been removed, use the Code Golf & Coding Challenges' Stack Exchange API to find a user it could be and ...
27
votes
3answers
692 views

Heavy Box Stacking

You have a bunch of heavy boxes and you want to stack them in the fewest number of stacks possible. The issue is that you can't stack more boxes on a box than it can support, so heavier boxes must go ...
19
votes
12answers
2k views

Calculate Landau's function

Landau's function \$g(n)\$ (OEIS A000793) gives the maximum order of an element of the symmetric group \$S_n\$. Here, the order of a permutation \$\pi\$ is the smallest positive integer \$k\$ such ...
-1
votes
4answers
324 views

Compress my Malbolge!

Background Malbolge is truly intriguing language. But programs written in it are also extraordinairly huge (and in some cases, unpostable on PPCG). Your challenge (shall you accept it) is, to ...
9
votes
2answers
375 views

​Plane​ ​Blow​up​

The Blow-up is a powerful tool in algebraic geometry. It allows the removal of singularities from algebraic sets while preserving the rest of their structure. If you're not familiar with any of that ...
-3
votes
2answers
192 views

Write a “hello world” program that can be compiled/interpreted as two different languages simultaneously [duplicate]

Rules: Your program must print "hello world" when executed Your program must be interpretable or compilable into 2 or more languages Your program must require no input or arguments Languages with ...
24
votes
17answers
3k views

Create a list of snaking numbers under 50,000

Snaking Number Challenge I wonder how many snaking numbers there are between 1 and 50,000? Snaking Numbers, in this game, are numbers which can be typed out on a traditional numberpad (format below) ...
19
votes
4answers
448 views

Compute height of Bowl Pile

Bowl Pile Height The goal of this puzzle is to compute the height of a stack of bowls. A bowl is defined to be a radially symmetric device without thickness. Its silhouette shape is an even ...
5
votes
1answer
255 views

Tips for golfing in Smalltalk

What general tips do you have for golfing in Smalltalk? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Smalltalk (e.g. "remove ...
11
votes
13answers
2k views

Normalized Malbolge to Malbolge translator

In this task, you will write a program/function that takes a Normalized Malbolge program and outputs the resulting Malbolge program. (This is a secret tool that all Malbolge programmers are using!) ...
22
votes
24answers
4k views

Count the number of triangles

Given a list of positive integers, find the number of triangles we can form such that their side lengths are represented by three distinct entries of the input list. (Inspiration comes from CR.) ...
13
votes
3answers
1k views

Is it checkmate?

Wholly surprised this hasn't been posted already, given the large number of chess puzzles on the site. While I thought of this myself, credit to Anush for posting it to the sandbox back in March. But ...
-9
votes
1answer
163 views

Bot Problem.How to solve this problem in c? [closed]

Programming problem: In BotLand, Robots can understand all words of any combination of letters and letters with leading or trailing (not both) numeric value. Given a word W (string of alphanumeric). ...
21
votes
10answers
2k views

Count the number of shortest paths to n

This code challenge will have you compute the number of ways to reach \$n\$ starting from \$2\$ using maps of the form \$x \mapsto x + x^j\$ (with \$j\$ a non-negative integer), and doing so in the ...
34
votes
15answers
4k views

Unlock your Lock

You have locked your bike with a combination lock of 3 digits. Now you want to go for a ride and need to unlock it with the help of following program. Input 1st parameter The digit combination of ...
24
votes
8answers
4k views

Billiard balls collision

Given the 2-dimensional positions and velocities of a pair of billiard balls right before impact, calculate their velocities after a perfectly elastic collision. The balls are assumed to be ideal ...

15 30 50 per page