instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
You will need to generate the smallest prime with n digits, and it will only contain digits specified in the list k.
Examples:
Input:
4
1 2
For this, you must generate the smallest prime with 4 digits, and that prime must only contain the digits 1 and 2.
Output:
2111
Input:
10
0 4 7
Output:
4000000007
Input:
6
5 5... | stackexchange_codegolf |
This is a quine variation.
Introduction
We all write short code, because some obscure reasons, but whatever we do, the'll take up at least 144 pixels/byte (with a 12px font). But what would happen, if we would encode our code in images? This is your task today.
Challenge
You task is to read in your own source code (non... | stackexchange_codegolf |
Create a program that can be run in 4 different languages such that:
One language prints "Hello World!"
One language outputs its own source code
One language outputs 99 bottles of beer on the wall, that is:
99 bottles of beer on the wall
99 bottles of beer
Take one down, pass it around
98 bottles of beer on the wall
... | stackexchange_codegolf |
Stevin's Notation is a way to represent decimals in a non-fractional way.
The Flemish mathematician and engineer Simon Stevin is
remembered for his study of decimal fractions. Although he was not the
first to use decimal fractions (they are found in the work of the
tenth-century Islamic mathematician al-Uqlidisi), it ... | stackexchange_codegolf |
Challenge
Given two numbers, output their quotient. In other words, integer divide one number by another.
Both divisor/dividend will be under 10001. Division must be performed using integer division, rounding down.
Here are some example inputs and outputs:
5 1 5
-4 2 -2
4 -2 -2
6 ... | stackexchange_codegolf |
Input:
Ten unique integer coordinates, between (0,0) and (100,100).
Output:
The coordinates arranged in the order/an order such that a path drawn between the coordinates in that order is the shortest path possible.
This is code golf so the shortest code wins!
| stackexchange_codegolf |
Integers are tedious to represent in Brain-Flak. There are 8 operators:
() Evaluates to 1, but does not push anything on any stack
[] Evaluates to an indeterminate value for the purposes of this question
{} Removes the top of the stack and evaluates to it
<> Switches to or back from the alternate st... | stackexchange_codegolf |
An arithmetico-geometric sequence is the elementwise product of an arithmetic sequence and a geometric sequence. For example, 1 -4 12 -32 is the product of the arithmetic sequence 1 2 3 4 and the geometric sequence 1 -2 4 -8. The nth term of an integer arithmetico-geometric sequence can be expressed as
$$a_n = r^n \cdo... | stackexchange_codegolf |
RPS 25 is a version of Rock Paper Scissors which has 25 hand symbols instead of just 3. Each symbol defeats 12 symbols, and is defeated by 12 others.
Here's a link to a chart showing which symbols defeat which.
The challenge here is simple: your program should take in two strings representing the symbols thrown by each... | stackexchange_codegolf |
Rules/Objectives:
The program must be executed using ./program-name without shell parameter/arguments.
the program-name may not contain any of characters in /etc/passwd, that is acdepstw
You may not open any other file, including own's source code, only /etc/passwd that should be read.
The program must print the conte... | stackexchange_codegolf |
Given a string, replace all left-double-quotes into two backticks and all right-double-quotes into two single-quotes.
Left-quotes means the quotes that starts a quote. Right-quotes means the quotes that ends a quote. Quotes cannot be nested. You may assume that there are an even number of double-quotes in the string.
E... | stackexchange_codegolf |
Definition:
A number m is called a primitive root of a prime p the condition that the smallest integer k for which p dividies mk-1 is p-1
Your task
Given a tuple (a,b) of positive integers, return the fraction:
(number of primes p equal to or less than a which has b as a primitive root) divided by (number of primes ... | stackexchange_codegolf |
Introduction
I don't particularly know where the fizz buzz trend came from. It might just be a meme or something, but it is somewhat popular.
Challenge
Your job today is to convert Fizz Buzz into binary (0, 1) respectively, and convert that binary to text. Pretty standard stuff.
How does that work?
FizzBuzzBuzzFizzBuzz... | 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 |
Challenge
Write a full program/function to Demolish a given building at the rate 1 floor per second.
INPUT
Input is a building through STDIN(or whatever is called in your language) or through an ARGUMENT of a function.
t=0 s
|
|#|
{#}
|# #|
|# # #|
|# # #|
|# # #|
TTTTTTT
input consists of :
| marks sta... | stackexchange_codegolf |
In this challenge, your task is to create a program which takes in a nested array and returns a single-dimensional flattened array. For Example [10,20,[30,[40]],50] should output [10,20,30,40,50].
Input
The input will be a nested array (eg. [10,20,[[[10]]]]). It will contain only Integers (both negative and positive),... | stackexchange_codegolf |
My stovetop has 10 (0 through 9) different settings of heat and a very odd way of cycling through them.
It always starts at 0
When I hit plus it increments the number, unless the number is 9 in which case it becomes 0, or the number is 0 in which case it becomes 9.
When I hit minus it decrements the number, unless t... | stackexchange_codegolf |
TL;DR
Record (left-right)/length for each pair of consecutive elements. If they're 0 or negative, don't record it.
Once this is done, take these actions. Don't update quotients:
Increment right and decrement left for (0, .3)
Remove from the array at >=.3
Print both elements for >.5
Print the remaining array. Have s... | stackexchange_codegolf |
SmileBASIC deserves more attention. I've only seen 3 users here (including myself!) providing SB answers, and while that doesn't surprise me, it disappoints me. It being a paid lang as well as being a BASIC dialect certainly turns people off, but for those who own it it's actually pretty flexible and, surprisingly, gol... | stackexchange_codegolf |
Given a number N, the challenge is to get the sum of the pyramid of N primes. To clarify things, here is an example:
Input: 4
We will list the first 4 primes, and then compute the sum of them. After that, we will compute the sums of the sums, and so on:
2
> 5
3 > 13
> 8 > 33
5 > 20
> 12
... | stackexchange_codegolf |
Write the shortest program or function that will determine if an input is a valid Go type.
Spec
This challenge will use the following simplified subset of Go types. For more information, see the Golang specification.
"Primitive" types:
bool
int,uint,float(32|64),complex(64|128),byte,rune
string
*T where T is any ty... | stackexchange_codegolf |
Introduciton
Some of you might have realised that I am a sloppy typer when using my phone. That's why I want you to write a program which corrects my typos.
Chalkrnge
Given a misspelled word, output all of the possible words which I meant to write.
Typso
The main cause of my typos is down to the fact that I hit the wro... | stackexchange_codegolf |
In the hovertext of this xkcd:
There's an "encoding" based on replacing runs of roman numerals with their sums. To do this:
Find all runs of at least 1 roman numeral (IVXLCDM)
Replace them with their sums, as numbers
The Roman Numerals are IVXLCDM, corresponding respectively to 1, 5, 10, 50, 100, 500, 1000. You shou... | stackexchange_codegolf |
A piggy bank is a container used to collect coins in. For this challenge use the four US coins: quarter, dime, nickel, and penny.
Challenge
Your challenge is to create an electronic piggy bank. Write a program (or function) that when run (or called), outputs (or returns) the count of each coin you have, as well as the ... | stackexchange_codegolf |
Challenge
Given two question IDs, try to figure out how similar they are by looking at the answers.
Details
You will be given two question IDs for codegolf.stackexchange.com; you may assume that there exist questions for both IDs that are not deleted, but are not necessarily open. You must run through all of the answer... | 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 |
This is a cops-and-robbers challenge based around defining languages and proving they are Turing complete.
This is the cops' thread. The robbers' thread is here.
Cops
As a cop, you will prepare two things:
A formal specification of a programming language, or other computational system. (Computational systems are defin... | stackexchange_codegolf |
Rules
The program should receive a string/array of words as input. For each word in the string/array, it will reconstruct the word by taking characters in alternating fashion from the front and back of the word.
12345 678 9 -> 15243 687 9.
It will then rearrange the words in an alternating fashion between the earliest ... | stackexchange_codegolf |
The challenge:
Given four coordinates, each in x y form, your job is to find out whether or not the given coordinates form a rectangle, and output a truthy/falsey.
Rules:
For the sake of simplicity, squares, lines (two identical pairs of coordinates) or dots (all four of the coordinates are the same) are all counted a... | stackexchange_codegolf |
There is a rather curious number which shows up sometimes in math problems or riddles. The pseudofactorial(N) is the least (i.e. lowest) common multiple of the numbers 1 through N; in other words, it's the lowest number which has all numbers from 1 through N as factors.
For instance pseudofactorial(7) = 3 * 4 * 5 * 7, ... | stackexchange_codegolf |
Your program should take an array as input.
The array:
Will always be 1 dimensional
Will only contain integers
Can be empty
The program should reverse the array, and then add up the elements to the original for example:
Input: [1, 2, 3]
Original: [1, 2, 3]
Reversed: [3, 2, 1]
[1, 2, 3]
+ + +
[3, 2, 1]
[1+3, 2+2,... | stackexchange_codegolf |
Note that this challenge requires no handling or understanding of complex numbers.
Given a non-empty square matrix where every element is a two-element (Re,Im) integer list, determine (giving any truthy/falsy values or any two consistent values) whether this represents a Hermitian matrix.
Note that the input is a 3D ar... | stackexchange_codegolf |
My little kid has a toy like this:
This toy consists of 10 stackable little buckets, that we are going to number from 1 (the smallest one) to 10 (the biggest one). Sometimes he makes small piles and the toy ends up like this:
We can represent schematically the piles like this:
1 6
4 9 2 7
5 10 3 8
-------... | 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 |
The random Fibonacci sequence is defined as follows:
$$
f_n =
\begin{cases}
f_{n-1}+f_{n-2} \text{ with probability } 1/2 \\
f_{n-1}-f_{n-2} \text{ with probability } 1/2 \\
\end{cases}
$$
$$
f_1 = f_2 = 1
$$
i.e. whether the next term is the sum or difference of the previous two is chosen at random, independently of ... | stackexchange_codegolf |
Let's have string multiplication to take a string and a positive number and concatenate that string that many times. In Haskell:
0 * s = ""
n * s = s ++ ((n - 1) * s)
Your task is to write a program that outputs a number \$n > 0\$. When you double your program (with the described procedure) the new program should ou... | stackexchange_codegolf |
Background
Two numbers, \$a\$ and \$b\$, are said to be connected by a Brussels choice operation* if \$b\$ can be reached from \$a\$ by doubling or halving (if even) a substring (the substring must not be empty and may not contain any leading 0s but it can be 0) in the base-10 representation of \$a\$
*This operation is... | 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 |
Take a list of 2-digit hexadecimal numbers as input, and output the binary value, replacing each 1 with an 'X', and each 0 with a space.
For example
Input = FF, 81, 47, 99.
FF = 11111111 in binary, so print XXXXXXXX
81 = 10000001 in binary, so print X X
47 = 01000111 in binary, so print X XXX
99 = 10011001 in ... | stackexchange_codegolf |
I don't know if something like this exists already (and I'm not finding the right key words) but if not, it felt like it could be an interesting coding puzzle.
The challenge is, to take an arbitrarily nested list (no more than 2 deep), and display the content in a terminal in 2 dimensions in a 'pretty' manner. Each 'to... | stackexchange_codegolf |
This challenge is based on, and contains test cases from, a programming course I took at Aalto University. The material is used with permission.
Two and a half years ago there was a challenge about spoonerisms in English. However, in Finnish spoonerisms are much more complicated.
Spoonerisms in Finnish
In Finnish, the ... | stackexchange_codegolf |
In this code golf, you will have to determine the direction of the shortest shot that hits exactly n cushions before falling into a pocket.
The billiard table is a 6 pocket pool table with the following characteristics:
Dimensions are variable (a x b)
No friction : the ball will roll forever until it falls into a pock... | stackexchange_codegolf |
Related
You are a manager at a large number factory. You want to show everyone your business is doing well, by showing randomly chosen samples. Unfortunately, your business is not doing that well. But luckily, you have a bit of ingenuity...
Write a program or function that when given an array of unique, positive numbe... | stackexchange_codegolf |
Introduction
You're making a robot that can navigate a set of books of varying heights. It can climb books and jump off books, but if the distance is too big it will stop to prevent damage. To figure out the ideal design, you're writing a simulator.
Your program will take as input a list of numbers, representing the he... | stackexchange_codegolf |
The challenge
Given a list of words ["Programming", "Puzzles", "Code", "Golf"] output the words crossword-style:
P r o g r a m m i n g
u
z
z
G l
C o d e
l s
f
The Algorithm
You have to process the list in the given order.
The words are printed in alternating orientations, starting h... | stackexchange_codegolf |
Introduction
Each Unicode codepoint can be represented as a sequence of up to 4 bytes. Because of this, it is possible to interpret some 2, 3, or 4-byte characters as multiple 1-byte characters. (See here for a UTF-8 to bytes converter).
Challenge
Given a UTF-8 character, output it split into a sequence of 1-byte chara... | stackexchange_codegolf |
The program should start out with 2 separate files, here named "a" and "b". "a" and "b" should be what I am calling inverse quines: "a", when run, should output "b"'s source code, and "b", when run, should output "a"'s source code, for example:
./a
#source code of b, optionally followed by newlines
./b
#source code of ... | stackexchange_codegolf |
Challenge
Given a string, make it into a triangle as shown below:
Input
Hello, world!
Output
H
He
Hel
Hell
Hello
Hello,
Hello,
Hello, w
Hello, wo
Hello, wor
Hello, worl
Hello, world
Hello, world!
The first line contains the first character of the string. The following lines contain one more character on each line, u... | stackexchange_codegolf |
In the English language, a surefire way to make a pronounceable nonsense letter combination is to make it entirely out of consonant-vowel pairs, e.g., Wu ko pa ha, or, Me fa ro, consonant first, followed by vowel.
Challenge:
Write a program or function that will, given a user-specified number of letters, create a rando... | stackexchange_codegolf |
Earlier, we did the pseudofactorial of a number, which is the LCM of the numbers from 1 to n.
It would be useful in adding fractions together.
However, we find that the denominator of 1/1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6 is 20 instead of the pseudofactorial of 6, which is 60.
Your task is to find the denominator of 1/1 + ... | stackexchange_codegolf |
In this variant of the Four fours puzzle your should use up to x x's (and no other number) and a defined set of operations to reach every number from 0 to 100. If x = 4 then you can use up to four 4s and this question becomes the classic four fours puzzle (except you can use up to four 4s rather than having to use exac... | stackexchange_codegolf |
A hill number is a number that has the same digit in the first & the last, but that's not all. In a hill number the first digits are strictly increasing until the largest digit, and after the largest digit, the last digits are strictly decreasing. The largest digit can be repeated but consecutively only, meaning no gap... | stackexchange_codegolf |
Today computers use millions of bytes of memory, and decimal or hexadecimal notations get less and less informative.
Most human-readable formatting just display the number with the highest unit prefix. What about the rest?
I devised a notation that I use for myself, and since then, I'm often faced with re-implementing ... | stackexchange_codegolf |
Task
Given a positive integer return the geologic era and period it was that many million years ago.
Input/output
The input is a string or integer; the output is a string. Eras and periods are separated by slashes (/). Input will always be between 0 and 542 inclusive
Data
The possible outputs for eras and periods and t... | stackexchange_codegolf |
Introduction (may be ignored)
Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive numbers. This is the fourth challenge in this series (links to the first, second and third challenge).
In this ... | stackexchange_codegolf |
Challenge
Take an input string \$s\$, and split it into words \$w_1, w_2, ..., w_n\$. If the amount of words is odd, then return \$s\$. Otherwise, for each word: Take the second last letter, and swap it with the first letter keeping capitalization positions. So GolF becomes LogF.
Now check if the amount of words is a m... | stackexchange_codegolf |
Alex is a Truck Driver who wants to find the quickest way to deliver goods to multiple cities. He knows the distances between his destinations, but you need to write a program to help him find the quickest way to deliver goods to them.
Input
The first line of input gives the number of cities Alex needs to deliver goods... | stackexchange_codegolf |
The Challenge
Given a string indicating the symbolic notation of UNIX permission of a file and its ownership (user ID and group ID), decide whether a given user A has permission to read / write / execute it.
Related.
Permissions in UNIX system
In UNIX, every file has three classes of permissions (user, group and others... | stackexchange_codegolf |
Introduction
This is how a chessboard looks like.
You can see that a1 is a dark square. However, b1 is a light square.
The Task
The challenge is, given dark, light or both, output all the dark, light or all squares with a separator (like a whitespace or a newline). The order of all the squares does not matter.
Test ca... | stackexchange_codegolf |
Suppose I have a linear inequality like
x0A0 + x1A1 + ... + xnAn <= C
with xi a non-zero positive integer and Ai and C a positive non-zero multiple of 0.01. Find all the positive integer n-tuples {x1,...,xn} such that:
D <= x0A0 + x1A1 + ... + xnAn <= C
where D is also a positive non-zero multiple of 0.01.
Challen... | stackexchange_codegolf |
The task is simple: given a 32 bit integer, convert it to its floating point value as defined by the IEEE 754 (32-bit) standard.
To put it another way, interpret the integer as the bit-pattern of an IEEE binary32 single-precision float and output the numeric value it represents.
IEEE 754 single precision
Here is a conv... | stackexchange_codegolf |
In this challenge you have to make an ascii pulsing heart with rhythm problems (Heart arrhythmia) and then measure the pulse.Don't worry it's easy!
Making the heart
The heart alternates between these 2 states:
state 1
,d88b.d88b,
88888888888
`Y8888888Y'
`Y888Y'
`Y'
state 2
d8b d8b
... | stackexchange_codegolf |
Thanks to @KritixiLithos for helping me out with this challenge!
V is a programming language that I wrote so that I could use and extend vim for code-golf challenges. The very first commit was on March 3rd, 2016, meaning that today V turns one year old! Woo-hoo
Over V's first year of existence, there have been 176 com... | stackexchange_codegolf |
Introduction
I don't see many regex challenges on here, so I would like to offer up this deceptively simple one which can be done in a number of ways using a number of regex flavours. I hope it provides regex enthusiasts with a bit of fun golfing time.
Challenge
The challenge is to match what I've very loosely dubbed a... | stackexchange_codegolf |
If you're sad, that's wrong. We need to scrub out ALL sadness.
This is a sad face, for reference:
......
.S..S.
........
...SS...
..SS..SS..
.S......S.
........
Where S is a consistent pixel, . is any pixel other than S, and is any pixel. Note that the sad face is not a perfect square, only the . shoul... | stackexchange_codegolf |
We are used to the term "squaring" n to mean calculating n2. We are also used to the term "cubing" n to mean n3. That being said, why couldn't we also triangle a number?
How to triangle a number?
First off, let's pick a number, 53716.
Position it in a parallelogram, whose side length equals the number of digits of the... | stackexchange_codegolf |
Your task is to decompose a number using the format below.
This is similar to base conversion, except that instead of listing the digits in the base, you list the values, such that the list adds up to the input.
If the given base is \$n\$, then each number in the list must be in the form of \$k\times n^m\$, where \$0\l... | stackexchange_codegolf |
\$\left\{ n \atop k \right\}\$ or \$S(n, k)\$ is a way of referring to the Stirling numbers of the second kind, the number of ways to partition a set of \$n\$ items into \$k\$ non-empty subsets. For example, to partition \$\{1,2,3,4\}\$ into \$2\$ non-empty subsets, we have
$$\begin{matrix}
\{\{1\},\{2,3,4\}\} & \{\{2\... | stackexchange_codegolf |
Motivated by this challenge
Background
Let we have a square sheet of flexible material.
Roughly speaking, we may close it on itself four ways:
Here the color marks the edges that connect and the vectors indicate the direction.
The sphere and torus are obtained without flipping the sides, Klein bottle — with one flippi... | stackexchange_codegolf |
F# solutions known inside 140 chars, and this is a Rosetta Code problem.
Required result on stdout or in a string variable for input year 2014:
2014-01-26 2014-02-23 2014-03-30 2014-04-27 2014-05-25 2014-06-29 2014-07-27 2014-08-31 2014-09-28 2014-10-26 2014-11-30 2014-12-28
As it was requested, for 1900:
1900-01-28 ... | stackexchange_codegolf |
Introduction:
In Dutch, the words leading and suffering, being 'leiden' and 'lijden' respectively, are pronounced the same way. One is written with a "short ei", and one with a "long ij", as we Dutchman would say, but both 'ei' and 'ij' are pronounced [ɛi].
Challenge:
Given a list of numbers, determine which (if any) a... | stackexchange_codegolf |
The Challenge
The goal of this challenge is to determine whether a given String can be typed using only one line of a standard UK QWERTY keyboard.
This is code golf, so shortest solution in bytes wins!
IO
Input will be a single String of zero or more characters in the ASCII decimal range of 32-126 inclusive.
You may ... | stackexchange_codegolf |
Input: A valid 6 HEX digit color code wihout a # prefix
Valid:
000000
FF00FF
ABC123
Your job is to find to which one of these:
Red: FF0000
Green: 00FF00
Blue: 0000FF
White: FFFFFF
Black: 000000
the input color is the closest too, in this case you try to only match it to black or white when the RGB is the same v... | stackexchange_codegolf |
A numerical polynomial is a polynomial \$p\$ in one variable with rational coefficients such that for every integer \$i\$, \$p(i)\$ is also an integer. The numerical polynomials have a basis given by the binomial coefficients:
$$p_n = {x \choose n} = \frac{x(x-1)\cdots(x-n+1)}{n!}$$
For instance:
\$p_0 = 1\$
\$p_1 = x\... | stackexchange_codegolf |
Your Task: Print "Hello, World!" using a palindrome.
Simple, right?
Nope.
You have one restriction: you may not use comments.
"Comments" include
Normal // or # comments
Adding extraneous characters to a string literal
Triple-quoted string comments
Creating a string literal to hide characters
You may not use a pre-de... | stackexchange_codegolf |
Challenge
In this challenge you will construct trees, in the form of ASCII Art using recursion. Basically you will generate the ASCII version of the Fractal Tree
Input
Number of iterations 0 < N <= 5
Output
The Nth iteration of the Fractal Tree. It must be a matrix of 63 rows and 100 columns. (i.e. 6300 printable ch... | stackexchange_codegolf |
Given a key, and an array of strings, shuffle the array so that it is sorted when each element is XOR'd with the key.
XOR'ing two strings
To XOR a string by a key, XOR each of the character values of the string by its pair in the key, assuming that the key repeats forever. For example, abcde^123 looks like:
a ... | stackexchange_codegolf |
Display the 12 numbers on a clock face exactly like this:
12
11 1
10 2
9 3
8 4
7 5
6
To better see the grid, here's one with dots:
...........12............
.... | stackexchange_codegolf |
Introduction
Everyone's first program outputs Hello World!. This program should be very simple, that's all you have to do.
Challenge
Output the string Hello World! to the STDERR.
Rules
If your language doesn't support STDERR or STDERR doesn't exist for it, you can output it to it's corresponding error system.
You can'... | stackexchange_codegolf |
A digit addition generator of an integer n is any integer x that satisfy the equation x + s(x) = n, with s(x) being the sum of the digits of x. (We will work under base 10 for convenience.)
For example, a digit addition generator for 29 would be 19, because 19 + (1 + 9) = 29. Some numbers have more than one generator. ... | stackexchange_codegolf |
Given two strings of letters, transfer the capitalization pattern of each string onto the other one. Fewest bytes wins.
Input: CodeGolf xxPPCGxx
Output: coDEGOlf XxppCgxx
Both strings will be equal-length and nonempty, with only letters a..z and A..Z.
You may output the two resulting strings in either order rel... | stackexchange_codegolf |
Your task is to output all possible ways to end a game with a tie (all rows, columns, and diagonals are completely filled and do not have 3 X's or 3 O's, and there are exactly 5 X's and 4 O's in total) in Tic-Tac-Toe (assuming X goes first):
OXO XXO XOX OXX
XOX OOX XOX XOO
XOX XXO OXO OXX
XOX XOX OXX XXO
O... | stackexchange_codegolf |
Given an array of letters in the range 'a' to 'o', compute how to construct the array by successively inserting the letters in alphabetical order. You will always start the insertion with a base array of all the 'o's that are in the array to be reconstructed.
Examples
Let the input array be:
['o', 'b', 'o', 'b', 'a']
... | stackexchange_codegolf |
You probably know the game mastermind:
The player tries to guess a code of 4 slots, with 8 possible colors - no duplicates this time.
Let's call those colors A through H, so possible solutions could be ABCD or BCHD.
Each time you place a guess, the game master will respond with two information: how many slots you got r... | stackexchange_codegolf |
Background
The monkeys need your help again organizing their defense and have asked you, Benjamin the code monkey, to create a program that will list all tower upgrade options as they appear in your insta-monkey collection. Each tower has three unique upgrade "paths", called "top", "middle", and "bottom", each having a... | stackexchange_codegolf |
In: Enough memory and a positive integer N
Out: N-dimensional N^N array filled with N, where N^N means N terms of N-by-N-by-N-by...
Examples:
1: [1] which is a 1D array (a list) of length 1, containing a single 1
2: [[2,2],[2,2]] which is a 2D array (a table) with 2 rows and 2 columns, filled with 2s
3: [[[3,3,3],[3,3,... | stackexchange_codegolf |
Underload is a stack-based semi-functional tarpit created by ais523. I've recently been trying to golf in it, as it's a surprisingly elegant language.
What tips do you have for golfing in Underload? (One tip per answer)
| stackexchange_codegolf |
Given a polynomial in one variable with rational coefficients, output an equivalent expression containing only 1, variables, and definite integrals. For example, -x2 can be expressed as ∫x∫111dtxdu.
E := 1 | var | ∫EEEdvar
Any reasonable input/output method is allowed.
Examples:
Your score will be the your code length... | stackexchange_codegolf |
You know it: keyboard or mouse input is just too mainstream to create Random Numbers through human behavior.
Create the most unique (Pseudo)Random Number Generator that create its numbers through human behavior.
Web-API's are not restricted! Anyone should use the code provided, so any special hardware is restricted. (I... | stackexchange_codegolf |
Consider a positive integer N written in base b. A sequence is generated from this number by finding the largest digit d in the expansion of N and writing N in base d+1, repeating until the base the number is written in can be decreased no further. For example, the sequence generated by 346 (10) in starting base 16 has... | stackexchange_codegolf |
Challenge
You must write a program which takes a string and a flag as input and performs one of the following functions.
Input
If your language does not support command line arguments, you may take the arguments as input via STDIN.
The flag will be two characters: a dash and an ASCII character such as -d or -c.
Functio... | stackexchange_codegolf |
Write a program that precisely clones GNU cat version 8.32, which is
installed on my computer.
In any case, if called with the same arguments, same stdin, and same files,
your program's output to both stdout and stderr must by byte-for-byte identical
to that of GNU cat, and the exit code must be the same. This applies ... | stackexchange_codegolf |
A ragged list is a (finite depth) list where each element is either a positive integer or a ragged list.
A ragged list is properly tiered if it contains either all positive integers or all properly tiered ragged lists.
For example [1,2,3,6] is properly tiered because it is a list of only positive integers. [[1,2],[[1]... | stackexchange_codegolf |
The task is to compute the divisor sum of a number given its prime factorisation.
Input
Two arrays (or something equivalent) of length n, one containing the prime factor and the other containing the corresponding exponent.
Output
The sum of all divisors (including the number itself).
Example
The number 240 has 2, 3, an... | stackexchange_codegolf |
Background
In the game stick ranger, there is an item which grants the character the ability to get critical hits.
Each time a projectile hits an enemy, it has some probability to be a critical hit (crit). For most weapons this is calculated independently each time, but for one class (the angel) things work differently... | stackexchange_codegolf |
This is a quine challenge related to Write the shortest self-identifying program (a quine variant)
Write a function or a full program that compares lexicographically its source code and input, that is, output three distinct values of your choice telling if input / source code is Bigger, Equal or Less than source code /... | stackexchange_codegolf |
RLE Brainfuck
(related to BF-RLE)
The hypothetical RLE (Run-Length Encoding) dialect of Brainfuck accepts the symbols for the 8 commands and also accepts digits. The digits are used to represent the number of successive repetitions of a command, thus allowing run-length encoding of the source code.
8> is equal to >>>>>... | stackexchange_codegolf |
In this challenge, you are given a limited amount of information about a particular game of chess, and you need to predict who won the game.
You are given two sets of data:
Piece counts (What pieces are still alive)
Board colors (The color of pieces on the board)
More importantly, you don't know where the pieces are ... | stackexchange_codegolf |
Your task is to decompose a number using the format below.
This is similar to base conversion, except that instead of listing the digits in the base, you list the values, such that the list adds up to the input.
If the given base is \$n\$, then each number in the list must be in the form of \$k\times n^m\$, where \$0\l... | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.