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
4
votes
1answer
36 views

Tips for golfing in Z80 or SM83 machine code

There's only one question for machine-language golfing, and it's for the ia32 and amd64 architectures. Here's one for a predecessor of them: the Zilog Z80! The ISA is available here. As usual, if your ...
12
votes
10answers
187 views

Outputting Blum Integers

According to Wikipedia, In mathematics, a natural number \$n\$ is a Blum integer if \$n = p \times q\$ is a semiprime for which \$p\$ and \$q\$ are distinct prime numbers congruent to \$3 \bmod 4\$. ...
6
votes
1answer
89 views

Jump trajectory

This is an ascii-art challenge where you will draw ascii-art showing a person "jumping" off the top of a building. The building Input given will be a group of rectangular buildings. You may ...
11
votes
1answer
126 views

Create Word Lightning

Sandbox Inspired by a Codingame challenge I tried (and failed at) about a month ago. Given a binary tree of words, say: ...
17
votes
1answer
198 views

A multiple of n in every base!

In November 2019, Alon Ran published a particularly lovely sequence in the OEIS, A329126: \$a(n)\$ is the lexicographically earliest string of digits which yields a multiple of \$n\$ when read in any ...
14
votes
17answers
669 views

Draw an ASCII Grid

(Based on this closed challenge, related) Given an integer n > 1, draw a grid composed of the characters: "-" "+" and "|". However, since I want the grid to look nice, ...
12
votes
2answers
262 views

Counting uniquely solvable polylinks

Related: Counting polystrips Background Link-a-Pix is a puzzle on a rectangular grid, where the objective is to reveal the hidden pixel art by the following rules: Connect two cells with number N ...
43
votes
8answers
3k views

Write a C++ demangler

If you have ever looked at an objdump of a C++ program, you have likely seen something like this: _ZN3foo3bar3bazI6sampleEE3quxvi3foo This is a C++ mangled symbol, ...
32
votes
24answers
3k views

Is there a single straight line in the matrix?

Inspired by Wzl Determine if a given square binary matrix has exactly one row or column consisting of entirely 1s, and the rest of the matrix is ...
0
votes
0answers
69 views

Make a Webcrawler dictionary writer [closed]

Notice: for any text within <> tags, please ignore any .'s. These are simply added so that they are treated as plain text, and not code. Your goal is to make a program that acts as a regular ...
6
votes
6answers
232 views

US Tax Due Dates

Introduction In a standard* (e.g. not 2020) tax year, estimated payments are due quarterly according to the schedule outlined in Publication 505. Payment Period Due Date January 1 – March 31 April ...
21
votes
16answers
2k views

Largest Number with No Repeating Digit Pairs

Inspired by the problem with the same name on Puzzling SE by our very own Dmitry Kamenetsky. You are to find the largest number that only uses every digit pair once, in a given base. For example, in ...
13
votes
7answers
220 views

Side to side, not up and down

Task Given a list of nodes representing a binary tree of positive integers serialized depth-first, return a list of nodes representing the same tree serialized breadth-first. To represent an absent ...
14
votes
16answers
664 views

Square chunk my matrix

