Questions tagged [atomic-code-golf]

Atomic code golf is scored by the number of operations in a specific fragment of a language you define.

Filter by
Sorted by
Tagged with
135 votes
11 answers
14k views

(-a) × (-a) = a × a

We all know that \$(-a) \times (-a) = a \times a\$ (hopefully), but can you prove it? Your task is to prove this fact using the ring axioms. What are the ring axioms? The ring axioms are a list of ...
Wheat Wizard's user avatar
  • 97.8k
74 votes
5 answers
9k views

Machine Learning Golf: Multiplication

I'd like to propose a different kind of golfing challenge to this community: (Artificial) Neural Networks are very popular machine learning models that can be designed and trained to approximate any ...
Stefan Mesken's user avatar
50 votes
5 answers
2k views

Multiply with restricted operations

There's a 500 rep unofficial bounty for beating the current best answer. Goal Your goal is to multiply two numbers using only a very limited set of arithmetic operations and variable assignment. ...
xnor's user avatar
  • 145k
47 votes
3 answers
4k views

Construct a pentagon avoiding compass use

Rules You will start with only two elements: Points \$A\$ and \$B\$ such that \$A \neq B\$. These points occupy a plane that is infinite in all directions. At any step in the process you may do any ...
Wheat Wizard's user avatar
  • 97.8k
35 votes
2 answers
4k views

Tribute to John Conway: Collatz in FRACTRAN

