Linked Questions

194 votes
413 answers
74k 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 ...
Beta Decay's user avatar
  • 23.3k
66 votes
234 answers
18k views

Add two numbers

Input: Two integers. Preferably decimal integers, but other forms of numbers can be used. These can be given to the code in standard input, as arguments to the program or function, or as a list. ...
anna328p's user avatar
  • 6,332
53 votes
155 answers
10k views

Stay away from zero

Task Given a non-negative integer n, output 1 if n is 0,...
Leaky Nun's user avatar
  • 49.6k
54 votes
128 answers
18k 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 ...
Amphibological's user avatar
77 votes
62 answers
8k views

Is it a Cyclops number? "Nobody" knows!

Task: Given an integer input, figure out whether or not it is a Cyclops Number. What is a Cyclops number, you may ask? Well, it's a number whose binary representation only has one ...
absoluteAquarian's user avatar
48 votes
83 answers
4k views

Type uniqchars!

Given a string consisting of printable ASCII chars, produce an output consisting of its unique chars in the original order. In other words, the output is the same as the input except that a char is ...
Luis Mendo's user avatar
  • 104k
47 votes
85 answers
8k views

Greatest Common Divisor

Your task is to compute the greatest common divisor (GCD) of two given integers in as few bytes of code as possible. You may write a program or function, taking input and returning output via any of ...
Mike Shlanta's user avatar
48 votes
84 answers
6k 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 ...
Charlie's user avatar
  • 12.8k
62 votes
64 answers
8k views

The Luhn algorithm for verifying credit card numbers, etc

Challenge Write the shortest program or function to calculate the Luhn Algorithm for verifying (credit card) numbers. Luhn algorithm explained From RosettaCode, this algorithm for the purposes of ...
Chris Laplante's user avatar
43 votes
77 answers
5k views

Print random integers until 0

You are to write a program which generates random integers between \$0\$ and \$99\$ inclusive, outputting each integer in turn, until \$0\$ is generated. You may choose which single-order random ...
caird coinheringaahin g's user avatar
59 votes
35 answers
12k views

Print the phrase "And she said, 'But that's his.'" using only the alphabet

Print the phrase And she said, 'But that's his.' using only the following characters: ...
Blue-Maned Hawk's user avatar
66 votes
47 answers
5k views

User Appreciation Challenge #1: Dennis ♦

I got the spontaneous idea of making a series of challenges of users that have helped and continue to help the PPCG community be an enjoyable place for everyone, or maybe just specifically for me. :P ...
hyper-neutrino's user avatar
  • 41.3k
60 votes
49 answers
5k views

How many steps does it take from n to 1 by subtracting the greatest divisor?

Inspired by this question over at Mathematics. The Problem Let n be a natural number ≥ 2. Take the biggest divisor of ...
insertusernamehere's user avatar
32 votes
80 answers
4k views

Swap the parity

Task Given a positive integer n, output n+1 if n is odd, and output ...
Leaky Nun's user avatar
  • 49.6k
35 votes
63 answers
5k views

GET your dubs together

On 4chan, a popular game is get. Every post on the site gets a sequential post ID. Since you can't influence or determine them, people try to guess (at least a part of) their own post number, usually ...
sagiksp's user avatar
  • 1,385

15 30 50 per page