All Questions

Filter by
Sorted by
Tagged with
36 votes
61 answers
5k views

Sum of primes between given range

Write the shortest code for finding the sum of primes between \$a\$ and \$b\$ (inclusive). Input \$a\$ and \$b\$ can be taken from command line or stdin (space seperated) Assume \$1 \le a \le b \le ...
st0le's user avatar
  • 2,208
35 votes
20 answers
9k views

Balanced Ternary Converter

Credits for the challenge idea go to @AndrewPiliser. His original proposal in the sandbox was abandoned and since he has not been active here for several months, I have taken over the challenge. ...
user avatar
34 votes
16 answers
5k views

Calculate 500 digits of pi

Write a program to calculate the first 500 digits of pi, meeting the rules below: It must be less than 500 characters in length. It cannot include "pi", "math.pi" or similar pi constants, nor may it ...
Thomas O's user avatar
  • 3,318
29 votes
20 answers
4k views

Decipher a Vigenère ciphertext

The Vigenère cipher was a simple polyalphabetic cipher that basically applied one of several Caesar ciphers, according to a key. Basically the letters in the key indicate which shifted alphabet to use....
Joey's user avatar
  • 12.9k
28 votes
13 answers
2k views

Tips for golfing in Swift

What are some tips for code-golfing in Swift? Its focus on safety seems to make it difficult to golf in, but that makes little tips and even more useful. Are there any features in Swift that may help ...
addison's user avatar
  • 1,063
26 votes
8 answers
2k views

All your bijective base are belong to us

Background A bijective base b numeration, where b is a positive integer, is a bijective positional notation that makes use of b symbols with associated values of 1 to b. Unlike its non-bijective ...
Dennis's user avatar
  • 210k
26 votes
24 answers
2k views

Case Permutation

Who needs to compare things case insensitively when you're able to generate every permutation of uppercase and lowercase? No one! That's the answer. No one does. Your task is to achieve this feat; ...
Poke's user avatar
  • 3,175
26 votes
66 answers
6k views

Display number of occurrences for every character in an input string

The code should take a string as input from keyboard: The definition of insanity is quoting the same phrase again and again and not expect despair. The output ...
Eduard Florinescu's user avatar
25 votes
11 answers
2k views

Tips for golfing in Kotlin

Given Google's recent announcement of official Kotlin support for Android development, I thought it might be timely to poll the community for some awesome golfing tips for this relatively new JVM ...
Tyler MacDonell's user avatar
25 votes
29 answers
3k views

Different Way Forward

Given a list of integers produce a Forward Difference at a specified order/depth. For the list of integers: (10, 18, -12, 4, 8, -3, -5, 67, 9, 14) The Forward ...
MickyT's user avatar
  • 12.2k
18 votes
16 answers
1k views

Tips for Golfing in Vyxal

Vyxal is a golfing language that has 500+ different commands (achieved through overloads), and is a known beater of Jelly, 05AB1E and most golfing languages. Henceforth, it seems like a good idea to ...
lyxal's user avatar
  • 32.5k
17 votes
34 answers
2k views

Spell out the Revu'a

Actually not inspired neither by Atbash Self Palindromes nor by Generalized Gematria Calculator. Given a string s of length n, output the Revu'a sequence, which is the first character of s, the first ...
Adám's user avatar
  • 29.9k
14 votes
49 answers
8k views

Sum of positive integers. [closed]

Problem: Given a set of integers, find the sum of all positive integers in it. Input: t – number of test cases [t < 1000] On each of next t lines, an integer N [-1000 ≤ N ≤ 1000] Output The ...
gmunkhbaatarmn's user avatar
10 votes
5 answers
2k views

Words from periodic table of elements [closed]

Back when I was a freshman in highschool taking chemistry, I'd look at the periodic table of elements and spell dirty words out with the number of the elements (HeCK would be 2619, 2-6-19). I was ...
Rob's user avatar
  • 307
235 votes
184 answers
38k views

Evolution of "Hello World!"

This contest is officially over, the winner is jimmy23013. Congratulations! The challenge is to make a program that prints Hello World! to stdout. The catch is that ...
Calvin's Hobbies's user avatar
183 votes
29 answers
24k views

Do you want to code a snowman?

Here is a simple ASCII art snowman: _===_ (.,.) ( : ) ( : ) Let's make him some friends. This will be the general pattern for our ASCII art snowpeople: ...
Calvin's Hobbies's user avatar
124 votes
128 answers
17k views

