instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Recently a friend of mine posed the following:
What subset of the integers satisfies the condition if distinct a and b are in the subset, their average is not in the subset? I know the set of non-0 squares satisfies the condition, but I wonder if there exists a more... dense set that satisfies the condition.
(It turn... | stackexchange_codegolf |
Specification
This challenge is simple to state: your input is a non-empty array of nonnegative integers, and your task is to partition it into as few substrings as possible, such that each substring is a permutation of a consecutive integer range.
More formally, if the input array is A, then the output is minimum numb... | stackexchange_codegolf |
The Post's Correspondence Problem (PCP) gives you a list of pairs of strings, P_1 ... P_n. Your task is to find a k, and some sequence of k indices such that fst(P_i1) ... fst(P_ik) = snd(P_i1) ... snd(P_ik)
We're trying to find some sequence of the pairs where the word we build from the first part is equal to the word... | stackexchange_codegolf |
Challenge
Given a rectangular area arrange a group of rectangles such that they cover the rectangular area entirely.
Input
An integer denoting the height.
An integer denoting the width.
The dimensions of the rectangles consisting
of the following form: axb,cxd,... where a,b,c, and d are integers - any reasonable for... | stackexchange_codegolf |
The challenge is actually extremely simple. Pick 5 distinct letters (you can just pick the 5 that allow you the shortest code if you like) and output them to the console. However, the twist is that they must be from the following list:
AAA BBBB CCCC DDDD EEEEE FFFFF GGG H H
A A ... | stackexchange_codegolf |
note: the string art might look horrible here because of SE font weirdness :P :(
Given a list of four-tuples representing the corners of rectangles, draw translucent rectangles over each other in that order.
For this challenge, you are required to have the smallest coordinate in the top-left corner and the x-axis incre... | stackexchange_codegolf |
Given a string \$ x \$, we say another string \$ y \$ is half of it, if both of the following properties are true:
\$ y \$ is a (not necessarily continuous) subsequence of \$ x \$ - there exists a strictly increasing sequence \$ a_i \$ such that \$ y_i = x_{a_i} \$
Each character appears in \$ x \$ exactly twice as ma... | stackexchange_codegolf |
(based on this deleted question)
Take the English alphabet a b c d e f g h i j k l m n o p q r s t u v w x y z (spaces added for clarity), and split it into chunks of X width, padding any leftover lines with spaces if necessary for your language. For example, splitting it into width 4 results in
a b c d
e f g h
i j k l... | stackexchange_codegolf |
We already have challenges dealing with simulating vanilla Conway's Game of Life, Wireworld and rule 110, but so far none corresponding to a (specific) non-totalistic rule. So here is one.
In June 2000 David Bell described the Just Friends rule, which uses the same square grid and two states as regular Life but has the... | stackexchange_codegolf |
Write a program that outputs a list of the number of occurrences of each unique character in its source code.
For example, this hypothetical program {Source_Print_1}; should produce this output:
; 1
P 1
S 1
_ 2
c 1
e 1
i 1
n 1
o 1
p 1
r 2
t 1
u 1
{ 1
} 1
The formatting should match this example. No extraneous whitespa... | stackexchange_codegolf |
Challenge:
Your challenge (should you choose to accept it) is to compress and decompress the 5MB "Complete Works of William Shakespeare" as found here:
http://www.gutenberg.org/cache/epub/100/pg100.txt
(MD5: a810f89e9f8e213aebd06b9f8c5157d8)
Rules:
You must take input via STDIN and output via STDOUT...
...and you must... | stackexchange_codegolf |
I'm not sure if this kind of golf is allowed, but here it is.
Your objective is to create an image containing one pixel of every possible RGB color. The image with the smallest file size wins.
Rules:
The image must be a PNG.
The image must contain exactly one of every possible RGB color.
Acceptable image dimensions ar... | stackexchange_codegolf |
Task:
Input will consist of some text, with nested [] separating some of it into nested groups:
abc[d[fgijk]nopq]rst[u[v[[w]]]xy[[[z]]]]
Your task is to remove all brackets, and everything wrapped in an odd number of brackets. For example, a[b]c would remove the [], and the b inside of it. a[[b]]c, however, would only... | stackexchange_codegolf |
The sequence A109648 starts with the following numbers
53, 51, 44, 32, 53, 49, 44, 32, 52, 52, 44, 32,
51, 50, 44, 32, 53, 51, 44, 32, 52, 57, 44, 32,
52, 52, 44, 32, 51, 50, 44, 32, 53, 50, 44, 32,
53, 50, 44, 32, 52, 52, 44, 32, 51, 50, 44, 32,
53, 49, 44, 32, 53, 48, 44, 32, 52, 52, 44, 32,
51, 50, 44, 32, 53, 51, 4... | stackexchange_codegolf |
Recently I read the novel "The Solitude of Prime Numbers" where the main characters are somewhat compared to twin prime numbers ("always together, but never touching").
A twin prime is a prime number that is either \$\require{cancel}2\$ less or \$2\$ more than another prime number —for example, the twin prime pair \$(... | stackexchange_codegolf |
An alternating permutation is a permutation of the first \$ n \$ integers \$ \{ 1 ... n \} \$, such that adjacent pairs of values in the permutation alternate between increasing and decreasing (or vice versa).
Equivalently, it is a permutation where there are no "runs" of continuously increasing or decreasing values wi... | 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 |
I have a set of colored plastic cups. They come in four colors: green, yellow, pink, and blue. When I put them on my shelf, I like to stack them in a certain pattern. Your job is, given a list of any number of four distinct values (to represent the four cup colors), output a visual representation of how I would stack t... | stackexchange_codegolf |
Given the output of the cop's program (o), the byte-count (n) and the number of unique bytes (c) used, come up with a corresponding piece of code that is n bytes long with c unique bytes which matches the cop's output o.
This is the cops thread. Post solutions that are to-be-cracked here.
The robbers thread is located... | stackexchange_codegolf |
Whilst trying (and failing) have persuade my infant son to eat his dinner, I tried singing to him. Mid way through this song I realised the formulaic structure might lend itself well to code golfing!
The task is to write a program or function which accepts no input and produces the following text:
There's a hole in the... | stackexchange_codegolf |
There's a lot of questions about Conway's Game of Life, but nothing about customization (Related: 2-Player Life). Given an input, determine the result on a 100x100 grid after some iterations. The input is given as a string. For example:
Using the character #, follow the following rules:
If there are 2 or 3 neighboring ... | stackexchange_codegolf |
Create a program (any language) which, given positive integer m, outputs a valid C expression that:
Uses a single variable x assumed of 32-bit unsigned type (i.e. uint32_t)
Would evaluate to range [0, m) for any of the 2³² possible x, reaching any of the m possible outcomes either 2³² / m or 2³² / m + 1 times (where /... | stackexchange_codegolf |
Implement a function or program that can run simplified BitCycle code. The functions you must implement are:
<^>v: Change the direction of a bit to the direction this is pointing.
+: Turn all 0s left and all 1s right.
\ and /: Reflect one bit 90 degrees, then become inactive. In regular BitCycle, this is displayed as -... | stackexchange_codegolf |
I know there have been a lot of challenges about "the two best code-golfers in the world", but this one is a bit more unique, being Round 1 in a series of (future) challenges involving the two of them.
Your task is to write a program or function that returns two different non-whitespace ASCII strings, corresponding to... | stackexchange_codegolf |
Let's see how good your language of choice is at selective randomness.
Given 4 characters, A, B, C, and D, or a string of 4 characters ABCD as input, output one of the characters with the following probabilities:
A should have a 1/8 (12.5%) chance to be chosen
B should have a 3/8 (37.5%) chance to be chosen
C should h... | stackexchange_codegolf |
Task
Given an \$m\times n\$ binary ascii "photo", return the negative of the photo
Example:
#
# #
# #
# #
#
->
## ##
# # #
###
# # #
## ##
General rules:
This is code-golf, so the shortest answer in bytes wins
Standard rules and default I/O rules apply
Your output characters must be the same as your in... | stackexchange_codegolf |
*What is a transmogrifier?
In the C programming language, there are formations called digraphs and trigraphs that are two and three characters sequences that evaluate to less common characters. For example, you can use ??- if your keyboard doesn't have ~.
Given text, replace all instances of the following digraphs and ... | stackexchange_codegolf |
Given two nonnegative integers n,k such that 0 <= k <= n, return the binomial coefficient
c(n,k) := (n!) / (k! * (n-k)!)
Test cases
Most languages will probably have a built in function.
c(n,0) = c(n,n) = 1 for all n
c(n,1) = c(n,n-1) = n for all n
c(5,3) = 10
c(13,5) = 1287
Related challenges
Catalan Numbers Compu... | stackexchange_codegolf |
Given an array of positive integers in base 10, where n > 0, output their representation of a binary wall.
How does this work?
Convert each number to its binary representation.
Pad the representation with leading zeroes to the length of the longest one i.e. 1, 2 -> 1, 10 -> 01, 10.
Create a wall where the 1s are brick... | stackexchange_codegolf |
The variable star designation is an identifier for a variable star (a star that fluctuates in brightness). It consists of either a 1-2 letter code or (when the letter code is no longer sufficient) a 'V' followed by a number. This code is followed by the genitive of the star constellation the star is found in (eg. "RR C... | stackexchange_codegolf |
OEIS A090461 details the ‘numbers k for which there exists a permutation of the numbers 1 to k such that the sum of adjacent numbers is a square’. This has also been the subject of Matt Parker’s Numberphile and Alex Bellos’ Monday puzzle.
This code-golf challenge is related to the square sum problem above and asks you ... | stackexchange_codegolf |
Challenge:
Given a list of non-negative integers, determine by how much you should increase each item to create the closest binary box with the resulting integer-list.
What is a binary box?
A binary box is where the first and last rows consists of 1-bits; the first and last columns consist of 1-bits; and everything els... | stackexchange_codegolf |
What general tips do you have for golfing in Uiua?
I'm looking for ideas that can be applied to code golf problems in general that are specific to Uiua. (e.g. "remove comments" would not be an answer.)
Please post one tip per answer.
| stackexchange_codegolf |
Take the string abcdfghjk. To overwrite it, starting from f, with the string wxyz, you would continue along the original, replacing each character with the one from the replacement string. The result would be abcdwxyzk.
Now, consider a string which would be too long to fit, like lmnopqrs. Starting at f you would get ab... | stackexchange_codegolf |
Input:
Any Brainfuck program. This includes brainfuck programs with comments such as +++COMMENT[>+++<-]..
Output:
A program in one of the below languages that produces the same output as the Brainfuck program on all inputs. It should produce the same output exactly as the interepreter on this website There are no code-... | stackexchange_codegolf |
Given two different positions on a chess board and the type of piece, output the minimum number of moves it will take for that piece to go from one position to another.
Rules
The given piece can be King,Queen,Rook,Knight and Bishop. (This input can be taken as any 5 unique characters)
The 2 positions can be taken in an... | stackexchange_codegolf |
Given an expression matching the regex /^[-~]*x$/, evaluate it in terms of x and output a string matching the regex /^-?x[+-]\d+$/.
For example, the string -~x evaluates to x+1, while the string -~-x evaluates to -x+1, and the string -~-~--x evaluates to x+2.
We start from x and evaluate the string right to left. - neg... | stackexchange_codegolf |
Given an array where each number represent a color. After iterating each item in the array (for each item in the iteration the pointer can also point to the second-item-to-the-right), and the two colors in the iteration is the same, do the following checking:
If there is a different color between the pointed colors, th... | stackexchange_codegolf |
The Challenge:
Print every 2 letter word acceptable in Scrabble using as few bytes as possible. I have created a text file list here. See also below. There are 101 words. No word starts with C or V. Creative, even if nonoptimal, solutions are encouraged.
AA
AB
AD
...
ZA
Rules:
The outputted words must be separated so... | stackexchange_codegolf |
Write a program that takes in an integer N via stdin or the command line.
If N is 0, the single letter O must be printed to stdout.
If N is positive, this horizontal ASCII art double helix, drawn N segments wide, must be printed.
If N is 1, the output is:
/\
O O
\/
If N is 2, the output is:
/\ /\
O / O
\/ \/
... | stackexchange_codegolf |
The Enigma machine is a fairly complex cipher machine used by the Germans and others to encrypt their messages. It is your job to implement this machine*.
Step 1, Rotation
Our enigma machine has 3 slots for rotors, and 5 available rotors for each of these slots. Each rotor has 26 different possible positions (from A t... | stackexchange_codegolf |
If \$R\$ runners were to run a race, in how many orders could they finish such that exactly \$T\$ runners tie?
Challenge
Given a positive integer \$R\$ and a non-negative integer \$0\leq T\leq {R}\$ produce the number of possible finishing orders of a race with \$R\$ runners of which \$T\$ tied.
Note, however, that run... | stackexchange_codegolf |
Your mission, should you choose to accept it, is to write code for a GPS receiver.
Input
The current time, as nanoseconds from the Unix epoch. [EDIT: This is optional, please state whether you require it]
Four satellite signals, in the following format:
The time the signal was sent, as nanoseconds from the Unix epoch... | stackexchange_codegolf |
Challenge
Your challenge is to design an interpreter for a lisp-like language, which will from hence forth be coined: GLisp. The program code for GLisp will consist of an arbitrary amount of nested expressions denoted by brackets, in the following form:
(func arg1 arg2 ...)
Note that the interpreter must allow for ext... | stackexchange_codegolf |
Related OEIS sequence: A008867
Truncated triangular number
A common property of triangular numbers is that they can be arranged in a triangle. For instance, take 21 and arrange into a triangle of os:
o
o o
o o o
o o o o
o o o o o
o o o o o o
Let's define a "truncation:" cutting triangles of the same s... | stackexchange_codegolf |
You are developing some code to generate ID numbers. Policy requires that no ID numbers include the digit sequence 666.
Create a function (or your language's equivalent) which takes a positive integer parameter and returns the next integer that does not include 666 when that integer is expressed in decimal. (60606 is f... | stackexchange_codegolf |
John Horton Conway was a brilliant mathematician. Among his contributions were three Turing-complete esolangs: Game of Life (esolangs wiki), FRACTRAN (esolangs wiki), and Collatz function (esolangs wiki).
Because we did an extremely amazing job around GoL, it is time for the challenge with the other two.
Background
A F... | stackexchange_codegolf |
Help! I just logged into Stack Exchange, but I forgot what my password is! I need a way to work it out before I log off.
Luckily, I'm an excellent hacker. Not only was I able to find my password's hash, but I also found Stack Exchange's hashing algorithm! It takes the ASCII value of each digit multiplied by that digit... | stackexchange_codegolf |
Oh no! Nemo, our small clown fish is lost in this ASCII ocean and his dad Marlin is trying to find him.
Your task is to get Marlin to Nemo safely. But beware, we have a feeding frenzy Bruce on the loose, so better avoid him at all costs!
Details
You are given a rectangular ASCII ocean grid containing only lowercase alp... | stackexchange_codegolf |
So I'd like you to attempt to generate Rorschach images like the below image:
Here is a link to further inspiration.
This is a popularity contest, but I will say that colours are likely to be more popular than black and white, as well as textures.
Rorschach images are created by folding paper with ink on so one criter... | stackexchange_codegolf |
Introduction
The challenge itself was something I came across and had to try and figure out for a personal of project of mine. I ended up branching out and asking family members if they could provide an equation to meet the requirements.
Note: I have (with the help of others) found a solution for this but now I'm just ... | stackexchange_codegolf |
Disclaimer
This question is not a duplicate of this question. I'm not counting specific digits, as we already have those set in the initial parameters. This question is focusing on the decimal numbers that can be constructed from the binary strings based on the digits provided.
Challenge
Given two integers X and Y, rep... | stackexchange_codegolf |
https://en.wikipedia.org/wiki/Connect_Four
Does anyone remember the 2 player game connect 4? For those who don't it was a 6x7 board that stands vertical on a surface. The goal of connect 4 is to, well connect 4! The connection is counted if it is horizontal, diagonal, or vertical. You place your pieces on the board by ... | stackexchange_codegolf |
Note: this is heavily inspired by this question.
Task:
Your task is to generate the nth prime, when each character of your program is repeated n times in place.
Let's say your program is:
Derp
Every character in there is repeated once, so it should output 2.
When every character is duplicated in place, like so:
DDeerr... | stackexchange_codegolf |
You probably all know the fibonacci sequence:
fibonacci(n)=fibonacci(n-1)+fibonacci(n-2)
fibonacci(0)=0
fibonacci(1)=1
Your task is as simple as it could be:
Given integer N compute fibonacci(n)
but here is the twist:
Also do negative N
Wait. What?
fibonacci(1)=fibonacci(0)+fibonacci(-1)
so
fibonacci(-1)=1
and
f... | stackexchange_codegolf |
Today's challenge is simple: Without taking any input, output any valid sudoku board.
In case you are unfamiliar with sudoku, Wikipedia describes what a valid board should look like:
The objective is to fill a 9×9 grid with digits so that each column, each row, and each of the nine 3×3 subgrids that compose the grid (... | stackexchange_codegolf |
In this question I will talk about programs as strings, this is strings of bytes, not characters. How your resultant program is rendered or displayed is not important to this challenge, only how it appears in memory matters.
A pristine program is a program \$S\$ that when run does not error, however it will error when... | stackexchange_codegolf |
Background
The number of values for a given type is called the cardinality of that type, and that of type T is written as |T|.
Haskell and a few other languages have a certain set of enum types, each of which has a small finite number of values (the exact names vary, so this challenge uses some arbitrarily chosen names... | stackexchange_codegolf |
Task
The task is to tile polygons, given a vertex configuration.
Scoring
Your score is equal to the "complexity level" your submission reaches. Complexity levels are cumulative, meaning that to reach #3 you must also support #1 & #2.
Submissions at an equal complexity level are distinguished by byte count; lowest wins... | stackexchange_codegolf |
I want an n*n table that is filled with black or white and the following conditions are satisfied in it:
All cells of a 2*2 square in this table should not be the same color.
All black and white cells must be connected horizontally or vertically.
Acceptable examples:
Can anyone design a function that takes n as inpu... | stackexchange_codegolf |
Consider the sequence 1/2, 1/3 + 1/2, 1/4 + 1/3 + 1/2, and so on. In mathematical symbols, this is
$$S(n)=\sum_{m=2}^{n+1}\frac{1}{m}$$
where S is the function that makes the sequence.
Outputting this sequence as a fraction would not be complicated. To add depth to the challenge, you must output as a repeating decimal.... | stackexchange_codegolf |
You should write 3 programs and/or functions in one language.
All of these programs should solve the same task but they all should give different (but valid) outputs. (I.e. for every pair of programs their should be some input which generates different (but valid) sets of output numbers.)
The task
You are given an int... | stackexchange_codegolf |
Objective
Given two Chinese ideographs meaning basic colors, output the ideograph that means the color resulting from mixing them.
Basic colors
The basic colors are:
靑(U+9751; blue)
赤(U+8D64; red)
黃(U+9EC3; yellow)
白(U+767D; white)
黑(U+9ED1; black)
Mixed colors
Mixing 靑(blue) and 赤(red) yields 靘(U+9758; purple).
Mix... | stackexchange_codegolf |
The famous game of Qwirkle has simple but intricate rules (See part 2 of this question for a summary of the rules!)
The Challenge
You are somehow (text input, function parameter, whatever) given a board of a Qwirkle game, like a snapshot from any current timeframe within a game. This board can be anything from complet... | stackexchange_codegolf |
The Collatz Conjecture
The famous Collatz Conjecture (which we will assume to be true for the challenge) defines a sequence for each natural number, and hypothesizes that every such sequence will ultimately reach 1. For a given starting number N, the following rules are repeatedly applied until the result is 1:
While N... | stackexchange_codegolf |
The Collatz Sequence (also called the 3x + 1 problem) is where you start with any positive integer, for this example we will use 10, and apply this set of steps to it:
if n is even:
Divide it by 2
if n is odd:
Multiply it by 3 and add 1
repeat until n = 1
10 is even, so we divide by 2 to get 5. 5 is odd, so we... | stackexchange_codegolf |
It is quite simple, any language, make output show the time in the HH:MM or HH:MM:SS while the numbers and the colons being ascii art(The output is ascii art not the program)
Sample output:
____________ ________ _____ .________ ________
/_ \_____ \ /\ \_____ \ / | | /\ | ____// _____/
| ... | stackexchange_codegolf |
Given a natural numbers n>1, find the smallest narcissistic number of n digit.
A narcissistic number is a number which is the sum of its own digits, each raised to the power of the number of digits.
For example, for n=3 (3 digits) the out put should be 153:
1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153
For n=4 (4 digits) the ou... | stackexchange_codegolf |
With this challenge we pay homage to everyone around the whole world fighting against the coronavirus crisis; particularly represented are the people tied to medicine, as the Rod of Asclepius is a symbol associated with medicine and health care.
For that matter, we resort to some ASCII art found at asciiart.eu (wrongfu... | stackexchange_codegolf |
Your task: write a program/function that when given a string containing only ASCII characters, outputs/returns the string in reverse-ish.
Example:
1) Input
Hello, World!
2) Number unique characters in input. (Input string separated by pipes (|) for readability)
H|e|l|l|o|,| |W|o|r|l|d|!
1 2 3 4 5 6 7 8 9 10
3) ... | stackexchange_codegolf |
Your task is, to count how many pluses I have.
What Pluses?
The no plus: 0 Points
-
The naïve Plus: 1 Point
+
The double Plus: 2 Points
+
+++
+
The mega double plus: 3 Points
+
+++
+
+ + +
+++++++++
+ + +
+
+++
+
Pluses of higher order than 3 must be ignored.
Rules
Input will ... | stackexchange_codegolf |
Challenge
The challenge is to write a function that prints the number of repeats a given array of integers has.
What are repeats?
Repeats of a slice (as in a section of an array) [ a1, a2, a3, ..., an] are any other non-overlapping slices of the forms [ a1+an, a2+an, a3+an, ..., an+an], [ a1+2an, a2+2an, a3+2an, ..., a... | stackexchange_codegolf |
Background
The metallic means, starting with the famous golden mean, are defined for every natural number (positive integer), and each one is an irrational constant (it has an infinite non-recurring decimal expansion).
For a natural number , the metallic mean is the root of a quadratic equation
The roots are always
... | stackexchange_codegolf |
From what I've seen throughout my time here on PPCG, most JavaScript entries involving fat arrow functions tend to be one of two camps:
The simple ones that are capable of running as a single statement and returning an answer, straight off the bat, like x=(a,b)=>a*a+b
The more complex ones that usually have curly brac... | stackexchange_codegolf |
Can you decrypt me?
Cops
Cops, post obfuscated code that hides a number \$n\$ (n must not be greater than the program length) inside its code. If \$n\$ chars are changed (no additions or deletions), the program outputs exactly one \$n\$ (any amount of whitespace before or after is allowed.) Otherwise, it outputs someth... | stackexchange_codegolf |
The Challenge
Write a complete program that writes twice as many bytes to standard output as the length of the program.
Rules
The program must write ASCII characters to the standard output.
The contents of the output doesn't matter.
The output, measured in bytes, must be exactly twice the length of the program, also ... | stackexchange_codegolf |
Logic gates are functions which perform basic logic operations. In this problem, we will account for the following 6 logic gates: AND, OR, XOR, NAND, NOR, and XNOR. Each of these takes two boolean inputs \$ a \$ and \$ b \$, and outputs a boolean. Below are the truth tables which show the output of each gate given two ... | stackexchange_codegolf |
Objective
Given a vertex figure consisting of regular convex polygons, determine whether it represents a convex uniform polyhedron.
What is a uniform polyhedron?
A uniform polyhedron is a polyhedron whose faces are regular polygons, while having the same vertex figure for each vertices. Generally a uniform polyhedron c... | stackexchange_codegolf |
My phone number (which I will not be sharing here) has a neat property where there is a two digit number, which when iteratively removed from my phone number will eventually remove all the digits. For example if my phone number were
abaababbab
Then by repeatedly removing ab we would eventually get nothing (I encluse ... | stackexchange_codegolf |
This challenge is not code golf. Please read the scoring before you attempt to submit an answer.
You will be given a multi-line string as input. You should output the size of the largest contiguous chunk of non-space characters. Contiguous just means that the chunk is a single piece rather than multiple disconnect... | stackexchange_codegolf |
Input: a sequence of uppercase letters (ASCII [65;90]) which is the Nth* lexicographical permutation of the multiset of its characters
*permutations are numbered from 0 or 1 upwards
Output: base-10 integer N
Rulez
There might be duplicates (that's how this challenge differs from
this one)
The characters are ordered b... | stackexchange_codegolf |
Taylor series are a very useful tool in calculating values of analytic functions that cannot be expressed in terms of elementary functions, using only information about that function at a single point.
In this challenge, you won't be actually doing any math with them, but merely making string representations of taylor ... | stackexchange_codegolf |
Introduction
Cacti come in various different sizes, shapes and colors. However, the most iconic cactus and must-have in every Western has to be the saguaro. Important features are its size and arms, which have defined the stereotypical cactus appearance.
Your task is to bring the saguaro in the ASCII world. However, ... | stackexchange_codegolf |
Some friends and I have played some DSA (a mainly german tabletop RPG much like D&D). I was wondering what the chance on passing rolls are, so you will have to write some code to calculate it.
Your character is defined by stats (from 8 to 14) and (TV) Talent values (0 to 21). For now we will use climbing as an example.... | stackexchange_codegolf |
Task
Given a positive integer number and a threshold, split into every possible way without generating any numbers above the threshold.
Examples
Input: 15008
Threshold: 400
Valid Output:
[[1, 5, 0, 0, 8], [15, 0, 0, 8] [1, 50, 0, 8], [150, 0, 8]]
Invalid outputs:
[[1, 5, 0, 0, 8], [15, 0, 0, 8], [150, 0, 8], [1, 500... | stackexchange_codegolf |
A port of my other question: Double Prime Words
Consider a word/string of n alphanumeric characters with sum of the characters, s, using their numeric position in the alphabet (a=1, B=2, c=3, etc.) or numeric value (0,1, 2, 3 - 9). Numeric characters should be taken at individual value. (66 is two 6 characters for a su... | stackexchange_codegolf |
We know that not all fractions have a terminating binary representation. However every fraction can be written as a leading portion followed by a repeating portion. For example \$1/3\$ starts with \$0.\$ and then just repeats \$01\$ endlessly. This corresponds to the bar notation taught in primary school. For examp... | stackexchange_codegolf |
A digit word is a word where, after possibly removing some letters, you are left with one of the single digits:
ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT or NINE (not ZERO).
For example, BOUNCE and ANNOUNCE are digit words, since they contain the digit one.
ENCODE is not a digit word, even though it contains an O,... | stackexchange_codegolf |
Pascal's triangle is a triangular diagram where the values of two numbers added together produce the one below them.
This is the start of it:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
You can see that the outside is all 1s, and each number is the sum of the two above it. This continues forever.
Your challenge is to coun... | stackexchange_codegolf |
EDIT: I'm getting a lot of comments about this not terminating - I will give the "correct answer" tag to either the first person who gives me FF(3) (as in provides it in their answer) or proves that FF(3) does indeed blow up indefinitely.
Task:
Your task is make the smallest program possible that generates the list of ... | stackexchange_codegolf |
While Rust is very, very rarely competitive in code golfing competitions (Java is often shorter), it can still be fun to golf in. What are some tricks for making Rust code shorter?
Please post only one tip in each answer.
| stackexchange_codegolf |
Given a list of n strings, return a list of that strings in ascending order. However, be aware, that in this case we want integer comparison for all numbers appearing in the strings, meaning that "12" > "3".
Example cases:
{"abc123", "abc6", "abc47", "abd49"} -> {"abc6", "abc47", "abc123", "abd49"}
{"foo0", "bar12", "f... | stackexchange_codegolf |
Write a program that outputs a list of the number of occurrences of each unique character in its source code.
For example, this hypothetical program {Source_Print_1}; should produce this output:
; 1
P 1
S 1
_ 2
c 1
e 1
i 1
n 1
o 1
p 1
r 2
t 1
u 1
{ 1
} 1
The formatting should match this example. No extraneous whitespa... | stackexchange_codegolf |
This challenge is inspired by a talk about Schläfli symbols, etc that I gave in a Geometry seminar. While I was putting together this challenge, I saw that Donald Knuth himself was interested in (some subset of) this problem. In October 2016, he commented on a related OEIS sequence:
If [the OEIS author] is wrong about... | stackexchange_codegolf |
I started a CodeWars kata in Python, just two days ago, related to code golf.
Task: Given two congruent circles a and b of radius r, return the area of their intersection rounded down to the nearest integer, in less than 128 chars.
Has to be a one-liner.
Version: Python 3.6
External libraries: You may import NumPy as ... | stackexchange_codegolf |
Background:
For this challenge, a polynomial looks like this:
$$P(x)=a_nx^n+a_{n-1}x^{n-1}+\dots+a_2x^2+a_1x+a_0$$
The degree, \$n\$, is the highest power \$x\$ is raised to. An example of a degree 7 polynomial would be:
$$P(x)=4x^7+2x^6-7x^4+x^2-6x+17$$
All powers are integers \$n\ge0\$. This means \$x\$, \$-2\$, and ... | stackexchange_codegolf |
To celebrate Rounded Pi Day, you must take advantage of today's date to make a program that takes in a circle's diameter and outputs its circumference by multiplying the diameter by 3.1416, where 3.1416 must be obtained using today's date.
Input 3
Output 9.4248
etc.
Does not take the date as input. You do not have to ... | stackexchange_codegolf |
Given a string of printable ASCII, output the frequency of each character in that string.
The Challenge
Input is given as a string of printable ASCII characters (decimal [32-126] inclusive).
Output the frequency of each character, in ASCII order.
The output must have a format similar to [character][separator][count]. ... | stackexchange_codegolf |
For those of you who are unfamiliar, Kirkman's Schoolgirl Problem goes as follows:
Fifteen young ladies in a school walk out three abreast for seven days in succession: it is required to arrange them daily so that no two shall walk twice abreast.
We could look at this like a nested 3 by 5 list (or matrix):
[[a,b,c]
... | stackexchange_codegolf |
As the title -- although discretely -- hints, I only pay with dollars.
The challenge
Write a function/program that takes a string as input, which is a monetary value preceded by a symbol. ex) £4.99. Then, return that same amount converted to USD.
Input
You will get a string as input. It will have the currency symbol f... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.