# All Questions

11,684 questions
Filter by
Sorted by
Tagged with
133 views

### Print a Ternary Value

Put simply, you are to print out the following number: ...
2k views

### Interviewer's Room

You are James and four of your friends (Bjarne, Eich, Rossum, Ada) are called for an interview. There are n interviewers, and they can each serve one person at a time, alphabetically. Each round of ...
446 views

### Never trust a mastermind

You probably know the game mastermind: The player tries to guess a code of 4 slots, with 8 possible colors - no duplicates this time. Let's call those colors A through H, so possible solutions could ...
4k views

### Interpret ><> (Fish)

While ><> is not a popular language, it can be good for golfing and has been used on this website. It was inspired by Befunge and has some similarities in its instructions. Required Commands: <...
2k views

### Source Code Byte Frequency

Source Code Byte Frequency Write a program that get a single byte character as an input and prints the frequency of that byte in the program's source code as an output. Examples: Assuming my program ...
376 views

### Rock Paper Scissors Meta-Gaming Tournament

This is a rock paper scissors competition. Algorithms will face each other in 100 rounds of rock paper scissors. Except that the algorithms will also be able to read the source code of each other! ...
51 views

### Inspired by HQ9+: 4-Behavior Polyglot

Create a program that can be run in 4 different languages such that: One language prints "Hello World!" One language outputs its own source code One language outputs 99 bottles of beer on ...
27 views

### Write a program that reads 2 integers and draws a rectangle of corresponding dimensions [closed]

Write a program that reads 2 integers and draws a rectangle of corresponding dimensions. modify the program such that in all casses the rectangle is always in horizontal position. meaning when the ...
15k views

### Is this number evil?

Introduction In number theory, a number is considered evil if there are an even number of 1's in its binary representation. In today's challenge, you will be identifying whether or not a given number ...
1k views

### Mode length of a sentence

The task is simple. You are given a string with alphabetical words (say "Hello world, this are tests"). You have to return the mode of the lengths of ...
1k views

### Counting characters

Write a function or program that accepts one character (or a string of length 1) as input, and outputs the number of times that character occurs inside the code. This program must be a Proper Quine, ...
38k views

### Shortest infinite loop producing no output

Your task is to create the shortest infinite loop! The point of this challenge is to create an infinite loop producing no output, unlike its possible duplicate. The reason to this is because the code ...
628 views

### Draw the flag of Tennessee

The flag of Tennessee is specified by chapter 498 of the Public Acts of 1905. An oblong flag or banner in length one and two thirds times its width, the large or principal field of same to be of ...
29k views

### Fibonacci function or sequence

The Fibonacci sequence is a sequence of numbers, where every number in the sequence is the sum of the two numbers preceding it. The first two numbers in the sequence are both 1. Here are the first ...
3k views

### Sum the array times n, except the last

I've been posting relatively hard challenges recently, so here goes an easy one. Task Given an array $A$ and a number $n$, calculate the sum of all numbers of $A$ multiplied by $n$, except the ...
2k views

### Surround a string with hashes

I've already made this in Python, but it seems that it could be shortened a lot: ...
539 views
+200

### Saddle points in a matrix

A matrix can be thought of as the altitudes of a surface in 3D space. Consider the 8 neighbours (orthogonal and diagonal) of a cell as a cyclic sequence in clockwise (or anticlockwise) order. Some ...
345 views
+200

### Simplest Tiling of the Floor

You should write a program or function which receives a string describing the floor as input and outputs or returns the area of the simplest meta-tiling which could create the given pattern of the ...
495 views
+200

### Pre-order + post-order to in-order

Task Given the pre-order and post-order traversals of a full binary tree, return its in-order traversal. The traversals will be represented as two lists, both containing n distinct positive integers,...
4k views

### Sort the pixels

Your task is to create a program that will, given an input image, create an output image of the same size, where all pixels are ordered by hex value. Your program may: Sort the pixels from left to ...
1k views

### Tips for golfing in Rust

While Rust is very, very rarely competitive in code golfing competitions (Java is often shorter), it can still be fun to golf in. What are some tricks for making Rust code shorter? Please post only ...
21k views

### Is this even or odd?

Note: There is not been a vanilla parity test challenge yet (There is a C/C++ one but that disallows the ability to use languages other than C/C++, and other non-vanilla ones are mostly closed too), ...
111 views

### One-card Poker for Two

This is a challenge to write bots to play the 1st and 2nd players in the following simple poker game. Rules of the poker game There are two players, A and B. Each antes \$10 into the pot, and is dealt ...
18k views

### What is the smallest positive base 10 integer that can be printed by a program shorter (in characters) than itself?

