# All Questions

11,171 questions
Filter by
Sorted by
Tagged with
3k views

### Smallest number such that concatenation is a square

Challenge Write a program or function that takes a number $n$ and returns the smallest $k$ such that concatenation $n'k$ is a square. This sequence is described by A071176 on the OEIS. I/O ...
324 views

### Elastic collisions between blocks

The 3Blue1Brown Youtube channel released a video a year ago called "Why do colliding blocks compute pi?" which describes a model where a block A of mass $a$ ...
391 views

### Sequence and Series

Use any programming language to display numbers divisible by 1000000 that are greater than 1 and less than 10000000. Each number should be displayed in new line. Your program should display exactly: <...
834 views

### The longest period iterating quine

As we know, a quine is a program that outputs its own source code. However, it's also possible to write a program that outputs another, different program, that outputs the first program again. For ...
26k views

### GO OUT AND VOTE

Today is November 8th, 2016, Election Day in the United States of America. If you are a U.S. citizen eligible to vote, then go out and vote if you haven't already before answering this challenge. Do ...
2k views

### Narcissistic Quine

Write a program/method that: Becomes a quine when the input matches the source code; Doesn't halt otherwise. This is code-golf, so shortest solution wins. Avoid any standard loopholes.
202 views

### Minigolf Solitaire

Inspired by a question on the puzzling stack exchange. Rules Given 5 stacks of 5 cards numbered 1 to 7, output the moves needed to empty all stacks. A move is defined as the index of a column to ...
4k views

### Make me a s'more!

Make me a s'more! I tell you the width, the amount of graham cracker, the amount of chocolate, and the amount of marshmallow. An example: Input: Width: 10 Graham: ...
152 views

### Approximating the amount of prime numbers below x

Background We define the prime-counting function, $\pi(x)$, as the number of prime numbers less than or equal to $x$. You can read about it here. For example, $\pi(2) = 1$ and $\pi(6) = 3$. ...
3k views

### Simple Circular Words

A "simple circular" word is a word whose chords do not intersect. The chords of a word may be seen by laying out the alphabet in a circle, and then connecting the word's consecutive letters. ...
22k views

### Print a 10 by 10 grid of asterisks

Background This is a standard textbook example to demonstrate for loops. This is one of the first programs I learned when I started learning programming ~10 years ago. Task You are to print this ...
7k views

Challenge Description: Write a program that asks the user for input. The user will enter Good or Bad. You do not have to ...
6k views

### Make me a square!

Task Given one non-whitespace printable character, make a 3x3 square representation of that input. For example, if the input is #, then the output is: ...
5k views

### Largest monetary amount impossible to make with two types of coin

Suppose we have two different types of coin which are worth relatively prime positive integer amounts. In this case, it is possible to make change for all but finitely many quantities. Your job is to ...
42k views

### 1, 2, Fizz, 4, Buzz

Introduction In our recent effort to collect catalogues of shortest solutions for standard programming exercises, here is PPCG's first ever vanilla FizzBuzz challenge. If you wish to see other ...
5k views

### ROT-13 transform standard input

The challenge: To read an input of arbitrary length and produce the ROT13 of the input. All characters besides A-Z should be copied to the output verbatim, and case should be preserved if possible. ...
1k views

### Bucket and Minimize

The challenge - given a numeric list L and an integer N as inputs, write a function that: finds the bucket sizes for L such that it is split into N whole buckets of equal or near-equal size, and ...
3k views

### Orthodiagonal steps

It's a common problem to navigate in a 2D matrix. We've seen it many times and will see again. So let's help future us and develop the shortest solutions to generate all eight possible steps in a 2D ...
2k views

### Write the longest period iterating quine bounded by 500 bytes

Your job is to create the longest period iterating quine, where the length of each program in the sequence is bounded by 500 bytes. That is, if you repeat the following steps: Start with your ...
5k views

### Tips for golfing in R

I'm looking for tips for golfing in the R statistical language. R is perhaps an unconventional choice for Golf. However, it does certain things very compactly (sequences, randomness, vectors, and ...
644 views

### Counts Of Orderings Containing At Most K Of The Kth Class

This challenge is about the number of orderings which contain at most $n$ classes and at most $k$ of the $k^{\text{th}}$ class. One way to represent such an ordering is as a sequence of ...
2k views

### Super permutations

Super permutations Input: A string The program should loop through all lengths of the input (decrementing one each time), generate all combinations with replacement of the string, then make ...
5k views

### Shift right by half a bit