Make an error quine!

Your challenge: write a "program", for a language of your choice, that causes the compiler/interpreter/runtime to produce error output when compiling/running your program which is identical to your ...
nneonneo's user avatar
  • 12.3k
123 votes
95 answers
23k views

ASCII's 95 Characters...95 Movie Quotes

Update: The winner has been decided, but the challenge is not over! Finally, nearly 3 months after the question first started, someone has remained the last answerer for more than a week! ...
Calvin's Hobbies's user avatar
96 votes
51 answers
14k views

In Honor of Adam West

Adam West passed away, and I'd like to honor his memory here on PPCG, though I doubt he knew of our existence. While there are many, many different things that this man is known for, none are more ...
Magic Octopus Urn's user avatar
75 votes
39 answers
7k views

Stack Exchange Vote Simulator

Write a program or function that takes in a string only containing the characters ^ and v (you can assume there will be no other ...
Calvin's Hobbies's user avatar
72 votes
207 answers
18k views

The Programming Language Quiz, Mark II - Cops

A repost of this challenge. Meta discussion. Sandbox post. Body of the question similar to the original Robber's challenge This cops and robbers is now (08/03/2018) closed to further competing cop ...
caird coinheringaahin g's user avatar
71 votes
17 answers
6k views

Write a polyglot that prints the language's name

Your task is to write a program that executes in as many languages as possible, with as few characters as you can. To avoid trivial solutions, the program must print the name of the language it was ...
vsz's user avatar
  • 8,117
63 votes
44 answers
9k views

Print the N-bonacci sequence

This isn't very widely known, but what we call the Fibonacci sequence, AKA 1, 1, 2, 3, 5, 8, 13, 21, 34... is actually called the Duonacci sequence. This is ...
DJMcMayhem's user avatar
  • 58.9k
59 votes
19 answers
17k views

Biggest Irreducible Hello World

Create a program that outputs Hello, World! The winner is the source code that is the biggest, subject to the constraint that it is irreducible For this challenge,...
Mason's user avatar
  • 2,147
51 votes
11 answers
10k views

Build a random number generator that passes the Diehard tests

While there are many code golf questions on here involving randomness, I haven't seen one yet that actually asks for building an algorithmic pseudorandom number generator. There's this one that asks ...
Joe Z.'s user avatar
  • 34.7k
50 votes
24 answers
7k views

Minecraft Mirrored

This is Calvin. Just trying to get 20 rep so this user can chat in the PPCG Minecraft Server chatroom. Write a program or function that takes in a positive integer. If the integer is even (2, 4, 6, ....
Old Chat Relay's user avatar
48 votes
16 answers
6k views

Zigzagify a Matrix

As part of its compression algorithm, the JPEG standard unrolls a matrix into a vector along antidiagonals of alternating direction: Your task is to take a matrix (not necessarily square) and return ...
Martin Ender's user avatar
47 votes
32 answers
7k views

Very Simple Triangles

Write a program or function that takes in a positive integer (via stdin, command line, or function arg) and prints or returns a string of that many of these small triangles tiled together, alternating ...
Calvin's Hobbies's user avatar
46 votes
146 answers
6k views

Full Width Text

Full width text is text that has a space after every character, including the last one. For instance, the first sentence of this question becomes: ...
Jess Smith's user avatar
45 votes
84 answers
9k views

Binary to decimal converter

Binary to decimal converter As far as I can see, we don't have a simple binary to decimal conversion challenge. Write a program or function that takes a positive binary integer and outputs its ...
Stewie Griffin's user avatar
41 votes
22 answers
4k 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 ...
Doorknob's user avatar
  • 71.4k
39 votes
3 answers
4k views

Tiny Lisp, tiny interpreter

Lisp programmers boast that Lisp is a powerful language which can be built up from a very small set of primitive operations. Let's put that idea into practice by golfing an interpreter for a dialect ...
DLosc's user avatar
  • 38k
37 votes
39 answers
4k views

Determinant of an Integer Matrix

Given a square integer matrix as input, output the determinant of the matrix. Rules You may assume that all elements in the matrix, the determinant of the matrix, and the total number of elements in ...
user avatar
36 votes
21 answers
4k views

Write a Polyquine

A polyquine is both quine and polyglot.1 You are to write a quine which is valid in at least two different languages. This is code golf, so the shortest answer (in bytes) wins. 1 I made that up. Or ...
Martin Ender's user avatar
35 votes
44 answers
5k views

Calculate Euler's totient function

Background Euler's totient function φ(n) is defined as the number of whole numbers less than or equal to n that are relatively ...
jqkul's user avatar
  • 2,272
35 votes
8 answers
5k views

Self-Interpreting Interpreter

Based on a comment by George Edison to this question, write the smallest self-interpreting interpreter. You may use the language of your choosing. Empty languages do not count. Your program must be ...
Hoa Long Tam's user avatar
  • 2,092
35 votes
50 answers
10k views

Will Jimmy fall off his platform?

Backstory Meet my friend Jimmy: /o\ Jimmy is a little character who likes to stand on platforms. Here's Jimmy safely standing on a platform: ...
moltarze's user avatar
  • 2,552
34 votes
45 answers
3k views

Calculate the prime factors

We had a prime factorization challenge a while ago, but that challenge is nearly six years old and barely meets our current requirements, so I believe it's time for a new one. Challenge Write a ...
ETHproductions's user avatar
32 votes
77 answers
12k views

Count the number of ones in an unsigned 16-bit integer

Write some statement(s) which will count the number of ones in an unsigned sixteen-bit integer. For example, if the input is 1337, then the result is ...
ayane_m's user avatar
  • 1,019
32 votes
47 answers
7k views

Implement hyperexponentiation/tetration without the use of '^' [closed]

The Challenge Implement tetration (aka Power Tower or Hyperexponentiation) with the least amount of characters. The Conditions Don't use the 'power' operator or its equivalents (such as ...
MrZander's user avatar
  • 942
30 votes
4 answers
2k views

Create a rotating quine

A rotation of a string is made by splitting a string into two pieces and reversing their order, for example "world!Hello, " is a rotation of ...
Gordon Bailey's user avatar
29 votes
8 answers
3k views

Are you in the biggest room?

Introduction You have recently accepted a job offer at a Pretty Good Software Company. You're pretty content with the size of your office, but do you have the biggest office? Its kinda hard to tell ...
turbulencetoo's user avatar
29 votes
5 answers
2k views

Advanced Calculator

You must write a program that evaluates a string that would be entered into an advanced calculator. The program must accept input using stdin and output the correct answer. For languages that do no ...
Kevin Brown-Silva's user avatar
28 votes
47 answers
4k views

Shortest power set implementation

Problem definition Print out the powerset of a given set. For example: [1, 2, 3] => [[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]] Each element is to ...
beatgammit's user avatar
27 votes
16 answers
3k views

Tips for Golfing in Go

What general tips do you have for golfing in Go? I'm new to Code Golfing and looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Go. Please ...
Sheharyar's user avatar
  • 729
27 votes
17 answers
13k views

Transform number into 7-segment display pattern [closed]

Given two arbitrary numbers A,B. Print number B as a Digital LED Pattern where A is the scale. input: 1 2320451640799518 ouput: ...
Wasi's user avatar
  • 1,770
26 votes
6 answers
2k views

The Coin Problem

Background The official currency of the imaginary nation of Golfenistan is the foo, and there are only three kinds of coins in circulation: 3 foos, 7 foos and 8 foos. One can see that it's not ...
Zgarb's user avatar
  • 42.5k
25 votes
11 answers
4k views

Generate a Kolakoski sequence [duplicate]

Definition1 A Kolakoski sequence is a self-describing infinite sequence {kn} of alternating blocks of 1's and 2's, given by the following rules: k0 = 1 kn = the length of the (n+1)'th ...
ardnew's user avatar
  • 2,329
23 votes
9 answers
816 views

Given an input, move it along the keyboard by N characters

The Challenge: Given any input that can be typed on a keyboard, move the text along by N chars. Here is the QWERTY keyboard to be used. You can ignore the modifier keys (Shift, Caps, Enter, Delete ...
Tim's user avatar
  • 2,879
23 votes
4 answers
3k views

Four fours puzzle

The Four fours puzzle is a popular recreational mathematical puzzle that involves using exactly four 4s (and no other number) and a defined set of operations to reach every number from 0 to a given ...
Volatility's user avatar
  • 3,374

15 30 50 per page
1 2 3
4
5
93