Linked Questions

203 votes
434 answers
82k 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.6k
71 votes
243 answers
20k 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,476
57 votes
170 answers
12k views

Stay away from zero

Task Given a non-negative integer n, output 1 if n is 0,...
Leaky Nun's user avatar
  • 50.4k
57 votes
137 answers
20k 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
52 votes
92 answers
7k 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
  • 13k
49 votes
90 answers
5k 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
  • 106k
79 votes
65 answers
9k 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
67 votes
69 answers
10k 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
47 votes
86 answers
9k 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
45 votes
82 answers
6k 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
62 votes
38 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
34 votes
89 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
  • 50.4k
66 votes
47 answers
6k 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 ...
hyperneutrino's user avatar
  • 42.7k
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
36 votes
68 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,405

15 30 50 per page