John Horton Conway was a brilliant mathematician. Among his contributions were three Turing-complete esolangs: Game of Life (esolangs wiki), FRACTRAN (esolangs wiki), and Collatz function (esolangs ...
Bubbler's user avatar
  • 75.2k
34 votes
9 answers
5k views

Make 1s using a bunch of 1s

Your task is to form an expression equaling \$ 11111111111 \text{ (11 ones)} \$ using only the following characters: 1+(). Keep in mind that the result is in base ...
dingledooper's user avatar
  • 22.6k
34 votes
7 answers
4k views

Shortest "arithmetic" formula to output 1000 primes

Write a formula using only the digits 0-9, +, *, -, <...
prime_directive's user avatar
33 votes
3 answers
30k views

Google's doodle on kids coding: shortest program solving all the levels

Today's Google doodle is about Celebrating 50 years of Kids Coding: The goal is program the path of a little bunny so that it can eat all the carrots. There are 4 types of blocks (see pictures below): ...
Surb's user avatar
  • 441
28 votes
11 answers
4k views

Calculate n % 12 [closed]

Calculate n modulo 12 for an unsigned 32 bit integer. The Rules: Must work for all n ...
Nathaniel Bubis's user avatar
27 votes
11 answers
5k views

Is this number an exact power of -2: (Very) Hard Mode

This is a version of the recent challenge Is this number an integer power of -2? with a different set of criteria designed to highlight the interesting nature of the problem and make the challenge ...
Jason C's user avatar
  • 6,502
25 votes
5 answers
5k views

Shortest expression for {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}

Given list of integers {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}. For those who interested these numbers are used in weekday calculation. Weekday = ...
Somnium's user avatar
  • 2,669
23 votes
2 answers
13k views

Build a multiplying machine using NAND logic gates

Based on my previous question of the same type, Build an adding machine using NAND logic gates, this time you're being asked to multiply instead of add. Build a diagram of (two-wire) NAND logic gates ...
Joe Z.'s user avatar
  • 34.8k
23 votes
5 answers
2k views

Implement a very simple ALU using only NAND gates

Note: This challenge was inspired by Joe Z's many excellent questions surrounding NAND golfing. Description Your goal in this challenge, should you choose to accept it, is to implement a very simple ...
Qaziquza's user avatar
  • 1,623
22 votes
2 answers
865 views

Write it into number theory style

Write a mathematical statement, using the symbols: There exists at least one non-negative integer (written as E, existential ...
l4m2's user avatar
  • 22.3k
22 votes
3 answers
963 views

Prove DeMorgan's laws

Using the the ten inferences of the Natural Deduction System prove DeMorgan's laws. The Rules of Natural Deduction Negation Introduction: {(P → Q), (P → ¬Q)} ⊢ ¬P ...
Wheat Wizard's user avatar
  • 97.8k
20 votes
12 answers
6k views

Determine if an integer is divisible by 3

Your goal is to determine if a number is divisible by 3 without using conditionals. The input will be an unsigned 8 bit number from 0 to 255. Creativity encouraged! You are ONLY allowed to use ...
qwr's user avatar
  • 12.1k
20 votes
4 answers
1k views

SKI calculus golf: Half of a Church numeral

Background SKI combinator calculus, or simply SKI calculus, is a system similar to lambda calculus, except that SKI calculus uses a small set of combinators, namely ...
Bubbler's user avatar
  • 75.2k
17 votes
15 answers
5k views

Find the maximum of 3 numbers without branching

This time around your goal is to find the maximum of 3 integers (from -(2^31) to 2^31 - 1 in binary 2's complement) without using branching or loops. You are only allowed to use Inequality/Equality ...
qwr's user avatar
  • 12.1k
17 votes
1 answer
2k views

Google's Hopping Bunny

On December 4, 2017, the Google Doodle was a graphical programming game featuring a bunny. The later levels were nicely non-trivial and they seemed like a great candidate for an atomic-golf challenge. ...
El'endia Starman's user avatar
17 votes
0 answers
763 views

How to golf string output in Chef

I'm attempting to solve a programming golf style programming puzzle. I need to write an 18 character phrase in Chef in less than 32 "lines" of code. In this case, a line counts as an ingredient or an ...
Jason Thompson's user avatar
16 votes
3 answers
2k views

Final tribute to John Conway: FRACTRAN self-interpreter

It's time to conclude the series of John Conway challenges of mine. Background A FRACTRAN program consists of an ordered list of fractions. The program starts by taking a single integer as input. Each ...
Bubbler's user avatar
  • 75.2k
16 votes
5 answers
2k views

Abstract Syntax Tree Golfing: FizzBuzz, Python

Summary Implement FizzBuzz in Python, with the fewest possible tokens. Challenge Write a program that prints the decimal numbers from 1 to 100 inclusive. But for multiples of three print “Fizz” ...
isaacg's user avatar
  • 41.9k
16 votes
1 answer
865 views

Build a minifloat adding machine using NAND logic gates

A minifloat is a binary representation of a floating-point number that has very few bits. The minifloat in this question will be defined as an 6-bit number m, ...
Joe Z.'s user avatar
  • 34.8k
15 votes
3 answers
563 views

Count the number of disjoint 11 blocks

The task is to count the number of disjoint 11 blocks in a 64-bit word, using the minimum number of straight-line instructions. That is, how many nonoverlapping ...
Falk Hüffner's user avatar
15 votes
4 answers
1k views

No branching please

Anyone who is moderately into low level code optimization know about the perils of branching, be it implemented as if-statements, loops or select-statements the possibility of a branch misprediction ...
aaaaaaaaaaaa's user avatar
  • 4,395
15 votes
1 answer
431 views

Build the stove controller (physically)

Challenge Build the Wheat Wizard's stove using 2-input NAND gates. The solution with the fewest NAND gates wins. Externally, it works in the following way: (the first line is added from the original ...
Bubbler's user avatar
  • 75.2k
14 votes
4 answers
6k views

Drive a hexadecimal 7-segment display using NAND logic gates

The ubiquitous 7-segment numerical display can unambiguously display all 16 hexadecimal digits as show in this wikipedia .gif Entries for this challenge will create a circuit diagram using NAND logic ...
Digital Trauma's user avatar
14 votes
2 answers
818 views

Densely packed decimal (DPD) to decimal, with logic gates

Inspired by recent popularity of nandgame on TNB, and my own previous challenge. Background Densely packed decimal (DPD) is a way to efficiently store decimal digits in binary. It stores three ...
Bubbler's user avatar
  • 75.2k
13 votes
3 answers
2k views

Hexcellent Minesweeping

Hexcells is a game based off of Minesweeper played on hexagons. (Full disclosure: I have nothing to do with Hexcells. In fact I don't really like the game.) Most of Hexcells rules can be pretty ...
Wheat Wizard's user avatar
  • 97.8k
13 votes
4 answers
669 views

Build a 4-vertex Connectedness Tester using NAND gates

A connected graph is a graph that contains a path between any two vertices. Challenge Build a [2-input NAND-gate] circuit that determines whether a 4-vertex graph is connected. (A gate's 2 inputs can ...
user avatar
12 votes
14 answers
8k views

Print NxN spiral of ascending numbers [closed]

The numbers should be printed with leading zeroes in a field with length = (number of digits of N^2). Input (N): 4 Output: ...
Hristo Hristov's user avatar
12 votes
6 answers
4k views

Implement an 8 bit adder

The Challenge Implement a function which accepts two integers whose values range from 0 - 255 and returns the sum of those integers mod 256. You may only use bitwise negation (~), bitwise or (|), bit ...
Orby's user avatar
  • 874
12 votes
2 answers
1k views

SKI calculus golf: Hello, World!

Background SKI combinator calculus, or simply SKI calculus, is a system similar to lambda calculus, except that SKI calculus uses a small set of combinators, namely ...
Bubbler's user avatar
  • 75.2k
12 votes
5 answers
579 views

Get Two from One

As we saw in this question complex logical statements can be expressed in terms of the simple connectives of generalized Minesweeper. However Generalized minesweeper still has redundancies. In order ...
Wheat Wizard's user avatar
  • 97.8k
12 votes
2 answers
2k views

Build a bit-counting comparator using NAND logic gates

A bit-counting comparator (BCC) is a logic circuit that takes some number of counting inputs A1, A2, A3, ..., An as well as inputs ...
Joe Z.'s user avatar
  • 34.8k
12 votes
2 answers
617 views

Branchless (MIPS) assembly code for median of 3

I was trying to write a short MIPS32 code for computing the median of three registers. The rules: Assume that some values are pre-loaded into $t0, ...
M A's user avatar
  • 221
12 votes
4 answers
936 views

Find the password

An ordinary N-digit combination lock consists of N rotating discs. Each disc has digits 0-9 inscribed in order, and you need to turn them to the correct password to open it. Obviously, if you don't ...
Colera Su's user avatar
  • 2,421
11 votes
2 answers
551 views

Egg hunting in Collatz style

Inspired by The Great API Easter Egg Hunt! Summary Your task is to search for a predetermined integer in the "Collatz space" (to be explained later) using the fewest step possible. ...
Weijun Zhou's user avatar
  • 3,637
10 votes
2 answers
1k views

Build an EBCDIC converter using NAND logic gates

In this question, a mapping is defined between EBCDIC and a superset of ISO-8859-1. Your task is to build a network of two-input NAND gates that will take eight inputs ...
Joe Z.'s user avatar
  • 34.8k
10 votes
3 answers
981 views

Blind binary adder

Imagine you have two boxes B(x) and B(y), each containing an unknown bit - 0 or 1, and a machine ...
ngn's user avatar
  • 15.2k
10 votes
3 answers
965 views

"Atomic" code golf - determine the number of neutrons in an isotope

Your task is to take an string containing an isotope of an element as input, encoded like the following example with the atomic number followed by a space and the IUPAC chemical symbol for the element:...
Joe Z.'s user avatar
  • 34.8k
10 votes
3 answers
1k views

Sort a list of numbers on the λ-calculus

Write a term on the pure untyped lambda calculus that, when applied to a church-encoded list of numbers, returns it with its numbers sorted in ascending or descending order. Church lists and numbers ...
MaiaVictor's user avatar
9 votes
4 answers
454 views

Collatz sequence on a two counter machine

The Collatz sequence starting from a positive integer n is defined in this way: if n is even then divide it by 2 (n' = n / 2) if n is odd then multiply it by 3 and ...
Marzio De Biasi's user avatar
9 votes
3 answers
1k views

Build a 2-way universal logic processor using NAND logic gates

A 2-way universal logic processor (2ULP) is a network of logic gates that takes two input wires A and B, as well as four other ...
Joe Z.'s user avatar
  • 34.8k
9 votes
5 answers
372 views

Write biSp in point-free form using as few terms as possible

The Haskell function biSp has type signature ...
dspyz's user avatar
  • 933
9 votes
2 answers
1k views

Create a universal two-dimensional cellular automaton cell using two-way universal logic processors

In Conway's Game of Life, a cell is in a state of either on or off, depending on the on-and-off state of the eight cells surrounding it. We can simulate this using a logic gate network with some sort ...
Joe Z.'s user avatar
  • 34.8k
9 votes
3 answers
535 views

Efficient table-lookup computation

The challenge: compute the day of the week from a MM-DD representation of a day in this year (2021). However, you have to write your program in the following subset ...
DELETE_ME's user avatar
  • 17.3k
8 votes
3 answers
834 views

Crack the Lost Numbers

The Lost Numbers are 4, 8, 15, 16, 23, 42. Your goal is to create an expression to output them all. Your allowed characters are 0123456789, ^+-*/, (), % for modulo and n as the single variable allowed....
AndrewTheCodegolfer's user avatar
8 votes
1 answer
493 views

Use a Finite Combo in Magic the Gathering to Produce Graham's Number

Produce Graham's Number in Magic the Gathering using the fewest number of cards and without using any infinite combos. Rules: Producing Graham's number means do anything that requires Graham's number ...
Zags's user avatar
  • 397
8 votes
4 answers
887 views

Pretty Printing Parentheses [closed]

The worst part about long lines or code or math equations are the parentheses. Nobody wants to read through 2x(3y+4*abs(x^[2*e^x])-5{3(x+y)-5})! So, the goal of ...
beary605's user avatar
  • 4,310