Linked Questions

151
votes
267answers
41k 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 ...
34
votes
88answers
14k 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 ...
67
votes
46answers
7k 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 ...
40
votes
65answers
6k 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 ...
51
votes
45answers
6k 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 ...
53
votes
37answers
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 ...
50
votes
33answers
4k 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 ...
22
votes
60answers
3k views

Swap the parity

Task Given a positive integer n, output n+1 if n is odd, and output ...
47
votes
13answers
7k views

Extreme Fibonacci

There have been a billion iterations of Fibonacci challenges on this website, so lets spice things up with a Fibonacci challenge of a billion iterations! Your challenge is to output the first 1000 ...
31
votes
32answers
4k views

Binary Fibonacci

Challenge You need to generate a program or function that takes in a positive integer N, calculates the first N terms of the Fibonacci sequence in binary, concatenates it into a single binary number, ...
35
votes
26answers
5k views

Exchange capitalization

Given two strings of letters, transfer the capitalization pattern of each string onto the other one. Fewest bytes wins. ...
33
votes
24answers
6k views

Can the number be split into powers of 2?

Yesterday while playing with my kid I noticed the number in his toy train: So we have $$4281$$ that can be split into $$4-2-8-1$$ or $$2^2-2^1-2^3-2^0$$ So simple challenge: given a non-negative ...
24
votes
32answers
3k views

ASCII art uncompression from a base-n number

This is inspired by an 05AB1E answer by Magic Octupus Urn. Given two arguments, a positive integer and a string/list of characters: Translate the number to base-n, where n is the length of the ...
29
votes
20answers
2k views

Stewie's sequence: + * - / + * - /

Let's use the four basic operations, addition +, multiplication *, subtraction - and ...
19
votes
21answers
2k views

The repetitive byte counter

Your task is to write a non-empty program / function of byte count L, which, when repeated M times, checks whether a given positive integer N is equal to L × M. You should, in theory, support an ...

15 30 50 per page