instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
If we assign each letter a respective integer, starting from 1, then a is 1, b is 2, c is 3, and so on. After z, the letters loop back around, but with a in front (aa, ab, ac). It then goes to ba, bb, bc... After this is completed, as you may have figured, another letter is added (aaa, aab, aac). "Prime letters" would... | stackexchange_codegolf |
Background
"Fly straight, dammit" (OEIS A133058) is a sequence of integers, which has these rules:
\$a_0 = a_1 = 1\$
\$a_n = a_{n-1}+n+1\$ if \$gcd(a_{n-1}, n) = 1\$
Otherwise, \$a_n = \frac{a_{n-1}}{gcd(a_{n-1}, n)}\$
In pseudocode:
a[0] = a[1] = 1
if gcd(a[n-1], n) == 1 then
a[n] = a[n-1] + n + 1
else
a[... | stackexchange_codegolf |
Originally the Multiplicative digital root
Challenge
Basically do what the title says
Method
Given a positive integer 1 <= N <= 100000000 through one of our standard input methods, multiply every digit together, ignoring zeroes.
Ex: Take a number, say 361218402:
3 * 6 = 18
18 * 1 = 18
18 * 2 = 36
36 * 1 = 36
36 * 8 =... | stackexchange_codegolf |
Given an integer \$N\$ consider a permutation \$p=p_1,p_2,p_3,\ldots\$ of \$1,\ldots,N-1\$. Let \$P = p_1 , p_1+p_2 \bmod N, p_1+p_2+p_3 \bmod N, \ldots\$ be its prefix sums modulo \$N\$. Sometimes \$P\$ will be a permutation of \$1,\ldots,N-1\$ itself.
For example, \$N=4: p=3,2,1 \rightarrow P=3,1,2\$
Negative example... | stackexchange_codegolf |
Leaderboard
154 Calculator
144 Taxman
138 Statistician
137 Solver
137 RandoAggroLawyer
136 Gambler
134 Turncoat
119 Lawyer
119 BloodyMurder
113 Bandit
79 Challenger
74 Mask
64 Random
An archive of the latest match, including the log and all output files, is available.
Calculator, by Brilli... | stackexchange_codegolf |
Taking a positive integer n as input, print the sample space of n consecutive coin flips. The coin is fair, with two sides H and T, each with probability 0.5.
For example,
Input - 3
Output -
HHH
HHT
HTH
HTT
THH
THT
TTH
TTT
Rules
Standard loopholes apply
You may print the elements out of order, but all of them should ... | stackexchange_codegolf |
With the US election going on right now, I noticed that there is one (completely meaningless, but still) thing which Trump can still achieve and which is out of reach for Biden: Having the won states being connected.
Task: Given a list of strings of two-letter abbreviations (see below) for US states, determine whether ... | stackexchange_codegolf |
Write a program that accepts chess moves, validate them and shows the results.
The program should:
Check wheter or not a move is valid
Check if a king is in check or in checkmate
Process the changes in position of the pieces
Not procees invalid moves
Use the format shown below, but format can be changed freely if you ... | stackexchange_codegolf |
Write a program or function that, given two ASCII strings A and B, will produce strings A' and B' where the common substrings are reversed in their place. The process for finding A' is as follows:
A' is initially empty.
If the first character of A is in B, find the longest prefix of A which is a substring of B. Remove... | stackexchange_codegolf |
Lets define a class of functions. These functions will map from the positive integers to the positive integers and must satisfy the following requirements:
The function must be Bijective, meaning that every value maps to and is mapped to by exactly one value.
You must be able to get from any positive integer to any o... | stackexchange_codegolf |
The absolute value of a number \$x\$ is normally written as \$|x|\$. The left and right side of the absolute value uses the same symbol, so it is not immediately obvious how to parse nested absolute values e.g. \$||1-2|+|3-|4-5|||\$
Your goal is to parse such an expression containing nested absolute values:
The express... | stackexchange_codegolf |
The goal of this challenge is to fill a niche that is mostly lacking on this site. In my observations there most parsing verification challenges fall into two categories:
Super easy parsing. This parsing can usually be done with a regex, and regex based answers usually do well.
Super complex parsing. These are cha... | stackexchange_codegolf |
The Mel calendar is used in the fictional world of Kaldia. Your goal is to convert dates into the Mel calendar.
This calendar has 13 months of 28 days each, plus 1 or 2 extra days after the last month. A year that is divisible by 4 but not by 100, or divisible by 400 has 366 days, and other years have 365 (i.e. our lea... | stackexchange_codegolf |
A Latin square of order n is text which is arranged as a square of n lines by n columns, contains n different characters, and each character appears once in each line and column. For example, here is a Latin square of order 9:
Code gOlf
ode gOlfC
de gOlfCo
e gOlfCod
gOlfCode
gOlfCode
OlfCode g
lfCode gO
fCode gOl
M... | stackexchange_codegolf |
Inspiration.
Task
Reverse runs of odd numbers in a given list of 2 to 215 non-negative integers.
Examples
0 1 → 0 1
1 3 → 3 1
1 2 3 → 1 2 3
1 3 2 → 3 1 2
10 7 9 6 8 9 → 10 9 7 6 8 9
23 12 32 23 25 27 → 23 12 32 27 25 23
123 123 345 0 1 9 → 345 123 123 0 9 1
| stackexchange_codegolf |
There is an asdfmovie video about a pie flavoured pie. Someone also made an edited version with more pies, so I created this challenge.
The input is a positive integer.
The code should first output the following string:
I baked you a pie!
Oh boy, what flavour?
Then, the next line should be PIE (input number of times)... | stackexchange_codegolf |
Write some code that takes a single non-negative integer \$n\$ and outputs the \$n\$th power of phi (\$\phi\$, the Golden Ratio, approximately 1.61803398874989) with the same number of decimal digits as the \$n\$th Fibonacci number.
Your code must produce the correct sequence of digits for all inputs up to at least 10 ... | stackexchange_codegolf |
Given a pattern and a ragged list of positive integers, your task is to decide whether the pattern matches the ragged list.
The pattern is also represented by a ragged list. But in addition to positive integers, it may contain a wildcard value.
Here is the rule for matching:
A positive integer matches the same positiv... | stackexchange_codegolf |
Inspired by the Lego gear ratios challenge by Keith Randall.
I, too, plan on building a giant lego robot that will eventually be able to destroy the other robots in the never-before-mentioned competition.* In the process of constructing the robot, I will be using a lot of gear trains to connect different parts of the r... | stackexchange_codegolf |
I'm currently converting a Float32Array to an Int32Array for input to a real-time audio raw PCM to MP3 recording application.
new Int32Array([...new Float32Array(b)].map(f=>f<0?f*32768:f*32767)
The examples in the wild I've seen convert each float individually to avoid static, gaps, glitches when the audio recording i... | 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 |
Today while playing with my kids I noticed that an apparently simple toy in the park hid a challenge.
The wheel has a triangle that points to a number, but also has three circles that point to the numbers every 90 degrees from the first one. So:
Challenge (really simple)
Given an integer between 1 and 12 (the one poi... | stackexchange_codegolf |
The game of Ghost is played between two players who alternate saying a letter on each turn. At each point, the letters so far must start some valid English word. The loser is the player to complete a full word first. So, for example, if the letters so far are E-A-G-L, then the only valid next letter to say is "E" an... | stackexchange_codegolf |
Please help me automate my discrete mathematics homework. Given a valid propositional formula, check if it is an instance of one of Łukasiewicz's axioms. Here's how it works.
A term can be defined inductively as follows:
Single lower-case letters of the Latin alphabet (a, b, c, etcetera) are terms.
Given a term ϕ, ¬ϕ ... | stackexchange_codegolf |
Challenge
You have one string of input bytes, output only the last byte in it.
Rules
Your submission may be a program or function outputting the last byte in the input which
is either a string, stdin or command-line arguments, and
is non-empty.
I was trying to solve this with brainfuck, however all languages are allo... | stackexchange_codegolf |
Given an \$n \times n\$ matrix of integers, The task is to find the optimal dividing line that maximizes the sum of the integers on the same side as the top left corner. The dividing line should be connected and made up of only vertical and horizontal lines. For an example with a non-optimal dividing line:
[[ 3, 0,... | stackexchange_codegolf |
We once made a Hexagony template without actually knowing it. But after a bit of experience with Hexagony, it becomes apparent that it is not enough; sometimes the source code is too short for the given hexagon, and you get totally unexpected results.
So I came up with an idea: a template that gives a hint when the cod... | stackexchange_codegolf |
You've gotten out of Earth's gravity well - good for you! However, you're feeling a bit uncomfortable in zero-gravity, and you want to replicate 1 \$g\$ of force in a centrifuge. Use the equation for force in a centrifuge:
$$\text{RCF} = \frac{r_\text{m} \, \left(\frac{2 \pi N_\text{RPM}}{60}\right)^2}{g}$$
Where
\$\t... | stackexchange_codegolf |
You are the electoral strategist for a sudden late entrant in the 2020 US presidental election.
Your task: print out the names of states* your candidate will win, totalling at least 270 electoral college votes.
Background
Each state (and Washington DC) in the US system has an arbitrary number of "electoral college vot... | stackexchange_codegolf |
Chained Binary Operations
Here's a challenge involving truth tables and binary operations. For this specific challenge, your task is to use the following table of operations:
To create a function that takes in two inputs f(p,a), where p is the initial truthy/falsy value and a is a list of tuples representing multiple ... | stackexchange_codegolf |
Assume the result of an exam has been published.
After 5 minutes, First person knows the result.
In next 5 minutes, new 8 persons know the result, and in total 9 know it.
Again after 5 minutes, new 27 people know, and total 36 know.
In similar fashion, total 100, 225..... people keep knowing it on 5 minute interval.
Ch... | stackexchange_codegolf |
Summary
A new string manipulation language has been made, using only the characters $+#-!*|@>! Your task is to implement an interpreter for it in as few bytes as possible.
Input
A string, which is a single line of this language. This can be taken in any reasonable way (stdin, function parameter, command line argument e... | stackexchange_codegolf |
You have to decompose a positive integer/fraction as a product of powers of factorials of prime numbers.
For example
22 = (11!)^1 × (7!)^(−1) × (5!)^(−1) × (3!)^(−1) × (2!)^1
10/9 = (5!)^1 × (3!)^(−3) × (2!)^1
Use this special notation: prime number#power
to denote each term, e.g. (11!)^4 is denoted as 11#4.
Output... | stackexchange_codegolf |
In this challenge, you are required to shift characters in an inputted string n number of times and output the shifted string
Input
Input will first contain a string. In the next line, an integer, which denotes n will be present.
Output
If n is positive, shift the characters in the string to the right n times.
If n is... | stackexchange_codegolf |
(Randomly inspired by https://codegolf.meta.stackexchange.com/a/17272/42963)
Given a rectangular matrix of digits (i.e., 0 - 9), output the "pieces" of the matrix as if the digits are connected together forming a single piece, in ascending order by the digits. The pieces are guaranteed to connect only orthongonally -- ... | stackexchange_codegolf |
As a little kid, I liked to play with these toys a lot:
They probably intended for these to be used for art, but I always used them for math! Fractals, patterns, etc. One time, I was given this challenge:
Build a triangle without using any of the green triangle tiles.
This challenge stumped me for the longest time, ... | stackexchange_codegolf |
The PGP Word List is a set of 512 English words for verbally communicating strings of bytes, such as authentication codes or hashes. It is used in secure VoIP software as well as in some other important applications, such as the DNSSEC Root KSK Ceremonies held four times a year.
It consists of 256 two-syllable words a... | stackexchange_codegolf |
Introduction
In this challenge, we will be dealing with a certain infinite undirected graph, which I call the high divisor graph.
Its nodes are the integers starting from 2.
There is an edge between two nodes a < b if a divides b and a2 ≥ b.
The subgraph formed by the range from 2 to 18 looks like this:
16-8 12 18
\|... | stackexchange_codegolf |
Creating a golfing language can be hard. Let's help budding golfing language creators out and provide some helpful tips on how to create one.
I'm looking for tips on:
The design process
Implementation
Community engagement
One tip per answer would be appreciated, and tips like "don't create a new language, use an exis... | stackexchange_codegolf |
A polynomial is divisible by a factor (x-n) if f(n)=0 for a function f. Your job: to determine if a polynomial function f(x) is divisible by (x-n).
The input
The input is in the form of (x-n), (Polynomial). Remember, if n is negative, (x-n) will be in the input form of (x+n). For the polynomial, all exponents will... | stackexchange_codegolf |
Challenge
Create the shortest program that meets the requirements
Requirements
The code must generate a 5x5 grid of 0s, like so:
00000
00000
00000
00000
00000
The code must accept an input (column, row, character). The grid must change accordingly:
Start:
00000
00000
00000
00000
00000
Input:
(2,5,*)
Output:
0*000
0... | stackexchange_codegolf |
This is the robbers' thread. The cops' thread is here.
Your challenge is to take an uncracked submission from the cops' thread and try to find the original unredacted program. Please comment on the cop's submission when you've cracked their code.
| stackexchange_codegolf |
Background
Jelly's arithmetic atoms vectorize automatically. In fact, x + y is well-defined whenever x and y are numbers or ragged arrays of numbers. Jelly's source code implements this behavior using a generic vectorizer, but for this challenge, we'll only consider addition of integers and nested integer arrays.
Defin... | stackexchange_codegolf |
Given a random code written using Brainfuck commands. You program should translate that code into the following ascii art: each Brainfuck command represents as 5x9 array of A and B symbols. All commands are concatenated with 5x3 arrays of A symbols. Symbols A and B you choose yourself.
For example, when input is ><+,.[... | stackexchange_codegolf |
Stack Cats is a reversible, stack-based language. Its reversible nature makes for somewhat weird loops. This challenge is about the conditional loop (...). When these loops are nested in certain ways, it's possible to transform the code to reduce the nesting depth. Here are the rules (where A and B stand for an arbitra... | stackexchange_codegolf |
It is in my humble opinion that standard text is boring. Therefore I propose a new writing standard, walking words!
Walking words
Walking words are words which will respond to certain characters. For the purpose of this challenge the trigger characters are [u, d, r, l] from up down right left.
Whenever you encounter su... | stackexchange_codegolf |
The card game War is interesting in that the final outcome is entirely determined by the initial arrangement of the deck, so long as certain rules are followed for the order in which cards are picked up from the playing field and moved to decks. In this challenge, there will only be 2 players, simplifying things greatl... | stackexchange_codegolf |
Suppose you are given a set of non-intersecting intervals of integers [a1,b1],[a2,b2],[a3,b3],...,[aN,bN]. (Where [a,b] is the set of integers greater than or equal to a and less than or equal to b.)
The interval at index X covers bX - aX + 1 values. We'll call this number cX.
Given that each interval can either be...
... | stackexchange_codegolf |
You have n coins which each weigh either -1 or 1. Each is labelled from 0 to n-1 so you can tell the coins apart. You have one (magic) weighing device as well. At the first turn you can put as many coins as you like on the weighing device which is able to measure both negative and positive weights and it will tell yo... | stackexchange_codegolf |
The computational parity of an integer is defined as 1 if the integer has an odd number of set bits, and 0 otherwise. (src).
Input
You will receive one nonnegative integer that you will take the parity of. Optionally, you may take the size of the integer in bytes or bits as an argument, but you must specify this in yo... | stackexchange_codegolf |
Normally, I'd open with some flavor text here about being bored and/or lazy but looking through the stack-exchange-api questions that would be far from original. So instead I'm going to open with a meta and self-referential flavor text describing this lack of originality that then describes itself and how meta and self... | stackexchange_codegolf |
How do I remove all duplicates from list and order it based on count?
s = ["foo", "this", "lem", "foo", "lem"]
s = ["foo", "ebh", "wosv", "wosv", "ebh", "4whcu"]
#should return
>>> ["foo", "lem", "this"]
>>> ["ebh", "wosv", "foo", "4whcu"]
Rules:
Must be shorter than the below code in terms of byte size.
Order must b... | stackexchange_codegolf |
I just had a genius idea for making the work-life easier - a countdown to a specific date which only counts workdays.
The basic task is to create a countdown to a specific date which only includes the workdays in the countdown.
As workday counts Monday, Tuesday, Wednesday, Thursday and Friday.
The Input should be a sp... | stackexchange_codegolf |
The continued fraction of a number n is a fraction of the following form:
which converges to n.
The sequence a in a continued fraction is typically written as: [a0; a1, a2, a3, ..., an].
Your goal is to return the continued fraction of the given rational number (positive or negative), whether it is an:
integer x
frac... | stackexchange_codegolf |
Background
This challenge is about the game of Go. Go is a game played on a board with a square grid N x N. You don't have to know how to play the game to do this challenge, but if you are interested, google "Tromp-Taylor rules" for a minimal and precise set of rules to play a full game.
Let's use a 4 x 4 board. As the... | stackexchange_codegolf |
Universal Command Sequence
Definition
An \$n\$-maze is a \$n\times n\$ chessboard which has "walls" on some edges, and a "king" on the board that can move to the 4 adjacent cells, which cannot pass through any walls. Starting from any cell the king should be able to reach every cell on the board.
A command sequence is ... | stackexchange_codegolf |
Explanation
In this task you'll be given a set of N points (x1,y1),…,(xN,yN) with distinct xi values and your task is to interpolate a polynomial through these points. If you know what Lagrange interpolation is you can skip this section.
The goal of a polynomial interpolation is to construct the (unique) polynomial p(x... | stackexchange_codegolf |
Challenge
Given an IPv4 address in dotted-quad notation, and an IPv4 subnet in CIDR notation, determine if the address is in the subnet. Output a distinct and consistent value if it is in the subnet, and a separate distinct and consistent value if it is not in the subnet. The output values do not necessarily need to be... | 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 |
Introduction
We all know prefixes and suffixes. But there are other types of affixes that exist too. Such as circumfixes, a type of affix that has two parts, one of which is a prefix and another of which is a suffix. Figuring out whether some string is a prefix or a suffix of some other string is easy, but what about f... | stackexchange_codegolf |
Why was 6 afraid of 7? Because 7 8 9!
Given a string apply the following transformations:
If there is a 6 next to a 7 remove the 6 (6 is afraid of 7)
If the sequence "789" appears remove the 8 and the 9 (7 ate 9)
(If I'm not mistaken it doesn't matter what order you do the transformations in)
Keep applying these tran... | stackexchange_codegolf |
Description
While support is getting better and better for people to write in various scripts around the world using unicode, and now you can even write in emojis as well, unfortunately most fonts[citation needed] are still missing Latin characters based on the double acute accent, which is required to write properly i... | stackexchange_codegolf |
The narcissist is a program which, given its own source as input, prints a truthy value and, given anything other than that, prints a falsey value. Today, we're reversing this.
Create a program that, given the name of whatever your language's truthy value is (True, true, 1), prints its own source. Given the name of wha... | stackexchange_codegolf |
This is the robbers thread of this cops and robbers challenge. The cops thread is here.
Related, but hashes numbers instead of strings and uses a different scoring system.
Definitions
A hash collision is when two different strings produce the same hash.
Summary
In this challenge, the cops will make a hash function, wit... | stackexchange_codegolf |
Given a nonempty finite list of integers, output a truthy value if there are exactly two equal entries and all other entries are distinct, and a falsey value otherwise.
Examples
truthy:
[1,1]
[1,2,1]
[1,6,3,4,4,7,9]
falsey:
[0]
[1,1,1]
[1,1,1,2]
[1,1,2,2]
[2,1,2,1,2]
[1,2,3,4,5]
| stackexchange_codegolf |
The lack of a social life drove a poor nerd into inventing another superfluous esolang called !+~%. For no good reason it initializes the accumulator with 6 and knows the following commands:
! (out(Accu); Accu = 6) prints the accumulator value as decimal string to stdout (without newline) and resets the accumulator to... | stackexchange_codegolf |
Setup:
A block is any rectangular array of squares, specified by its dimensions \$(w,h)\$. A grid is any finite ordered list of blocks. For example, \$\lambda = ((3,2),(3,1),(1,2))\$ defines a grid.
Let \$\lambda\$ and \$\mu\$ be two grids with equal area.
A tiling of \$\lambda\$ by \$\mu\$ is any rearrangement of the ... | stackexchange_codegolf |
Problem
You are given a binary string A of length N.
You can perform the following type of operation on the string A:
Choose two different indices \$i\$ and \$j\$ (\$1 \le i\$, \$j \le N\$)
Change \$A_i\$ and \$A_j\$ to \$Ai \oplus Aj\$. Here \$\oplus\$ represents the bitwise XOR operation.
Input
A binary string con... | 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 |
In calculus, the derivative of a mathematical function defines the rate at which it changes. The derivative of a function f(x) can be marked as f'(x), and these can sometimes be abbreviated to f and f'.
The derivative of the product of two functions fg is f'g + g'f. The derivative of three fgh is f'gh + fg'h + fgh'. In... | stackexchange_codegolf |
The Venetian election system was... complicated.
The Great Council came together and put in an urn the ballots of all the councilors who were older than 30. The youngest councilor went to St Mark's Square and chose the first boy he met who drew from the urn a ballot for each councillor and only those 30 who got the wo... | stackexchange_codegolf |
In most programming languages, the string Hello, World! can be represented as "Hello, World!". But if you want to represent "Hello, World!" you need to escape the double quotes with backslashes for "\"Hello, World!\"", and to represent that you also need to escape the backslashes resulting in "\"\\\"Hello, World!\\\"\"... | stackexchange_codegolf |
Write a program or function that takes in two integers that represent the X and Y coordinates of a point on a Cartesian plane.
The input may come in any reasonable format as long as the X value comes before the Y. For example, 1 -2, (1,-2), [1, -2], or 1\n-2 would all be fine for X = 1, Y = -2.
Print or return a single... | stackexchange_codegolf |
Write a program or function (hereafter "function") that returns or prints the source code of four new functions: Increment, decrement, undo, and peek.
The initial function contains an internal integer value of 0. Each of the returned functions contains a value based on that value, and each behaves differently:
Increme... | stackexchange_codegolf |
A counterstring is some sort of self-describing test data that is used in software testing. Not sure it was actually invented by James Bach, but I know it from there.
The idea is as follows: the test data contains many asterisk (*). The number in front of the asterisk tells you how long the test data is at that point. ... | stackexchange_codegolf |
Note: this problem was inspired by the Unsolved Mathematical Problems for K-12 youtube video, which also features other interesting puzzles.
From the wikipedia article:
The no-three-in-line problem asks for the maximum number of points that can be placed in the n × n grid so that no three points are collinear ..... Al... | stackexchange_codegolf |
Playing the game of memory against a machine is highly unfair, because they play almost as good as small children. So let's make the machine play alone, but in a fair way:
Input: 1...26 pairs of lowercase letters in random order like zz or gttg or abcdefghiabcdefghi. You can trust each letter appears exactly twice and... | stackexchange_codegolf |
Two dimensional chiral objects are not chiral in three dimensional space. This is because you can flip them over which is equivalent to taking the mirror image unlike in two dimensions where only rotations in the plane of the object are allowed which cannot reproduce the effect of a mirror operation. In this challenge,... | stackexchange_codegolf |
Generator functions
This gives the context for why this challenge came to life. Feel free to ignore.
Generator functions are a nice way of encoding the solution to a problem of combinatorics. You just write some polynomials, multiply them and then your solution is the coefficient of one of the terms.
For example, how m... | stackexchange_codegolf |
Take a square matrix containing positive integers as input, and calculate the "rotated sum" of the matrix.
Rotated sum:
Take the sum of the original matrix and the same matrix rotated 90, 180 and 270 degrees.
Suppose the matrix is:
2 5 8
3 12 8
6 6 10
then the rotated sum will be:
2 5 8 8 ... | stackexchange_codegolf |
I've enjoyed reading this site; this is my first question. Edits are welcome.
Given positive integers \$n\$ and \$m\$, compute all ordered partitions of \$m\$ into exactly \$n\$ positive integer parts, and print them delimited by commas and newlines. Any order is fine, but each partition must appear exactly once.
For e... | stackexchange_codegolf |
In this cops-and-robbers challenge, robbers must crack cop answers by finding out which languages the cops used.
This is the Cops thread. For the Robbers' challenge, see here
Cops, you are to write a program, which, when executed in a specific language, does one of the following:
Outputs one of the 5 phrases below
Out... | stackexchange_codegolf |
This challenge is inspired by Fortran's idiosyncratic implicit typing rules. Your task will be to determine the data type of the object GOD according to the implicit typing rules explained below.
Background
Fortran 77 has six data types: CHARACTER, COMPLEX, DOUBLE PRECISION, INTEGER, LOGICAL, and REAL. Any object not e... | stackexchange_codegolf |
Story (skip, if you prefer the naked task): You need five skills for an imaginary sport: Speed, strength, endurance, accuracy and tactics. If you achieve a score in each of these disciplines, you can work out how well you have mastered the sport as a whole. But, as your coach always says: concentrate on your strengths,... | 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 |
Given a strictly positive integer, N, produce an output satisfying the following:
Produce an array of length N.
Every string (i.e. "word") in the array is of length N.
Every letter in the word is unique.
Every first letter of the words are unique between each other.
The remaining items of each word are equal to each o... | stackexchange_codegolf |
Given as input a list of positive integers, your task is to determine if every integer present has exactly two neighbors in the list. The neighbors of a integer \$x\$ are the distinct integers that appear next to an \$x\$ anywhere in the list. For example in the list:
[1,3,4,4,3,2,1]
The number 3 has 3 neighbors 1, 4... | stackexchange_codegolf |
The Golfer Adventure
This is the first challenge ! There will be more challenges later that will require data from the previous challenge :)
Chapter 1 : The Vase
Let's imagine a minute.. You are a powerful God, your powers are limitless but require one thing : Souls.
Each soul is here represented by a byte, each byte y... | stackexchange_codegolf |
Build a function in python that can win a Sevens game provided that there are only 2 players
Here are the instructions from Wikipedia:
All cards are dealt to the players, even if as a result some players
have one card more than others. The owner of the seven of hearts
begins by playing it. Similarly, the other ... | stackexchange_codegolf |
In base-10, all perfect squares end in \$0\$, \$1\$, \$4\$, \$5\$, \$6\$, or \$9\$.
In base-16, all perfect squares end in \$0\$, \$1\$, \$4\$, or \$9\$.
Nilknarf describes why this is and how to work this out very well in this answer, but I'll also give a brief description here:
When squaring a base-10 number, \$N\$, ... | stackexchange_codegolf |
You want to create a square chessboard. Adjacent tiles must alternate black and white like a standard chessboard, and the bottom left corner can be either black or white.
Your program will take in two positive integers, the number of black and the number of white tiles. These will always be less than 1024. You don't ha... | stackexchange_codegolf |
Part 1 of the task is here
Flags Mashup Bot is a small Twitter bot that generates a new country name based on two random country names and tweets the result every couple of minutes.
Task
Your task is to replicate what the bot does by writing a script or a function based on the following criteria:
The input is two cou... | stackexchange_codegolf |
Definition
\$a(0) = 0\$
\$a(n) = n-a(a(a(n-1)))\$ for integer \$n > 0\$
Task
Given non-negative integer \$n\$, output \$a(n)\$.
Testcases
n a(n)
0 0
1 1
2 1
3 2
4 3
5 4
6 4
7 5
8 5
9 6
10 7
11 7
12 8
13 9
14 10
15 10
16 11
17 12
18 13
19 13
20 ... | stackexchange_codegolf |
What general tips do you have for golfing in Haxe? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Haxe (e.g. "remove comments" is not an answer).
Please post one tip per answer.
Haxe can be run online here!
| stackexchange_codegolf |
The partial sums of a list of integers [a1, a2, a3, ..., an] are
s1 = a1
s2 = a1 + a2
s3 = a1 + a2 + a3
...
sn = a1 + a2 + ... + an
We can then take the list of partial sums [s1, s2, s3, ..., sn] and compute its partial sums again to produce a new list, and so on.
Related: Iterated forward differences
Input:
A non-em... | stackexchange_codegolf |
Definition
Given a matrix \$M\$ of non-negative integers and a non-negative integer \$k\$, we define \$F_k\$ as the "chop-off" function that removes all rows and all columns in \$M\$ that contain \$k\$.
Example:
$$\begin{align}M=\pmatrix{\color{red}6&\color{red}1&\color{white}{\bbox[red,1pt]{5}}\\1&2&\color{red}8\\\col... | stackexchange_codegolf |
Task
A pure mirror checkmate is a checkmate position, where the mated king is surrounded by 8 empty squares which are attacked or guarded by the winning side exactly once. You will be given a valid chess position where Black is in mate. Your task is to find if that mate is a pure mirror checkmate.
Examples (click for l... | stackexchange_codegolf |
Given a positive integer input n seconds, output the time in human readable format.
The time will be considered from 00:00:00, 1st January, 1 A.D.
Leap years must be taken into account.
Assume that the gregorian calendar was followed since the beginning.
(Gregorian Calendar: Every year that is exactly divisible by four... | stackexchange_codegolf |
AKA: Generate Clickbait From an Array.
Given an array of integers, generate some cringe-worthy clickbait based on its arrangement and length:
If it's 20 elements or less, you can make a Top X List. Parameters: length of the array.
Prime numbers are celebrities, so anytime two of them are next to each other it'll pass ... | stackexchange_codegolf |
So your task is to take a 3x3 block where -'s mean blank spaces, and *'s mean filled spaces, for example:
-**
-*-
*-*
and rearrange the block so that the *'s form an X, like this:
*-*
-*-
*-*
Input:
3x3 squares like above, they can be 3 lines, an array, or however you want.
Output: The shortest amount of moves to rea... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.