The challenge is to implement a program or function (subsequently referred to as "program") that takes a nonnegative integer $n$ as input and returns $n\over\sqrt{2}$ (the input divided by the ...
2k views

### Check if all non-zero elements in a matrix are connected

Input: A matrix containing integers in the range [0 - 9]. Challenge: Determine if all non-zero elements are connected to each other vertically and/or horizontally. Output: A truthy value if all ...
1k views

### Map of Islands (and a river)

Introduction For many centuries, there has been a certain river that has never been mapped. The Guild of Cartographers want to produce a map of the river, however, they have never managed to succeed -...
890 views

### Draw 'Til You Drop

In Dungeons & Dragons 5th edition (as well as most other editions), there exists a magic item called the Deck of Many Things. It is an incredibly powerful item, as the cards all have very strong ...
2k views

### Draw ASCII boxes in boxes

Problem given input a,b,c where a,b,c are positive even integers and a > b > c ...
576 views
+200

### Singly lossy integers: Concatenated sequences missing a single element

I define the method of combining a sequence to mean that every number in the sequence is concatenated as a string, then that result is made an integer. ...
3k views

### Draw a big ASCII X

Problem Inspired by a previous challenge doing something similar Given positive integer input n output a shape that follows this pattern: input ...
2k views

### Newtons Method by Recursive Quines

Your task is to calculate the square root of 2 using Newton's Method - with a slight twist. Your program is to calculate an iteration using Newton's Method, and output the source code for the ...
4k views

### Write the shortest self-identifying program (a quine variant)

Write a program that will generate a "true" output iff the input matches the source code of the program, and which generates a "false" output iff the input does not match the source code of the ...
6k views

### Write a program that sees the New Year in itself

Write the smallest program that maps strings injectively to outputs and maps itself to 2020. To be clear, your program $p$ must have the following properties: every possible input string $s$ has ...
46k views

### Golf you a quine for great good!

Using your language of choice, golf a quine. A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output. No cheating -- that means ...
5k views

### Russian Roulette

Write a program which plays Russian Roulette! If the program is started, there should be a 5 in 6 chance of it ending normally after printing "I survived!" there should be a 1 in 6 chance of the ...
3k views

### Make it rain characters

Inspired by this chat mini-challenge. Given a string as input (ASCII printable characters only), output the string with the letters "raining" down. Each letter must be a random number of lines ...
1k views

### Quoting Big Brother

Task: Have your program randomly choose one of the following two quotes at runtime and print that one quote, exactly as shown. 1: ...
364 views

### Minified Intcode Computer

As the trip through the solar system on your way to rescue Santa gets a little droll, so perhaps some optimizations to your Intcode Computer are in order. Namely, making it as small as possible ...
5k views

### Internal Truth Machine

It's a normal truth machine but instead of taking input, it uses the first character of the program. Thus, internal. The 0 and 1 are plain characters, i.e. ASCII code 0x30 and 0x31 respectively. ...
479 views

### Make a random drum loop

Do randomly generated drum loops sound good? A drum loop is a $5\times 32$ matrix $A$ of $1$s and $0$s such that $A_{1,1}=A_{1,17}=A_{2,9}=A_{2,25}=1$, for each $i$, the $i$th row has ...
58 views

### How to run the 2019 IOI test cases against my solution? [closed]

The question and solutions are available here: https://ioinformatics.org/page/ioi-2019/51 There's a folder containing "MakeFile" for tests, I do not know what to do with it. Can someone please help ...
829 views

### Quit Whining; Start Quining

Goal: Write a function or program that, given an integer n, will output a program in the same language that is a quine with a period of ...
3k views

### The plus-minus sequence

The plus-minus sequence The plus-minus sequence is one that starts with two seeds, a(0) and b(0). Each iteration of this ...
46k views

### Is this number a prime?

Believe it or not, we do not yet have a code golf challenge for a simple primality test. While it may not be the most interesting challenge, particularly for "usual" languages, it can be nontrivial in ...
91 views

### Tetris Game in C challenge (Strictly in C) [closed]

The challenge is to show your game written in the Mother of all programming languages, i.e. C. Criteria: A reasonable scoring system must be in place, which rewards multi-line clears more than single-...
2k views

### Simplification of numbers

How, you can’t remember the 6 or 7-digit phone number that appeared on the TV screen for a second?! Using the special technique described below, you will turn into a walking phonebook! Obviously, the ...
7k views

### Output the sign

Given a number N, output the sign of N: If N is positive, output 1 If N is negative, output -1 If N is 0, output 0 N will be an integer within the representable range of integers in your chosen ...
5k views

### Make it explode!

Take a matrix of positive integers as input, and make it explode! The way you explode a matrix is by simply adding zeros around every element, including the outside borders. Input/output formats are ...
4k views

### Product over a range

Your task is simple: given two integers a and b, output ∏[a,b]; that is, the product of the ...