instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Background:
Okay, i dropped my android smartphone and damaged the touchscreen
The lower half (yeah, exact half!) is spider-webbed and does not work (potrait-mode)
Fortunately for me, the display itself is working
My phone is already rooted and adb enabled, so i have managed to enable 360 degree display rotation
Using t... | stackexchange_codegolf |
Referencing xkcd 1688:
Your task is to deduct the age of a map by asking the user questions. These question must be exactly the same as in the xkcd guide, except from the capitalisation and additional newline(s). Additionally, you should give the user some options to choose from, which don't have to be in the order as... | stackexchange_codegolf |
Identify each letter of the English alphabet with the number denoting its position in the alphabet, that is,
a = 1, b = 2, c = 3, ..., z = 26
(no distinction between lower and upper case letters is made). Every other character is identified with 0.
The "sum" of a word is the sum of its characters, for example: the su... | stackexchange_codegolf |
I've been really interested with sequences that follow the property
\$a(n+1) = a(n - a(n))\$
recently, so here's another question about these sequences. In particular we are concerned with sequences from the integers to the natural numbers.
A periodic sequence with the above property is an n-Juggler if and only if it... | stackexchange_codegolf |
Background
Conway's Soldiers is a version of peg solitaire played on an infinite checkerboard. The board is initially full of pegs below an infinite horizontal line, and empty above it. Following the ordinary peg solitaire rules (move a peg by jumping over another one horizontally or vertically, removing the one that w... | stackexchange_codegolf |
A few days ago I made a puzzle about moving people on an airplane. Now I am interested in the general version of this puzzle and the shortest code golf for it.
I will briefly summarise the puzzle here. A small airplane went through some heavy turbulence and all its N passengers ended up sitting in reverse order, ie., p... | stackexchange_codegolf |
My teacher was more than unhappy with my Martian Homework. I followed all the rules, but she says that what I output was gibberish... when she first looked at it, she was highly suspicious. "All languages should follow Zipf's law blah blah blah"... I didn't even know what Zipf's law was!
It turns out Zipf's law states ... | stackexchange_codegolf |
Task
Your task is to make the smallest function/program that can, when gives an number N, return/print:
the number of possible choices a, b such that \$1 \leq a < b < N\$ and a and b have exactly one common digit in base 10 (there exists a digit, and only one digit, which appears both in a and b, for example 12 and 23,... | stackexchange_codegolf |
Task description
In number theory, the Carmichael function λ takes a positive integer n and returns the least positive integer k so that the k-th power of each integer coprime to n equals 1 modulo n.
Given a positive integer n, your solution must compute λ(n). The shortest code in bytes wins.
Your program should theore... | stackexchange_codegolf |
This tweet lists the possible orders for Wings of a Chinese restaurant1:
When ordering Pizza I usually calculate what size gives me the best Pizza-price ratio which is a simple calculation. However minimizing the price of an order at this restaurant isn't such a simple task, so I'd like to be prepared for my next orde... | stackexchange_codegolf |
Your challenge is to make an infinite loading screen, that looks like this:
Or, to be more specific:
Take no input.
Output Loading..., with a trailing space, but no trailing newline.
Infinitely cycle through the chars |, /, - and \: every 0.25 seconds, overwrite the last one with the next in the sequence. You can ov... | stackexchange_codegolf |
Jelly has an "untruth" atom: Ṭ. This takes a non-empty array of positive integers and returns a Boolean array with 1s at the indexes in the input. For example:
[1,3,5,6]Ṭ ⁼ [1,0,1,0,1,1]
[5]Ṭ ⁼ [0,0,0,0,1]
[2,1,1,2]Ṭ ⁼ [1,1]
[5,4,3]Ṭ ⁼ [0,0,1,1,1]
[1]Ṭ ⁼ [1]
Try it online!
Note that Jelly uses 1-indexing... | stackexchange_codegolf |
Definition of long text
Long text usually shows emphasis, for instance, loooooool or yaaaaaaaaaay. Usually the vowel is replicated many times. In this challenge we require:
At least 3 times, which means yaaay and yaaaay are allowed, but yay and yaay are not.
Consistent, which means that shoes can turn out be shoooeee... | stackexchange_codegolf |
yOu wiLl bE giVen A sTriNg wHich cOnsiSts oF pRintAble asCii
cHarActErs.
yOu iTeraTe tHrougH thE sTrIng tHen chAnge rAndOM(uNifoRm, 50% cHanCe uPPercAse) lEtteRs to
uPPercAse aNd eVerytHing elSe tO lOwercAse.
tHat'S iT.
(sorry for the punctuation, it was for the concept of the question)
Readable version:
You wi... | stackexchange_codegolf |
The Challenge
Write a program that can break down an input chemical formula (see below), and output its respective atoms in the form element: atom-count.
Input
Sample input:
H2O
Your input will always contain at least one element, but no more than ten. Your program should accept inputs that contain parentheses, which... | stackexchange_codegolf |
Let's consider the following sequence:
$$9,8,7,6,5,4,3,2,1,0,89,88,87,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,71...$$
This is the sequence of \$9\$'s complement of a number: that is, \$ a(x) = 10^d - 1 - x \$ where \$ d \$ is the number of digits in \$ x \$. (A061601 in the OEIS).Your task is to add the first \$n\... | stackexchange_codegolf |
I have the following Haskell code to generate the the values of the Fibonacci sequence which are even as an infinite list:
z=zipWith(+)
g=z((*2)<$>0:0:g)$z(0:g)$(*2)<$>scanl(+)1g
This works by starting with 0,2 and then defining every following term to be the sum of:
twice all prior terms
the previous term
twice the ... | stackexchange_codegolf |
Background:
I originally posted this question last night, and received backlash on its vagueness. I have since consulted many personnel concerning not only the wording of the problem, but also its complexity (which is not O(1)). This programming problem is an evil spin on an Amazon interview question.
Question:
Given a... | stackexchange_codegolf |
Introduction
By steganography we mean hiding a message along an existing text or image so the result would be unsuspicious of the existence of the original message. This challenge is about hiding data in Unicode variants of a grapheme called homoglyphs. For instance:
cyrillic Е (ye) appears the same as latin E which ap... | stackexchange_codegolf |
Given an image that has only black and white pixels and an (x,y) location that's a white pixel, color the white pixels based on their minimal Manhattan distance from (x,y) in a path that only involves traversing other white pixels.
The hue of the colored pixels must be proportional to their distance from (x,y), so the ... | stackexchange_codegolf |
Despite your protest, you have been put to work by your boss on a program that takes a single unsigned integer as input and prints the string "prime" if that integer is prime and "not prime" if it isn't. You may choose which language you do this in, as long as the resulting program is short; your boss very much appreci... | stackexchange_codegolf |
Output this 1364-digit base-10 number:
10346063175382775954983214965288942351853612536382034663905935101461222060548195774084941504127779027795484711048746289269095513027910438498906751225648197766590064457965461314130149942152545074712074006545797623075756579902190433531325851645586375231773037880535184421903026638874... | stackexchange_codegolf |
Challenge
The goal of this challenge is to generate and output a \$16 \times 32\$ (height \$\times\$ width) grid where all cells contain a decoy
character, except for a random single cell that contains the target character. The input will be a pair of ASCII (32-126) characters: [target,decoy], where target is the chara... | stackexchange_codegolf |
Consider a word/string of length \$n\$, only including the letters A-Z, a-z. A word/string is a double prime word if and only if n is prime and the sum of the letters, s, is also prime, using their numeric position in the alphabet (a=1, B=2, c=3, etc.).
Input can be any combination of upper or lower case alphabetic cha... | stackexchange_codegolf |
Context :
Suppose you have a sheet of paper measuring 8 x 10. You want to cut it exactly in half while maintaining its rectangular shape. You can do this in two ways.
You can cut it in half preserving its long dimension of 10 (for our purpose we will refer to this as long cut from now on).
Example :
$$
[8, 10] \right... | stackexchange_codegolf |
The 3Blue1Brown Youtube channel released a video a year ago called "Why do colliding blocks compute pi?" which describes a model where a block A of mass \$a\$ slides into a block B of mass \$b\$, which then pushes block B into a wall, causing it to bounce off the wall and then collide again with block A.
The miracle of... | stackexchange_codegolf |
Inspired by Create a binary wall
Given a list of positive integers, we can write them out all above each other like so, for [2, 6, 9, 4] as an example:
0010
0110
1001
0100
We can imagine this as a wall:
..#.
.##.
#..#
.#..
However, this is a very weak wall, and it has collapsed! Each 1 (#) falls down until it hits th... | stackexchange_codegolf |
Takuzu is a logic game in which you have to complete a grid with cells containing 0s and 1s. The grid must follow 3 rules:
No three horizontal or vertical consecutive cells can be the same.
There must be an equal number of 0s and 1s in each row and column.
No two rows can be the same, and no two columns can be the sam... | 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 |
While implementing polynomial multiplication in Itr I found the following interesting operation on strings
To compute the convolution of two strings (for instance Hello and World) first combine all pairs of letters with indices that add up to the same number
(ordered by the index of the first element)
0 -> "HW"
1 -> "... | stackexchange_codegolf |
Given an input string S, print S followed by a non-empty separator in the following way:
Step 1: S has a 1/2 chance of being printed, and a 1/2 chance for the program to terminate.
Step 2: S has a 2/3 chance of being printed, and a 1/3 chance for the program to terminate.
Step 3: S has a 3/4 chance of being printed,... | stackexchange_codegolf |
Background
Tetris is a single-player game played on a rectangular grid with tetromino pieces.
When you fill one or more lines with tetrominoes, the filled lines are removed, and all blocks above them move down accordingly. In the following diagrams, . is an empty space, # is an existing block, and the tetromino marked ... | 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 |
You might know Alan Walker from his ever popular song Faded. Now his "followers" are called Walkers and they have a logo, here is a simplified version:
\\
\\ //\\
\\ // \\ //
\\ // \\ //
\\ // \\ //
\\ // \\ //... | stackexchange_codegolf |
Create a function which takes in a input integer and then returns the number of factors it has, like if you pass 25 then it will return 3 since it has 3 factors i.e. 1,5,25.
Challenge:
Make the fastest and the smallest code!
| stackexchange_codegolf |
Introduction
Write a program to output the outgoing spiral of the famous pangram following given rules.
Challenge
A pangram is a sentence using every letter of a given alphabet at least once. One of the most famous pangrams is the one used extensively in Windows font viewer, namely "The quick brown fox jumps over the l... | stackexchange_codegolf |
Given a positive integer as input, output that integer, but with its bits rotated two times to the right. Also, think of the number as a donut of bits, eg. 21 -> (10101). If all of the bits suddenly decided to move to the right, they would wrap around. eg. rRot(21) -> (11010) = 26. Do what i explained 2 times (at the s... | stackexchange_codegolf |
In set theory, a set is an unordered group of unique elements. A pure set is either the empty set \$\{\}\$ or a set containing only pure sets, like \$\{\{\},\{\{\}\}\}\$.
Your challenge is to write a program that enumerates all pure sets, in some order of your choice. Standard sequence rules apply - you may:
Output al... | stackexchange_codegolf |
Given a non-flat list of integers, output a list of lists containing the integers in each nesting level, starting with the least-nested level, with the values in their original order in the input list when read left-to-right. If two or more lists are at the same nesting level in the input list, they should be combined ... | stackexchange_codegolf |
Monday Mini-Golf: A series of short code-golf challenges, posted (hopefully!) every Monday.
(Sorry this one's a little late.)
I'm sure most of you folks have heard of Levenshtein distance, an algorithm for calculating the distance between two strings. Well, this challenge is about implementing a similar algorithm of my... | stackexchange_codegolf |
This challenge is a simple ASCII-art challenge inspired by the solar eclipse that happened on August 21, 2017. Given an input 0 <= n <= 4, output the corresponding stage of the eclipse described below:
n=0:
*****
** **
* *
* *
** **
*******
n=1:
*****
** *****
* *******
* *****... | stackexchange_codegolf |
Output a sequence of all the primes that are of the following form:
123...91011...(n-1)n(n-1)..11109...321. That is, ascending decimal numbers up to some n, followed by a descending tail, all concatenated.
Background
Recently, Numberphile posted a video about primes that follow this pattern.
Output
1 -> 123456789109876... | stackexchange_codegolf |
You are given two strings, each consisting of the English word for a number between 1 and 13:
one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen
Your program or function must find out whether it's possible to spell at least one other word from the same list without using any of the let... | stackexchange_codegolf |
The pigeonhole principle states that
If N items are put into M boxes, with N > M, then at least one box must contain more than one item.
For many, this principle has a special status compared to other mathematical enouncements. As E.W. Dijkstra wrote,
It is surrounded by some mystique. Proofs using it are often rega... | stackexchange_codegolf |
Adam7 is an interlacing algorithm for raster images, such as PNG. It is called the "Adam7" algorithm because it was invented by Adam M. Costello, and it is generated by following a certain pattern 7 times. One of the cool things about the Adam7 algorithm that makes it really fun for code golf, is that the pattern can b... | stackexchange_codegolf |
Introduction
One question that I have come across recently is the possibility of dissecting a staircase of height 8 into 3 pieces, and then re-arranging those 3 pieces into a 6 by 6 square.
Namely, is it possible to dissect the following into 3 pieces:
x
xx
xxx
xxxx
xxxxx
xxxxxx
xxxxxxx
xxxxxxxx
And rearrange those 3 ... | stackexchange_codegolf |
Challenge
Given an ASCII operator from the list below and a number n, draw an ASCII representation of the operator using that operator as the character with the line segments of the operator having length n.
Input
An ASCII character from the list = + - x / and an integer n where n >= 1. (I'm using x instead of * and /... | stackexchange_codegolf |
I was wondering if it was possible to make this code even shorter than it already was.
f=lambda x:f(x-1)+f(x-2) if x>1 else 1
[print(f(i))for i in range(20)]
Expected output:
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
Good luck, "golfers" (I'm assuming thats what you guys are called)
Note: spe... | stackexchange_codegolf |
(or: Output the plural demonym.)
When in Rome, do as the Romans do. This is a well-known English phrase meaning that it’s best to follow what others are doing around you — to go with the flow. Today, you're going to rewrite the phrase to fit most (Western) place names.
To get the name of a group that lives within a reg... | stackexchange_codegolf |
The reason for this question is because I made a deadlineless bounty and I need a tips question to link in the bounty
Vyxal 3 is the third major version of the Vyxal golfing language. As it is significantly different to Vyxal 2, the tips there don't apply.
Therefore, what tips and tricks do you have for golfing in Vyxa... | stackexchange_codegolf |
What is the most frequent word?
Given a sentence, your program must make its way through it, counting the frequencies of each word, then output the most used word. Because a sentence has no fixed length, and so can get very long, your code must be as short as possible.
Rules/Requirements
Each submission should be eith... | stackexchange_codegolf |
A whole program to find the prime factors of a given number. The number will be given on standard input.
| stackexchange_codegolf |
It's one of these again :D
Your task, if you wish to accept it, is to write a program/function (without any uppercase letters) that outputs/returns its string input/argument. The tricky part is that if I convert your source code to uppercase, the output must be reversed.
For simplicity, you can assume that the input is... | stackexchange_codegolf |
Introduction
So my boss is making me do some manual labor...urgh...I have to take a part out a box of parts, process it and put it back in the box. To make this more interesting I try to sort the parts as I do this, as each part has a unique alphanumeric serial number.
Unfortunately, I only have room to have four part... | stackexchange_codegolf |
Given a sorted list of unique positive floats (none of which are integers) such as:
[0.1, 0.2, 1.4, 2.3, 2.4, 2.5, 3.2]
Evenly spread out the values that fall between two consecutive integers. So in this case you would get:
[0.333, 0.666, 1.5, 2.25, 2.5, 2.75, 3.5]
(I have truncated the values 1/3 and 2/3 for ease of... | stackexchange_codegolf |
This challenge is inspired by the same task I read some time ago in CACM.
There are many ways to sort stuff. Most attempt to sort in as few operations as possible (= as fast as possible). However, it is also possible to consider how few resources you might require to sort stuff, which seems more fitting for a codegolf ... | stackexchange_codegolf |
The challenge is simple: write a program or function that, when given a finite non-negative integer, outputs a nested array.
The rules
Your code must produce a unique valid nested array for every integer 0 ≤ n < 231.
Every possible nested array with up to 16 open brackets must be outputted within this range. (This d... | stackexchange_codegolf |
The title pretty much describes it all. Given as input a \$n \times m\$ matrix and an integer \$i\$ create a complete function/program that returns the matrix \$i\$ times clockwise rotated by \$90^\circ\$.
Rules:
as matrix you can use any convenient representation you like e.g. a list of lists etc...
matrix values can... | stackexchange_codegolf |
Given an ASCII-art shape made of the characters /\|_, your challenge is to return the number of sides it has.
A side is a straight line of one of those, for example:
\
\
\
/
/
|
|
|
|
_____
Are all sides.
For example, this shape:
___
/ \
/_____\
Has four sides. You can assume the input will be a single va... | stackexchange_codegolf |
Here, x (supplied as input) and n (the result of your computation) are both positive integers. n * x = n shifted. Find n.
Here's an example of shifting:
123456789 -> 912345678
abcdefghi -> iabcdefgh (letters = any 0~9 digit)
123 -> 312
Shifting only happens once to the right. Shifting left, e.g.
123456789 -> 234... | stackexchange_codegolf |
A Latin Square is a square of size n × n containing numbers 1 to n inclusive. Each number occurs once in each row and column.
An example of a 3 × 3 Latin Square is:
[[1, 2, 3],
[3, 1, 2],
[2, 3, 1]]
Another is:
[[3, 1, 2],
[2, 3, 1],
[1, 2, 3]]
Given an integer input n where n > 0, determine how many Latin Square... | stackexchange_codegolf |
Write a full program or a function taking an unsigned integer number N and doing this cut out work:
Cut out a hollow hexagon 'donut' shape with side B-C equal to 2N times '/'
Translate the piece above by 3 lines.
Repeat the job N times (from the piece obtained) decrementing by 2 '/' side B-C , until smallest hexagon ... | stackexchange_codegolf |
Lexicographic Ordering
For this challenge we will be talking about the lexicographic ordering of strings. If you know how to put words in alphabetical order you already understand the basic idea of lexicographic ordering.
Lexicographic ordering is a way of ordering strings of characters.
When comparing two strings lex... | stackexchange_codegolf |
This is a micro-optimization challenge. The task is to sample from the maximally skewed stable distribution F(x;1,-1,Pi/2,0). See Table 1 of http://arxiv.org/pdf/0908.3961v2.pdf . It is easiest to describe how to do this using the following C code which uses the Mersenne Twister RNG C code from here .
#include <stdi... | stackexchange_codegolf |
Given a non-negative integer, print out an X that is that big. X is the output for input 0, and you will add slashes equal to the input in each direction to extend the X for larger inputs.
Test Cases
0
X
1
\ /
X
/ \
2
\ /
\ /
X
/ \
/ \
...
10
\ /
\ /
\ /
... | stackexchange_codegolf |
Input: an array of length \$n\$ containing integers in the range \$0\$ to \$2n\$.
For each integer \$x\$ in the array, compute the number of integers that occur before \$x\$ that are no larger than \$x\$.
As an example, if the array is
[3, 0, 1, 4, 3, 6]
the output should be equivalent to:
3: 0
0: 0
1: 1
4: 3
3: 3
6: ... | stackexchange_codegolf |
A magic word is a word whose Braille spelling contains precisely 26 dots (because the Morse code alphabet can be circularly encoded within). For example:
⠎ ⠝ ⠥ ⠛ ⠛ ⠇ ⠽ snuggly
⠏ ⠕ ⠇ ⠽ ⠛ ⠕ ⠝ polygon
⠝ ⠥ ⠛ ⠛ ⠑ ⠞ ⠽ nuggety
⠽ ⠕ ⠛ ⠓ ⠥ ⠗ ⠞ yoghurt
are all magic words.
Objective:
Craft a program to identify 77 such mag... | stackexchange_codegolf |
Introduction:
Aaron is a young game developer. He recently joined the development team of a game where the players select their character from a predefined set, aka "heroes". Unfortunately, the names of the existing heroes are not evenly distributed throughout the alphabet. For example, there are 6 heroes that have a n... | stackexchange_codegolf |
This is a simple one: Take a matrix of integers as input, and output the index of the row with the most non-zero elements. You may assume that there will only be one row with the most non-zero elements.
Test cases:
These are 1-indexed, you may choose if you want 0 or 1-indexed.
1
0
row = 1
---
0 -1
0 0
row = 1
---
1... | stackexchange_codegolf |
Let me explain one by one the above terms...
We will call \$\text{Z-Factorial}(n)\$ of a positive integer \$n\$, \$n!\$ (i.e. \$n\$ factorial) without any trailing zeros.
So, \$\text{Z-Factorial}(30)\$ is \$26525285981219105863630848\$ because \$30!=265252859812191058636308480000000\$
We will call Modified Z-Factorial ... | stackexchange_codegolf |
A marquee is a low-tech board that allows customizable letters. For example, here is a marquee:
SALE ON SNEAKERS
However, someone might come along and vandalize it by removing letters to send a different message:
S N AKE
Given two non-empty string inputs, an original message and a new message, determine whethe... | stackexchange_codegolf |
You are given an array/list/vector of pairs of integers representing cartesian coordinates \$(x, y)\$ of points on a 2D Euclidean plane; all coordinates are between \$−10^4\$ and \$10^4\$, duplicates are allowed. Find the area of the convex hull of those points, rounded to the nearest integer; an exact midpoint should ... | stackexchange_codegolf |
Given a string to encode, and a number of columns (the key), encode the string as follows:
I will be using the example Hello, world! and the key 3
First, write out the number of columns:
1 2 3
Next, write the text starting from the upper left, one character per column, and when you run out of columns, go to the next l... | stackexchange_codegolf |
Today is Tax Day!
Oops.
Well, today is tax day if you are a resident of Maine or Massachusetts.
So you're probably still completing your return and need a calculator for when you get to Line 44.
Given an input of taxable income (US$, accurate to 2 decimal places) and a string representing filing status, output the amou... | stackexchange_codegolf |
Definition
From the description on OEIS A006345:
To find a(n), consider either a 1 or a 2. For each, find the longest repeated suffix, that is, for each of a(n)=1,2, find the longest sequence s with the property that the sequence a(1),...,a(n) ends with ss. Use the digit that results in the shorter such suffix. a(1) =... | stackexchange_codegolf |
Introduction
Kerning means adjusting the spacing between the letters of a text.
As an example, consider the word Top written with the following three glyphs:
##### ..... .....
..#.. ..... .....
..#.. ..##. .###.
..#.. .#..# .#..#
..#.. .#..# .#..#
..#.. ..##. .###.
..... ..... .#...
..... ..... .#...
We could just fil... | stackexchange_codegolf |
Task: Output the Swiss flag.
Happy Swiss National Day / Schweizer Bundesfeiertag / Fête nationale suisse / Festa nazionale svizzera / Fiasta naziunala svizra!
Details:
The flag consists of a white (#FFFFFF) cross on a red (#FF0000) background. The cross consists of a 6x6 square with arms of size 6x7 glued to each sid... | stackexchange_codegolf |
Based on a list of numbers and their equivalent letters, take a string input, replace the characters of that string with the equivalent number/letter and output the result.
List
1 = a
2 = b
3 = c
4 = d
5 = e
6 = f
7 = g
8 = h
9 = i
0 = j
Input
thisisastring1124
Output
t89s9s1str9n7aabd
Rules
Numbers are equiva... | stackexchange_codegolf |
Adapted from this StackOverflow question
In this challenge you will take a list of lists of integers, e.g.
A = [[1,2],[3,4],[5],[]]
And an additional single integer (e.g. n = 7). If you were to add n to the front of one of the lists in A there would be as many ways to do that as there are lists in A. In this example ... | stackexchange_codegolf |
Wireworld is a cellular automaton that was designed to be resemble electrons flowing through wires. Its simple mechanics allow the construction of digital circuits. It has even permitted the construction of an entire computer.
Your mission is to create the shortest Wireworld implementation in your language of choice.
... | stackexchange_codegolf |
Note: This is an attempt at recycling guest271314's permutation question(s)
There's an interesting pattern that forms when you find the differences between lexographically sorted permutations of base 10 numbers with ascending unique digits. For example, 123 has permutations:
123 132 213 231 312 321
When you find the d... | stackexchange_codegolf |
A number is in base-b simplified Goodstein form if it is written as
b + b + ... + b + c, 0 < c ≤ b
The simplified Goodstein sequence of a number starts with writing the number in base-1 simplified Goodstein form, then replacing all 1's with 2's and subtracting 1. Rewrite the result in base-2 simplified Goodstein for... | stackexchange_codegolf |
Recently I've been having some trouble with the new TeaScript interpreter. The biggest problem is identifying whether or not a string contains any special characters.
Challenge
A special character is defined as a character with codepoint 160 to 255. You will be given an input which is a string of characters with codep... | stackexchange_codegolf |
Your task is to make a program that prints out its own source.
"Hey, we already have this challenge, and tons of variations of it! Why are you making another one?" you may ask, but this one is going to be one of the most difficult ones (hopefully, anyway).
Your quine must be "mutation-hardened", which means the quine, ... | stackexchange_codegolf |
Sometimes I make bad jokes... And a bad joke I like to make involves interpreting exclamation marks in sentences as the factorial sign.
Task
Your task is to write a program that receives a sentence and applies the factorial joke to the sentence.
The "factorial joke" consists of looking for exclamation marks "!" and doi... | stackexchange_codegolf |
Sometimes in chat, if someone says something you agree with, you'll send a message with an ^, which points at the message above:
Radvylf: Cats are far superior to JavaScript
You: ^
Sometimes you'll also add some text:
Radvylf: I sure do like integers
You: I mostly agree with ^ but floats are pretty neat too
You can a... | stackexchange_codegolf |
Cubes can be made of six squares as sides. But you could also fold three 2x1 rectangles in half and glue them together to form a cube. Now in this challenge you get a set of pieces which are each made from squares, and you have to determine whether you can choose pieces to form a unit cube. Not all of the pieces have t... | stackexchange_codegolf |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
The story continues from AoC2016 Day 2, Part 2.
You finally figure out the bathroom code (on the weird diamond-shaped keypad) and open the bathroom door. And then you see another door behind it, with yet another keypad design:
For those who... | stackexchange_codegolf |
Let's say you are given an integer array. Create a function to determine the largest sum of any array's adjacent subarrays. For instance, the contiguous subarray with the largest sum is [4, -1, 2, 1] in the array [-2, 1, -3, 4, -1, 2, 1, -5, 4].
You can employ a variant of Kadane's algorithm to resolve this issue. The ... | stackexchange_codegolf |
You are given two functions \$g(x)\$ and \$h(x)\$, each of which takes an integer \$x\$ and returns the number \$ax + b\$ (where \$a\$ and \$b\$ are integers defined in the function).
Your task is to write a function \$f(g, h)\$ that takes these two functions, and returns a function \$k(x) = g(h(x))\$, but where the pr... | stackexchange_codegolf |
As we all know, meta is overflowing with complaints about scoring code-golf between languages (yes, each word is a separate link, and these may be just the tip of the iceberg).
With so much jealousy towards those who actually bothered to look up the Pyth documentation, I thought it would be nice to have a little bit mo... | stackexchange_codegolf |
I've been posting relatively hard challenges recently, so here goes an easy one.
Task
Given an array \$A\$ and a number \$n\$, calculate the sum of all numbers of \$A\$ multiplied by \$n\$, except the last one. All numbers (the elements of \$A\$ and the value of \$n\$) are positive integers, and \$A\$ is non-empty. Sho... | stackexchange_codegolf |
This challenge was inspired by this non-challenge about the natural logarithm base \$e\$ and the following pandigital approximation to \$e\$ appearing on a Math Magic page:
$$\left|(1+9^{-4^{7×6}})^{3^{2^{85}}}-e\right|$$
$$\approx2.01×10^{-18457734525360901453873570}$$
It is fairly well-known that
$$e=\lim_{n\to\infty... | stackexchange_codegolf |
Input:
A list of integers
Output:
Put each digit (and the minus sign) in its own lane, in the order -0123456789, ignoring any duplicated digits.
Example:
Input: [1,729,4728510,-3832,748129321,89842,-938744,0,11111]
Output:
-0123456789 <- Added as clarification only, it's not part of the output
1
2 7 ... | stackexchange_codegolf |
The Challenge
Your challenge is to write a program that evaluates the following function:
f(x, t) = d^x / dt^x (sin t)
That is, the x-th derivative of sin t. In case you aren't familiar with calculus, here is a table of derivatives for the sine function:
...
f(-1, t) = -cos t
f(0, t) = sin t
f(1, t) = cos t
f(2, t)= -s... | stackexchange_codegolf |
Cyclic Polyglot Challenge
This is the cops thread. You can find the robbers thread here.
Cyclic Polyglot
A N-element cyclic polyglot is a complete program that can be run in N different languages. In each language, when the program is run with no input (possibly subject to this exception), it should print the name of a... | stackexchange_codegolf |
Lean is a theorem prover and programming language. It's also as of writing the Language of the Month!
What tips do people have for golfing in Lean? As always, tips should be specific to to Lean (e.g. "Remove comments" is not an answer), and stick to a single tip per answer.
| stackexchange_codegolf |
If you visit Code Golf often, you may have heard of Kolmogorov complexity. It's usually defined as the amount of bytes required to express some string in a programming language.
Here the Kolmogorov-complexity of a natural number is defined similarly: the number of bytes required to represent it in a programming languag... | stackexchange_codegolf |
Given a number as input, determine how many significant figures it has. This number will should be taken as a string because you have to do some special formatting. You'll see what I mean soon (I think).
A digit is a sig-fig if at least one of the following apply:
Non-zero digits are always significant.
Any zeros bet... | stackexchange_codegolf |
Print the following output of a happy coincidence addition pattern:
8
8
8
88
+888
----
1000
Rules:
No leading spaces except the ones already present
There can be a trailing newline
+ sign needs to be displayed
Order of parcels needs to be the same
No winner. It is code-golf per language.
| stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.