Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [code-golf]

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

47 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
18 votes
0 answers
992 views

Find a Glider Synthesis (Game of Life)

Challenge Summary In summary, the challenge is to provide the glider synthesis for a Game of Life configuration, which is your input. What does this mean? Well, firstly, let me explain a few terms. ...
user avatar
  • 40.2k
13 votes
0 answers
437 views

Lean golf: Balanced Bracket Sequence

Ungolfed, ugly, horrible proof to help you make progress on this challenge: https://gist.github.com/huynhtrankhanh/dff7036a45073735305caedc891dedf2 A bracket sequence is a string that consists of the ...
user avatar
13 votes
0 answers
593 views

Finding Radical Ideals

Sandbox Finding radicals of arbitrary ideals in rings is hard! However, it's a doable task in polynomial rings, since they are Noetherian (all ideals are finitely generated) Background A quick ...
user avatar
11 votes
0 answers
160 views

Optimize for Bgil Midol's slicing scoring

In Bgil Midol's question, the score of a sequence of slice is defined as sumof|startslices|∗2+sumof|endslices|∗2+sumof|stepslices|∗3 Such scoring method makes multiple slices possibly take less ...
user avatar
  • 12.7k
11 votes
0 answers
470 views

Radiation is Painful

A radiation-hardened quine can take a hit and stay standing, but nobody ever said that the quine can't be a wuss about it. For this challenge, you should write a quine that: If no characters are ...
user avatar
  • 3,566
11 votes
0 answers
381 views

Tips for Golfing in SQLite?

I was looking for this page to help me enhance my first answer with SQLite, but I couldnt find one. So here we are! What general tips do you have for golfing in SQLite? I'm looking for ideas that can ...
user avatar
  • 1,937
11 votes
0 answers
246 views

Simulate Alpha Decay

Alpha Decay is a kind of radiation decay where every time the atom "decays", it loses a helium nucleus (an alpha particle). This means that an atom loses 2 protons and 2 neutrons each time. ...
user avatar
11 votes
0 answers
1k views

Find a dual graph

A dual graph is defined such that for every "face" in a graph G, there is a corresponding vertex in the dual graph, and for every edge on the graph ...
user avatar
10 votes
0 answers
135 views

NP-complete reduction: (grid-)Hamiltonian circuit

Background Hamiltonian circuit problem is a decision problem which asks whether a given graph has a Hamiltonian circuit, i.e. a cycle that visits every vertex exactly once. This problem is one of the ...
user avatar
  • 62.2k
10 votes
0 answers
205 views

Cover positions with snakes of same 'colour'

Imagine a grid where the origin square \$(0,0)\$ is at the top left of the screen, and positive \$x\$ is rightwards whereas positive \$y\$ is downwards. Coloured squares are at various positions on ...
user avatar
10 votes
0 answers
548 views

mini SPICE solver

SPICE is an electrical circuit simulation program originating from UC Berkeley. Your goal is to implement a minimalistic version which can solve for the nodal voltages and branch currents of a circuit ...
user avatar
9 votes
0 answers
253 views

Tips for golfing in Chef

