instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Goal
Given a deal result from Duplicate Contract Bridge, calculate the deal score.
Basically the same as iBug's question, which was deleted. I figured out this scoring system while trying to answer that question.
Input
Input is a deal result, and whether or not the declaring side is vulnerable.
The deal result is a str... | stackexchange_codegolf |
Mathemania Specs:
Every piece of Mathemania code starts off with the number 2. From the 2, you can do the following operations:
e: Exponentiation. This command's default is squaring the number.
f: Factorial. This command's default is using the single factorial on the number (using f on 2 = 2! = 2).
r: Root. This comma... | stackexchange_codegolf |
I made my own sequence recently (called the Piggyback sequence), and it works like this:
P(1), P(2) and P(3) = 1.
For all P(n) where n>3, the sequence works like this:
P(n) = P(n-3) + P(n-2)/P(n-1)
So, continuing the sequence:
P(4) = 1 + 1/1 = 2
P(5) = 1 + 1/2 = 3/2
= 1.5
P(6) = 1 + 2/(3/2) = 7/3
= 2.33333...
P(7) = 2... | stackexchange_codegolf |
A math Olympiad will be held, and participants are being registered. The highest number of participants is 100. Each participant is given an ID number. It is given in a sequence like \$100, 97, 94, 91, 88, ...., 1\$, and when the first sequence is over, then \$99, 96, 93, 90, 87, ...., 3\$ sequence and so on.
Let's ass... | stackexchange_codegolf |
Your task is to create a good multiplication table for others to use. Given an integer \$n\$, generate a multiplication table that displays products up to \$n×n\$. You should start with \$2×2\$ as 1 times any number is itself and that is reflected in the row/column indices. Scientific notation and floating-points are N... | stackexchange_codegolf |
Write a program that takes an input to STDIN and makes all of the lowercase letters (including accented letters) in the 2k-1th word uppercase and all the uppercase letters (also including accented letters) in the 2kth word lowercase (k is a positive integer). The program should not affect any other characters in any wo... | stackexchange_codegolf |
Bounty
One of the convincing conjectures, by Loopy Walt is,
maxlib(n) = 0, if n = 1
2, if n = 2
6, if n = 3
(2n - 1)⌊n / 3⌋, if n % 3 = 0
(2n - 1)⌊n / 3⌋ + n, if n % 3 = 2
2n⌊n / 3⌋ + 1, otherwise
Loopy Walt's post below explains how this conjecture is derive... | stackexchange_codegolf |
The Challenge
Given a grid of numbers (10 <= N <= 99)
Return number with the highest sum of the four numbers adjacent to it; that is the numbers above, below, right, and left of the number, but not itself.
The number itself does not count, only its four neighbors.
A number on the edge should be treated as though the m... | stackexchange_codegolf |
I love functional programming in Octave, but it's rather unwieldy in practice. I'm wondering about the shortest way to define an anonymous recursive function.
I have some ideas, but I'm wondering if there is a way to combine these ideas to make them even shorter (or equally short but more versatile). For the sake of th... | stackexchange_codegolf |
Write a program/function that finds the amount of fuel needed to escape Earth's gravity well given the exhaust velocity of the fuel and the amount of mass to transport using the Tsiolkovsky rocket equation:
$$\Delta v = v_\text{exhaust}\ln\dfrac{m_\text{start}}{m_\text{end}}$$
where
\$\Delta v\$ is the change in veloc... | stackexchange_codegolf |
Given a positive integer, output a truthy/falsy value as to whether the number can eat itself.
Rules
Leftmost is the head, rightmost is the tail
If the head is greater than or equal to the tail, the head eats the tail and the new head becomes their sum.
If \$sum \ge 10 \$ then the head is replaced by \$sum \mod 10\$.
\... | stackexchange_codegolf |
Write a function that calculates a row of the pascal triangle and returns the middle number, if there are 2 it should return their sum.
Example:
5
would return
20
Example 2:
4
would return
6
EDIT:
To be clear:
a) if the number inputted is odd then find then return the middle number of a row on the pascal triangle.
... | stackexchange_codegolf |
In Dungeons and Dragons, some of the most important atributes of a character are the ability scores. There are 6 ability scores, for the six abilities. The abilities are Strength, Dexterity, Constitution, Intelligence, Wisdom and Charisma.
When determining the scores for a character, I use the following procedure: Roll... | stackexchange_codegolf |
It is easy to describe a finite state machine that recognizes multiples of 9: keep track of the digit sum (mod 9) and add whatever digit is accepted next. Such a FSM has only 9 states, very simple! By the equivalence between FSM-recognizability and regular languages, there is a regular expression for multiples of 9. Ho... | stackexchange_codegolf |
Inspired by Random with your hands tied:
The Goal
The goal of this challenge is to write a program that generates a pseudorandom bit stream, which is a string of 1s and 0s that appears to be purely random, but is actually generated in a deterministic way. Your program should output a string of 1 and 0s (with optional ... | stackexchange_codegolf |
Spirals are cool , so are numbers, and number spirals are even cooler. But what if I want a specific number, in a specific place using xy coordinates...
Challenge
Using an infinite spiral moving down first, curling in a counterclockwise manner
ex:
6 5 4
7 0 3
8 1 2
9 10 11
Take negative and positive inputs(... | stackexchange_codegolf |
proposed by @Adám in chat
Given an even number of finite points return a line \$y=mx+b\$ that evenly splits the points on both sides.
Specs
Take a list of distinct points \$(x,y)\$ (or a list of x-coordinates and a list of y-coordinates), output a possible \$(m,b)\$ pair
Half of the points should be true for \$y>mx+b\... | stackexchange_codegolf |
Write the smallest program you can to create affine fractals. You may use any method you feel like that generates the same results as the rules below. You don't have to use any ideas from the suggested methods!
Your program will take two inputs, the first to define the pattern in the format 074 made of three digits fro... | stackexchange_codegolf |
I like to pretty print multidimensional arrays, like this:
[ [ [1, 2, 3],
[4, 5, 6] ],
[ [7, 8, 9],
[6, 4, 2] ] ]
But it's a pain to do by hand and it'd be nice to have a program that does this for me. Your challenge is to create a program that does this for me, taking a multidimensional array containing onl... | stackexchange_codegolf |
Background
Quaternion is a number system that extends complex numbers. A quaternion has the following form
$$ a + bi + cj + dk $$
where \$ a,b,c,d \$ are real numbers and \$ i,j,k \$ are three fundamental quaternion units. The units have the following properties:
$$ i^2 = j^2 = k^2 = -1 $$
$$ ij = k, jk = i, ki = j $$
... | stackexchange_codegolf |
Game
The game is simple. Test the user's response time by asking them to enter the correct value that is displayed on the screen in the shortest time possible. Each round of the game will be as follows:
Show Value ----> Get Response ----> Check Response ----> Report Response Time
Example
ROUND ONE
---------
COMPUTER ... | stackexchange_codegolf |
Given an input array having minimum length 2 and maximum length 9 having any initial values output an array having length 2 consisting of the 1-based indexes of the array represented as either an integer or string in forward and reverse order.
The values of the array or string do not matter and are ignored. For example... | stackexchange_codegolf |
The goal of this challenge is to print the following tongue twister:
She sells seashells by the seashore,
The shells she sells are seashells, I'm sure.
So if she sells seashells on the seashore,
Then I'm sure she sells seashore shells.
This is more complicated than just calling your language's print equivalent. Since ... | stackexchange_codegolf |
From the subreddit r/SpeedOfLobsters:
Edit the text of an image to create a new phrase
This meme format/style is pretty self-explanatory. Simply have a browse through the subreddit if you need more examples. However, when coming up with ideas, it can be quite difficult to decide exactly which letters to keep and whic... | stackexchange_codegolf |
Time sheets
In a work place you often have to complete time sheets. This task is write code to help this.
Input
Two times in a slightly non- standard 12 hour clock signifying the start and end of the day separated by a space. A third number represents the number of minutes taken for lunch. For example
9:14 5:12 30
Th... | stackexchange_codegolf |
Given an integer, output an upside-down tent.
The input determines both the size of the tent (absolute value) and whether the entrance is on the left side (negative numbers) or the right side (positive numbers).
If input = -1:
____
\/_/
If input = -2:
________
\ / /
\/___/
If input = -3:
____________
\ / /... | stackexchange_codegolf |
The challenge
Create a function which takes an array of numbers and subtract from each element the lowest element in the array that has not yet been subtracted from another.
After using the lowest value, It can not be used again.
Numbers in the array are decimal numbers, and not necessarily integers.
Example:
Input: ... | stackexchange_codegolf |
Hexcells is a game based off of Minesweeper played on hexagons. (Full disclosure: I have nothing to do with Hexcells. In fact I don't really like the game.) Most of Hexcells rules can be pretty easily expressed in Generalized Minesweeper (Minesweeper played on an arbitrary graph). The one that is most difficult is th... | stackexchange_codegolf |
Minesweeper is a popular puzzle game where you must discover which tiles are "mines" without clicking on those tiles. Instead, you click on nearby tiles to reveal the number of adjacent mines. One downside about the game is that it is possible to end up in a scenario where there are multiple valid answers and you may o... | stackexchange_codegolf |
Related
Now you have some dice which you may roll several times. You need a uniform random integer between 1 and \$n\$, inclusive. Show a method that rolls the fewest times and behaves as an \$n\$-sided dice.
Alternative question: Given a set \$S\$ and \$n\$, pick the fewest elements from \$S\$(each element can be pick... | stackexchange_codegolf |
Input
You are given a 2D map with balls and ground in it.
It looks like this:
1 5 2
3
4
__________________________
Each number is a ball, and the _ is ground level. The underscore _ character is not allowed in any other line than ground level line. There are only spaces, newl... | stackexchange_codegolf |
Given two non-negative integers e.g. 27, 96 their multiplication expression would be 27 x 96 = 2592.
If now each digits is replaced with a symbol, such that
two digits are replaced with the same symbol if and only if they are equal
we could get something like AB x CD = AECA or 0Q x 17 = 0Z10 or !> x @^ = !x@!.
(follo... | stackexchange_codegolf |
Introduction
In number theory, a number is considered evil if there are an even number of 1's in its binary representation. In today's challenge, you will be identifying whether or not a given number is evil.
Challenge
Your job is to write a full program or function which accepts a single, non-negative integer as input... | stackexchange_codegolf |
Overview
The sharpness of a word is the sum of the sharpness of each of its letters, using the following rules:
Sharp letters
A, and V each have a sharpness of 1
N and Z each have a sharpness of 2
M and W each have a sharpness of 3
Dull letters
C and U each have a sharpness of -1
S has a sharpness of -2
O has a shar... | stackexchange_codegolf |
Your task is to print this exact text:
| | | | | |
&***********&
| Code Golf |
| e---------f |
| d___________l |
| o-------------o |
| C_______________G |
###Dennis$Dennis###
#####################
Rules
Trailing or leading newline is allowed
code-golf, so shortest code wins!
| stackexchange_codegolf |
The challenge
Create a function which takes an array of numbers and subtract from each element the lowest element in the array that has not yet been subtracted from another.
After using the lowest value, It can not be used again.
Numbers in the array are decimal numbers, and not necessarily integers.
Example:
Input: ... | stackexchange_codegolf |
When we publish some software, we assign a version number to it. And users may want to update to the latest version of some software. So, it is the time to find out which version should be newer.
Input
Input two version numbers as strings.
In the context of this challenge, we only support version numbers which are some... | stackexchange_codegolf |
The height of a binary tree is the distance from the root node to the node child that is farthest from the root.
Below is an example:
2 <-- root: Height 1
/ \
7 5 <-- Height 2
/ \ \
2 6 9 <-- Height 3
/ \ /
5 11 4 <-- Height 4
Height of binary ... | stackexchange_codegolf |
A Math.SE user have a funny game explained as such:
Pick a random positive integer X.
Add +1, 0, -1 to make it divisible by 3Keep track of how much you've added and subtracted. That is your "score"..
Divide by 3 to create a new X.
Repeat steps 2 and 3 until you reach one.
I'm expecting the shortest code to give the... | stackexchange_codegolf |
Challenge
I'm under attack by the larcenous Midnight Crew and I need to summon the Catenative Doomsday Dice Cascader in order to defend myself. Since I'm low on space, I need the code to be as short as possible.
The algorithm for the Catenative Doomsday Dice Cascader is as follows:
First, the six sided die in the Prime... | stackexchange_codegolf |
This is a two-player card game which resembles a vastly simplified game of Texas Hold'em,
combined with RPS (rock-paper-scissors) and the most basic mechanic of commercial turn-based card games.
The deck
A single full deck consists of 30 unique cards, where each card has one symbol out of RPS and one number between 0 a... | stackexchange_codegolf |
Related: Sort these bond ratings
Credit rating agencies assign ratings to bonds according to the credit-worthiness of the issuer.
The rating business is mostly controlled by "Big Three" credit rating agencies (i.e. Fitch Ratings, Moody's, and Standard & Poor's (S&P)), which use a similar tiered rating system.
Task
For ... | stackexchange_codegolf |
Given a matrix of positive integers, output whether it's possible to generate it by starting with an empty1 matrix of the same dimensions and repeatedly filling a whole row or a whole column with the same value, overwriting any values already written.
Example
The following matrix:
$$\begin{pmatrix}1&1&1\\2&3&4\\2&3&4\e... | stackexchange_codegolf |
To increase data safety at our company, we are planning to start using Gray code numbers (where successive values differ by only one bit) instead of classical binary ones.
Please help us to make a program that converts numbers to Gray code (single number to single number), but the program needs to be safe as well. This... | stackexchange_codegolf |
A covering array is an N by k array in which each element is one of {0, 1, ..., v-1} (so v symbols in total), and for any t columns chosen (so an N x t array) contains all possible v^t tuples at least once. The applications of Covering Arrays range from software and hardware testing, interaction testing, and many other... | stackexchange_codegolf |
Your task is to automatically complete URLs like the address bar in most browsers is doing. We will use the following (simplified) rules:
If the input string starts with http://, ftp:// or https://, return the string unchanged.
Otherwise, if the input string contains a dot ., e.g. in.put then the HTTP is assumed and ... | stackexchange_codegolf |
Create quine variant such that the program prints its first character, then the first two, then three and so on until the whole program is printed.
Example
Suppose your code is @@@@@2 in some language. Then the output should be
@
@@
@@@
@@@@
@@@@@
@@@@@2
in that order, each line separated by a newline.
The winner is t... | stackexchange_codegolf |
Well, although this challenge turned out to be a huge success, it also turned out to be very trivial to solve. Therefore, for those of looking for more of a challenge, I created a sequel to this challenge in which you must now count the number of unique rectangles. Check it out!
Now, for those of you looking to solve ... | stackexchange_codegolf |
The challenge
Given point and a path of points, say whether or not the point is in the polygon that is created by the path.
Also return true if the point is on an edge of the polygon.
Input
A list of pairs of integers.
The first 2 integers represent the point.
The remaining pairs (3rd and 4th, 5th and 6th etc.) represe... | stackexchange_codegolf |
The happy ending problem (actually a theorem) states that
Any set of five points in the plane in general position has a subset of four points that form the vertices of a convex quadrilateral.
The problem was so named by Paul Erdős when two mathematicians who first worked on the problem, Ester Klein and George Szekere... | stackexchange_codegolf |
In this challenge, all bots are wizards. At the beginning of each round, they create a wand which has a certain chance of successfully stunning another wizard. They then fight, by choosing one bot to attack in each turn. The last bot remaining wins.
Results
500 games, 1000 rounds each
Revenge!: 132101.68886125216
JustE... | stackexchange_codegolf |
Sandbox
French License Plates
French license plates come in a sequential order, following a specific pattern of numbers and letters : AB-012-CD
Challenge
Write a program or function that, for a given number, outputs the corresponding french license plate number. Your program should not handle any special case as specif... | stackexchange_codegolf |
Very heavily inspired by this challenge Code Golf: Your own pet ASCII snake - I thought making it horizontal would add an extra layer of complexity.
An example horizontal snake:
0 0
0 0 0 000
00 0 00 000 0 0
000 0 0 0 00
0 ... | stackexchange_codegolf |
Challenge:
In the programming language of your choice, take no input and output your programming language's name.
Fair enough, right?
Restrictions:
You can't use any character that is included in your programming language's name in your code. E.g., if I use Batch, I must not use the chars 'B' 'a' t' 'c' 'h' in my code... | stackexchange_codegolf |
Something I found while looking through some old files. It seemed like a neat idea for a code golf challenge.
The intro
One of the most popular events at the annual Cyclist's Grand Competition for Charity (CGCC) is the rocket bike parcours. The rules are simple: Inspect the parcours and place a bet on wheather is it po... | stackexchange_codegolf |
At work I've been acting as quality control on our public documents, to make sure that they are WCAG 2.0 compliant. Given the length of some of these documents there tend to be issues, and so I record the issues and the pages they occur on.
The challenge: Given a string input, output a count of all distinct pages with... | 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 |
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 |
You have to decompose a positive integer/fraction as a product of powers of factorials of prime numbers.
For example
22 = (11!)^1 × (7!)^(−1) × (5!)^(−1) × (3!)^(−1) × (2!)^1
10/9 = (5!)^1 × (3!)^(−3) × (2!)^1
Use this special notation: prime number#power
to denote each term, e.g. (11!)^4 is denoted as 11#4.
Output... | stackexchange_codegolf |
Task
Write a program that will output another distinct program, and so on, while using as few distinct characters (and as few bytes) as possible.
For example, program 1 should output program 2, and when program 2 is executed, it should output program 3. This can be nested as deeply as needed, but must be at least 3 dis... | stackexchange_codegolf |
Given a non-empty list of decimal digits (0, 1, ..., 9), replace each zero by the most recent nonzero, if possible.
Example 1: given
1 4 3 0 0 7 5 5 0 3
the output should be
1 4 3 3 3 7 5 5 5 3
Note how the first two zeros are replaced by 3, which is the most recent (i.e. rightmost) nonzero. Similarly, the last zer... | stackexchange_codegolf |
Here is the 3rd ABACABA city:
_
A|_|
B|__|
A|_|_
C|___|
A|_|
B|__|
A|_|
It is made out of the ABACABA sequence, which is basically:
A (1st iteration)
place B - AB
repeat A - ABA (2nd iteration)
Place C - ABAC
Repeat ABA - ABACABA (3rd iteration)
and you get the idea.
The buildings have a height (corresponded by no... | stackexchange_codegolf |
Currently, the Stack Exchange network has nearly 150 sites. These sites are as follows:
Computer Graphics
Portuguese Language
elementary OS
Open Source
Law
Русский язык
Mythology
Health
Stack Overflow на русском
CiviCRM
Woodworking
Music Fans
Vi and Vim
Coffee
Engineering
Lifehacks
Economics
History of Science and Math... | stackexchange_codegolf |
There are currently nine feature length films in the core Fast & Furious/The Fast and the Furious media franchise, a series of films about bald men scowling and driving cars very fast. The names of the films, as can be seen, follow a completely logical and sensible convention:
The Fast and the Furious
2 Fast 2 Furious... | stackexchange_codegolf |
The incenter of a triangle is the intersection of the triangle's angle bisectors. This is somewhat complicated, but the coordinate formula for incenter is pretty simple (reference). The specifics of the formula do not matter much for this challenge.
The formula requires lengths of sides, so it can be very messy for mos... | stackexchange_codegolf |
Aliens have arrived, and they aren't friendly.
Turns out, they've been in the process of converting all matter in the universe into compute capability so they can have more fun in their VR simulations.
Our solar system is the last bit of space they haven't converted yet, and they're about to remedy this oversight.
Howe... | stackexchange_codegolf |
disclaimer: the Mean mean is made up by me
Define the arithmetic mean of \$n\$ numbers as
$$M_1(x_1,...,x_n)=\frac{x_1+x_2+...+x_n}{n}$$
Define the geometric mean of \$n\$ numbers as
$$M_0(x_1,...,x_n)=\root{n}\of{x_1x_2...x_n}$$
Define the harmonic mean of \$n\$ numbers as
$$M_{-1}(x_1,...,x_n)=\frac{n}{\frac{1}{x_2} ... | stackexchange_codegolf |
Write a program or function which takes three positive integers \$a, b, c\$ and returns/outputs one value if there is, and a different value if there isn't, a triangle on the square lattice, whose sides' lengths are \$\sqrt{a}, \sqrt{b}, \sqrt{c}\$. By "on the square lattice" I mean that its vertices are in the \$xy\$ ... | stackexchange_codegolf |
Goal: Create the smallest possible code to open a separate window, in which there are 100 circles of random sizes and colors.
Rules: All circles must be visible to the unassisted, naked eye, so in other words more than 2 pixels across, the background must be black, at least 5 different colors must be recognizable, and ... | stackexchange_codegolf |
Challenge
Create a function or program that, when given an integer size, does the following:
If size is equal to 1, output
H H
HHH
H H
If size is greater than 1, output
X X
XXX
X X
where X is the output of the program/function for size - 1
(If you prefer, you may have the base case correspond to 0, so long as you spe... | stackexchange_codegolf |
I've become alarmed with the growing hatred of spaces and this answer has inspired me to make sure Morse code is safe from this insidious removal of whitespace.
So, your task will be to create a program that can successfully translate Morse code with all of the spaces removed.
Rules:
Input will be a string consistin... | stackexchange_codegolf |
Write a program or a function in your favorite programming language that will take as input a number n (integer or non-integer) between 0 and 100 inclusive, and output the corresponding grade as outlined below:
If 0 < n <= 40, then output E.
If 40 < n <= 55, then output D.
If 55 < n <= 65, then output C.
If 65 < n <= ... | stackexchange_codegolf |
Description
The task of this challenge is to devise a program or function that tracks a given object in an \$n×n\$ space.
I/O
Your program will be given 3 inputs, which may be taken in any sensible way:
n will be the size of the plane's side. (so, for \$n=5\$, your plane will be \$5×5\$). You may assume n will always b... | stackexchange_codegolf |
This is a simple challenge:
Given a sequence of integers, find the sum of all integers in it.
But with a twist.
Your score is the Levenshtein distance between your code and the following phrase (The challenge):
Given a set of integers, find the sum of all integers in it.
You may assume there are no newlines or traili... | stackexchange_codegolf |
Challenge
Create a 3D word puzzle where the cube's dimensions match the length of the input word. The uppercase word (A-Z) must be validly placed within the cube in one of the fixed orientations: horizontally, vertically, or diagonally. The program should randomly place the hidden word and fill the rest of the cube wit... | stackexchange_codegolf |
Write an \$n\$-bytes program \$AB\$ such that:
it outputs an integer \$x,\ 0\lt x\lt n\$;
both its \$x\$-byte prefix \$A\$ and \$(n-x)\$-byte suffix \$B\$, when run as programs, output \$AB\$.
\$A, B\$ and \$AB\$ should:
run in the same language
not take any input
use the same output method
This is code-golf, so th... | 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 |
I came up with a series of numbers the other day and decided to check what the OEIS number for it was. Much to my surprise, the sequence did not appear to be in the OEIS database, so I decided to name the sequence after myself (note that someone else who's a lot smarter than me has probably already come up with this, ... | stackexchange_codegolf |
Background:
Every war eventually comes to an end, but the end is never absolute. The Stone Maze Chess scenario takes place after a game of chess is finished. The enemy King is dead and the pieces is lost in vacuity almost out of faith, multiplying. The winning side has moved on except for the Hero who is left behind wi... | stackexchange_codegolf |
Piet is an interesting programming language for a number of reasons. Today we will focus on one reason: the roll command. The roll command was originally from PostScript and is a powerful way to manipulate the stack.
The roll command pops the top two elements of the stack and uses them as parameters. We'll call the fir... | stackexchange_codegolf |
Consider a grammar over the alphabet {0, 1, ?, :} defined by the production rule
s → 0 ┃ 1 ┃ 0 ? s : s ┃ 1 ? s : s
Given a string generated from s, parse it as an expression where ?: is right-associative (for example, a?B?X:Y:c?d:e?f:g means a?(B?X:Y):(c?d:(e?f:g))) and evaluate it with the following semantics:
eval(... | stackexchange_codegolf |
Implement a function \$f\$ (as a function or complete program), such that
\$
\displaystyle\lim_{n\rightarrow \infty} f(n)
\$
converges to a number which is not a computable number.
Answers will be scored in bytes with fewer bytes being better.
IO formats
Your answer may be in any of the following formats
A program or ... | stackexchange_codegolf |
Task
Given a string s, output a truthy value if the ASCII code of each letter is divisible by the length of s, and a falsey otherwise.
Input/Output
Input is a nonempty string containing only ASCII [32-126]. Output is a standard truthy/falsey value. Note that you can switch the values, for example returning 0/False if d... | stackexchange_codegolf |
Inspired by A014486.
Challenge
Given an integer input in base 10, construct a representation for the binary forest corresponding to the input. Representations include, but are not limited to, nested arrays and strings.
How?
Convert the input to binary. 1s represent branches, and 0s represent leaves.
To make this easier... | stackexchange_codegolf |
We've all been burned by the grammar police on the internet. What we need is a regex that can be used in place of "there", "their", and "they're". This would shift burden of grammar parsing from the writer to the reader (a sort of "client-side" grammar, if we you will). So, here's what I have to start with:
the([re]|[i... | stackexchange_codegolf |
Your task is to find how many distinct Blackjack sequences can be found in an ordered list of 12 cards.
A Blackjack sequence is defined as a sequence of consecutive cards whose sum of points is exactly 21. Points are counted according to the following table:
Symbol | Name | Points Symbol | Name | Points
-------+-... | stackexchange_codegolf |
Create a program that solves a mathematical expression using the elements from alternating sides of the expression. The way it’s done is, instead of reading from left to right, you read the first character, then the last, then the second, then the second to last etc. This will give you a new expression that you must ev... | stackexchange_codegolf |
Given a list of positive integers, give the longest contiguous sublist which contains at most 1 pair of identical items. In the case of a tie return any of the solutions.
This is code-golf so the goal is to minimize your source code with answers being scored in bytes.
Test cases
[] -> []
[1,2,3] -> [1,2,3]
[1,2,2,3] -... | stackexchange_codegolf |
(inspired by a question over on Code Review)
Suppose two people are playing Hangman, but you've only overheard the game and want to draw the current status.
Given two words as input, where the words each match [A-Z]+ or [a-z]+ (your choice), output the current state of the hangman game as ASCII art, following the below... | stackexchange_codegolf |
Given a string consisting of only printable ascii (letters, numbers, symbols, and spaces), how many keystrokes are required minimally to type out this string from scratch?
That is, current text is initially an empty string and should end up being equal to the input string. These are the allowed actions and their cost i... | stackexchange_codegolf |
Inspired by Find the largest fragile prime
A recurring prime (or whatever you choose to call it) is a prime that, when removing leading digits, always remain prime regardless of how many digits are removed.
for example
6317 is a recurring prime because...
317 is a recurring prime because...
17 is a recurring prime beca... | stackexchange_codegolf |
The game of xiangqi, also known as Chinese chess, is a chess-like game popular in China, Vietnam, Taiwan, and other East Asian countries. The colours of the two sides in xiangqi are red and black. There are 16 black pieces in xiangqi: the 1 general (G), 2 advisor (A), 2 elephant (E), 2 horse (H), 2 chariot (R), 2 canno... | stackexchange_codegolf |
Challenge:
Write a lossless encoder/decoder that is able to compress its own source code.
Usage:
progname encode
Encodes data provided on the standard input, writes the encoded representation of the data to the standard output.
progname decode
Decodes data produced by progname encode. Reads the encoded data from the s... | stackexchange_codegolf |
Katlani is a constructed language being designed in chat. In this challenge, your goal is to print the largest dictionary of katlani nouns possible in 400 bytes or less.
Task
In 400 bytes or less, your program should print a list of katlani nouns. You can choose to output them as a list/array in your language, or as a ... | stackexchange_codegolf |
Inspired by this question over at Mathematics.
The Problem
Let n be a natural number ≥ 2. Take the biggest divisor of n – which is different from n itself – and subtract it from n. Repeat until you get 1.
The Question
How many steps does it take to reach 1 for a given number n ≥ 2.
Detailed Example
Let n = 30.
The... | stackexchange_codegolf |
Originally from caird coinheringaahing's idea, I (Bubbler) am hosting Advent of Code Golf 2021.
On each day from today (Dec 1) until Christmas (Dec 25), a challenge will be posted at UTC midnight, just like an Advent calendar. It is a free-for-all and just-have-fun-by-participation event, no leaderboards and no prizes ... | stackexchange_codegolf |
What is elementary cellular automata?
Since I'm not sure I'll be able to explain this so that somebody who has never heard of this is able to understand, I'm giving an explanation from https://mathworld.wolfram.com/ElementaryCellularAutomaton.html
Elementary cellular automata have two possible values for each cell (0 ... | stackexchange_codegolf |
Make a program that outputs the number of seconds from the beginning of today (00:00:00 of the day you run it) to the second you ran it. However, if this number is divisible by three, print Fizz instead. If it is divisible by five, print Buzz instead. If it is divisible by three and five, print FizzBuzz.
Don't pad the ... | stackexchange_codegolf |
The fast growing hierarchy is a way of categorizing how fast functions are growing,
defined the following way (for finite indices):
\$ f_0(n)=n+1 \$
\$ f_k(n)=f_{k-1}^n(n)\$ with \$f^n\$ meaning repeated application of the function f
Examples
f0(5) = 6
f1(3) = f0(f0(f0(3))) = 3+1+1+1= 6
f2(4) = f1(f1(f1(f1(4)))) = 2*... | stackexchange_codegolf |
Statement
Given an input like this 35 15 0 0 10 that matches the following constrains:
Width in characters of the grid (5-50)
Height in characters of the grid (5-25)
Initial X position of the ball (0-(Width-1)
Initial Y position of the ball (0-(Height-1)
Number of movements to simulate
Generate a grid that shows the ... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.