Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [code-golf]

Code-golf is a competition to solve a particular problem in the fewest bytes of source code. If you want to score by characters instead of bytes, please state this explicitly in the challenge. If source code length is not the primary scoring criterion, consider using another tag instead.

7
votes
5answers
308 views

Maximizing by swapping

Input An integer n in the range 100 to 10^18 and an integer k in the range 1 to 18, inclusive. The swap operation A swap chooses two digits at different positions and exchanges their positions, as ...
8
votes
8answers
547 views

Type-check an expression

Given an infix expression, determine whether all constants are of the same type. Operators will consist only of these dyadic operators: +-/* Your program or ...
22
votes
23answers
3k views

Upside-Down Pyramid Addition…REVERSED!

Upside-Down Pyramid Addition is the process of taking a list of numbers and consecutively adding them together until you reach one number. When given the numbers ...
16
votes
22answers
910 views

Enumerate Derangements

Given some positive integer \$n\$ generate all derangements of \$n\$ objects. Details A derangement is a permutation with no fixed point. (This means in every derangement number \$i\$ cannot be in ...
4
votes
1answer
217 views

Alphabetical Justice Warrior [closed]

Introduction: Aaron is a young game developer. He recently joined the development team of a game where the players select their character from a predefined set, aka "heroes". Unfortunately, the names ...
27
votes
22answers
4k views

Binary Numbers Magic Trick

The challenge is simply; output the following six 2D integer arrays: ...
13
votes
9answers
375 views

Word Changer Reachability

Word changer is a game where you are trying to turn one word into another via single-character edits, with each step being its own word. For this challenge, edits may be replacements, insertions, or ...
21
votes
5answers
476 views

Congruent Numbers

Definitions: A triangle is considered a right triangle if one of the inner angles is exactly 90 degrees. A number is considered rational if it can be represented by a ratio of integers, i.e., ...
9
votes
0answers
112 views

Fix Brain-Flak push-pop redundancy

Brain-Flak is a stack-based esoteric language with eight commands: ...
13
votes
1answer
330 views

Interactive Maze Solver

Bob got kidnapped and is stuck in a maze. Your job is to help him find a way out. But since it is a very dark and scary maze, he can't see anything. He can only feel walls when he runs in to it, and ...
32
votes
21answers
2k views

A ​Note ​on ​N!

J. E. Maxfield proved following theorem (see DOI: 10.2307/2688966): If \$A\$ is any positive integer having \$m\$ digits, there exists a positive integer \$N\$ such that the first \$m\$ digits of \$...
6
votes
12answers
303 views

Probabilistic approach puzzle

A few hours earlier, I got this puzzle: Suppose, you toss a coin n times, then what is the probability of getting m number of heads? ( where m belongs to the set of all prime numbers) For instance,...
10
votes
6answers
1k views

Which really big number is bigger?

This question is tricky (and in particular harder than Which big number is bigger?), for those who like more challenging puzzles. Input Integers a1, a2, a3, a4, a5, b1, b2, b3, b4, b5 each in the ...
22
votes
16answers
5k views

Which big number is bigger?

Input Integers a1, a2, a3, b1, b2, b3 each in the range 1 to 20. Output True if a1^(a2^a3) > b1^(b2^b3) and False otherwise. ^ is exponentiation in this ...
-2
votes
7answers
417 views

Kill The Dragon!

John, a knight wants to kill a dragon to escape the castle! The dragon has A heads and B tails. He knows, that: if you cut off ...
24
votes
40answers
4k views

Check if a string is entirely made of the same substring

This is taken from this question (with permission ofcourse). I'll quote: Create a function which takes a string, and it should return true or false based on whether the input consists of only a ...
30
votes
50answers
4k views

All ASCII characters with a given bit count

(Title with thanks to @ChasBrown) Sandbox The Background This challenge is inspired by a question that I recently posted on Puzzling Stack Exchange. Please feel free to follow the link if you are ...
-2
votes
6answers
238 views

Map values to any multidimensional array [closed]

Codegolf challenge - mapping values in a multidimensional array [ [0, 0, 0], [0, 0, 0], [0, 0, 0] ] This 2D array is sick of being so false, and wants to ...
15
votes
6answers
560 views

Generate a Pronounceable Nonsense Word \$n\$ syllables long

Your task is to generate a nonsense word that is reasonably pronounceable with the specified number of 'syllables'. Each time the program is run possibly results in a different nonsense word. ...
39
votes
27answers
3k views

Marquee sign letters

Each day you put up a new word on a marquee sign with movable letters, buying just the letters you need to write it. You re-use letters you've bought for earlier words whenever possible. Given the ...
12
votes
14answers
854 views

Draw the Easter Bunny

This happy individual is known in folklore as the Easter Bunny. Colours It is created using 4 colours: Light pink Dark pink White Black (I'm happy for these colours to be approximated in your ...
13
votes
10answers
1k views

New Order #6: Easter Egg

Introduction (may be ignored) Putting all positive integers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all ...
26
votes
12answers
2k views

The Nth Gryphon Number

I came up with a series of numbers the other day and decided to check what the OEIS number for it was. Much to my surprise, the sequence did not appear to be in the OEIS database, so I decided to ...
23
votes
20answers
1k views

Maximum summed subsequences with non-adjacent items

Introduction: Inspired by these two SO questions (no doubt from the same class): print the elements in the subarray of maximum sum without adjacent elements java and Maximum sum of non adjacent ...
35
votes
21answers
4k views

Amount of permutations on an NxNxN Rubik's Cube

Introduction: A 3x3x3 Rubik's Cube has \$43,252,003,274,489,856,000\$ possible permutations, which is approximately 43 quintillion. You may have heard about this number before, but how is it actually ...
8
votes
10answers
548 views

A Megachess Board

You want to create a square chessboard. Adjacent tiles must alternate black and white like a standard chessboard, and the bottom left corner can be either black or white. Your program will take in ...
46
votes
54answers
6k views

Generate an RGB colour grid

This! is an RGB colour grid... Basically it's a 2-dimensional matrix in which: The first row, and the first column, are red. The second row, and the second column, are green. The third row, and the ...
24
votes
21answers
2k views

Fundamental Solution of the Pell Equation

Given some positive integer \$n\$ that is not a square, find the fundamental solution \$(x,y)\$ of the associated Pell equation $$x^2 - n\cdot y^2 = 1$$ Details The fundamental \$(x,y)\$ is a pair ...
36
votes
6answers
3k views

List of Python versions

Python is the fastest-growing major programming language today. It is the most wanted language for the third year in a row, meaning that developers who do not yet use it say they want to learn it.[1] ...
35
votes
21answers
3k views

List *all* the tuples!

Write a program, given an input n, will generate all possible n-tuples using natural numbers. ...
26
votes
12answers
1k views

Letter Boxed validator

The New York Times has a daily online game called Letter Boxed (the link is behind a paywall; the game is also described here), presented on a square as follows: You are given 4 groups of 3 letters (...
8
votes
6answers
1k views

Area of a 2D convex hull [closed]

You are given an array/list/vector of pairs of integers representing cartesian coordinates (x, y) of points on a 2D Euclidean plane; all coordinates are between −104 and 104, duplicates are allowed. ...
16
votes
5answers
655 views

New Order #5: where Fibonacci and Beatty meet at Wythoff

Introduction (may be ignored) Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all ...
17
votes
13answers
2k views

Stars Make Stars

Introduction The idea is to use the asterisk character (star) * to display an ascii-art star at a specified dimension. The dimension is an input number greater ...
1
vote
0answers
149 views

How many right triangles can you find? [closed]

Challenge You will be given an input represented by x, which is a string containing at least 3 characters. It will consist only of the standard numeric characters, ...
21
votes
12answers
1k views

Slither Like a Snake

The Idea We've done matrix spirals before, and full rotations, and even diagonal rotations, but not, as far as I can find, snake rotations! What is a snake rotation? Imagine the rows of a matrix ...
31
votes
50answers
4k views

Simulating Exploding Dice

Your task is to make a program that takes in an integer n > 1, and outputs the roll of a single n-sided die. However, this ...
31
votes
22answers
2k 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 ...
19
votes
15answers
2k views

Match Roman Numerals

Challenge Given some input string, return a truthy value if it represents a correct roman numeral between 1 (=I) and 3999 (=...
14
votes
14answers
1k views

Multiply Two Integer Polynomials

Your task is to take two single-variable integer polynomial expressions and multiply them into their unsimplified first-term-major left-to-right expansion (A.K.A. FOIL in the case of binomials). Do ...
35
votes
14answers
3k views

Worn-tile Scrabble

Problem You're stuck in a cabin in the middle of the woods, with only an old scrabble set to entertain yourselves. Upon inspection you see that the scrabble letters are so worn, that only the points ...
0
votes
0answers
86 views

Output the Missing Character [duplicate]

When writing a programm 1 missing character can ruin everything, wouldn't it be great if the programm told you what was missing ? Task: Create any (non Empty) programm, that takes no input and ...
36
votes
25answers
4k views

Output the Arecibo Message

The Arecibo message is a 1974 interstellar radio message carrying basic information about humanity and Earth sent to globular star cluster M13 in the hope that extraterrestrial intelligence might ...
27
votes
13answers
2k views

Pristine Bit Checking

Write a program/function that takes two integers in the range \$0\$ to \$255\$ inclusive, and returns whether the binary forms of the numbers are exactly one bit different. For example, \$1\$ and \$...
17
votes
19answers
2k views

New order #4: World

Introduction (may be ignored) Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all ...
44
votes
41answers
10k views

Patience, young “Padovan”

Everyone knows the Fibonacci sequence: You take a square, attach an equal square to it, then repeatedly attach a square whose side length is equal to the largest side length of the resulting rectangle....
11
votes
11answers
524 views

Simulate Bitwise Cyclic Tag

Challenge Given two strings in any default I/O format, do the following: NOTE: The challenge will refer to the first string as the "data" and the second referred to as the "program". Change the ...
10
votes
3answers
668 views

How long does it take to type this?

Introduction I can type at a moderate pace, using the QWERTY keyboard layout. But if a word like yellowwooddoor has a ton of repeated letters, it takes a bit longer to type it. Even worse is when a ...
11
votes
6answers
430 views

String Manipulation Interpreter

Summary A new string manipulation language has been made, using only the characters $+#-!*|@>! Your task is to implement an interpreter for it in as few bytes ...
5
votes
18answers
998 views

To string or not to string

Given an input string, output at random the unique combinations with repetition of the characters in the input string, from length 1 up to the length of the input string, with an equal chance of each ...