instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
A curious kid uses a program which can factorize a number or an expression into the following form: p1^e1 * p2^e2 * ... * pn^en . Exponents equal to 1 are omitted e.g. 360 = 2^3 * 3^2 * 5
The kid types this output into the program as new input but they don't understand the ^ sign so sometimes they skip one or more of t... | stackexchange_codegolf |
Challenge
Given a non-empty string S of length L consisting entirely of printable ASCII chars, output another string of length L that consists entirely of printable ASCII chars, but is not equal to S.
For the purposes of this challenge, a printable ASCII char is one between U+0020 and U+007E, inclusive; that is, from ... | stackexchange_codegolf |
Use any programming language to display "AWSALILAND" in such a way, so that each letter is in a new line and repeated as many times as its position in the English alphabet. For example letter, (A) should be displayed just once because it is the first letter of the alphabet. Letter D should be displayed 4 times because ... | stackexchange_codegolf |
If you wanted to compute a very large long problem, that on a machine that you could buy today for an inflation adjusted price, will take some amount of years/decades. The issue is, if you only have that budget, and so can only purchase one machine. So if you purchase the machine now, it may actually take longer to com... | stackexchange_codegolf |
Challenge
This is a simple challenge. Given two positive integers w and h create an ASCII fence with a width of w and a height of h. The fence should be constructed using the following rules:
The + character will represent a post.
The - character will be used to represent the width of the fence.
The | will be used to ... | stackexchange_codegolf |
The minimal power iteration of a number \$n\$ is defined as follows:
$$\text{MPI}(n):=n^{\text{min}(\text{digits}(n))}$$
That is, \$n\$ raised to the lowest digit in \$n\$. For example, \$\text{MPI}(32)=32^2=1024\$ and \$\text{MPI}(1234)=1234^1=1234\$.
The minimal power root of a number \$n\$ is defined as the number o... | stackexchange_codegolf |
Your task is to create the given target string. Starting with an string that is empty, you will have to add characters to it, until your string is the same as the one we want. You can either add a character to the end of you string with cost x, or you can clone you string with cost y. What we want is the cheapest way t... | stackexchange_codegolf |
An easy way to understand the unit n-dimensional hypercube is to consider the region of space in n dimensions that you can get if every coordinate component lies in [0, 1]. So for one dimension it's the line segment from 0 to 1, for two dimensions it's the square with corners (0, 0) and (1, 1), etc.
Write a program or ... | stackexchange_codegolf |
You are given an integer n as input, and, regardless of the current date, must return the calendar year (Gregorian calendar, other calendars not allowed) taking place n seconds from now.
Rules
You may not assume that the current year is 2021. In other words, imagine a user testing your solution in five years.
Standard... | stackexchange_codegolf |
This is based off a previous deleted challenge of mine with the same name
Introduction
You are tasked with writing a program that returns a truthy or falsey value based on if the input has all its XML-like1 tags appropriately opened and closed and in the right order. Consider the following as input:
<Apple>
This would... | stackexchange_codegolf |
In the strategy game "Hexplode", players take turns placing tokens on a hexagonal board. Once the number of tokens equals the number of adjacent tiles, that tile hexplodes, and moves all of the tokes on it to the surrounding neighbors. You can play the game online here.
I like this game, but sometimes it's hard to know... | stackexchange_codegolf |
Your challenge is given an input of a prison layout to work out whether any of the prisoners can escape.
Input
Input may be in any reasonable format such as a string, array, array of arrays etc. The input will consist of three characters, in this case #, P and space. The input will not necessarily contain all three cha... | stackexchange_codegolf |
Task
Your task is to take a character in:
AÁÀÃÂBCÇDEÉÊFGHIÍJKLMNOÕÓÔPQRSTUÚVWXYZaáàãâbcçdeéêfghiíjklmnoõóôpqrstuúvwxyz
and turn it into a characters in:
AAAAABCCDEEEFGHIIJKLMNOOOOPQRSTUUVWXYZaaaaabccdeeefghiijklmnoooopqrstuuvwxyz
by the obvious operation: dropping the accents in the letters.
Input
A character in any se... | stackexchange_codegolf |
Almost six years ago, fellow PPCG member steenslag posted the following challenge:
In a standard dice (die) the numbers are arranged so that opposite
faces add to seven. Write the shortest possible program in your
preferred language which outputs a random throw followed by 9 random
tippings. A tipping is a quart... | stackexchange_codegolf |
There are some iron particles on a board. We pass a current carrying wire through that board and the particles form circles. Show these circles if input given is the position of the wire.
Consider the board to be a grid of size 7x7 (fixed)
No extra white spaces are allowed.
Input can be 0-indexed or 1-indexed. (0-index... | stackexchange_codegolf |
Following the fine tradition of questions such as Find the largest prime whose length, sum and product is prime , this is a variant on a largest prime challenge.
Input
Your code should not take any input.
Definition
We say a prime p is good if p-1 has exactly 2 distinct prime factors.
Output
Your code should output the... | stackexchange_codegolf |
Challenge :
Sort the vowels (only vowels) in the given string .
Note :
Vowels are the following characters: A, E, I, O, U
Vowel sorting is cyclic i.e. After rearrangement the first vowel of sorted string goes where the original first vowel was
Input :
A string line, the original line (consisting of alphabets and wh... | stackexchange_codegolf |
The challenge here is to take a string and output all its rotations, by repeatedly moving the first character to the end, once per character in the string, ending with the original string:
john -> ohnj, hnjo, njoh, john
You may also cycle in the other direction, moving characters from the end:
john -> njoh, hnjo, ohnj... | 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 |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
While other Elves are busy carrying air blowers, Fen comes and shouts, "I've got a spell for this job!"
To recap, a chimney is modeled as a rectangular grid. The number in each cell represents the amount of smoke in the region. The lef... | stackexchange_codegolf |
Task
Given a square array of 0s and 1s, determine whether or not there exists a path of 1s connecting the leftmost and rightmost columns. A path can take steps of one unit up, down, left or right, but not diagonally. Every symbol on the path must be a 1, and it must start somewhere in the first column and end somewhe... | stackexchange_codegolf |
Introduction
We have 22 Collatz conjecture-related challenges as of October 2020, but none of which cares about the restrictions on counter-examples, if any exists, to the conjecture.
Considering a variant of the operation defined in the conjecture:
$$f(x)=
\cases{
\frac{x}{2}&for even x \cr
\frac{3x+1}{2}&for odd x
}... | stackexchange_codegolf |
Draw a program or function that will write to STDOUT n times (each for one step) a string that contains a dot . at the location of the walker. The program also needs to write a line every s seconds (or wait s seconds after each line).
A random walk is a mathematical formalization of a path that consists of a succession... | stackexchange_codegolf |
kolmogorov-complexity is one of the tags on this site, representing challenges that test how much code is needed to output a given fixed result (usually a piece of text). The info page for this tag lists the string 4c1j5b2p0cv4w1x8rx2y39umgw5q85s7uraqbjfd as an example of a string with a high Kolmogorov complexity, sta... | stackexchange_codegolf |
For a given list of number \$[x_1, x_2, x_3, ..., x_n]\$ find the last digit of \$x_1 ^{x_2 ^ {x_3 ^ {\dots ^ {x_n}}}}\$
Example:
[3, 4, 2] == 1
[4, 3, 2] == 4
[4, 3, 1] == 4
[5, 3, 2] == 5
Because \$3 ^ {(4 ^ 2)} = 3 ^ {16} = 43046721\$.
Because \$4 ^ {(3 ^ 2)} = 4 ^ {9} = 262144\$.
Because \$4 ^ {(3 ^ 1)} = 4 ^ {... | stackexchange_codegolf |
Introduction
Most code-golfers here add explanations to their submissions, so it's easier to understand what's going on. Usually the codelines go on the left and the corresponding explanation to the right with some kind of separator. To make it look pretty, the separators are all on the same column. Also long explanati... | stackexchange_codegolf |
Introduction / Background
In a recent discussion in the crypto chat I was challenged to discuss / help with the Fermat primality test and Carmichael numbers. This test is based on the premise that a^(p-1) mod p==1 will always hold for primes p, but not always for composites. Now a carmichael number is essentially the F... | stackexchange_codegolf |
Challenge
The primitive circle problem is the problem of determining how many coprime integer lattice points \$x,y\$ there are in a circle centered at the origin and with radius \$r \in \mathbb{Z}^+
\$ such that \$x^2+y^2 \le r^2 \$. It's a generalization of Code-Golf: Lattice Points inside a Circle.
Input
Radius \$r... | stackexchange_codegolf |
Task
Continuously print a random character (a-z, A-Z, 0-9) not separated by a newline (\n).
Expected output
b7gFDRtgFc67h90h8H76f5dD55f7GJ6GRT86hG7TH6T7302f2f4 ...
Note: output should be randomised.
Requirements/Rules
Output must be continuous (i.e. never ending),
Output may not comprise of newlines,
Output must b... | stackexchange_codegolf |
Inspired by this stack of little statues that are currently on my desk at work, given to me by my colleagues from Sri Lanka when they visited The Netherlands:
This is split into two different challenges due to popular demand:
Part 1) Determine the amount of statues (this challenge)
Part 2) Can the statues be stacked?
... | stackexchange_codegolf |
A number spiral is an infinite grid whose upper-left square has number 1. Here are the first five layers of the spiral:
Your task is to find out the number in row y and column x.
Example:
Input: 2 3
Out : 8
Input: 1 1
Out : 1
Input: 4 2
Out : 15
Note:
Any programming language is allowed.
This is a code-golf cha... | stackexchange_codegolf |
I have a coding problem that goes like this:
Given a positive integer \$N\$, return a list of all possible pairs of positive integers \$(x,y)\$ such that $$\frac1x+\frac1y=\frac1N$$
I already solved the problem using Python, but I was wondering how I can code golf it. The following is my attempt at golfing (I try to ... | stackexchange_codegolf |
If you place a knight on any square of a chessboard, what is the smallest amount of steps to reach every position?
Rules
It is an 8 by 8 board.
The knight starts at an arbitrary position, taken as input.
The knight moves 2 squares in one direction and 1 square in the other, for example, a knight on the square marked N... | stackexchange_codegolf |
Description
In this challenge, you need to write a function that takes in a list of strings and returns the smallest string based on their ASCII value. You should assume that the input list contains only lowercase alphabetical strings.
Test Cases
["a", "b", "c"] => "a"
["hello", "world", "code"] => "code"
["aaa", "aa",... | stackexchange_codegolf |
You are given four integers: \$e,s,b\in\{0,1\}\$ and \$S\in \{0,1,2,4\}\$, where \$e,s,b,S\$ stand for egg, sausage, bacon and spam respectively.
Your task is to figure out whether the corresponding ingredients match a valid entry in the following menu:
[e]gg | [s]ausage | [b]acon | [S]pam
-------+-----------+--------... | stackexchange_codegolf |
Sequel to Verify Tents and Trees solution.
Background
Tents and Trees (try here) is a puzzle played on a square (or rectangular) grid, where the objective is to place tents horizontally or vertically adjacent to each of the trees, so that no two tents touch each other in 8 directions (horizontally, vertically, and diag... | stackexchange_codegolf |
The set of all polynomials with integer coefficients is countable.
This means that there is a sequence that contains each polynomial with integer coefficients exactly once.
Your goal is it to write a function or program that outputs such a sequence.
Example (you may use another sequence):
// list of integers [i -> Z(i)... | stackexchange_codegolf |
Sandbox post
In this code-golf challenge, you are provided with a series of y values at even x-values as well as a console width and height. The desired output is an ASCII-art representation of a ribbon plot of the y-values scaled to the desired size. If all values are positive or negative, the x-axis should be display... | stackexchange_codegolf |
So I have the situation where I have one boolean value a and, if that one is true and b<c I want it to end up as true, if a is false and b>c I want it to resolve as true as well. If b=c I want it to be always false, no matter the value b and c are both numbers. My best approach so far is a?b<c:b>c or maybe b^c^a^b<c. I... | stackexchange_codegolf |
An arborally satisfied point set is a 2D set of points such that, for any axis-aligned rectangle that can be formed using two points in the set as opposite corners, that rectangle contains or touches at least one other point. Here is an equivalent definition from Wikipedia:
A point set is said to be arborally satisfi... | stackexchange_codegolf |
Eyeballing the binary values printed as ovals and sticks is not so easy...
To help with that, you must write a function (or a program) that prints numbers in custom binary representation.
So I want to take a number, say 3 (00000011) and output the bits in user-defined format, for example with space separated pairs:
0... | stackexchange_codegolf |
Challenge:
Take a vector / list of integers as input, and output the largest number that's adjacent to a zero.
Specifications:
As always, optional input and output format
You may assume that there will be at least one zero, and at least one non-zero element.
Test cases:
1 4 3 6 0 3 7 0
7
9 4 9 0 9 0 9 15 -2
9
-4 -6... | stackexchange_codegolf |
Introduction:
Inspired by a discussion that is already going on for many years
regarding the expression \$6÷2(1+2)\$.
With the expression \$6÷2(1+2)\$, mathematicians will quickly see that the correct answer is \$1\$, whereas people with a simple math background from school will quickly see that the correct answer ... | stackexchange_codegolf |
Ken Iverson, 1920–2020
Let's implement his favourite expression:
Given a row of Pascal's triangle, compute the next row.
This can for example be computed by taking the input padded with a zero on the left, and the input padded with a zero on the right, and then adding the two element-by-element.
Test cases... | stackexchange_codegolf |
Inspired by Golf me an ASCII Alphabet, of which this challenge is (almost) a direct inverse.
Task:
Take a string of ASCII-art text and output the content of the text as regular ASCII text.
Input:
String of ASCII-art text.
Input will only contain instances of ASCII character #, spaces and 4 or 5 newlines (a trailing n... | stackexchange_codegolf |
In the poker game there are 1277 unique 'High Card' ranks. It's 1287 (13 over 5) if we include all straights.
The challenge is to write a function which returns an integer value corresponding to the rank of each 'High Card' poker combination including all straights. Possible cards are(in ascending order): '23456789TJQK... | stackexchange_codegolf |
Note: In this post, the terms 'character' and 'color' mean essentially the same thing
This image:
can be represented as
....'''333
.eeee'''3e
..dddd33ee
%%%dd####e
(mapping colors to ascii characters)
The four color theorem states that
"given any separation of a plane into contiguous regions, producing a figure cal... | stackexchange_codegolf |
A certain well-known cable company has a somewhat clumsy 'Search for Program' feature that works through the remote. It takes muchly much button pushing; so, being an admirer of economy of motion, I thought I'd seek out a programmer's help to minimize the number of finger movements I have to make.
The Craptastic Search... | stackexchange_codegolf |
Fennel is a lispy language which compiles to Lua.
From its page:
Fennel is a programming language that brings together the speed, simplicity, and reach of Lua with the flexibility of a lisp syntax and macro system.
I am looking for general tips for golfing in this language. Tips should be specific to Fennel, "Remove ... | stackexchange_codegolf |
Problem
Given a file with:
56 (65%), 33(75%), , 44, "“hello”,(5) world", goodbye
89 (25%), 33(75%), , 44, "hello world", goodbye
92 (97%), 33(75%), , 44, "hello world", goodbye
Goal
Write back to that file with:
56, 33, , 44, "“hello”,(5) world", goodbye
89, 33, , 44, "hello world", goodbye
92, 33, , 44, "hello world"... | stackexchange_codegolf |
The challenge here is to accurately depict the flower of life (which is a sacred geometrical figure according to some) in the language of your choice.
The design consists an arrangement of circles and partial circles of radius 1 as shown whose centres arranged on a triangular grid of pitch 1, plus one larger circle of... | stackexchange_codegolf |
It's election time, and your job is to beat your competitor in a head-on rivalry! You are both trying to win over a city of 256 people in a 16x16 grid. Right now, the city hasn't been divided into voting regions yet, but that's where your gerrymandering skills come in! You can also campaign in arbitrary areas of the ci... | stackexchange_codegolf |
The set of necklaces is the set of strings, where two strings are considered to be the same necklace if you can rotate one into the other. Your program will take nonnegative integers k and n, and generate a list of the k-ary (fixed) necklaces of length n.
Necklaces will be represented by any representative string. So t... | stackexchange_codegolf |
This challenge is to golf an implementation of SKI formal combinator calculus.
Definition
Terms
S, K, and I are terms.
If x and y are terms then (xy) is a term.
Evaluation
The following three steps will be repeated until none of them apply.
In these, x, y, and z must be terms.
(Ix) will be replaced by x
((Kx)y) will be... | stackexchange_codegolf |
You have been hired by the American embassy in the UK to act as a translator. Being a programmer, you decide to write a program to do a bit of the work for you.
You've found out that often just doing the following things can satisfy Word's spellcheck, which has been set to "English (United States)", somewhat, so you do... | stackexchange_codegolf |
I know, I know, yet another primes challenge...
Related
A lonely (or isolated) prime is a prime number p such that p-2, p+2, p-4, p+4 ... p-2k, p+2k for some k are all composite. We call such a prime a kth-times-isolated prime.
For example, a 5th-times-isolated prime is 211, since all of 201, 203, 205, 207, 209, 213, 2... | stackexchange_codegolf |
Find a maximally profitable sequence of exchanges given an exchange rate table.
As an example consider the currencies Ariary (your home currency), Baht, Cedi, and Denar where the rate from one to another (after any transaction rate has been levied) is given by the (row, column) entry in the exchange rate table below:
... | stackexchange_codegolf |
Your job is to write a program that rewrites and makes itself longer on each run of the program.
Challenge
The program will print Hello, World!\n (\n denotes a newline). Then, it will modify its own file so that the new program length is exactly 2x the length at runtime. This modified file when run, will print Hello, W... | stackexchange_codegolf |
Write a program that takes 2 strings as input, and returns the longest common prefix. This is code-golf, so the answer with the shortest amount of bytes wins.
Test Case 1:
"global" , "glossary"
"glo"
Test Case 2:
"department" , "depart"
"depart"
Test Case 3:
"glove", "dove"
""
| stackexchange_codegolf |
Background
I like my old 8-bit 6502 chip. It's even fun to solve some of the challenges here on PPCG in 6502 machine code. But some things that should be simple (like, read in data or output to stdout) are unnecessarily cumbersome to do in machine code. So there's a rough idea in my mind: Invent my own 8-bit virtual ma... | stackexchange_codegolf |
Your challenge is to write a polyglot that works in different versions of your language. When run, it will always output the language version.
Rules
Your program should work in at least two versions of your language.
Your program's output should only be the version number. No extraneous data.
Your program may use what... | stackexchange_codegolf |
Anyone who has spent any time around a deck of playing cards will recognize the riffle shuffle. The deck is cut in half and the two stacks are riffled simultaneously into the same pile before being tidied up in a sometimes visually appealing way.
This code-golf challenge is to write a function/method/(language equivale... | stackexchange_codegolf |
... Not that you would, would you? The task is simple, output the following text:
____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ________
||` |||1 |||2 |||3 |||4 |||5 |||6 |||7 |||8 |||9 |||0 |||- |||= |||BS ||
||__|||__|||__|||__|||__|||__|||__|||__|||__|||__|||__|||__|||__|||______||
|/__\|/__\... | stackexchange_codegolf |
A followup to this challenge by Jeremy Collprav, inspired by DLosc solving this in Regenerate. Some sections copied from the linked challenge.
Linking chains
We define a chain to be a string containing exactly one or more of only the - character, or 1 or more of only the _ character, or two chains linked by a =. More f... | stackexchange_codegolf |
A palindrome is a word that is its own reverse. I will define the left palindromic root of a word as the shortest prefix of the word for which the shortest possible palindrome that begins with that prefix is the original word. So the left palindromic root of racecar is race and the left palindromic root of ABBA is ABB.... | stackexchange_codegolf |
Code Golf Measurer © 2019
Hexdumps used with xxd look something like this:
00000000: 666f 6f20 6261 7220 7370 616d 2065 6767 foo bar spam egg
00000010: 730a s.
Your task is to convert a hexdump in this form in to the number of bytes used.
Rules:
Usual loopholes forbidden.
This is ... | stackexchange_codegolf |
Provided that the input is a monotone sequence of three or more integers:
Output -2 if the sequence strictly decreases. Example: [7,4,3,2]
Output -1 if the sequence monotone decreases but is neither strict nor constant. Example: [6,5,5]
Output 0 if the sequence is constant. Example: [0,0,0]
Output +1 if the sequenc... | stackexchange_codegolf |
Inspired by this challenge, as well as a problem I've been working on
Problem:
Given a non-empty set of points in 3D space, find the diameter of the smallest sphere that encloses them all. The problem is trivial if the number of points is three or fewer so, for the sake of this challenge, the number of points shall be ... | stackexchange_codegolf |
The Roman numeral for 499 is usually given as CDXCIX which breaks down as CD + XC + IX = 400 + 90 + 9 where numerals like CD and IX are written using subtractive notation. Some programming languages have a roman() function that extends this subtractive notation through various relaxation levels. From Google Sheets docu... | stackexchange_codegolf |
Introduction
During work with BMP (bitmap) generator I face problem of converting number to little endian hex string. Here is function which I create in JavaScript - but wonder how small code can works similarly
let liEnd= num => num.toString(16).padStart(8,'0').match(/../g).reverse().join``;
console.log(liEnd(304767... | stackexchange_codegolf |
Given a positive integer \$n\$ you can always find a tuple \$(k_1,k_2,...,k_m)\$ of integers \$k_i \geqslant 2\$ such that \$k_1 \cdot k_2 \cdot ... \cdot k_m = n\$ and $$k_1 | k_2 \text{ , } k_2 | k_3 \text{ , } \ldots \text{ , }k_{m-1}|k_m.$$
Here \$a|b\$ means \$b\$ is a multiple of \$a\$, say "a divides b". If \$n>... | stackexchange_codegolf |
Is it a good chord?
Definition of a chord:
We define a chord as three notes together.
Definition of a note:
We define a note as a number between 1 and 7, inclusive. As in music, we define 1 as do, 2 as re, 3 as fa, etc. However, the note names are not important. They will not be included in the question and likely not ... | stackexchange_codegolf |
Inputs:
current hour: from 0 to 23 (inclusive)
delta of hours: [current hour] + [delta of hours] = withing the range of Integer
Output:
delta of days: the value which shows difference in days between day of current hour and day of sum [current hour] + [delta of hours]
Scoring
Answers will be scored in bytes with ... | stackexchange_codegolf |
This is a fairly simple challenge.
Write a program that computes the distance between two points on a 2D plane. However, you can't use any functions or operators (referred to here as symbols) that are 1 character long.
Examples:
-=, +=, *=, /=, %=, etc. are allowed.
||, &&, --, ++ are allowed as well.
+, -, /, * are n... | stackexchange_codegolf |
I have the code below working. But there must be a better way.
file <- "http://s3.amazonaws.com/assets.datacamp.com/production/course_1127/datasets/tmp_file.csv"
x <- read.csv(file = file)
ts <- xts(x = x, order.by = as.Date(rownames(x), "%m/%d/%Y"))
cd=coredata(ts)
for (j in 1:length(names(ts))) cd[,j]<-cd[,j]/cd[1,... | stackexchange_codegolf |
The partition function:
In number theory, the partition function p(n) represents the number of possible partitions of a positive integer n into positive integers
For instance, p(4) = 5 because the integer 4 has five possible partitions:
1 + 1 + 1 + 1
1 + 1 + 2
1 + 3
2 + 2
4
Your task:
Accept an input (let's call i... | stackexchange_codegolf |
Challenge
Write a program or function that given a string, returns a valid Brainfuck program that when compiled and executed as Brainfuck, returns that string..
Assume all inputs are encoded as ASCII.
Assume the outputted BF program will execute in an environment with an infinite tape.
Assume the pointer starts at c... | stackexchange_codegolf |
Thanks to rak1507 for the suggestion
"Random" in this challenge always refers to "uniformly random" - of all possible choices, each has an equal chance of being chosen. Uniform shuffling means that every possible permutation of the array has an equal chance of being chosen.
Given an array consisting of positive digit... | stackexchange_codegolf |
The goal of this challenge is to write a program or function that returns the least amount of strikes needed to complete a given course.
Input
The layout of the course can be passed in any suitable way and format you prefer.
(read from the console, passed as an input parameter, read from a file or any other, multilin... | 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 |
You will be given a String consisting of printable ASCII (without newlines). Your task is to build a nice Stairway for my Castle.
How to build a nice Stairway?
First off, you should get all the rotations of the String. For example, the String abcd has the following rotations: abcd, bcda, cdab, dabc (each character is ... | stackexchange_codegolf |
Background and Rules
There is a variant of chess called atomic chess, which follows essentially the same rules as normal chess, except that pieces explodes other pieces around them when captured. In addition to checkmate, you can also win the game by blowing up the king.
When a piece captures another piece, all adjace... | stackexchange_codegolf |
We have lots of horizontal axis for numbers, but I honestly think they're kind of boring. Your task today is to build me a portion of a diagonal axis between two distinct non-negative integers given as input.
How to build a diagonal axis?
Let's take an example, with the input 0, 5. Our axis should look like this:
0
... | stackexchange_codegolf |
Thanks to rak1507 for the suggestion
"Random" in this challenge always refers to "uniformly random" - of all possible choices, each has an equal chance of being chosen. Uniform shuffling means that every possible permutation of the array has an equal chance of being chosen.
Given an array consisting of positive digit... | stackexchange_codegolf |
This sequence is defined as
Starts with 1, 2, 3
The next element of the sequence is the first number greater than the previous three that is co-prime with each of the previous 3 elements in the sequence.
In other words, if the previous 3 elements are a, b, c, then the next is the first integer n>c such that gcd(a,n)=... | stackexchange_codegolf |
In this challenge you will be determining how controversial a vote is, given an array of other votes, by figuring out a number called the C-factor. What is the C-factor, you ask?
Well, imagine you've got multiple votes on an election. We'll use 1 and 0 for the sake of the challenge to represent two different candidates... | stackexchange_codegolf |
For example, how many adjacent swaps are at least needed to convert some string such as BVVKCV to one without any instances of VK?
Input-length of the string will be within the range 1 <= length <= 200.
VK will be hardcoded across all test cases.
Input string examples:
Input: VKVKVVVKVOVKVQKKKVVK
Output: 8
Input: VV... | stackexchange_codegolf |
For the given string s, generate generate a table like below.
Input:abcd
Output:
abcd
bbcd
cccd
dddd
Input:Hello, world!
Output:
Hello, world!
eello, world!
llllo, world!
llllo, world!
ooooo, world!
,,,,,, world!
world!
wwwwwwwworld!
ooooooooorld!
rrrrrrrrrrld!
llllllllllld!
dddddddddddd!
!!!!!!!!!!!!!
Trailin... | stackexchange_codegolf |
The task here is to write a program that takes an natural number, \$n\$, and produces the \$n\$th term of an OEIS sequence. That sequence should have an identifier in the form of A followed by 6 digits. Now when you take your source code and reverse the order of it's bytes to produce a new program, that program shoul... | stackexchange_codegolf |
Sometimes authors will write (s)he as a stand in for she or he and for some reason they don't want to use singular they. This is ok for the nominative but doesn't work so well when you want to write "her or him". You can write h(er)(im) which covers both cases but gives two extra "pronouns"
h
her
him
herim
In formal... | stackexchange_codegolf |
Your task is to build a program that identifies the shape of the input. The shapes to be identified can be any of the following:
Square
To be identified as a square, the source must have lines of all equal length, and the same number of lines as characters per line (newline characters excluded). An optional trailing ne... | stackexchange_codegolf |
Entries are now closed. Any new entries or edits will not be counted in the final run.
Join the chat!
Challenge
Try to fill the canvas with as much paint as possible. Be careful of other bots that may paint over your hard work though!
Note: In this challenge description, paint means to change the colour of the squar... | stackexchange_codegolf |
I'd like you to build me a clock that displays time in this format:
18 ----------
19 --------------------------------------------------
This displays '18:10'. The current hour and the next hour are shown at the front of the line, followed by a space and a number of dashes: on the first line the number of minutes that ... | stackexchange_codegolf |
For Gregorian calendars, the date format varies from a country to another. There are three main formats recognized:
YY-MM-DD (big-endian)
DD-MM-YY (little-endian)
MM-DD-YY (middle-endian)
Your task is to write a program which, given an input string representing a date, output all the possible date formats by which th... | stackexchange_codegolf |
The question: Given an a number n ≥ 2, how many distinct pairs of points on an n-dimensional n x n x n x n x n x n ... x n lattice, where the coordinates range from 0 to n - 1, are a distance at least n apart? The pairs {(2,1,3,1), (3,2,1,3)} and {(3,2,1,3), (2,1,3,1)} are not considered distinct from each other, as th... | stackexchange_codegolf |
Challenge Taken with permission from my University Code Challenge Contest
The dependence we have on mobile phones makes us charge them every night up to the maximum level of the battery, so we do not run the risk of running out of power by the middle of the next day. There are even people who, when they see a free out... | stackexchange_codegolf |
Input is a single integer in ascending digit order.
The only valid inputs are:
12
123
1234
12345
123456
1234567
12345678
123456789
The only valid output is an array (set; list) of length equal to the factorial of input:
Input - Factorial of input - Output array length
12 -> 1*2 -> 2
123 -> 1*2*3 -> 6
1234 -> 1*2*3*4 ->... | stackexchange_codegolf |
Task
A reverse checkers position is a chess position where every piece for one player is on one colour and every piece for the other player is on the other colour. Your task is to find if the given (valid) position meets these criteria.
For example, this position does (click for larger images). Every white piece is on ... | stackexchange_codegolf |
Given two strings containing only 0 and 1, decide the probability that first appears earlier as a consecutive substring in an infinite random 0/1 stream.
You can assume that neither string is suffix of the other string, so 01, 1, 00, 0 are invalid. (*)
IO format flexible. Your answer should be precise given ideal float... | stackexchange_codegolf |
A woman works at a lottery ball factory. She's instructed to open up a lottery ball creation kit composed of 1 red rubber ball and n strips of digits from 0 through 9.
She's instructed to do the following:
Starting with 1, write the current number on the ball using the digits available on the n strips.
Put unused... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.