instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Take the string of brackets ]][][[. When you rotate it to the right once, you get []][][. If you rotate it again, you get [[]][]. All brackets in this string are balanced.
The Task:
Your program (or function) will be given a string of brackets, represented in any reasonable format (including using other things in place... | stackexchange_codegolf |
We define \$a(n)\$ as the 1-indexed position of \$n\$ in the sequence of positive integers with the same binary weight, i.e. the same number of 1's in their binary representation. This is A263017.
Given a positive integer \$n\$, your task is to determine how many positive integers \$k\$ satisfy:
$$k-a(k)=n$$
For instan... | stackexchange_codegolf |
As a big fan of the Lost TV series, I always got intrigued by the sequence of numbers that repetitively appears on the episodes. These numbers are:
\$ 4, 8, 15, 16, 23, 42\$ (A104101)
Using any programming language, write a code that outputs these numbers.
Scoring:
Shortest answer wins
The output must not contain any ... | stackexchange_codegolf |
inputs / outputs
your program/function/routine/... will be a predicate on two tuple sequences; call it relation ≡. for the purpose of simplicity we use natural numbers:
the input will be two list of pairs of numbers from ℕ (including 0); call them Xs and Ys
the output will be a "truthy" value
specification
≡ checks t... | stackexchange_codegolf |
Definitions
An algebraic number is a number that is a zero of a non-zero polynomial with integer coefficients. For example, the square root of 2 is algebraic, because it is a zero of x^2 - 2.
A transcendental number is a real number which is not algebraic.
Task
You are to choose a transcendental number.
Then, write a... | stackexchange_codegolf |
In this game of cops and robbers, each cop will make a vault: a program that stores a secret, and requires a key to unlock. The robbers should find a way to get the vault to reveal its secret without knowing the key.
Cop rules
Cops will write two short segments of code:
A vault, which takes a key and secret, then allo... | stackexchange_codegolf |
Write a program or function that takes in a string and outputs a count of each modern English alphabet letter in the string, case-insensitive.
Input: A string consisting of printable ASCII characters (code points 32-126).
Output: A list of pairs, where each pair consists of a letter and its count in the string. The lis... | stackexchange_codegolf |
We define \$R_n\$ as the list of remainders of the Euclidean division of \$n\$ by \$2\$, \$3\$, \$5\$ and \$7\$.
Given an integer \$n\ge0\$, you have to figure out if there exists an integer \$0<k<210\$ such that \$R_{n+k}\$ is a permutation of \$R_n\$.
Examples
The criterion is met for \$n=8\$, because:
we have \$R_8... | stackexchange_codegolf |
(Follow-up to my question about swapping bits with their neighbours.)
Task
Given a positive integer x = (2a · 3b) · (5c · 7d) · (11e · 13f) · …, print the integer obtained by swapping the exponents in this factorization for each successive pair of primes, y = (2b · 3a) · (5d · 7c) · (11f · 13e) · …
A061898 in the OEIS.... | stackexchange_codegolf |
A drug comes in 5mg, 2.5mg, and 1mg sized pills. The drug is taken once a day. The total daily dose will be only one of the following (all in mg):
1, 2, 3, ... 20, 22.5, 25, 27.5, 30, 32.5, 35, 37.5, 40, 42.5, 45, 47.5, 50
In words: any whole number less or equal to 20, then at 2.5mg increments up to 50.
Your task is t... | stackexchange_codegolf |
Consider you have a hash function \$\mathcal{H}\$ which takes strings of length \$2n\$ and returns strings of length \$n\$ and has the nice property that it is collision resistant, i.e. it is hard to find two different strings \$s \neq s'\$ with the same hash \$\mathcal{H}(s) = \mathcal{H}(s')\$.
You would now like to ... | stackexchange_codegolf |
A portmanteau word is a combination of two words that takes part of each word and makes them into a single new word. For example, lion + tiger => liger.
Let's write a program to generate portmanteaus from a pair of input words. Computers aren't the best at English, so we'll need to establish some rules to ensure that t... | stackexchange_codegolf |
Background
The fixed-point combinator \$\textsf{fix}\$ is a higher-order function that computes the fixed point of the given function.
$$\textsf{fix}\ f = f\ (\textsf{fix}\ f)$$
In terms of programming, it is used to implement recursion in lambda calculus, where the function body does not normally have access to its ow... | stackexchange_codegolf |
You are given 3 non negative numbers: \$x\$, \$y\$ and \$z\$, and must minimize the number of digits (non negative) inserted at any place in the numbers \$x\$, \$y\$, or \$z\$ to make
$$x + y = z$$
(a clarification: you can add any non negative digit any number of time at any place )
(you can assume that \$x\$, \$y\$, ... | stackexchange_codegolf |
I have one hundred vaults, each one within another. Each vault has a password, consisting of a single number.
95 43 81 89 56 89 57 67 7 45 34 34 78 88 14 40 81 23 26 78 46 8 96 11 28 3 74 6 23 89 54 37 6 99 45 1 45 87 80 12 92 20 49 72 9 92 15 76 13 3 5 32 9... | stackexchange_codegolf |
Cops thread
Robbers,
Write a program in the cop's language using the cop's P string and your own S string, and the amount of each of them specified in the cop's post. Your S string may not exceed the cop's S string in bytes.
The program
Using only strings P and S, write a program which takes a list of 5 or more non-rep... | stackexchange_codegolf |
\$723 = 3 \times 241\$ is a semi-prime (the product of two primes) whose prime factors include all digits from \$1\$ to \$n\$, where \$n\$ is the total number of digits between them. Another way to look at this is that the (sorted) digits in the factorisation of \$723\$ are all consecutive. The first 10 such semi-prime... | stackexchange_codegolf |
Write a function or program that takes string inputs, fully-spelled, English month names in title case: January, February, March, etc. (null/CR/LF terminated OK, delimited with some non-alpha character if you so choose) and either
compares two inputs, returning a Truthy value if the second input is greater (in month o... | stackexchange_codegolf |
You are a historian studying a long forgotten language. You have just discovered a clay tablet which seems to list all known words in the language, in alphabetical order. Your task is to find this alphabet's order, if it exists.
The Task
Given an ordered list of words, try to output an ordered list of characters such t... | stackexchange_codegolf |
Classic Tetris was often a difficult game to play. One problem was that you could only work with the Tetris piece you were given, so if you had an awkward board, it would sometimes be difficult to find a suitable location to put your piece. Another problem was that you could only look one piece ahead, so it was difficu... | stackexchange_codegolf |
Consider an \$n \times n\$ grid and a circle of radius \$r \leq \sqrt{2} n\$ with its center in the top left. In each square there is an integer from the range -3 to 3, inclusive. For a given radius, there is a set of squares in the grid which are not at least half covered by a circle of radius \$r\$ but are at least ... | stackexchange_codegolf |
Background
A staircase polyomino is a polyomino made of unit squares whose shape resembles a staircase. More formally, a staircase polyomino of size \$n\$ is defined as follows:
A staircase polyomino of size 1 is a single unit square.
A staircase polyomino of size \$n\$ is the same as that of size \$n-1\$ with a horiz... | stackexchange_codegolf |
You need to produce the word codegolf
Rules:
None of the characters of the word codegolf (i.e. 'c', 'o', 'd', 'e', 'g', 'o', 'l' and 'f') in either case can exist anywhere in the code.
Case of the word must be one of three:
All Upcase (CODEGOLF)
All Downcase (codegolf)
Capitalized (Codegolf)
You only need to produ... | stackexchange_codegolf |
In English, there is the fun and simple difference between an and a: you use an when preceding a word starting with a vowel sound, and a when the word starts with a consonant sound.
For the sake of simplicity in this challenge, an precedes a word that starts with a vowel (aeiou), and a precedes a word that starts with... | stackexchange_codegolf |
Your goal is to check whether a completed Minesweeper board is valid. This means that each number is a correct count of mines in cells adjacent to it, including diagonals. The board does not wrap around.
As usual, you should give a function or program, and shortest code in bytes wins.
See also past challenges to genera... | stackexchange_codegolf |
The Euclidean GCD Algorithm is an algorithm that efficiently computes the GCD of two positive integers, by repeatedly subtracting the smaller number from the larger number until they become equal. It can be visualised as such:
We start with a MxN grid, where M and N are the numbers. In this example I'll use M=12, N=5:
... | stackexchange_codegolf |
Input
An array A of integers of length 100,000. The array will contain only integers in the range 0 to 1e7.
Output
The convolution of A with itself. As this will be of length 199999 you should time just the convolution calculation however, not the time to print out the answer.
Example in Python
import numpy as np
from... | stackexchange_codegolf |
Your task is to write a program that will filter out some characters in a string, so that the remaining spells out (part of) the other string.
Let's say we received the string "123456781234567812345678", and the second string is "314159".
First, we put a pointer on the second string:
314159
^
So the pointer is now on ... | stackexchange_codegolf |
Most of you have probably heard of the famous Turtle Graphics program, initially made popular by Logo. This challenge is to implement a Turtle Graphics program in your language of choice.
Rules:
Rule one is that when the pen is in the down state, it must draw in both the square the turtle leaves and the square the tu... | stackexchange_codegolf |
This is a potato:
@@
@@@@
@@@@@@
@@@@@@
@@@@
@@
More generally, a size N potato is defined as the following shape:
If N is even, it is 2 centered @ symbols, followed by 4 centered @ symbols, followed by 6 centered @ symbols, all the way up to N centered @ symbols; then, N centered @ symbols, followed by N-2 ce... | stackexchange_codegolf |
A twin of this.
FizzBuzz is where a range of positive integers is taken, and numbers divisible by 3 are replaced with "Fizz", divisible by 5 with "Buzz" and divisible by 15 with "FizzBuzz". For example, FizzBuzz from 1 to 10 is 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz.
Your challenge is to, given a list of Fizzes, B... | stackexchange_codegolf |
UTF-1 is one of the methods to transform ISO/IEC 10646 and Unicode into a sequence of bytes. It was originally for ISO 10646.
The UTF-1 encodes every character with variable length of byte sequence, just like UTF-8 does. It was designed to avoid control codes. But it was not designed to avoid duplication of a slash cha... | stackexchange_codegolf |
The Pareto Distribution is a probability distribution that comes up a lot in nature. It has lots of special properties, such as an infinite mean. In this challenge, you will output a number sampled from this distribution.
The Pareto Distribution is defined to be greater than or equal to x with probability 1/x, for all ... | stackexchange_codegolf |
Challenge
I think everyone of us heard of URL encoding mechanism - it's basically everywhere.
Given an URLEncoded string on stdin, decode it, and output the decoded form to stdout.
The encoding is very simple, + or %20 is representing space. Every percent followed by two hex digits (uppercase or lowercase) has to be re... | stackexchange_codegolf |
The challenge here is to accurately depict the flower of life (which is a sacred geometrical figure according to some) in the language of your choice.
The design consists an arrangement of circles and partial circles of radius 1 as shown whose centres arranged on a triangular grid of pitch 1, plus one larger circle of... | stackexchange_codegolf |
I created a programming language for manipulating strings called Stringy. It's very different from other programming languages, since you only have one string (for manipulation) and some variables. With the various commands you can manipulate that one string. I created it because it might be useful for some challenges ... | stackexchange_codegolf |
This is taken from this question (with permission ofcourse). I'll quote:
Create a function which takes a string, and it should return true or
false based on whether the input consists of only a repeated character
sequence. The length of given string is always greater than 1 and the
character sequence must have a... | stackexchange_codegolf |
This is a cops-and-robbers challenge based around defining languages and proving they are Turing complete.
This is the robbers' thread. The cops' thread is here.
Robbers
The cops will post definitions of Turing-complete languages. Your task is to crack them by proving that they are indeed Turing complete. See the cops'... | stackexchange_codegolf |
Graham's number \$G\$ is defined in this way:
\begin{align*}
u(3,n,1) & = 3^n \\
u(3,1,m) & = 3 \\
u(3,n,m) & = u(3,u(3,n-1,m),m-1)
\end{align*}
Then,
\begin{align*}
g_1 & = u(3,3,4) \\
g_2 & = u(3,3,g_1) \\
g_3 & = u(3,3,g_2) \\
& \vdots \\
G & = u(3,3,g_{63})
\end{align*}
You are given that \$u(3,3,2)=7625597484987\$... | stackexchange_codegolf |
Challenge
Given the name of a PPCG member, output their PPCG ID number. If the user does not exist, you may report an error or return any non-positive number. If there are multiple members with this name, you may choose to output only one ID or all of them.
Test Cases
"musicman523" -> 69054
"Dennis" -> 12012
"xnor" ->... | stackexchange_codegolf |
Introduction
A farmer needs help calculating the least time it will take him to pick his fruit each day.
Challenge
This farmer has X orchards.
Each orchard has Y fruits in it. If the orchard has no fruits, then it will contain the string "none".
The farmer has a list, this list contains the fruit he must pick.
The f... | stackexchange_codegolf |
As you probably know, a Fibonacci Number is one which is the sum of the previous two numbers in the series.
A Fibonacci Digit™ is one which is the sum of the two previous digits.
For instance, for the series beginning 1,1, the series would be 1,1,2,3,5,8,13,4,7,11,2... The change occurs after the 13, where, instead of ... | stackexchange_codegolf |
Oops, Auto-correct.
You have a word. But it's wrong. You wonder what word it would be. Thankfully, being a code golfer, You can make a code to take a rough guess.
I/O
You will be given a (wrong, all lowercase) word, and a '(All lowercase)Dictionary list'. You have to output the word with the least Levenshtein distanc... | stackexchange_codegolf |
Assignment is simple to explain: write the shortest code you need to determine whether an executable binary program supplied as parameter is 32 or 64 bits.
If there is a different kind of bitness, you can also do for it, but is not mandatory.
What I really don't want is telling me you support other bitnesses and after ... | stackexchange_codegolf |
There have of course been challenges to render ASCII art fonts here and there. This challenge doesn't add anything to those. In contrary, it subtracts from them for a good reason. If you allow all characters,
it's a lot of boring work
the task is mainly about clever compression of the font and short extraction
This o... | stackexchange_codegolf |
I'm recieving 2-dimensional positions of two objects as a string with this format: x1,y1,x2,y2. The string is recieved from a readline call (replaced in the snippet with a prompt).
In order to get the horizontal and vertical position differentials, I'm writing the following code:
[x1,y1,x2,y2]=prompt("Please enter th... | stackexchange_codegolf |
This challenge is inspired by one of my other challenges: Pointlessly make your way down the alphabet
That challenge asked you to take a string of text, and for each letter produce a sequence of letters moving down the alphabet to 'a'.
For this challenge I'd like to decode the output of that challenge (minus the line b... | stackexchange_codegolf |
Given a number \$n\$, we have its sum of divisors, \$\sigma(n)\ = \sum_{d | n} {d}\$, that is, the sum of all numbers which divide \$n\$ (including \$1\$ and \$n\$). For example, \$\sigma(28) = 1 + 2 + 4 + 7 + 14 + 28 = 56\$. This is OEIS A000203.
We can now define the sum of sum of divisors as \$S(n) = \sum_{i=1}^{n}{... | stackexchange_codegolf |
Starting an the origin on an infinite grid, you follow a predetermined path going up (U), down (D), left (L), or right (R). You paint every square you visit, including the square you started at and the square you finish at. Using this method, we can paint the number six using the instructions RRDDLLUUUURR:
The origin ... | stackexchange_codegolf |
Conway's Game of Life is a well known cellular automaton "played" on an infinite grid, filled with cells that are either alive or dead. Once given an initial state, the board evolves according to rules indefinitely. Those rules are:
Any live cell with 2 or 3 living neighbours (the 8 cells immediately around it) lives ... | stackexchange_codegolf |
Challenge:
Given a matrix (or 2d array) of 0s and 1s, output the number of steps it takes for Conway's game of life to reach a stable state, or -1 if it never reaches one. A stable state is a state in which no cells are turned on or off each step. The game must run in the given matrix, with the top and bottom connec... | stackexchange_codegolf |
There's classic combinatorial result that the number of ways to tile a 2*n strip by 1*2 dominoes is the nth Fibonacci number. You goal is to print all the tilings for a given n, drawn with dashes and vertical lines like these 8 tilings for n=5:
|————
|————
——|——
——|——
|||——
|||——
————|
————|
||——|
||——|
|——||
|——|... | stackexchange_codegolf |
We seem to quite like digit runs lately, so here's a fairly simple challenge.
Given a positive integer, split it into it's digit runs, and return the product.
For example:
11122333 would become 111, 22, 333, the product of which is 813186
Input may be taken as an integer, string, or list/array of digits/characters. You... | stackexchange_codegolf |
Given a number n, find x such that x! = n, where both x and n are positive integers. Assume the input n will always be the factorial of a positive integer, so something like n=23 will not be given as input.
Examples: n=1 -> x=1 (0 is not a positive integer), n=24 -> x=4
Shortest code wins.
| stackexchange_codegolf |
It seems that any Simple Modification of deltas using a consistent function can almost always be done some other shorter way, Dennis.
Thus, the only solution I can imagine to make this harder, is to introduce some sort of inconsistent function.
Sorting.
Your task is to take an array of integers, sort their deltas, and ... | stackexchange_codegolf |
This is the inverse of negative seven's question.
Write a program or function which, given any single, possibly-empty string of printable ASCII (codes \$[32,126]\$) outputs or returns two strings of printable ASCII.
For any two ordered, possibly empty strings \$s_1\$ and \$s_2\$, there must be third string \$s_0\$, whi... | stackexchange_codegolf |
Very related
You're given a piece of ASCII art representing a piece of land, like so:
/‾\
__/ ‾\_
\_/‾\
\
Since an overline (‾) is not ASCII, you can use a ~ or - instead.
Your challenge is to determine if it is connected by the lines of the characters. For example, the above can be traced ... | stackexchange_codegolf |
Given, in any way and order,
dimensions (in whichever order you want)
a probability (in whatever format you want)
number of iterations (you may choose whether to count the initial state or not)
do one of the following:
animate, or
output each step of, or
return a list of states of
a spaces-filled sky of those... | stackexchange_codegolf |
Is it possible to make this C code smaller? It prints out all primes from 0 to 1000.
C, 89 chars
int i,p,c;for(i=2;i<1e3;i++){c=0;for(p=2;p<i;p++)if(i%p==0)c++;if(c==0)printf("%u\n",i);}
| stackexchange_codegolf |
This is a sequence question of the usual type, as applied to OEIS sequence A038666. That is, do either of the following:
Accept no or any input, and output A038666 until the heat death of the universe.
Accept a positive integer as input, and output the \$n\$th term of A038666 or its first \$n\$ terms. (If using \$0\$-... | stackexchange_codegolf |
Repost and improvement of this challenge from 2011
A vampire number is a positive integer \$v\$ with an even number of digits that can be split into 2 smaller integers \$x, y\$ consisting of the digits of \$v\$ such that \$v = xy\$. For example:
$$1260 = 21 \times 60$$
so \$1260\$ is a vampire number. Note that the dig... | stackexchange_codegolf |
On CodingGame, there is a Puzzle that ask to write words with ascii art.
I solve the puzzle then tried to golf it. What improvement can I do on it?
INPUT
>>> 20
>>> 11
>>> MANHATTAN
>>> .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------... | stackexchange_codegolf |
Your task is, given a array of numbers, that is strictly increasing, output the crate stack. The input is an array of positive integers which represents which layer has how many crates there are. So the first number is the top layer and so on. The sum of the array is the size of the crate.
Since the array order follows... | stackexchange_codegolf |
Adapted from tips for restricted-source in Python
Just like code-golf, restricted-source pushes one to exploit quirks and hidden features of the zsh language. While we already have a place to collect all these tips for code-golf, those for restricted-source remain transmitted by word of mouth or hidden deep within the ... | stackexchange_codegolf |
A Bell number (OEIS A000110) is the number of ways to partition a set of n labeled (distinct) elements. The 0th Bell number is defined as 1.
Let's look at some examples (I use brackets to denote the subsets and braces for the partitions):
1: {1}
2: {[1,2]}, {[1],[2]}
3: {[1,2,3]}, {[1,2],[3]}, {[1,3],[2]}, {[2,3],[1]}... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
Christmas is coming up, and Santa hasn't kept to his diet very well this year. Due to his size, he is getting the elves to collect a list of all the chimneys he will be able to fit down. Unfortunately, chimneys these days are a bit of ... | stackexchange_codegolf |
Background
We define the two types of chain to be a string that contains only dashes, "-", or only underscores, "_". We link two chains using one equals sign, "=".
Criteria:
The type of chain must change following an equals sign.
You must link the chains, you can do so multiple times, and it does not matter what lengt... | stackexchange_codegolf |
The Typical Way to Make an Acronym Out of a Phrase Is to Take the First Letter of Each Word: TTWMAOPITFLEW. howeveR, sometimEs, you can make an acronym of random leTters In a seNtence such As like this: RETINA. The only condition is that the letters have to be in the correct order. For instance:
LORD can be acronymise... | stackexchange_codegolf |
There's a minigame in Super Mario 3D World known as the Lucky House. It consists of a slot machine with 4 blocks.
Each block may be one of 5 different icons (Flower, Leaf, Bell, Cherry or Boomerang) and the goal of the player is to get as many identical icons as possible (see a video).
The player is rewarded with coin... | stackexchange_codegolf |
Write a program or function that takes input: all resistors available and a resistance value and outputs a truthy value of whether or not it is possible to get the resistance by using those resistors.
Rules:
Any format for input will do.
There will be at least 1 available resistor and your program should output for at ... | stackexchange_codegolf |
Fairly obviously, you have to print the Greek alphabet. But I thought I'd make it slightly more interesting, so there's a twist: when your program is ran with an argument (anything), it should output the Greek alphabet in lowercase.
Information
Greek alphabet (Capitals): ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ
Greek alphabet (Lower... | stackexchange_codegolf |
Your program has to have an year like 1957 to be the input and then output the century of that year.
For example:
In: 1946
Out: 20
In: 1705
Out: 18
In: 1900
Out: 19
In: 100
Out: 1
In: 2001
Out 21
because 1946 is in the 20th century.
Keep in mind that 2000 should be 20th century or 1900 should be in 19th century.
There... | stackexchange_codegolf |
Given an infinite arithmetically-progressive¹ sequence, compute the minimum length of a prefix with a product divisible by 2^8.
Sample cases & reference implementation
Here is a reference implementation that I wrote in Io.
1, 1 -> 10
2, 4 -> 8
3, 5 -> 10
2, 6 -> 5
7, 5 -> 6
4, 1 -> 9
10, 9 -> 7
256, 9 -> 1... | stackexchange_codegolf |
When making a Minecraft data/resource pack, you need to include a pack.mcmeta file, which specifies information about it. pack.mcmeta contains a description, but it also contains a pack_format number, which tells Minecraft which versions this pack is for.
Your task is to take a version string, and output what pack_form... | stackexchange_codegolf |
Your task here will be to implement a function1 that forms a permutation on the positive integers (A bijection from the positive integers onto themselves). This means that each positive integer should appear exactly once in the permutation. The catch is your function should have a larger probability of outputting an ... | stackexchange_codegolf |
You must write a program or function that sorts a nested list. Here are the rules for sorting a nested list:
Let's take this list as an example:
((5, 2), 2, 7, (2, 1, (3, 4)), 9)
Each element in this list has a "priority". An element counts as a number or a sublist. First, get the priority of each element at the same ... | stackexchange_codegolf |
If a positive integer \$N > 2\$ has (strictly) less prime factors (without counting multiplicities) than its successor and its predecessor, we will call it a factor-poor number.
In other words, \$\omega(N) < \omega(N - 1)\$ and \$\omega(N) < \omega(N + 1)\$, where \$\omega(N)\$ is the number of unique prime factors of... | stackexchange_codegolf |
Given a rectangular text as a word search puzzle and a search string, determine if the text contains the search string. The search string may appear:
horizontally, vertically or diagonally
forwards or backwards
You may write a function or a program and take two strings as input via function argument, ARGV or STDIN. T... | stackexchange_codegolf |
Dina loves most numbers. In fact, she loves every number that is not a multiple of n (she really hates the number n). For her friends’ birthdays this year, Dina has decided to draw each of them a sequence of n−1 flowers. Each of the flowers will contain between 1 and n−1 flower petals (inclusive). Because of her hatred... | stackexchange_codegolf |
I'm new to Japanese Mahjong and have trouble calculating the scores. Please help me write a program to calculate it.
Introduction
(aka you can skip this boring part)
Mahjong is a popular tile game in Asia. Different rules have evolved and systematically established in various regions. Japan, being an isolated island st... | stackexchange_codegolf |
Golf the leaderboard of this question (id=111735). Your program should issue one HTTP or HTTPS request to StackExchange API, parse it and present to user in form similar to a typical Leaderboard Snippet
Sample output (for the question 47338 instead of this):
Leaderboard
Author Language Size
1. FryAmTheEggman ... | stackexchange_codegolf |
This challenge is to calculate how to measure 4 liters of water with just two unevenly sized buckets, one of 3 liters and another of 5 liters, in minimum number of steps. To extend and generalize this, write a program to evaluate the minimum number of steps to measure “X” liters of water, with “Y” buckets each having a... | 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 |
Let's use augmented reality to hunt small creatures hidden in source-code. Write a quine program that outputs its own code source, except for 5 consecutive characters that will be modified and that will display a PCG-mon : (^_^)
The 5 consecutive characters can be positioned anywhere in the source code (from position 0... | stackexchange_codegolf |
Challenge:
Given a list of integer, sort descending by their single largest digit(s). The order for numbers with the same largest digit are then sorted by second largest digit, etc.
We ignore duplicated digits in numbers. And if all digits in a number are the same, the order of those numbers in the list can be in any w... | stackexchange_codegolf |
There is a rectangular 2D array containing viruses denoted by 'v', antidote1 denoted by 'a', and antidote2 denoted by 'b' (there are no values other than 'v', 'a' and 'b').
Antidote1 can kill neighboring viruses in horizontal and vertical directions only, but antidote2 can kill neighboring(if any) viruses in horizontal... | stackexchange_codegolf |
A skyline is an array of positive integers where each integer represents how tall a building is. For example, if we had the array [1,3,4,2,5,3,3] this would be the skyline in ascii art:
#
# #
## ###
######
#######
A maximal rectangle is a rectangle that cannot be extended in any direction while being contained... | stackexchange_codegolf |
Yesterday, as part of a IQ-style test, I got this interesting question:
The time on a 24-hour clock is 11:43. What is the least number of minutes I should wait before the same digits are on the screen again (in any valid 24-hour time order)?
The answer's 91 minutes, if you were wondering!
This stuck in my mind, and ... | stackexchange_codegolf |
In Python it is often necessary to use str.replace(a,b), however .replace is rather long and feels unnecessary. So is there a shorter alternative to str.replace.
Alternatively is there a similar trick to how you can use r=range for golfing for str.replace?
Example code for golfing
m=input()
f="hello"
print m.replace('t... | stackexchange_codegolf |
Your input is an array of numbers: a permutation of \$\{1, 2 \dots n\}\$ for some integer \$n \geq 2\$.
How many times must you repeat this list before you can "pick out" the numbers \$[1, 2 \dots n]\$ in order?
That is: find the lowest \$t \geq 1\$ so that \$[1, 2 \dots n]\$ is a subsequence of \$\text{repeat}(\text{i... | stackexchange_codegolf |
Surprised that we don't have a symmetric difference challenge yet.
Given two lists only containing positive integers, return all items among these two lists that aren't contained in both of the lists.
Rules
From the set definition:
A set is a collection of definite distinct items.
So you can assume the items in the ... | stackexchange_codegolf |
Challenge:
The concept is simple enough: write a full program to output its own code golf score!
Output should only be the byte count of your program and a trailing bytes.
BUT WAIT..... there is one restriction:
Your source code can not include any of the digits from your byte count
So if your score is 186 bytes, you... | stackexchange_codegolf |
Inspired by a bug in a solution to this challenge, your challenge is to produce this exact text:
ZYXWVUTSRQPONMLKJIHGFEDCBA
YXWVUTSRQPONMLKJIHGFEDCBA
XWVUTSRQPONMLKJIHGFEDCBA
WVUTSRQPONMLKJIHGFEDCBA
VUTSRQ... | stackexchange_codegolf |
Write a function which takes a set of integers and prints every permutation of the set, and the swap performed in between each step
Input
a set of integers, for example (0, 1, 2)
Output
the list of permutations and swaps in the format
(set)
(swap)
(set)
...
Test case
Input:
(3, 1, 5)
Output:
(3, 1, 5)
(3, 1)
(1, 3, 5... | stackexchange_codegolf |
Introduction
You must create a function to convert Arabic numerals into Greek numerals. The input will be an integer less than 1000 and more than 0.
Algorithm
Split number into digits (e.g. 123 -> 1, 2, 3)
Take each digit, and change to character found in table below, for letter symbol or letter name, (e.g. 123 -> 1,... | stackexchange_codegolf |
Note to those without experience in music: Through making an attempt to solve this problem, you may find that music and computer programming are similar in the ways that they implement rules and syntax. With some help from Wikipedia, you can likely solve this problem with no prior knowledge of music theory.
Write a pro... | stackexchange_codegolf |
We've had a couple of challenges about the Ulam spiral. But that's not enough.
In this challenge we will plot a triangular Ulam spiral (as opposed to the usual, square Ulam spiral). Here's a sketch of what the spiral looks like.
As we know, the Ulam spiral arranges all natural numbers in an outward spiral, and marks o... | stackexchange_codegolf |
Robbers' Thread
Your challenge is to find an existing challenge, and implement it in a way such that certain inputs fail. At least one input must not produce the correct output (use the other submissions on the challenge as a reference for this, but be sure to double-check). This must fail consistently, and you must kn... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
Inspired by https://xkcd.com/835
In the midst of his mid-life crisis, Santa has impulsively purchased a Sports Sleigh™ for present delivery this year. The only problem is that this sleigh has a specially designed Infinite Present Trunk... | stackexchange_codegolf |
The Challenge
Given an integer input x where 1 <= x <= 255, return the results of powers of two that when summed give x.
Examples
Given the input:
86
Your program should output:
64 16 4 2
Input:
240
Output:
128 64 32 16
Input:
1
Output:
1
Input:
64
Output:
64
The output may contain zeros if the certain power of... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.