Your challenge is to write a function/program that takes a matrix of integers m and a number n as input and: Splits m into n by n chunks Replaces each chunk with the most common value in that chunk (...
8
votes
20answers
717 views

Trapezoidal Riemann Sum

Given a list of coordinate pairs, output the Trapezoidal Riemann Sum of the values given between the first and last x-coordinates. You will be given a sorted list of coordinate pairs, like this: ...
-6
votes
0answers
105 views

Drawing a grid using '_' and '|' in Python using the least bytes possible [closed]

Write a subroutine in Python that draws a grid based on the two provided parameters. The subroutine should not return the grid, but rather it should output the grid to the console/shell. The ...
15
votes
20answers
799 views

Binomial transform

Background Binomial transform is a transform on a finite or infinite integer sequence, which yields another integer sequence. The binomial transform of a sequence \$\{a_n\}\$ is given by $$s_n = \sum_{...
18
votes
1answer
423 views

Demonstrate some advanced abstract algebra

Consider a binary operator \$*\$ that operates on a set \$S\$. For simplicity's sake, we'll assume that \$*\$ is closed, meaning that its inputs and outputs are always members of \$S\$. This means ...
26
votes
22answers
1k views

Consecutive Distance Rating

We'll call the consecutive distance rating of an integer sequence the sum of the distances between consecutive integers. Consider 2 9 3 6 8 1. ...
26
votes
32answers
2k views

Mr. Binary Counterman

Mr. Binary Counterman, son of Mr. Boolean Masker & Mrs. Even Oddify, follows in his parents’ footsteps and has a peculiar way of keeping track of the digits. When given a list of booleans, he ...
13
votes
7answers
1k views

A Cat’s Game to Claim

Intro You like cats. Naturally, you like cat’s games in tic-tac-toe. So, you’ve come up with a little party trick. You ask someone what square on the board they want you to make a move in. And you ask ...
18
votes
16answers
2k views

Is there a left-right connection?

Task Given a square array of 0s and 1s, determine whether or not there exists a path of 1s connecting the leftmost and rightmost columns. A path can take steps of one unit up, down, left or right, ...
17
votes
8answers
1k views

Generalised multi-dimensional chess knight's moves

Multi-dimensional chess is an extension of normal chess that is played on an 8x8x8x8... "board". In normal 2D chess, a knight's move is a movement by a vector of \$ \begin{bmatrix} \pm 2 \\ \...
11
votes
8answers
2k views

Visualize a Risky program

Risky is a new language of mine, which features an interesting form of tacit programming. In this challenge, you'll take a Risky program as input, and visualize the parsing. No knowledge of Risky is ...
8
votes
3answers
206 views

Implement Fix2 combinator

Background The fixed-point combinator \$\textsf{fix}\$ is a higher-order function that computes the fixed point of the given function. $$\textsf{fix}\ f = f\ (\textsf{fix}\ f)$$ In terms of ...
11
votes
1answer
265 views

Count all my sheep

Sandbox Given a boolean matrix representing my grass field, sheep length \$n\$ and wool thickness \$k\$, you will have to count my sheep. A sheep is a single independent unbroken line of sheep length \...
24
votes
9answers
2k views

Is it a valid Parker Square

5 Years ago, this happend, and then it became sort of a meme. Challenge The Challenge today is, to check if a "magic square" is a valid parker square. What is a Real Magic square? All the ...
25
votes
12answers
2k views

Collatz's ice cream cone factory

The Collatz sequence Given a positive integer \$a_1\$, the Collatz sequence with starting value \$a_1\$ is defined as \begin{equation} a_{n+1} = \begin{cases} a_n/2 & \mathrm{if}\ a_n\ \mathrm{is}\...
15
votes
14answers
1k views

Encode USB packets (part 2)

Inspired by this video by Ben Eater. This challenge forms a pair with Decode USB packets. The USB 2.0 protocol uses, at a low level, a line code called non-return-to-zero encoding (specifically, a ...
10
votes
7answers
379 views

Combinatorial Pipes

You're a plumber working on a house, and there's some pipes that must be connected at weird angles. You have 8°, 11.25°, 22.5°, 45°, and 90° fittings at your disposal, and you want to use as few as ...
17
votes
7answers
2k views

But, Is It Art?

But Is It Art? is an esolang created by ais523, where one step is break the program into orthogonally connected "tiles": A BBBB A B B AA CC A CC Each ...
21
votes
35answers
2k views

Generate this number table

Given an integer \$1 < n < 10 \$ generate a table like below. For \$n = 5\$, 1 2 3 4 5 2 2 3 4 5 3 3 3 4 5 4 4 4 4 5 5 5 5 5 5 For \$n = 8\$, ...
17
votes
12answers
2k views

Remove All Smalltalk Comments for Code Golf

Take a line of input (function arguments or stdin, etc.). Remove comments in it, where a comment starts and ends with ". Do not remove comments in string ...
10
votes
5answers
377 views

Rewrite strings without changing their order

Lexicographic Ordering For this challenge we will be talking about the lexicographic ordering of strings. If you know how to put words in alphabetical order you already understand the basic idea of ...
29
votes
19answers
3k views
+200

Decode USB packets

Inspired by this video by Ben Eater. This challenge forms a pair with Encode USB packets. The USB 2.0 protocol uses, at a low level, a line code called non-return-to-zero encoding (specifically, a ...
17
votes
8answers
1k views

Sum of set bits from 1 to n

Given an integer \$ n \$ \$ (n \ge 1) \$, return/output the total number of set bits between \$ 1 \$ and \$ n \$ inclusive. To make the problem more interesting, your solution must run with a time ...
7
votes
10answers
560 views

A triangle of numbers

Challenge Make a triangle of numbers like below. How to? Let say we get a numbers in the form of ab, for example 12. We then create a triangle like below: Sorry ...
12
votes
0answers
189 views

Help me prove the Four Color Theorem!

This is not just another challenge asking you to color random maps... In this challenge, you are asked to write a program that is actually used in the formal proof of the Four Color Theorem. First I ...
13
votes
8answers
700 views

Simplify K combinatory logic expression

Background Combinatory logic is a system where a term is written using a finite set of combinators and function application between terms, and reduction rules are defined for each combinator. The well-...
4
votes
4answers
359 views

Reorder it up and down

Given infinite different integers, order them into a sequence \$a_1, a_2, a_3, ...\$ such that \$a_i>a_{i+1}\$ iff \$i\$ is even(or odd, as long as it's constant for all possible inputs and all \$i\...
15
votes
14answers
940 views

Evaluation order of an APL n-train

From Codidact with permission. Description APL trains are a series of functions, that get applied to an argument in this way: (f g) x = f g x here ...
19
votes
11answers
4k views

I'm Lazy: Close my Superparens

Picolisp has a feature called "super parentheses": Brackets ('[' and ']') can be used as super parentheses. A closing bracket will match [all parentheses to and including] the innermost ...
5
votes
0answers
224 views

Yet another digit insertion problem

Given a positive number \$n\$ we call another (not same as n) positive number \$m\$ good if we insert same digits in both n and m and the resulting fractional value is same. $$m/n = m_{\text{...
12
votes
8answers
1k views

Is this FEN board a Fischer random chess starting board?

Introduction Fischer random chess, also known as Chess960 for the 960 valid starting boards, is a variant of chess where each player's pieces are randomly shuffled at the start. As a reminder, each ...
23
votes
60answers
5k views

iHateOddNumbers

Task Given a non-negative number, check if it's odd or even. In case it's even, output that number. Otherwise, throw any exception/error that your language supports, and stop the program. Example with ...
7
votes
8answers
487 views

Sums of square roots

Program the sequence \$R_k\$: all numbers that are sum of square roots of some(maybe one) natural numbers \$\left\{\sum_{i\in A}\sqrt i\middle|A\subset \mathbb{N}\right\}\$, in ascending order without ...
12
votes
37answers
2k views

Create an ASCII line, given a length

Information Create a diagonal line given its length (let’s call the variable, say, \$n\$ where \$n > 0\$) The diagonal line starts from the top left and goes to the bottom right. You must use the ...
12
votes
4answers
344 views

Road golf through the mountains

You have a bunch of cities on a grid which you wish to link up. Roads can be placed on any tile that doesn't contain a city, and connect to all roads or cities adjacent to them, vertically, ...
12
votes
9answers
347 views

Taking the long route

Challenge Your goal is to find the furthest point on a graph (from a provided start node). Your code doesn't need to handle cycles in the graph properly, but it might pose a fun challenge. For this ...
15
votes
2answers
211 views

Solve the halting problem for S combinatory logic

Background Combinatory logic is a system where a term is written using a finite set of combinators and function application between terms, and reduction rules are defined for each combinator. The well-...

1
2 3 4 5
209