instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Background
Skip to "Task" if you are familiar with Tic-Tac-Toe (I think most are!)
Tic-Tac-Toe is a famous two-player game. It consists of a 3x3 board that is filled gradually by two players (clarifications below); The first player uses the character X and the other one uses O. The winner is the first to get 3 consecut... | stackexchange_codegolf |
The Zen of Python must surely be one of the most beautiful Easter eggs in any language. (It is created by writing import this)
So why not create a version for your own language?
For those who don't have access to Python 2 or 3, your code should output the following:
The Zen of [YOUR LANGUAGE]
Beautiful is better than ... | stackexchange_codegolf |
Code Golf Challenge
Given a string of 10 characters:
'abcdefghij'
I want to format it in this pattern and print it in the console in a minimum number of characters:
(abc) def-ghij
My solution:
print(f"({s[0:3]}) {s[3:6]}-{s[6::]}")
| stackexchange_codegolf |
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.
By Game of Life, I mean Conway's Game of Life. If you don't know what this is, you can read the Wikipedia article at htt... | stackexchange_codegolf |
Sona is in her house with her 10 year old daughter. She needs to go to school to bring back another child from school, as school is over at 2 pm. It's hot outside, so she wants to leave her younger child at home.
She gave a bunch of strings to her child to keep her busy while she is gone. She asked her to reverse the w... | stackexchange_codegolf |
In these previous challenges[1][2] I've been dealing with "mushroom forests". To help with these I draw little diagrams of the forests to help. In this challenge we are going to reverse engineer the data from these diagrams.
To recap ha! mushroom forests are a list of pairs of non-negative integers. Each pair repres... | stackexchange_codegolf |
Introduction
Super Mario 64 has a heavily overcomplicated RNG, ably explained here by Pannenkoek.
I thought it might be interesting to implement it.
Challenge
Implement the RNG function, except for the two special cases. (Not part of the below description; everything below is what you should implement.)
Input and outp... | stackexchange_codegolf |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
The story continues from AoC2015 Day 3, Part 2. This challenge was kindly contributed by Wheat Wizard (Grain Ghost).
Santa is delivering presents to an infinite two-dimensional grid of houses each 1 unit apart. The delivery begins delivering... | stackexchange_codegolf |
Background
A Ruth-Aaron pair is a pair of consecutive positive integers n and n+1 such that the sum of the prime factors (counting repeated prime factors) of each integer are equal. For example, (714,715) is a Ruth-Aaron pair, since 714=2*3*7*17, 715=5*11*13, and 2+3+7+17=5+11+13=29. The name Ruth-Aaron pair was chosen... | stackexchange_codegolf |
Toki pona is a minimalist constructed language, and thus it has minimalist phonotactics (rules describing what sounds make valid words).
Toki Pona has 8 consonant sounds m, n, p, t, k, s, w, l and j and 5 vowel sounds a, e, i, o, u. A single basic syllable in toki pona consists of any 1 consonant, any one vowel and op... | stackexchange_codegolf |
Challenge
Given a list of SI base units, a list of equations and a target, you must derive the units of the target using only the base units.
Derived Units
From Wikipedia:
The International System of Units (SI) specifies a set of seven base units from which all other SI units of measurement are derived. Each of these ... | stackexchange_codegolf |
Background
Tetris Grand Master 3 has a hidden grading system based on the shape of the stack at the end of the game, which is called Secret ">" Stacking Challenge. It consists of entirely filling the lowest rows except for the zigzag pattern which starts at the left bottom cell and spans the entire width:
#
.#########
... | stackexchange_codegolf |
Sometimes a long absolute path, in e.g. a command-line parameter to a linux tool, can be shortened, using current working directory as reference:
$ pwd
/home/heh
$ cat /home/heh/mydir/myfile
my stuff
$ cat mydir/myfile
my stuff
In this challenge, you should make a function or a program that receives two parameters:
... | stackexchange_codegolf |
Muriel is a language where the only way to loop is to create a quine and execute it. Your job is to create your own language with this property and an implementation of it in a pre-existing language.
We will define a Muriel-like language like as follows:
It has a built-in command for executing code in its own language... | stackexchange_codegolf |
Consider the following process:
Take some non-negative integer N.
e.g. N = 571
Express it in binary with no leading zeroes. (Zero itself is the only exception, becoming 0.)
e.g. 571 = 1000111011 in binary
Break apart consecutive runs of ones and zeroes in this binary representation.
e.g. 1000111011 → 1, 000, 111, 0,... | stackexchange_codegolf |
Given n, k, and p, find the probability that a weighted coin with probability p of heads will flip heads at least k times in a row in n flips, correct to 3 decimal digits after decimal point (changed from 8 because I don't know how to estimate the accuracy of double computation for this (was using arbitrary precision f... | stackexchange_codegolf |
Befunge Chess is an esolang mini-game I invented that is centered around the Befunge esolang. The general gist of the game is to make the instruction pointer land on a specific target cell while avoiding the opponent's target cell.
Today's challenge isn't to play the game, but to simply execute arbitrary boards.
The Ru... | stackexchange_codegolf |
Oof! You've been coding the whole day and you even had no time for Stack Exchange!
Now, you just want to rest and answer some questions. You have T minutes of free time. You enter the site and see N new questions. To write an answer for each you'll need ti minutes. Of course, as a dedicated reputation gatherer, you wa... | stackexchange_codegolf |
Inspired by this question.
Challenge
Let L be a list of n distinct elements. Let P be the set of all (unordered) pairs of positions in P. Let R be a result of applying a pair-swap operation on L by every pair in P in any order.
Example:
L = [1, 7, 8]
P = {(1, 2), (0, 1), (0, 2)}
L = [1, 7, 8] -> [1, 8, 7] -> [8, 1, 7] ... | stackexchange_codegolf |
Posted from sandbox
The Intro
What is an ACU? This challenge is based on the concept of money and since this is an international community, we all use different currencies, so in keeping with our spirit of inclusiveness, I have invented a new currency called Arbitrary Currency Units (ACUs) specifically for this challen... | stackexchange_codegolf |
Some sleep commands implement a delay of an integer number of seconds. However, 2³² seconds is only about 100 years. Bug! What if you need a larger delay?
Make a program or a function which waits for 1000 years, with an error of less than ±10%. Because it's too time-consuming to test, please explain how/why your soluti... | stackexchange_codegolf |
I saw a problem which asks you to print "Hello World" using the fewest characters, including spaces. How can I further shorten this code? Thank you in advance!
#include<iostream>
int main(){printf("Hello World");}
| stackexchange_codegolf |
What is the Ultraradical?
The ultraradical, or the Bring radical, of a real number \$a\$ is defined as the only real root of the quintic equation \$x^5+x+a=0\$.
Here we use \$\text{UR}(\cdot)\$ to denote the ultraradical function. For example, \$\text{UR}(-100010)=10\$, since \$10^5+10-100010=0\$.
Challenge
Write a ful... | stackexchange_codegolf |
"Counter" is a language I've created for the purpose of this question.
Rules
Commands are read from left to right from the first character.
Each command may be executed as it is read, or you may execute all commands together at the end.
In case of an error, all commands up till the error must be executed.
A program is... | stackexchange_codegolf |
After giving back the results of the last topology exam to his students, Pr. Manifold was worried about complaints.
Since he is aware his students know where his office is located, Prof. Manifold decided to transform his office into a bunker with a 10 digit password (all characters are digits).
But he suspected his st... | stackexchange_codegolf |
True color (24-bit) at Wikipedia is described in pertinent part as
24 bits almost always uses 8 bits of each of R, G, B. As of 2018
24-bit color depth is used by virtually every computer and phone
display and the vast majority of image storage formats. Almost all
cases where there are 32 bits per pixel mean that... | stackexchange_codegolf |
Working on something in probability theory, I stumbled across another combinatorical exercise. These are always fun to solve, searching for intelligent approaches. Of course, one can use brute force for the following task, but this challenge is restricted complexity, so this is not allowed.
Task
Given an integer Input ... | stackexchange_codegolf |
Believe it or not, the Sex Bob-ombs have become a world famous band and are currently on world tour! As their bookkeeper you must oversee their day to day finances and provide regular reports.
Every few weeks you compile a list of their expenses (in whole USD) in the order they were incurred.
For example, the list
378
... | stackexchange_codegolf |
If a positive integer \$N > 2\$ has (strictly) less prime factors (without counting multiplicities) than its successor and its predecessor, we will call it a factor-poor number.
In other words, \$\omega(N) < \omega(N - 1)\$ and \$\omega(N) < \omega(N + 1)\$, where \$\omega(N)\$ is the number of unique prime factors of... | stackexchange_codegolf |
Write a self replicating program, in the source code filename H.*, contianed in an empty folder then manually compile and run or just run the program if your chosen language is dynamic, and it should then just create a new source file, e.*, with the same exact source code, and automatically compile/run that new program... | stackexchange_codegolf |
I'm trying to make a pointfree function f that can act like APL's dyadic forks/Husk's §, so f g h i a b equals g (h a) (i b), where g is a binary function, h and i are unary functions, and a and b are integers (I'm only dealing with integers and not other types right now). I converted the function to pointfree in the f... | stackexchange_codegolf |
Lagrange's four square theorem tells us any natural number can be represented as the sum of four square numbers. Your task is to write a program that does this.
Input: A natural number (below 1 billion)
Output: Four numbers whose squares sum to that number (order doesn't matter)
Note: You don't have to do a brute force... | stackexchange_codegolf |
The Fibonacci sequence is a fairly well known thing around here. Heck, it even has its own tag. However, for all that, we sure like to stick to our roots of 1, 1, ... (or is it 0, 1, ...? We may never know...). In this challenge, the rules are the same, but instead of getting the nth item in the Fibonacci sequence, you... | stackexchange_codegolf |
Given two strings \$ A \$ and \$ B \$ and a positive integer \$ n \$, determine whether \$ B \$ is composed entirely of (possibly overlapping) strict substrings of \$ A \$ of a length of at least \$ n \$.
Test cases
n A B Output
-----------------------------------------
2 abcdefg ... | stackexchange_codegolf |
Note: Anders Kaseorg warns me that this could be a duplicate of another previous question. It seems so, and I'm sorry I did not find that question before posting this one. Nonetheless, that question only received one answer and this one is simpler, just in case you all want to try this time. I'll understand if this qu... | stackexchange_codegolf |
What does "jelly" mean in the title?. Robber's thread
Jelly has an "Evaluate the argument as Python 3" atom, ŒV which takes a string as an argument as evaluates that string as Python 3 code: Try it online!.
It also has compressed strings, delimited with “...» that can compress any string containing printable ASCII (plu... | stackexchange_codegolf |
Related OEIS sequence: A008867
Truncated triangular number
A common property of triangular numbers is that they can be arranged in a triangle. For instance, take 21 and arrange into a triangle of os:
o
o o
o o o
o o o o
o o o o o
o o o o o o
Let's define a "truncation:" cutting triangles of the same s... | stackexchange_codegolf |
Take the vector of unknowns , and apply some generic differentiable function . The Jacobian is then given by a matrix such that:
For example, suppose m=3 and n=2. Then (using 0-based indexing)
The Jacobian of f is then
The goal of this challenge is to print this Jacobian matrix.
Input
Your program/function should ... | stackexchange_codegolf |
This code challenge will have you compute the number of ways to reach \$n\$ starting from \$2\$ using maps of the form \$x \mapsto x + x^j\$ (with \$j\$ a non-negative integer), and doing so in the minimum number of steps.
(Note, this is related to OEIS sequence A307092.)
Example
So for example, \$f(13) = 2\$ because t... | stackexchange_codegolf |
If we take the natural numbers and roll them up counter clock-wise into a spiral we end up with the following infinite spiral:
....--57--56
|
36--35--34--33--32--31--30 55
| | |
37 16--15--14--13--12 29 54
| | | | |
38 17 ... | stackexchange_codegolf |
Using the following table (source) write some code that takes the names of two planets and returns the distance between them:
+-------------------+---------------+
| Planets | Distance (km) |
+-------------------+---------------+
| Mercury -> Venus | 50290000 |
| Venus -> Earth | 41400000 |
| Ea... | stackexchange_codegolf |
I wanted to fool a friend by giving him a quine that almost worked, but became sloppier and sloppier.
Create a program that, when run, will output the program, but one character off. Either one character can be added, removed or both (one character changes). But only one character.
Your score will be (length of your pr... | stackexchange_codegolf |
Background
Famously, the acronym GNU stands for GNU's Not Unix. 1
It's recursive because, after expanding it once, it still contains the acronym GNU, and so must be exanded again:
(GNU's Not Unix)'s Not Unix
And so on, ad infinitum. Visualizing this, we get a kind of Droste effect:
┌─────────────────────────────────... | stackexchange_codegolf |
Due to technical limitations of Stack Exchange, the title is rendered incorrectly. The correct title for this challenge is
Make a
Word Icicle!
Word Icicle
Word cicle
ord cicle
ord icle
ord i le
or i le
or i l
or l
or
r
Today's challenge is to make icicles out of t... | stackexchange_codegolf |
This is the Robbers' thread. Cops' thread is here.
Background
Boggle is a board game where the players have to find English words on a 4-by-4 board of random alphabets. Words can be constructed by selecting sequentially adjacent cells on the board. ("adjacent" means horizontally, vertically or diagonally adjacent.) A... | stackexchange_codegolf |
BLC (Binary Lambda Calculus) is a binary encoding of untyped lambda calculus which was created to “provide a very simple and elegant concrete definition of descriptional complexity.”
What are some tips on how to golf down BLC programs/functions?
Please submit only one tip per answer!
| stackexchange_codegolf |
There are several questions regarding this game, even a king-of-the-hill contest here. But I think all those challenges and contests need a way to automatically determine the winner of a game. So:
Challenge
Given two inputs in the range ["rock", "paper", "scissors", "lizard", "spock"] representing the selections for pl... | stackexchange_codegolf |
The goal of this challenge is to extend the OEIS sequence A334581.
Number of ways to choose \$3\$ points that form an equilateral triangle from the \$\binom{n+2}{3}\$ points in a regular tetrahedral grid of side length \$n\$.
The sequence begins 0, 0, 4, 24, 84, 224, 516, 1068, ...
Example
For example, if we take sid... | stackexchange_codegolf |
Story
I need to remember a lot of passwords and don't want to use the same one for multiple websites so I came up with a rule, but the rule shouldn't be transparent so what I do is:
Think of a long word or concept such as breadpudding.
Replace the first letter with the site we are logging into. If we are logging into ... | stackexchange_codegolf |
Write a program that outputs the number 0.
That's a bit trivial, isn't it?
Let the length of your program be \$S\$. Write a program that outputs the number 0. When your program is cyclically shifted \$i < S\$ bytes left, it should output \$i\$. To cyclically shift a string \$i\$ bytes left means to move the last \$i\$ ... | stackexchange_codegolf |
Synopsis
Your goal is to implement the (asymptotically) fastest growing function within bounded code on a fictional CPU utilizing a quite limited, yet (probably) turing-complete instruction set.
Environment
The CPU utilizes unbounded RAM as well as two registers, the accumulator A and the program counter C, with words ... | stackexchange_codegolf |
Introduction:
Beckett Grading Service (aka BGS), is a company which encapusulates and grades Trading Card Game (TCG) cards (i.e. sport cards, Magic The Gathering, Pokémon, Yu-Gi-Oh, etc. etc.). The TCG cards that come in for grading will be checked on four categories (which we will later refer to as subgrades): centeri... | stackexchange_codegolf |
Write an infinite list of triangle codes, defined as code where the i-th line has i bytes for all lines, such that the i-th code generates (i-1)th code and has 1 more line than the (i-1)th code.
The score is the number of lines in the initial code. Lowest score wins.
For example, if
.
..
...
....
is outputted by
.
..
... | stackexchange_codegolf |
The objective of this challenge is to take an array of positive integers, and enumerate its indices, grouping like elements.
An enumeration without any duplicates is done by just outputting an array of pairs (value, index), for example, [3, 4, 13, 9, 2] => [[3,1],[4,2],[13,3],[9,4],[2,5]].
However, if a given element a... | stackexchange_codegolf |
On the TV cooking show Guy's Grocery Games, the chefs cannot begin shopping until Guy Fieri, the show's host, says "Three, two, one, go!" However, the words do not have to be all together. He often "hides" the words in things like this (based on a real example, but not quoting verbatim):
There are three of you here; a... | stackexchange_codegolf |
Here is a list of some common
ligatures in Unicode (the
ones I could create with my Compose key on Debian):
Orig Ascii Lig
ae [ae] æ
AE [AE] Æ
oe [oe] œ
OE [OE] Œ
ij [ij] ij
IJ [IJ] IJ
ff [ff] ff
fi [fi] fi
fl [fl] fl
ffi [ffi] ffi
ffl [ffl] ffl
You have two options in this ... | stackexchange_codegolf |
Problem:
Given a string representing a mathematical expression with constants (pi, e, psi, i), basic arithmetic operations (+, -, *, /), parentheses, fractions, and exponentiation, write a program or function to convert a string to its equivalent LaTeX code. The input string will only contain digits, arithmetic operato... | stackexchange_codegolf |
Your task is to output a spaceship of size n with shooters/guns and n bullets of character - (with spaces in between each bullet) for each gun
Rules
If n is odd, you must output the guns every even numbered row
If n is even, you must output the guns every odd numbered row
All rows with guns must have n+1 # character... | stackexchange_codegolf |
Suppose we have an array \$\texttt{ps}\$ of length \$n\$ with pointers pointing to some location in the array: The process of "pointer jumping" will set every pointer to the location the pointer it points to points to.
For the purpose of this challenge a pointer is the (zero-based) index of an element of the array, thi... | stackexchange_codegolf |
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 signed one (using two's complement).
For example:
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
1... | stackexchange_codegolf |
Substitute a string with itself
Your goal is to substitute a string with itself by replacing each character in the original string with the one before it, starting with the first character and wrapping around. Here are some examples to show what I mean:
1st example:
Input: program
Output: apgopra
How:
Program -> mrogr... | stackexchange_codegolf |
Related
From Wikipedia:
In number theory, the Calkin–Wilf tree is a tree in which the vertices correspond one-to-one to the positive rational numbers. The tree is rooted at the number \$1\$, and any rational number expressed in simplest terms as the fraction \$\frac{a}{b}\$ has as its two children the numbers \$\frac{... | stackexchange_codegolf |
Given a boolean function with inputs, check if it's possible to only use IMPLY gate to express it.
There's no extra limitation on how you use this gate, and you can use each input for any amount of times. See examples below:
\$\begin{matrix}
\text{Expression}&&&&&\text{Solution}&\text{Your output}\\
a&0&0&1&1&a&\text{t... | stackexchange_codegolf |
There has recently been a big snow, and my driveway needs snow-blowing. If the snow-blower goes over some area that it has already snow-blowed, then that area will have snow blown onto it and need to be blown again. And of course, the snow-blower cannot start in the middle of the driveway, it needs to start from my gar... | stackexchange_codegolf |
Your task
Given a integer input, \$ n \$ (such that \$ n > 1 \$), decide whether it can be written as the sum of (at least 2) consecutive square numbers.
Test cases
Truthy:
Input Explanation
5 1 + 4
13 4 + 9
14 1 + 4 + 9
25 9 + 16
29 4 + 9 + 16
30 1 + 4 + 9 + 16
41 16 + 25
50 9 + 16 + ... | stackexchange_codegolf |
A Shift matrix is a binary matrix with one superdiagonal or subdiagonal formed by only ones, everything else is a zero.
A superdiagonal/subdiagonal is a diagonal parallel to the main diagonal, which is not the main diagonal, i.e. all entries \$a_{ij}\$ where \$i=j+k\$ and \$k \neq 0\$.
The main diagonal is defined to b... | stackexchange_codegolf |
I am sorry for the very long description. But i think some information of how /proc/self/cmdline works and how it can be used to get a integer input was necessary.
You may skip the sections you don't need.
While part of this task is related to C and Linux, it can be done in any almost language that can start other prog... | stackexchange_codegolf |
A Hilbert Curve is a type of space-filling curve, and it basically maps a line to a plane. Each point in the line corresponds to just one point in the plane, and each point in the plane corresponds to just one point on the line. Shown are iterations 0 through 4 of the Hilbert Curve:
Iterations 0 up to 4:
The objec... | stackexchange_codegolf |
Discussion in courtrooms often occurs at a high speed and needs to be accurately transcribed in case the text of the decision is needed in future cases. For this purpose, the stenographers who transcribe court discussions use specially designed keyboards with a small set of buttons, which are pressed in groups to spell... | stackexchange_codegolf |
Background
Here in the UK1, these are the income tax rules:
You get a personal allowance (untaxed) of up to £12,570:
If you earn less than £100,000, you get the full £12,570 as personal allowance
For every £2 over £100,000, your personal allowance goes down by £1
After the personal allowance, the next £37,700 is ta... | stackexchange_codegolf |
Given a text like this:
# #### ## #
## # ## #
#### ##
Output the same text but by connecting the pixels with the characters ─│┌┐└┘├┤┬┴┼. If a pixel doesn't have any neighbours, don't change it.
So the output of the last text is:
│ ─┬── ┌─ │
└─ │ ┌┘ │
└──┘ ─┘
You can take input as a boolean array.
The inp... | stackexchange_codegolf |
Given integer n, output the smallest exponent e greater than 1 such that n^e contains n as a substring.
For example, for 25, the answer should be 2, as 25 ^ 2 = 625, which contains 25 as a substring, but the answer for 13 should be 10, as 13 ^ 10 = 137858491849, so 10 is the lowest exponent for which the result contain... | stackexchange_codegolf |
It is in my humble opinion that standard text is boring. Therefore I propose a new writing standard, walking words!
Walking words
Walking words are words which will respond to certain characters. For the purpose of this challenge the trigger characters are [u, d, r, l] from up down right left.
Whenever you encounter su... | stackexchange_codegolf |
Introduction
Busy Beavers are programs (specifically Turing Machine programs) that aim to output the most ones as possible, while having the least states as possible and halting.
Challenge
Your challenge is to make a busy beaver, which outputs as many ones as possible, but also outputs a second busy beaver. That secon... | stackexchange_codegolf |
If you haven't played the game Baba is You, I think you really should. Whether you’ve played it or not, have a go at implementing it as a code golf.
The idea behind this challenge is to have a bit more complicated, non-standard task with a bit longer answers.
Game rules
Alas, the challenge is not to implement the entir... | stackexchange_codegolf |
Your function must accept one string and return the opposite
The opposite string is a string where all characters go in reverse order, all letters are replaced with the opposite mirror letter from the English alphabet and are changed in case, and all digits are replaced with opposite mirror digits
opposite mirror for l... | stackexchange_codegolf |
The challenge:
Given four coordinates, each in x y form, your job is to find out whether or not the given coordinates form a rectangle, and output a truthy/falsey.
Rules:
For the sake of simplicity, squares, lines (two identical pairs of coordinates) or dots (all four of the coordinates are the same) are all counted a... | stackexchange_codegolf |
Is there any better way to golf this (other than removing newlines/indentation)?
function(a,b,...)
local c=s(a,b)
local d=c
for i,v in ipairs{...} do d=d:push(v) end
return c
end
I'm particularly bothered by the double local usage, but as Lua does not have multiple assignment, and I cannot use function paramet... | stackexchange_codegolf |
Traditionally presents are kept secret in boxes wrapped in paper. Since the ice caps are melting Santa Claus has begun to investigate some ways they might make the whole gift wrapping operation a little more eco-friendly. The first thing they've decided to do is to put all presents in perfectly cubic boxes. This makes... | stackexchange_codegolf |
Part of the lean Language of the Month
A pong* is a set \$P\$ with an operation \$+\$, that satisfies the following properties:
\$
\forall a, b \in P : (b + b) + a = a\\
\forall a, b \in P : a + (b + b) = a\\
\forall a, b, c \in P: a + (b + c) = (a + b) + c \\
\$
This makes a pong*, just a group where every element is ... | stackexchange_codegolf |
Introduction
You have gotten a job as the minister of finance in your made-up country in your back yard. You have decided to make your own bank in your country for you and your less trustworthy friends. Since you don't trust your friends, you have decided to write a program to validate all transactions to stop your fri... | stackexchange_codegolf |
Task
Given two positive integers:
Draw the rectangle with dimensions specified by the two integers.
Repeat Step 3 until there is no more space.
Draw and fill the largest square touching three sides of the (remaining) rectangle.
Output the resulting rectangle.
Example
For example, our input is 6 and 10.
We draw the ho... | stackexchange_codegolf |
Dungeon Master was one of the first ever real-time role-playing games, originally released in 1987 on the Atari ST. Among other exciting things for the time, it offered a rather sophisticated spell system based on runes.
Your task today is to write a program or function that evaluates the number of Mana points required... | stackexchange_codegolf |
Your challenge is to format a list of words across multiple lines that are no longer than a given number of characters, so that each line contains as many words as possible and no words are unnecessarily cut off.
Input
The input will be a space-separated list of words and then a number that is at least 4.
Output
The ou... | stackexchange_codegolf |
I've been doing quite a few code golf recently and I realised that a lot of times, I have to do something involving list.
Most of the times lists are space-separated or comma-separated values in the first argument (argv[2]), and the return value should also be a space/comma-separated string.
Are there any tips for conv... | stackexchange_codegolf |
Much harder than Can this pattern be made with dominoes?
Challenge
A grid of width \$w\$ and height \$h\$ is given, filled with 1s and 0s. You can place a domino somewhere on the grid only if both cells are 1. You cannot overlap dominoes. What is the maximum number of dominoes you can fit in the given grid?
The worst-c... | stackexchange_codegolf |
Fast and Golfiest Robbers Thread
Welcome to the first season of Fast and Golfiest, a cops-and-robbers challenge! I designed this challenge to encourage competitive coding for efficiency (fastest algorithm) to become more popular on the site.
The rules are simple. The cops choose problems from LeetCode, a competitive co... | stackexchange_codegolf |
You want to write your English essay. However, all characters on your keyboard broke other than the arrow keys and the enter key. You want to find out how to place the characters so you can write your essay with the least movement.
Formally, you have to assign to each character of !"$%&'()+,-./0123456789:;<=?[]`abcdef... | stackexchange_codegolf |
This proposal had few attention for 8 months (though an answer was posted in the sandbox at that time), so I decided to post it anyway.
Introduction
Napier's bones is a calculation tool, which helps speeding up the calculation of multiplication, division and digit-by-digit square root extraction by turning n-digit-by... | stackexchange_codegolf |
In this challenge, you implement an interpreter for a simple stack-based programming language. Your language must provide the following instructions:
push a positive number
pop two numbers and push their sum
pop two numbers and push their difference (second number - first number)
pop a number and push it twice (dup)
p... | stackexchange_codegolf |
Write some code that takes a single non-negative integer \$n\$ and outputs the \$n\$th power of phi (\$\phi\$, the Golden Ratio, approximately 1.61803398874989) with the same number of decimal digits as the \$n\$th Fibonacci number.
Your code must produce the correct sequence of digits for all inputs up to at least 10 ... | stackexchange_codegolf |
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-known S and K combinators have the following reduction rules:
$$
\begin{aligned}
S\;x\;y\;z & \overset{S}{\implies} x\;... | stackexchange_codegolf |
Find a maximally profitable sequence of exchanges given an exchange rate table.
As an example consider the currencies Ariary (your home currency), Baht, Cedi, and Denar where the rate from one to another (after any transaction rate has been levied) is given by the (row, column) entry in the exchange rate table below:
... | stackexchange_codegolf |
Write a single line program two or more characters long that contains no line terminators and takes no input. For example, your program might be:
MyProgram
When your program is arranged into the shapes a clock's hands make at 12, 3, 6, and 9 o'clock, it needs to output the corresponding hour number. No other times nee... | stackexchange_codegolf |
Challenge
Given a positive integer, determine whether that number is currently being used to represent a question on PPCG.
The question must not have been removed, but may be open or closed.
The number is the one being used in the URL of the question, such as:
https://codegolf.stackexchange.com/questions/[input]
Note... | stackexchange_codegolf |
Introduction:
I think most people will know how darts work. But since some might not, here are the rules of playing Darts in a nutshell:
Amount of players: 2
Starting points: 501
Goal: Get your points to 0 first
Darts per player: 3
Available numbers on the board: 1 through 20, and Bulls-eye
Here is the layout of a Da... | stackexchange_codegolf |
The problem over here introduces an new type of strings: if you split the string into equal halfs and swap the pairs, it produces the same output as sorting the string. We call that a half-sort.
Given a purely ASCII string, check if the string is in a half-sort.
An example of a half-sort string
The string node is a hal... | stackexchange_codegolf |
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 with a line spanning N cells, so that the two cells are at the two ends of the line.
The number 1 is considered connected t... | stackexchange_codegolf |
When writing a message with fridge magnets, you'll often find yourself substituting a 1 for an I. In this challenge, your goal is to find out if a message can be written using the letters of another message. The allowed substitutions are:
A = 4
B = 8
C = U
E = M = W = 3
G = 6 = 9
I = 1
L = 7
N = Z
O = 0
R = 2
S = 5
Fo... | stackexchange_codegolf |
Given a word, your task is to compact it by saving its first character and removing any other vowel (aeiou).
Input
Your input can be the word in STDIN, a function argument or any other input format that doesn't break the standard loopholes. You can assume the input only consists of lower characters.
Output
Your output... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.