instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
You will need to evaluate the definite integral (bounded by \$a\$ and \$b\$) of a certain polynomial function that takes the form of:
$$\int_a^b \left( k_n x^n + k_{n-1} x^{n-1} + \cdots + k_2x^2 + k_1x + k_0 \: \right) dx$$
Normally, this can be done using the fundamental theorem of calculus and power rules. For examp... | stackexchange_codegolf |
Yesterday while playing with my kid I noticed the number in his toy train:
So we have $$4281$$ that can be split into $$4-2-8-1$$ or $$2^2-2^1-2^3-2^0$$
So simple challenge: given a non-negative number as input, return consistent truthy and falsey values that represent whether or not the string representation of the n... | stackexchange_codegolf |
Given an integer n as input, write a function that dynamically allocates n bytes and returns their address.
Rules
The allocator must be able to dynamically allocate memory at runtime.
It doesn't matter where the memory is allocated to or in what form, as long as it's allocated in a valid location which can be read fro... | stackexchange_codegolf |
A Latin square is a square that has no repeated symbols in the rows or columns:.
13420
21304
32041
04213
40132
And as many Sudoku players know, you don't need all of the numbers to deduce the remaining numbers.
Your challenge is to compress a Latin square into as few bytes as possible. You need to provide one or two... | stackexchange_codegolf |
Write a program that takes two integers as an input; the first can be any integer and the second is less than or equal to the number of digits in the first number. Let these numbers be a and b respectively.
The program will do the following
Concatenate a minimal number of 1s to the end of a so the number of digits in ... | stackexchange_codegolf |
Write the shortest POSIX-form regular expression that matches only non-negative integers divisible by 9. The non-negative integer should be given in base 10.
| stackexchange_codegolf |
We can define the Divisibility Streak k of a number n by finding the smallest non-negative integer k such that n+k is not divisible by k+1.
Challenge
In your language of choice, write a program or function that outputs or returns the Divisibility Streak of your input.
Examples:
n=13:
13 is divisible by 1
14 is divisib... | stackexchange_codegolf |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
The story continues from AoC2018 Day 3.
But you're not Bubbler, you're Lyxal! yeah, I know.
After a long period of chaos, the Elves have finally agreed on how to cut the fabric. Unfortunately, the next day they have come up with how to utili... | stackexchange_codegolf |
Bitshift Variations in C Minor by Robert Miles is a Code Golf music piece written in C (with some additional bash commands). It was originally presented in a 2016 Computerphile video Code Golf & the Bitshift Variations. You can listen to clean renderings of it here (by Lucia Ceionia).
The original 2016 source code pres... | stackexchange_codegolf |
Challenge
Write a program that generates the song "There Was A Stream", detailed below.
Description
The song "There Was a Stream" is a camping song. It takes N parameters and generates a song of length O(N2) lines. A sample song (first 3 verses) is given here.
Rules
Your entry must take a list of strings and out... | stackexchange_codegolf |
So, this is a task from one very popular educational site in Russia:
https://acmp.ru/index.asp?main=task&id_task=786&ins=1
Mathematically, you need to find the power of two not exceeding the given number, read from the standard input stream, and output their difference in the standard output stream.
My python3 solution... | stackexchange_codegolf |
For this challenge, a linked list looks like this:
[1, 2, 4, 0, 6, 1, 3, 1]
You'll notice there's no data; each item in the list is just a reference to the index of the next one. Your task is to write a program or function which will follow a linked list like this forever, outputting each item as it is encountered. Fo... | stackexchange_codegolf |
Mission is simple. Just output number 2015 as QR code and write it to file named newyear.png in PNG format. Code must be valid any day, so maybe you shall not use current year.
QR code as text looks like this:
# # # # # # # # # # # # # # # # # #
# # # # #
# # # # # # # # ... | stackexchange_codegolf |
I'm looking for some solution in returning values in main function, I need to shorten my program more, return 0 takes too much characters of my code, I need to return 0, or my code fails. I know that in C there can be no return statement, and then program will use result of last operation - but on which operations I ca... | stackexchange_codegolf |
Dedicated to Martin Gardner, taken from his book
Background
In the old days, the Slavs had a divination method for finding out whether a girl would get married. The girl would clutch six straws in her hand so that the ends would poke out the top and bottom of her fist. Then her friend would join together the ends of pa... | stackexchange_codegolf |
Challenge
Write a function which takes one parameter: an integer t. Your function has to stop your program for t seconds before continuing, similar to time.sleep(t) in Python and WAIT t in BBC BASIC.
You must not use any built in waiting functions or any built in functions for executing code after a certain time, and y... | stackexchange_codegolf |
Step one
In a new google sheet insert an image into cell A1 with
Insert > Image > Image In Cell
Step two
Create a formula to return TRUE (if the cell contains an image) and FALSE (if the image is missing)
Rules
Only vanilla formulas are allowed. The shortest code in bytes wins.
| stackexchange_codegolf |
A mortality table or life table is an actuarial tool that gives the probability that a person aged \$A\$ years will die in the next year, and is used to help calculate the premiums for life insurance, among other things. One of the first people to compile a life table was Edmond Halley, of cometary fame. These probabi... | stackexchange_codegolf |
In the examples below, A and B will be 2-by-2 matrices, and the matrices are one-indexed.
A Kronecker product has the following properties:
A⊗B = A(1,1)*B A(1,2)*B
A(2,1)*B A(2,2)*B
= A(1,1)*B(1,1) A(1,1)*B(1,2) A(1,2)*B(1,1) A(1,2)*B(1,2)
A(1,1)*B(2,1) A(1,1)*B(2,2) A(1,2)*B(2,1)... | stackexchange_codegolf |
I want to read two strings on separate lines, each string the same length and containing only 0's and 1's, and determine if the first is the one's complement of the second. How succinctly can this be done in Python3? (Sorry to specify the language, but this is for my son who's studying Python)
A list comprehension see... | stackexchange_codegolf |
Gray Code is a number system where only 1 bit of the number changes from one number to the next number. Print the 8 bit Gray Code values of 0 to 255.
Shortest Code wins!
Start of output:
0 00000000
1 00000001
2 00000011
3 00000010
4 00000110
5 00000111
6 00000101
7 00000100
...
You only have to print the Gra... | stackexchange_codegolf |
As a couple of people may have noticed lately, I've largely abandoned development of Braingolf because it's boring and uninspired, and moved on to 2Col which is a little more interesting, and not designed to be a golfing language.
The defining feature of 2Col is that every line of code must be exactly 2 characters long... | stackexchange_codegolf |
The inspiration for this code golf puzzle is the Bridge and Torch problem, in which d people at the start of a bridge must all cross it in the least amount of time.
The catch is that at most two people can cross at once, otherwise the bridge will crush under their weight, and the group only has access to one torch, whi... | stackexchange_codegolf |
I found another sequence not yet in the OEIS
The binary expansion sequence is defines as follows, assuming 0 indexing:
The even numbers of the sequence are how often 0 has appeared in the binary expansion of all previous items in the sequence
The odd elements are the same, but for 1s.
If you choose to 1-index, revers... | stackexchange_codegolf |
Write a program that accepts chess moves, validate them and shows the results.
The program should:
Check wheter or not a move is valid
Check if a king is in check or in checkmate
Process the changes in position of the pieces
Not procees invalid moves
Use the format shown below, but format can be changed freely if you ... | stackexchange_codegolf |
The objective of this challenge is to write a program to convert an inputed string of what can be assumed as containing only letters and numbers from as many bases between 2 and 36 as possible, and find the base 10 sum of the results.
The input string will be converted to all the bases in which the number would be defi... | stackexchange_codegolf |
As you all know, today is election day!
Your task today is to print out a ballot, given an input.
If the input is Hillary Clinton, print:
Hillary Clinton ===-----===>
Donald Trump === ===>
____________ === ===>
However, if the input is Donald Trump, print:
Hillary Clinton === ===>
Donald Trum... | stackexchange_codegolf |
In this challenge, players need to tamper with a time bomb as late as possible without getting blasted in the face.
Mechanics
Let N be the number of bots plus one. Each round, each bot receives the following arguments:
numbers played by all bots last round in ascending order.
number of points it received last round. N... | stackexchange_codegolf |
Background
Many moons ago, in a galaxy much like our own, a young BrainSteel attempted to invent a board game. He believed that he, too, could find an amazingly simple set of rules that would generate wonderfully strategic gameplay. He drew up the first set of rules--it looked promising. He played with his thoughts, an... | stackexchange_codegolf |
Given a single positive odd integer as input, return a converging zigzag as a list of strings, list of lists of characters, or newline-separated string, in this form:
#
#
#
#
#
#
#
#
#
#
#
You can replace # with any consistent non-whitespace character. Trailing whitespace on each line is allowed... | stackexchange_codegolf |
Inputs
A list (array) of numbers, or numerical strings if that makes it easier. You can assume there will always be at least two elements in the list and every element will be a natural number (integer larger than zero).
Outputs
A single number, or again, a numerical string.
Problem
The idea is to reduce the list of nu... | stackexchange_codegolf |
The Dutch system for naming one's ancestors is a lot more interesting than the English version. For English, the sequence goes "parent", "grandparent", "great-grandparent", "great-great-grandparent", "great-great-great-grandparent"; and in Dutch those terms are "ouder", "grootouder", "overgrootouder", "betovergrootoude... | stackexchange_codegolf |
In this challenge you are supposed to fill a grid 10x10 with numbers from 1 to 100 (each number once) following this rules:
Number 1 must be on the bottom row
Number 100 must be on the upper row
Two consecutive numbers must be one next to the other (diagonals doesn't count)
The grid must be random
It's not necessary ... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
challenge idea by emanresu A
Santa has a bunch of presents wrapped in cuboid boxes of various sizes. As his sled flies above a chimney, a stack of presents will be automatically dropped through it. Santa wants to carefully choose the p... | stackexchange_codegolf |
Introduction
So the Challenge is to give out all combinations with two Inputs. The length of the string is also optional and you should be able to edit this.
I've selected this channel because I thought it would be very easy to do it "normally" but the challenge itself could be very interesting. I had to create that fo... | stackexchange_codegolf |
Given a positive integer, we can form a new number that's described by its digits taken pairwise (with a leading 0 added for numbers with odd number of digits).
For eg.:
1234 can be read as one 2, three 4s - so, the output for 1234 is 2444.
643 has an odd number of digits, so a leading zero is added to make it even.... | stackexchange_codegolf |
Challenge
You need to generate a program or function that takes in a positive integer N, calculates the first N terms of the Fibonacci sequence in binary, concatenates it into a single binary number, converts that number back to decimal, and then outputs the decimal as an integer.
For example
1 -> [0] -> 0 to decimal o... | stackexchange_codegolf |
Challenge:
Given a string only containing upper- and/or lowercase letters (whichever you prefer), put tape horizontally to fix it. We do this by checking the difference of two adjacent letters in the alphabet (ignoring wrap-around and only going forward), and filling the space with as much TAPE/tape as we would need.
... | stackexchange_codegolf |
Challenge
Task
Given a number N, output 2 NxN squares; each line of each square is a random permutation of [0, N); the squares are separated by a newline
Rules
Produce a randomised list of length N, separated by space
Repeat this N*2 times
Separate each output with a newline, with 2 newlines at the midpoint
The value ... | stackexchange_codegolf |
The Task
In this challenge, your task is to write some code which outputs one of its anagrams chosen randomly with uniform distribution but it should never output itself.
Elaboration
Given no input, your program should output any one of the anagrams of its source code. Your program should never output its own source a... | stackexchange_codegolf |
Challenge description
Let's define an W x H grid as a two-dimensional array of length H whose each subarray is of length W. Example: a 2x3 grid (. character used as a blank):
..
..
..
A unit is a single point of a grid. A block is either a single unit or a set of contiguous units (meaning each unit of a block has at l... | stackexchange_codegolf |
Challenge
Write \$2 \le n \le 10\$ distinct, valid non-halting full programs in your language of choice. If all of them are concatenated in order, the resulting full program should be a valid halting program, but if any of them are left out, the result should still be a valid non-halting program.
More formally, write \... | stackexchange_codegolf |
Play the Fruit Box Game
Intro
Fruit Box is a game consisting of a 10x17 grid of numbers, each between 1 and 9, where the goal is to clear as many numbers as possible in a two-minute time window. In order to clear numbers, one selects a rectangle aligned with the grid, and if the numbers inside of it sum to 10, they are... | stackexchange_codegolf |
Given a matrix, sum its values up/down or left/right to form an X, fold it up, and return the list. I describe the algorithm here:
Algorithm
Your input will be a odd-sized square matrix of integers within your language's reasonable numerical capacity.
Let's take the following matrix as an example:
1 2 3 2 1
0 3 2 3 0
4... | stackexchange_codegolf |
Context
After attempting to program in Grass for the entire morning, you decide to go outside and mow some real grass. The grass can be viewed as a string consisting exclusively of the following characters: wWv. w denotes tall grass which takes \$ 1 \$ unit of energy to mow. W denotes extremely tall grass which takes \... | stackexchange_codegolf |
Write the shortest code, in number of bytes, to display, return, or evaluate to the golden ratio (that is, the positive root of the quadratic equation: \$x^2-x-1=0\$, approximately
1.618033988749895), to at least 15 significant figures. No input will be given to your program.
Sample in Stutsk programming language:
1 10... | stackexchange_codegolf |
You are trapped in this 5x5 labyrinth - each room is labelled from 1 to 25 and the exit is in room 1.
You are given as input the room you are currently in. Your task is to output the shortest sequence of moves (north, east, south, west) needed to reach room 1.
Moves can be output in any format you wish (list, string, ... | stackexchange_codegolf |
Today's problem is easy. You're given two strings A and B of equal length consisting of only the characters ( and ). Check whether after any number of operations you can make both strings balanced or not. The only operation allowed is swapping A[i] and B[i], where i is an arbitrary index.
Here is the definition of a ba... | stackexchange_codegolf |
There's the classic run length encoding and decoding.
input output
a3b2c5 aaabbccccc
And that's fairly straight forward and done before.
The challenge is to also account for a non-standard behavior when multiple characters precede the run length (a single digit from 0-9). Each character before the run length digit ... | stackexchange_codegolf |
Gah! It's a shame that Pokémon Sword and Shield won't introduce a new eeveelution. Let's mourn them with a code golf.
The objective is to, when given a type name as the input, output the name of the corresponding eeveelution.
When given Water, output Vaporeon.
When given Electric, output Jolteon.
When given Fire, outp... | stackexchange_codegolf |
Challenge:
Given a matrix input, determine the amount of diagonals and anti-diagonals with duplicated numbers.
So if we have a matrix like this:
[[aa,ab,ac,ad,ae,af],
[ba,bb,bc,bd,be,bf],
[ca,cb,cc,cd,ce,cf],
[da,db,dc,dd,de,df]]
All diagonals and anti-diagonals would be:
[[aa],[ab,ba],[ac,bb,ca],[ad,bc,cb,da],[ae,... | stackexchange_codegolf |
Goal
Sort a list of items ensuring that each item is listed after its specified dependencies.
Input
An array of arrays of integers, where each integer specifies the 0-based or 1-based index of another item that this item must come after. The input may be an array or string or anything else human readable.
For example,... | stackexchange_codegolf |
We are probably all used to the English alphabetical order:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
When we compare words in English for the sake of alphabetization we first compare the first letter, whichever word has the later first letter comes later. If they are the same we check the second letter and... | stackexchange_codegolf |
It is simple. I cannot stand when people use spaces when naming files. It sometimes wrecks console commands and makes the output of ls ugly.
The challenge is to write a program (only ascii characters) which
renames all files (including directories) in the current directory to versions with spaces removed or replaced b... | stackexchange_codegolf |
Inspired by last week's APL lesson.
Given an uppercase 2D seat map and a 1D list of customers, return the seat map and the customer list but modified as follows (to indicate occupied seats and seated customers):
For each unique letter in the input passenger list, lowercase that many (or all, if there are not enough) of... | stackexchange_codegolf |
Background
Suppose that there are 2*n people to be married, and suppose further that each person is attracted to exactly n other people under the constraints that:
Attraction is symmetric; i.e. if person A is attracted to person B, then person B is attracted to person A.
Attraction is antitransitive; i.e. if person A ... | stackexchange_codegolf |
Disclaimer: This isn't my challenge but ThisGuy said I was OK to post.
Occasionally I want to make a word into it's opposite, like happiness goes to unhappiness. Unfortunately when this happens, my brain will sometimes go blank. Then one day, after yet another this happening, I thought to my self "This is what program... | stackexchange_codegolf |
Task
Implement a kind of "some users are typing" system, which can be found in Discord and some other chat clients.
If 1 user (say, Bubbler) is typing, output Bubbler is typing...
If 2 users (say, Bubbler and user) are typing, output Bubbler and user are typing...
If 3 or more users are typing (say, Bubbler, randomuse... | stackexchange_codegolf |
You are given an array A of length N and an array B of length N-1.
You need to output array where items alternates:
A[0], B[0], A[1], B[1], ..., B[N-2], A[N-1]
Restrictions:
N>0
Type of items is not specified, but code should work at least for unsigned integers.
Sample input:
A = [1,2,3,4]
B = [7,8,9]
Sample output:... | stackexchange_codegolf |
Happy Valentine's Day! To celebrate this day of love and happiness (or sadness and loneliness for those of us who are single...), let's write some code to create some hearts!
Specifically, if you take this challenge upon you, you are to write code to output a heart/hearts as an image file, with the ability to easily ch... | stackexchange_codegolf |
Explanation
Befunge is a two-dimensional program that uses stacks.
That means, to do 5 + 6, you write 56+, meaning:
56+
5 push 5 into stack
6 push 6 into stack
+ pop the first two items in the stack and add them up, and push the result into stack
(to those of you who do not know stacks, "push" just means add ... | stackexchange_codegolf |
Lisp programmers boast that Lisp is a powerful language which can be built up from a very small set of primitive operations. Let's put that idea into practice by golfing an interpreter for a dialect called tinylisp.
Language specification
In this specification, any condition whose result is described as "undefined" may... | 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 |
Camel Up Cup 2k18
In this challenge, we will be playing the semi-popular board game Camel Up.
Camel Up! is a board game that has players betting on camels to win rounds, win the game or lose the game, set traps to influence movement or move a camel. Each of these decisions rewards you with the chance of getting some mo... | stackexchange_codegolf |
Your task is to write a program that, given a number n, returns a list of all valid, halting Smallfuck programs of length n, in any order.
Actually, we're using a variation of Smallfuck called F2, which is just Smallfuck with a right-unbounded tape. For the purposes of this challenge, a program that moves left from the... | stackexchange_codegolf |
This code golf challenge is about making a rocket liftoff sequence.
Your output (STDOUT) should be equal to this:
Liftoff in T-10
Liftoff in T-9
Liftoff in T-8
Liftoff in T-7
Liftoff in T-6
Liftoff in T-5
Liftoff in T-4
Liftoff in T-3
Liftoff in T-2
Liftoff in T-1
LIFTOFF!
Rules:
Your output must print to STDOUT.
Yo... | stackexchange_codegolf |
We call a parens group the open paren (, its matching close paren ) and everything inside them.
A parens group or string is called parenthesly balanced if it contains either nothing or only 2 parenthesly balanced parens groups.
For example:
The string "(()())()" is parenthesly balanced
( )() ... | stackexchange_codegolf |
First line is made with ceil(n/2) elements where each element is: <space><odd-number><space>
Second line is made with ceil(n/2) elements, but each element is / \ only.
You may assume n >= 0 and n <= 10.
Examples
Input: 3
1 3
/ \/ \
Input: 10
1 3 5 7 9
/ \/ \/ \/ \/ \
Example in Python 3, 103 bytes:
lambda a:p... | stackexchange_codegolf |
This problem is inspired from shinh's problem.
Given an input of positive integer \$n\$, output a smiley triangle (see below) with \$n\$ rows.
Detailed rules
Can be either a function or a full program.
Standard I/O rules applied.
RULE CLARIFICATION: Output as exactly a string, rather than an array of strings whose it... | stackexchange_codegolf |
A Directed Acyclic Graph (DAG) is a type of graph that has no cycles in it. In other words, if there is a link from node A to node B, there exists no path from B to A (via any nodes).
Challenge
Determine whether the directed graph given as input is acyclic.
Input
A list of lists of integers representing the links betwe... | stackexchange_codegolf |
Consider two sorted arrays of integers \$X\$ and \$Y\$ of size \$m\$ and \$n\$ respectively with \$m < n\$. For example \$ X = (1,4)\$, \$Y = (2,10,11)\$.
We say that a matching is some way of pairing each element of \$X\$ with an element of \$Y\$ in such a way that no two elements of \$X\$ are paired with the same el... | stackexchange_codegolf |
Disclaimer: The story told within this question is entirely fictional, and invented solely for the purpose of providing an intro.
I am an evil farmer, and to drive up the price of wheat in my area, I've decided to burn the fields of all the farmers around me. I would really like to see the fields go up in flames (... | stackexchange_codegolf |
I've been using a library called Djangular recently, which integrates Django and Angular.
After a while I thought 'Wouldn't it be fun to programmatically generate portmanteau?'
Here are some examples (e.g. testcases):
Django + Angular -> Djangular
Camel + Leopard -> Cameleopard
Spoon + Fork -> Spoork
Ham + Hammer -> Ha... | stackexchange_codegolf |
I was wondering if there are any esoteric or golfing languages which specifically target text output and ASCII art?
For example, 05AB1E at least started by targeting base conversions. Are there any golfing languages targeting text output and text output art?
If so, do they have tip pages here, and are they in common ... | stackexchange_codegolf |
Given an input string containing only alphanumeric ASCII characters and starting with a letter, swap each letter run with the digit run which follows.
A run is a sequence of consecutive letters or digits. Note that in the case where the input string ends with a run of letters, this run is left untouched.
Walk-through e... | stackexchange_codegolf |
Given a 2D array of integers, let's sort its rows and columns in blocks. This means that you only have to sort a given row or column, but applying the transformations needed for sorting it to every other row or column in the 2D array.
Rules
Input will be a 2D array of integers and a 1-indexed integer. This integer wil... | stackexchange_codegolf |
A Latin square is a square that has no repeated symbols in the rows or columns:.
13420
21304
32041
04213
40132
And as many Sudoku players know, you don't need all of the numbers to deduce the remaining numbers.
Your challenge is to compress a Latin square into as few bytes as possible. You need to provide one or two... | stackexchange_codegolf |
Prelude:
This challenge is different from "another cat program".
There's literal tons of different twists, why can't I have my own, people?
Unique things:
It isn't reading direct input to output.
It is manipulating the string in a way that for sure isn't a straight-up cat.
Challenge:
Given 3 inputs (or one input, s... | stackexchange_codegolf |
Lets Play Kick The Can!
Although Moogie is the current winner, if anyone can take his crown they are encouraged to do so
Kick the can is a children's game. Involving one defender, and multiple attackers. Today it is no longer such a game! Your job is to write a bot that plays it, to win, king-of-the-hill style!
https:/... | stackexchange_codegolf |
Super simple challenge today, or is it?
I feel like we've heard a fair bit about double speak recently, well let's define it in a codable way...
Double speak is when each and every character in a string of text is immediately repeated. For example:
"DDoouubbllee ssppeeaakk!!"
The Rules
Write code which accepts one ... | stackexchange_codegolf |
In crossword terminology, the grid is the region into which the crossword answers are inserted, consisting of white and black squares. The crossword answers, called entries, are inserted into contiguous sequences of white squares in a row or column, separated by black squares.
For straight (American) crosswords, the g... | stackexchange_codegolf |
This is a rock:
*
Rocks can be stacked. Apart from the bottom-most layer, each rock must rest on two other rocks, like this:
*
* *
You have a pile of rocks, and your boss wants you to pile them symmetrically, taking up the least horizontal space possible.
Your challenge is to take a number of rocks as input, and out... | stackexchange_codegolf |
Based on a comment by Jo King on my previous question (called 'Inverse-quotes-quine'), I present this new question. The rules are similar, but just, the opposite:
If your program is run normally, all of the code not in the speech marks (" - double quotes) should be printed.
If your program is wrapped in double quotes ... | stackexchange_codegolf |
I was messing around with infinite resistor networks (long story) when I came across the following interesting recursive pattern:
|-||
|---
Each instance of this pattern is twice as wide as it is tall. To go from one level of the pattern to the next, you break up this rectangle into two sub-blocks (each of which is a ... | stackexchange_codegolf |
So, I wrote a simple Javascript game (as yet unnamed) and naturally I wanted to write an API so I could write a bot to play it for me, and naturally I wanted to let the PPCG community have a go for themselves.
It's a 'snake' game with the simple goal of collecting as many blue squares as possible while avoiding red squ... | stackexchange_codegolf |
Find a bijective function which maps integers to arbitrarily large tuples of integers. Given the input \$n\$, output the tuple it matches to.
Edit: The empty tuple is included in the mapping.
| stackexchange_codegolf |
Not entirely sure if this one or a similar challenge has already been posted, but here it goes anyway.
Write a program that takes a string as input and writes its trucated/summarized output form such that a specific sep (separator) is placed in the middle, removing the necessary characters of the original string so tha... | stackexchange_codegolf |
Your task is to write a program that:
Runs indefinitely
Produces no output
Consumes an unbounded amount of memory
Specifications
You must list the implementation used for your program. This is relevant because some implementations might preform optimizations while others do not. For example, the LISP code (defun f (... | stackexchange_codegolf |
This is a overhaul of this now deleted question by ar kang. If the OP of that question would like to reclaim this question or has a problem with me posting this I'd be happy to accommodate
Given a list of integers as input find the maximum possible sum of a continuous sublist that starts and ends with the same value.... | stackexchange_codegolf |
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):
From left to right:
O("...", k) = orange piece: these are for loops which executes k times the program "...".
G = g... | stackexchange_codegolf |
The Najdorf Variation of the Sicilian Defence is an opening often played at the highest level of chess. It is named after GM Miguel Najdorf and is known for being extremely sharp and theory heavy.
Your task is to write a program that, given a Boolean-like input, prints a chessboard representation of the opening from ei... | stackexchange_codegolf |
Very interesting background
Comcoins are a currency like any other. The residents of Multibaseania (an economically robust system of city-states with very few residents in a galaxy far, far away) use Comcoins to conduct transactions between themselves. Comcoins are represented by unique codes on special not-paper slips... | stackexchange_codegolf |
Description
Your task is to implement a simple UNIX command parser and file system. Your program will have to implement a file system that can be modified via commands.
The starting directory of your file system is an empty root directory /, with no subdirectories or files. Your program must be capable of handling the ... | stackexchange_codegolf |
Dotcomma is a simple esolang I made a while ago that only uses four operators: [.,]. In this challenge, you'll determine if a dotcomma program consisting only of [.] halts. Without ,, there is no input, output, or queue, making this challenge possible.
Blocks:
Any code wrapped in [] is a block. All blocks and operators... | stackexchange_codegolf |
Circa 1976. With the success of the Tiny BASIC Design Note, a variety of Tiny BASIC IL implementations now span a range of microcomputers. The time has come to expand the Tiny BASIC standard.
Grammar revisions:
(LET) var = expression
INPUT (string ,) var-list
PRINT expr-list (;)
IF expression relop expression (THEN) st... | stackexchange_codegolf |
The goal of this code-golf is to create a code that lets the user input an ASCII string (contains only printable ASCII characters), and your program outputs the lower-case variant of this string.
Important: you are NOT allowed to use a built-in function that converts the string (or just one character) to lowercase (suc... | stackexchange_codegolf |
Here is a very simple language definition:
A Variable is any string that does not contain ^, <, >, !, or ?
The empty string is a valid variable identifier
The value of every variable starts at 0.
A Statement is one of (var is a Variable, P is a Program):
var^ -> changes var to be equal to 1 more than itself
v... | stackexchange_codegolf |
Everyone knows, that you can leave out the multiplication symbol (\$\times\$, or *) in
a*b
23*a
(2+3)*a
a^(b*c)
(a+b)*(c+d)
but not in
2*3 => you don't want it to be 23
a*23 => most mathematicians just don't do it
a^2*b => now it's (a^2)*b, if you remove the *, it's a^(2b)
a/2*b => now it's (a/2)*b, if you remove th... | stackexchange_codegolf |
Background
"Fly straight, dammit" (OEIS A133058) is a sequence of integers, which has these rules:
\$a_0 = a_1 = 1\$
\$a_n = a_{n-1}+n+1\$ if \$gcd(a_{n-1}, n) = 1\$
Otherwise, \$a_n = \frac{a_{n-1}}{gcd(a_{n-1}, n)}\$
In pseudocode:
a[0] = a[1] = 1
if gcd(a[n-1], n) == 1 then
a[n] = a[n-1] + n + 1
else
a[... | stackexchange_codegolf |
This challenge is one of the two challenges which were planned for Advent of Code Golf 2021, but didn't fit into the 25-day schedule.
Related to AoC2020 Day 22, Part 2.
Combat is a simple two-player card game played with a deck of cards. A unique positive integer is written on each card. The game proceeds as follows:
... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.