Questions tagged [code-golf]

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

48 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
21 votes
0 answers
1k 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. ...
hyper-neutrino's user avatar
  • 42.4k
13 votes
0 answers
494 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 ...
aloisdg's user avatar
  • 2,017
12 votes
0 answers
486 views

Is it a legal atomic chess move?

Background and Rules There is a variant of chess called atomic chess, which follows essentially the same rules as normal chess, except that pieces explodes other pieces around them when captured. In ...
Aiden Chow's user avatar
  • 13.2k
12 votes
0 answers
677 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 ...
Rushabh Mehta's user avatar
12 votes
0 answers
531 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. ...
caird coinheringaahin g's user avatar
11 votes
0 answers
675 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 ...
Huỳnh Trần Khanh's user avatar
11 votes
0 answers
228 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 ...
Bubbler's user avatar
  • 76k
11 votes
0 answers
272 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 ...
lightlyheld's user avatar
10 votes
0 answers
216 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 ...
l4m2's user avatar
  • 23.8k
10 votes
0 answers
615 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 ...
Nissa's user avatar
  • 3,624
9 votes
0 answers
279 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 ...
Fmbalbuena's user avatar
  • 3,847
8 votes
0 answers
475 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 ...
Nick Clifford's user avatar
7 votes
0 answers
331 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 ...
CuttingChipset's user avatar
7 votes
0 answers
384 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 ...
PlatinTato's user avatar
7 votes
0 answers
250 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 ...
helloworld922's user avatar
6 votes
2 answers
54 views

Print all legal chess moves

The game of chess has moves. Lots of moves. But how many, exactly? In this challenge, you must print all possible chess moves for a single player (black or white — you choose). Moves are distinguished ...
anatolyg's user avatar
  • 13.5k
6 votes
0 answers
277 views

Solve the word problem*

In this challenge you will receive a list of positive integers \$W\$ called a word, and a square symmetric matrix \$M\$. Your task is to determine if the word can be turned into the empty list by ...
Wheat Wizard's user avatar
  • 98.5k
6 votes
0 answers
264 views

Shortest CSS selector to select ALL html elements, without using asterisk *

What is the shortest selector (by character count) to select ALL html elements on a web page, without using asterisk (*)? Some examples are the following: ...
user3163495's user avatar
6 votes
0 answers
269 views

Write a proof checker for first order logic

This originally came from Give the best Chaitin incompleteness bound, but I realized that there was a fragment of this problem which still potentially gives a good coding challenge. First Order Logic ...
Charles Wang's user avatar
6 votes
0 answers
205 views

Give the best Chaitin incompleteness bound

This was originally a pure mathematics question, but I think I've got the best chance for an answer here. The Challenge For concreteness, consider Peano Arithmetic (PA). For some language L of your ...
Charles Wang's user avatar
6 votes
1 answer
430 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 ...
TheLethalCoder's user avatar
6 votes
0 answers
2k views

Probability to win a hand of poker (Texas hold 'em)

Challenge: In the last stage of a two players Texas hold 'em, given a two-card hand and five cards on table, determine your probability to win versus an opponent by the standard ranking of poker ...
Cœur's user avatar
  • 435
5 votes
0 answers
267 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 ...
Baaing Cow's user avatar
5 votes
0 answers
234 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 ...
Baaing Cow's user avatar
5 votes
0 answers
374 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 ...
Felix Ha's user avatar
  • 169
5 votes
0 answers
364 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 ...
BenGoldberg's user avatar
5 votes
0 answers
753 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, ...
Adam Speight's user avatar
  • 1,314
4 votes
1 answer
277 views

Custom Games of Life

There's a lot of questions about Conway's Game of Life, but nothing about customization (Related: 2-Player Life). Given an input, determine the result on a 100x100 grid after some iterations. The ...
Infigon's user avatar
  • 563
4 votes
0 answers
272 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 ...
Saphereye's user avatar
  • 517
4 votes
0 answers
218 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 ...
DialFrost's user avatar
  • 5,079
4 votes
0 answers
162 views

Tips for golfing in Objective C

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 golfing methods (although I am a python person, I am currently trying ...
DialFrost's user avatar
  • 5,079
4 votes
0 answers
285 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 ...
wnnmaw's user avatar
  • 1,608
4 votes
0 answers
241 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 ...
unclemeat's user avatar
  • 2,334
3 votes
0 answers
104 views

Tips for golfing in Arn

Does anyone have tips on how to golf in this language? Please one tip per answer and avoid posting simple and general tips such as "remove whitespace". Here is the github link and here is ...
DialFrost's user avatar
  • 5,079
3 votes
0 answers
310 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 ...
l4m2's user avatar
  • 23.8k
3 votes
0 answers
154 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
302 views

Code Golf Pro Golfer Least Swings Calculator

Your Challenge: For a golf Course Of Inputted 'n' length to hole where: ...
Monster's user avatar
  • 67
3 votes
0 answers
396 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 ...
Teun Pronk's user avatar
  • 2,617
2 votes
0 answers
272 views

Implement the simplest functional programming language

The goal of this challenge is to compare how well different programming languages support functional programming, by seeing how much code it takes to implement BLC8, the simplest functional ...
John Tromp's user avatar
  • 1,176
2 votes
0 answers
164 views

Golf a PSK31 modulator

Given a string of ASCII text as input, encode it in BPSK31 using Varicode. You may either output an audio file in any common format, or play the audio over the device speakers. You may output at any ...
Someone's user avatar
  • 1,580
2 votes
0 answers
90 views

Tips for golfing in Thue

Anyone got tips for golfing in Thue. One tip per answer, and no tips aplicable to all languages (like remove comments)
Dadsdy's user avatar
  • 2,085
2 votes
0 answers
277 views

Shorten this dns txt record request script as much as possible

I have made a short script that will pull dns txt records down from a server and combine them into a single string. DNS txt records are: 1.website.com ...
I am Jakoby's user avatar
2 votes
0 answers
95 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 ...
zoomlogo's user avatar
  • 1,655
2 votes
0 answers
108 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 ...
Gabriel Jones's user avatar
2 votes
0 answers
159 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
302 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\$ ...
l4m2's user avatar
  • 23.8k
0 votes
0 answers
116 views

Shortest Float32Array to Int32Array conversion for audio processing

I'm currently converting a Float32Array to an Int32Array for input to a real-time audio raw PCM to MP3 recording application. <...
guest271314's user avatar
0 votes
0 answers
299 views

How quickly can you type this string?

Given a string consisting of only printable ascii (letters, numbers, symbols, and spaces), how many keystrokes are required minimally to type out this string from scratch? That is, current text is ...
Larry Bagel's user avatar
  • 4,173