All Questions

Filter by
Sorted by
Tagged with
8
votes
5answers
133 views

Print a Ternary Value

Put simply, you are to print out the following number: ...
12
votes
17answers
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 ...
12
votes
2answers
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 ...
21
votes
8answers
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: <...
23
votes
23answers
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 ...
-1
votes
13answers
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! ...
0
votes
0answers
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 ...
-6
votes
0answers
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 ...
43
votes
100answers
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 ...
11
votes
19answers
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 ...
15
votes
23answers
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, ...
128
votes
497answers
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 ...
10
votes
5answers
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 ...
122
votes
254answers
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 ...
23
votes
44answers
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 ...
24
votes
31answers
2k views

Surround a string with hashes

I've already made this in Python, but it seems that it could be shortened a lot: ...
8
votes
4answers
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 ...
11
votes
2answers
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 ...
13
votes
5answers
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,...
35
votes
14answers
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 ...
28
votes
14answers
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 ...
68
votes
221answers
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), ...
5
votes
0answers
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 ...
187
votes
156answers
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 ...
69
votes
82answers
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, ...
64
votes
28answers
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 ...
21
votes
21answers
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 (...
31
votes
18answers
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 ...
24
votes
33answers
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 ...
36
votes
59answers
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 ...
37
votes
36answers
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 ...
1
vote
2answers
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 ...
29
votes
42answers
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,...
24
votes
18answers
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 ...
446
votes
791answers
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 ...
147
votes
54answers
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 ...
16
votes
10answers
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 ...
16
votes
61answers
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 ...
6
votes
2answers
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 ...
8
votes
13answers
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: ...
17
votes
11answers
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 ...
117
votes
55answers
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 ...
50
votes
74answers
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 ...
15
votes
8answers
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 ...
100
votes
240answers
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 ...
12
votes
3answers
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 ...
20
votes
43answers
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 ...
22
votes
17answers
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, ...
98
votes
346answers
17k views

One OEIS after another

As of 13/03/2018 16:45 UTC, the winner is answer #345, by Scrooble. This means the contest is officially over, but feel free to continue posting answers, just so long as they follow the rules. As well,...
49
votes
71answers
7k views

Pointers, pointers, pointers!

Introduction In the error outputs of some languages such as Java, a pointer is shown to give the programmer an idea of exactly where the error went wrong. Take this example on Ideone: ...

15 30 50 per page
1
2 3 4 5
234