I think the question as above is clear, but just in case: Write a full program (not just a function) which prints a positive base 10 integer, optionally followed by a single newline. Qualifying ...
7k views

### Three-Three-Three!

Write a program that produces an output such that: At least three distinct characters appear. The number of occurrences of each character is a multiple of 3. For example, ...
7k views

### Write a Rectangular Program that Outputs the Number of Times it was Rotated

The title says it all. Your goal is to write a program that forms a w×h rectangle of characters that can be rotated and re-run to output the number of 90° Counter-Clockwise (CCW) rotations that have ...
2k views

### Find all the coordinates on a path

Given a 2D string as input, either as a string with newlines or a list of lines, output the coordinates (x, y) of all the hashes (...
3k views

### Cat, Quine, Hello World

Write a cat program, a quine, and a Hello World in the same language such that when two specific programs of the three are concatenated in a certain order, you get the third program. It does not ...
6k views

### I reverse the source code, you reverse the input!

Yet another blatant rip-off of a rip-off of a rip-off. Go upvote those! Your task, if you wish to accept it, is to write a program/function that outputs/returns its string input/argument. The tricky ...
4k views

### The shortest way to find one unique value when all other values are the same

In this question at Code Review they tried to find the fastest way to return the unique element in an array where all the elements are the same except one. But what is the shortest code that ...
3k views

### Hot moo shuffle: milk an array

Background Milking the deck is the name given to the following card shuffling method: 'Pinch' the deck to remove the top and bottom cards simultaneously. (With lots of imagination, this action ...
256 views

### Redirect HTTP links to HTTPS with Javascript

What is the shortest way to secure a site with Javascript? I am new to Code Golfing, and this is what I've come up with so far. I bet that this could be improved though: Challenge: Make a script ...
3k views

### How many 1's we get

Description Count how many occurrences there are of the digit 1 between two given numbers $[a, b]$, inclusive. For example, from 1 to 100 it should be 21: 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,...
3k views

### Legendre's (Unsolved) Conjecture

Legendre's Conjecture is an unproven statement regarding the distribution of prime numbers; it asserts there is at least one prime number in the interval $(n^2,(n+1)^2)$ for all natural $n$. The ...
140k views

### “Hello, World!”

So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most ...
27k views

### Tips for golfing in C

What general tips do you have for golfing in C? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to C (e.g. "remove comments" is not an ...
3k views

### Create pixel art!

The task Given an image as input, your task is to do the following: Resize the image so it is At least 2 times smaller, but still has the same width/height ratio by taking every second (if resized ...
4k views

### Round towards zero

This is a simple task. Given a positive or negative real number, round it to the next whole integer closer to zero. The challenge Take input through any reasonable form (stdin, function, etc.) of ...
429 views

### Can I exit the maze with this many bombs?

Inspired by this Puzzling challenge, and easier version of my previous challenge. Challenge A 2D rectangular grid is given, where each cell is either an empty space or a wall. You start at the top ...
632 views

### Descending dungeons of positional systems

The sequence discussed in this challenge is a variant of the Descending Dungeons sequence family. Specifically, the sequence generation rules: ...
2k views

### Compress your code in an image

This is a quine variation. Introduction We all write short code, because some obscure reasons, but whatever we do, the'll take up at least 144 pixels/byte (with a 12px font). But what would happen, if ...
18k views

### Interpret brainf***

Write the shortest program in your favourite language to interpret a brainfuck program. The program is read from a file. Input and output are standard input and standard output. Cell size: 8bit ...
7k views

### Print X without X (cop's thread)

This is the cop's thread of a cops-and-robbers challenge. You can view the robber's thread here A pretty common beginner style question is to print some string, but, there's a catch!, you need to do ...
7k views

### Extract all keys from an object (json)

Description Given an object (json), write code to extract all the keys from it. This is a question that I really wanted to ask everybody for a long time ago but I did not have time to write it up. It ...
16k views

### Output with the same length as the code

In this challenge, you should write a program or function which takes no input and prints or returns a string with the same number of bytes as the program itself. There are a few rules: You may only ...
2k views

### Draw a simple cube

We don't have a single challenge about drawing a real 3 dimensional cube, so here it goes: Challenge Your task is to draw a rotated, cube with perspective. It can be in a separate window or as an ...
4k views

### Draw an ASCII-art rainbow

Draw an ASCII-art rainbow! Input An integer between 0 and 1000, inclusive. Examples Input 0: /\ || Input 1: _ / \ | | Input ...
2k views

### Concentric rings on a snub square tiling

This challenge takes place on the snub square tiling. Start by choosing any triangle, and color it $c_1$. Next, find all tiles which touch this triangle at any vertex, and color them $c_2$. Next, ...