What general tips do you have for golfing in Chef? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Chef (e.g. "remove unnecessary ...
user avatar
  • 2,493
9 votes
0 answers
296 views

Jelly compression quine

The golfing language Jelly has a very complex and clever string compression system which I'm not going to go into depth about here. You can find a very good explanation here. Basically, Jelly's string ...
user avatar
  • 27.6k
9 votes
0 answers
521 views

Chaining autograms

Write a program that takes one integer input n and one format letter and outputs n autograms in the format This sentence contains ? "A"s, ? "B"s ... and ? "Z"s. ...
user avatar
  • 4,220
9 votes
0 answers
1k views

Simple chess bot

Inspired by this Implement simple chess bot (with console or GUI) that has following features: [Pseudo-]graphically showing the board; Accepting user moves and making their own moves; Playing by ...
user avatar
  • 2,697
8 votes
0 answers
302 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{...
user avatar
  • 509
8 votes
0 answers
432 views

Get ERC-20 token balance

Ethereum is a blockchain platform. It has its own native cryptocurrency, ether, but in this challenge, we'll be focusing on its ability to run smart contracts. The ERC-20 standard describes an ...
user avatar
8 votes
0 answers
238 views

Find the smallest triangle encompassing the specified polygon

Input: An integer N which represents the polygon's vertices and a list of their x and y coordinates. Expected output: The smallest difference possible between the area of the(not necessarily convex) ...
user avatar
  • 315
8 votes
0 answers
780 views

Generate Loopy puzzles

Loopy is a puzzle game from the collection of Simon Tatham. The previous link contains a javascript implementation of a Loopy puzzle generator. I suggest everybody who wants to attempt this challenge ...
user avatar
  • 9,952
7 votes
0 answers
297 views

Count the length of head movement

Once upon a time I wanted to order custom tokens for a board game. They say they can do it, and then they present me their price list. I was confused because they charge per inch of head movement, and ...
user avatar
7 votes
0 answers
344 views

Code Golf: BlackJack - best moves

The Challenge I was looking into small code examples for a specific language as a small tutorial and came accross a simplified Blackjack that should be implemented. In this Challenge you will have to ...
user avatar
7 votes
0 answers
222 views

Decompose the domain

In scientific computing, it is often desirable to decompose some large domain into smaller "subdomains", then parallelize the computation by performing the work on each subdomain in parallel and the ...
user avatar
6 votes
0 answers
194 views

Heart Point Generator

It's mentioned last time that, in Hearts, Each round every player gets a non-negative amount of points. The sum of the points is 26, and at least one player gets 13 or more points. Actually, it's ...
user avatar
  • 12.7k
6 votes
1 answer
289 views

Further golfing this C# code from Scramble words while preserving their outlines

I'll start off by saying I checked and checked again that this question should be on topic. I will also clearly state that this is a tips question about further golfing a certain set of code not a ...
user avatar
5 votes
0 answers
199 views

Simulate the isotropic non-totalistic cellular automaton

There are many generalizations of Conway's Game of Life. One of them is the isotropic non-totalistic rulespace, in which the state of a cell in the next generation depends not just on its state and ...
user avatar
5 votes
0 answers
188 views

Construct the suffix automaton

In computer science, a suffix automaton is the smallest partial deterministic finite automaton that recognizes the set of suffixes of a given string. (Wikipedia) Given a string \$S\$ consisting of ...
user avatar
5 votes
0 answers
331 views

Another version of "The Bridge and Torch Problem"

The idea for this code golf puzzle is from link: The Bridge and Torch Problem The inspiration for this code golf puzzle is the Bridge and Torch problem, in which d people at the start of a bridge ...
user avatar
5 votes
0 answers
378 views

Find the pattern

I feel tired to do "find the pattern" exercise such as 1 2 3 4 (5) 1 2 4 8 (16) 1 2 3 5 8 (13) Please write a program that finds the pattern for me. Here, we ...
user avatar
  • 12.7k
5 votes
0 answers
333 views

Tetris overlooked move counter

Playing tetris is fun. Watching an AI play tetris is also fun. Some tetris AIs will always ignore the possibility of maneuvering a piece under an overhang, which makes me sad. It means that the ...
user avatar
5 votes
0 answers
688 views

Chess Light Solver

Challenge Write a solver for the Chess Light puzzle game, in the smallest amount of code. The input will be a representation of a chessboard, how in yours is up to you. My examples below is textual, ...
user avatar
  • 1,318
4 votes
0 answers
211 views

Convert To Shorthand Part 2

Part 1 of the challenge revolved around converting the letters into specific unicode characters. Lore In this part we receive the output from the function made in Part 1, which now has to be arranged ...
user avatar
  • 409
4 votes
0 answers
109 views

Tips for golfing in Objective C

Surprisingly, I do not think this question has been asked before Although on codingame.com, Objective C and C are two of the best golfing languages there, so I would like to know some of the best ...
user avatar
  • 3,051
4 votes
0 answers
166 views

Tips for Golfing the Lambda Calculus & Friends

This includes tips for all related derivatives, as coding in these langs often primarily consists of writing the function in the lambda calculus and then compiling it down at the end. Among others, ...
user avatar
  • 1,921
4 votes
0 answers
284 views

Rope&Nail logic

Related, both rope, nail and falling, but reversed and some other differences Consider a loop of rope hanging on n nails on a row. Given a table showing whether ...
user avatar
  • 12.7k
4 votes
0 answers
262 views

2017 SCRAM Finder

Background The nuclear industry has term, SCRAM, used to describe a quick shutdown of the reactor. There's a fun myth that it stands for "Safety Control Rod Ax Man," the role which served ...
user avatar
  • 1,628
4 votes
0 answers
279 views

Code Golf Pro Golfer Least Swings Calculator

Your Challenge: For a golf Course Of Inputted 'n' length to hole where: ...
user avatar
  • 69
4 votes
0 answers
220 views

Golfing Delayed Expansion Variables in Batch

Enabling delayed expansion variables in Batch chews up a lot of bytes. The shortest I have managed to make it is: @!! 2>nul||cmd/q/v/c%0&&exit/b ...
user avatar
  • 2,354
3 votes
0 answers
176 views

Tips for golfing in Seriously

I am looking for tips to code in this golfing language Seriously, and was wondering what some of the ways for golfing this language is. "Remove comments" is not a tip. Actually is also ...
user avatar
  • 3,051
3 votes
0 answers
146 views

Tips for golfing in SageMath

SageMath is an open-source mathematics software system, built on Python 2. Its extensive math library support makes it a strong choice for golfing in math-based challenges. What tips do you have for ...
user avatar
3 votes
0 answers
383 views

Create a World Cup overview

I'm not to sure about the title so feel free to suggest a better one. Task/challenge Create an overview for the World Cup tracking the cup from the group phase till the finals. Group phase There ...
user avatar
  • 2,609
2 votes
0 answers
65 views

Tips for golfing in Fennel

Fennel is a lispy language which compiles to Lua. From its page: Fennel is a programming language that brings together the speed, simplicity, and reach of Lua with the flexibility of a lisp syntax ...
user avatar
  • 1,579
2 votes
0 answers
206 views

Bracket Depth List

Challenge Your challenge is simple, calculate the depth of each matching brackets in the given input e.g. (()()(()))->...
user avatar
  • 3,051
2 votes
0 answers
69 views

Smallest OCI Container That Handles PID 1 Signals Correctly

Introduction There have been a few examples of the smallest possible OCI container that does "X". However these examples never correctly handle termination signals. Challenge Produce the ...
user avatar
2 votes
0 answers
134 views

Conic Sections (simplified)

Given the equation of a non-parabolic conic section, output its characteristics. Spec Some info on conic sections: for more info visit Wikipedia From an equation of the form \$ax^2+bx+cy^2+dy+E=0\$, ...
user avatar
1 vote
0 answers
272 views

FreeCell stack moving

This question is about moving stacks around in the card game FreeCell, but here it will be presented more abstractly. Given three integers \$0\le n,m<10000,0<k<10000\$. There are \$m+2\$ ...
user avatar
  • 12.7k
1 vote
0 answers
197 views

Mixed fractions without delimiters

Help! I printed a bunch of rational numbers with no spaces or other delimiters other than the / in the fractions. There is, however, good news! All the numbers are ...
user avatar
  • 5,978
-2 votes
1 answer
190 views

Compare array of decimal sum of Integers and exact fractional part

Develop a program which takes two arrays of decimal numbers, and compare the sum of whole numbers only and the decimal part. If the sums of the whole numbers are the same, and the decimal parts of ...
user avatar