Questions tagged [code-golf]

Code-golf is a competition to solve a particular problem in the fewest bytes of source code.

Filter by
Sorted by
Tagged with
7
votes
3answers
65 views

Is this an L-shape?

Background An L-shape is defined as a polyomino which can be made by extending two rectangular legs in orthogonal directions from a full square (called a pivot). The size of the square should be at ...
7
votes
6answers
158 views

Coordinate Connecting

Input: Ten unique integer coordinates, between (0,0) and (100,100). Output: The coordinates arranged in the order/an order such ...
11
votes
22answers
636 views

Implement a zipwith function

zipwith is a functional construct that takes three arguments: one binary function and two lists of the same length, and returns a single list where each element is ...
28
votes
16answers
4k views

Is it a lobster number?

Introduction A "lobster number", by my own designation, is a number that contains within itself all of its prime factors. The "lobster" description was inspired by the recent ...
9
votes
0answers
133 views

8 out of 10 programmers like countdown [duplicate]

Edit (Jan 24/2021): The original specification for the challenge had a few problems. Underneath the original text, I have added alternate conditions that were suggested by @caird-coinheringaahing (...
16
votes
18answers
2k views

Print a 3D shape

Write a program or a function to print the following cube (if you allow me to call it so) in different sizes: ...
11
votes
5answers
358 views

Approx how many search results

When one performs a search query using Google, one of the first things you see is an approximation of how many results were found. Today, you'll be simulating this in as few bytes as possible. Input A ...
11
votes
14answers
936 views

Merge Two Paragraphs with Removing Duplicated Lines

Challenge The goal of this challenge is to make a function that takes two paragraphs and output a concatenated result with removing the duplicated overlapped lines due to redundancy (but a single copy ...
11
votes
3answers
328 views

A graph and its seven closures

Background A little while ago, someone posted an interesting puzzle on Math.SE: What is the smallest digraph (directed graph) G where the following eight graphs are all distinct: G, the original ...
32
votes
26answers
6k views

Speed of Lobsters

From the subreddit r/SpeedOfLobsters: Edit the text of an image to create a new phrase This meme format/style is pretty self-explanatory. Simply have a browse through the subreddit if you need more ...
-1
votes
0answers
85 views

The Changing Quine [duplicate]

the goal here is to make a proper quine that outputs its source code and changes the source code to another quine that does the same thing. after some runs, which doesn't have to be two, the source ...
21
votes
34answers
2k views

Print a conversion table for (un)signed bytes

Your task: Print or return a conversion table with every byte from 00 to ff's value as an unsigned integer, to its value as a ...
41
votes
11answers
5k views

The first published picture of the Mandelbrot set

Here’s the picture of the first published picture of the Mandelbrot set. Use the fewest bytes possible to write a program or function that outputs the following. A trailing new line is permitted. ...
17
votes
13answers
3k views

Landau logarithm

Related: Landau's function (OEIS A000793) Background Landau's function \$g(n)\$ is defined as the largest order of permutation of \$n\$ elements, which is equal to \$\max(\operatorname{lcm}(a_1,a_2,\...
2
votes
0answers
105 views

Compute the minimal and maximal subset of a set of sets [closed]

Let S be a set of sets, for example S = {{A},{B},{A,B}}. A maximal subset, Max, is an element of S such that no other set in S ...
7
votes
5answers
599 views

Does this JavaScript function support keyword arguments?

JavaScript has no direct support for keyword arguments, but it supports argument object destructuring. It is standard to use a destructed final argument for keyword arguments. Here is an example: <...
14
votes
8answers
2k views

Is my triangle on the lattice?

Write a program or function which takes three positive integers \$a, b, c\$ and returns/outputs one value if there is, and a different value if there isn't, a triangle on the square lattice, whose ...
3
votes
0answers
333 views

Solve a Cubic Equation [closed]

Input Your program will take in the integer coefficients of the equation \$ax^3+bx^2+cx+d=0\$ as inputs (a, b, c, and d). Output All real solutions of the input equation, with an accuracy of at ...
9
votes
1answer
273 views

Win a KQ vs K endgame

Win a K vs KQ endgame Summary The goal of this challenge is to create a program or function which will win a Chess game with a King and Queen against a lone King. The user will specify three squares, ...
20
votes
5answers
729 views

The Caged Circles

This problem will have you analyzing circles drawn on the grid, with the gridlines drawn at integer values of \$x\$ and \$y\$. Let \$\varepsilon\$ be a very small number (think, \$\varepsilon = 0.0001\...
8
votes
3answers
493 views

Validating a Battleship board

Do you know the game Battleship? Well, I want to play with my little brother, but before we can begin we need to set up our ships on the board. This is your input. Now, we need to check that the ships ...
3
votes
2answers
346 views

Minimal Pairing

Your program should take two lists, where each entry (a positive integer) represents the number of members of some group, as input. These lists will have the same sum but may have different lengths. ...
18
votes
14answers
662 views

Sub-string Extractor with Specific Keywords

Challenge The goal of this challenge is to make a function that takes an input string, a start keyword and a end keyword. The output extracted result is from (but excluded) the given start keyword to (...
21
votes
19answers
3k views

Draw an ASCII hexagon of side length n

Given a positive integer \$n\$ output an ASCII hexagon with diagonal side length \$n\$, as pictured (note there are \$2n\$ _ characters on the top edge) Examples: \$...
27
votes
10answers
2k views

Help Stack Exchange transpose tables

Stack Exchange doesn't know how to transpose tables. Let's help. Given a markdown table, transpose it. Input assumptions: There will be at least two rows (including header) and two columns Either all ...
13
votes
20answers
1k views

Linear integer function generator

Inspired by a recent challenge involving Fibonacci numbers in which OEIS was mentioned, I would like to present a challenge of creating a function that generates a wide array of different linear ...
22
votes
18answers
972 views

Interpret Interval Notation

Interval notation is a way to write complicated range bounds more conveniently and concisely than writing an inequality. The challenge, should you choose to accept it, is to write a program or ...
18
votes
5answers
1k views

Find a sequence in the binary digits of π

Given a binary sequence of finite length, find the starting position where this sequence first appears in the binary digits of π (after the decimal). You can assume that an answer exists for any input ...
11
votes
5answers
566 views

Ellipsoid surface area

Related: Ellipse circumference Introduction An ellipsoid (Wikipedia / MathWorld) is a 3D object analogous to an ellipse on 2D. Its shape is defined by three principal semi-axes \$a,b,c\$: $$ \frac{x^2}...
24
votes
13answers
4k views

How long till Halley's Comet returns?

Halley's Comet is the only comet that may appear (i.e. become visible to the naked eye on Earth) twice in a human lifetime. The orbital period of Halley's Comet is not constant: it has varied between ...
13
votes
11answers
1k views

Golfing Advent of Code 2020, Day 3

I thought it'd be interesting to turn AoC day 3 puzzle into a Golfing Challenge, so here it is. Task Find the number of # you'd encounter in an 11x11 grid (...
17
votes
18answers
2k views

Vandalizing Marquees

A marquee is a low-tech board that allows customizable letters. For example, here is a marquee: SALE ON SNEAKERS However, someone might come along and vandalize it ...
8
votes
13answers
394 views

Von Neumann Neighborhood

Your goal is to make a function that takes the coordinates of a cell in 2D space and a distance \$r\$ and returns the coordinates of all cells in the input coordinate's von Neumann neighborhood of ...
6
votes
15answers
789 views

Prime generating function

Background The Python code ((((((((n%35)^11)*195)|53)&181)+n)%168)*n)+83 produces 74 distinct primes for \$0 \le n \le 73\$. This code also works in Java. The ...
23
votes
14answers
2k views

Pascal's Fibonacci Triangle

What do you get when you cross Pascal's Triangle and the Fibonacci sequence? Well, that's what you have to find out! Task Create a triangle that looks like this: ...
20
votes
27answers
974 views

Partial sums of the Kempner series

The Kempner series is a series that sums the inverse of all positive integers that don't contain a "9" in their base-10 representations (i.e., \$\frac{1}{1} + \frac{1}{2} + \frac{1}{3} + .. +...
23
votes
12answers
1k views

Bedevil your hangman opponent

Task You are playing Hangman, and your opponent uses a simple but effective strategy: Each turn, from the remaining letters, they guess the letter that appears most frequently across all possible ...
16
votes
14answers
1k views

Split a number in every way possible way within a threshold

Task Given a positive integer number and a threshold, split into every possible way without generating any numbers above the threshold. Examples Input: 15008 Threshold: 400 Valid Output: ...
2
votes
1answer
136 views

Twist on words to numbers [closed]

The Goal The goal of this question is to put a twist on this question. Your answer should be able to convert an array of words associated with integers into those integers. As an extra challenge, ...
30
votes
2answers
1k views

Golf the smallest sphere!

Inspired by this challenge, as well as a problem I've been working on Problem: Given a non-empty set of points in 3D space, find the diameter of the smallest sphere ...
13
votes
7answers
619 views

Generalised Taxicab Numbers

\$\newcommand{T}[1]{\text{Ta}(#1)} \newcommand{Ta}[3]{\text{Ta}_{#2}^{#3}(#1)} \T n\$ is a function which returns the smallest positive integer which can be expressed as the sum of 2 positive integer ...
24
votes
25answers
2k views

Based Palindromes

A palindromic number, as a refresher, is any number which reads the same forward as backwards. However, what about palindromes in other bases? Input Any integer b ...
17
votes
16answers
5k views

I don't like curry

I don't like curry. Help me reverse the effects of this evil question - Make me some curry - by uncurrying functions. Task Given a blackbox curried function, output its uncurried equivalent. The ...
23
votes
2answers
1k views

Eye test - How many squares are in this picture?

The picture: Sick of the same old grid where the answer is simply a square pyramidal number? Accept the challenge and write a program that given a positive integer \$n\$ counts how many squares are ...
11
votes
17answers
1k views

Polynomial Laplace transform

This is a repost of this challenge, intended to revamp it for looser I/O formats and updated rules You are to write a program which takes an integer polynomial in \$t\$ as input and outputs the ...
6
votes
3answers
335 views

Golf me a polygonal loader

Codidact post, CGCC Sandbox, Codidact Sandbox Given three positive integers as input, animate an ascii-art polygonal loading symbol on the screen. Intro You will be given three inputs, \$n\$, \$l\$, ...
4
votes
5answers
177 views

Strobogrammatic Numbers [duplicate]

Strobogrammatic Numbers Definition A number which is rotationally symmetrical, i.e., it'll appear the same when rotated by 180 deg in the plane of your screen. The following figure illustrates it ...
27
votes
37answers
2k views

Jelly's Untruth

Jelly has an "untruth" atom: . This takes a non-empty array of positive integers and returns a Boolean array with 1s at the indexes in the input. For ...
13
votes
8answers
1k views

How Many Atoms?

How Many Atoms? Write the shortest code that when given a chemical formula as input, outputs the total number of atoms in the formula. Input A chemical formula in any reasonable format. Each chemical ...
37
votes
31answers
4k views

Find the “Bittiest” Number [closed]

The Challenge Given a list of integers, the "bittiest" number among them is the one with the most bits on - that is, the largest amount of bits set to 1. Write a function (or a program) that ...

1
2 3 4 5
203