instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
You are to write a program which outputs a single positive integer \$n\$. The integer may have leading zeros and whitespace, and/or trailing whitespace.
Then, choose a positive integer \$m > 1\$. When the program is repeated exactly \$m\$ times, it should output \$m \times n\$ (and only \$m\times n\$). When repeated an... | stackexchange_codegolf |
Pick a quote or phrase that is exactly 5 words long, such as Programming puzzles and code golf!.
Write a program that, when appended to itself n times, outputs the first n + 1 words of your phrase in order.
For example, if your program code was MYPROG and your phrase was Programming puzzles and code golf!, running...
... | stackexchange_codegolf |
Inspired by We do tower hopping and related to 2D Maze Minus 1D
Introduction
Your task is to find the shortest path to get out of an array maze following specified rules.
Challenge
A 1D array a with n elements can be regarded as a maze composed of n points, where point with index k is connected to the points with k+a[k... | stackexchange_codegolf |
Challenge
Given a quark composition of a particle as input, output the corresponding hadron's name.
Quarks will be represented by a capital letter and antiquarks by a lowercase letter.
The quarks may be in any order, not necessarily the order given below.
Built-in functions the access data about particles and/or quarks... | stackexchange_codegolf |
The wizard is determined to pose the most challenging challenge yet for which he believes the previous solution techniques will not work. He decides to go multidimensional.
If there is a number line with \$x = 10\$ then your task is to prove this. If you do so you win. In this situation, for your code to be correct, ... | stackexchange_codegolf |
My parents have an home theater device. The remote is broken making it incredibly difficult to navigate rightwards in a menu. Most the time it doesn't work but when it does it moves rightwards incredibly quickly.
This is obviously frustrating but it is most frustrating when you want to enter a movie title which requi... | stackexchange_codegolf |
Heavily inspired by Hello, World! (Every other character)
Write a program that outputs 1. When the first, third, fifth, etc. chars are removed, it outputs 2. When all chars where their (1-based) index in the source, mod N, are not 0, are removed, it should output N.
This is code-challenge. The winner is the program tha... | stackexchange_codegolf |
Given an integer N perform the following steps: (using 9 as an example).
Receive input N. (9)
Convert N from base10 to base2. (1001)
Increase every bit by 1. (2112)
Treat the result as base3 and convert it back to base10. (68)
Return/Output the result.
Input
May be received in any reasonable number format.
You only ... | stackexchange_codegolf |
Background
Inspired by I'm a palindrome. Are you?, where it is presented the shocking fact that “()() is not a palindrome, but ())(”, I asked myself what instead is ()() and the answer is simply: it is a string with a vertical symmetry axis!
The task
Write a program or function that takes a string S (or the appropriate... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
Inspired by https://xkcd.com/835
In the midst of his mid-life crisis, Santa has impulsively purchased a Sports Sleigh™ for present delivery this year. The only problem is that this sleigh has a specially designed Infinite Present Trunk... | stackexchange_codegolf |
Task
Given a positive integer n, output n+1 if n is odd, and output n-1 if n is even.
Input
A positive integer. You may assume that the integer is within the handling capability of the language.
Output
A positive integer, specified above.
Testcases
input output
1 2
2 1
3 4
4 3
5 ... | stackexchange_codegolf |
It is the year MDLXVII in a world in which the Roman Empire never fell, and the collapse into the dark ages never occurred. Due to the extended period of Pax Romana, the empire's economic stability enabled technology to progress at a rapid rate.
The Romans have begun to dabble with circuitry, and have invented an inge... | stackexchange_codegolf |
I have read a question similar to this. I found it interesting, and difficult so I rephrased the question as a code golf. (that question is closed )
Challenge:
In 1 million and 1 numbers, all the numbers having the duplicate except only one number . Write a program that can find this unique number.
Input form:
a t... | stackexchange_codegolf |
My dog ate my calendar, and now my days are all mixed up. I tried putting it back together, but I keep mixing up the days of the week! I need some help putting my calendar back together, with the days in the correct order.
And since I need my calendar put together as fast as possible, don't waste my time by sending me ... | stackexchange_codegolf |
Your input is an array of integers in the range [-1,4]. An array element of -1 means that there might be a bomb in that position. A non-negative element means that there is not a bomb in that position and also the numeric value tells how many bombs there are within distance 2.
For example, if we have the following arra... | stackexchange_codegolf |
Scratch is a visual programming language. For the sake of counting bytes, Scratch is usually written in scratchblocks2 syntax.
Post tips that specifically apply to Scratch or scratchblocks2.
| stackexchange_codegolf |
Cops thread
Your task as robbers is to find cops solutions and write a program in the language provided that computes the nth term of the sequence using only the bytes in the provided set.
The goal will be to crack as many cops answers as possible. With each crack awarding you a single point.
Cracks need not be th... | stackexchange_codegolf |
You are required to generate a random 18-hole golf course.
Example output:
[3 4 3 5 5 4 4 4 5 3 3 4 4 3 4 5 5 4]
Rules:
Your program must output a list of hole lengths for exactly 18 holes
Each hole must have a length of 3, 4 or 5
The hole lengths must add up to 72 for the entire course
Your program must be able to p... | stackexchange_codegolf |
The challenge is to golf a program when given a string composed of any number of asterisks, then a comma, than any number of asterisks, say which side has more.
The asterisk-strings can be empty.
Output
0 for ties.
1 for the left.
2 for the right.
Examples
Input: ***,**** Output: 2
Input: ***, Output: 1
Input: ***,*** ... | stackexchange_codegolf |
Introduction
How much of the English alphabet does a given string use? The previous sentence uses 77%. It has 20 unique letters (howmucftenglisapbdvr), and 20/26 ≃ 0.77.
Challenge
For an input string, return the percentage of letters of the English alphabet present in the string.
The answer can be in percentage or in ... | stackexchange_codegolf |
Challenge:
Create a program or function that takes an integer input, which outputs a new program/function as specified below.
Input:
Integer n: Time in seconds before the Time Bomb explodes.
Output:
The original program which had the time in seconds n as input, will output a new program/function that does the following... | stackexchange_codegolf |
There is a building with an infinite number of floors and you are the only passenger in an elevator which can lift an infinite number of people. You are going home, but before the elevator gets to your floor, the elevator stops at another floor to allow people to enter the elevator and input their destination floors. Y... | stackexchange_codegolf |
Origins
tl;dw (too lazy, didn't write): thought of it right before I fell asleep
Challenge
Breaking a number is defined as the following steps:
Take a number or a parseable data type as input in any allowed way.
Duplicate the first digit (64 -> 664)
Subtract 4 from the last digit (664 -> 660)
If the subtraction gets... | stackexchange_codegolf |
Your challenge: write a "program", for a language of your choice, that causes the compiler/interpreter/runtime to produce error output when compiling/running your program which is identical to your program's source code.
Rules:
Your program may be specific to a particular version or implementation of your language's c... | stackexchange_codegolf |
Definition
Given some number, x calculate the smallest number i such that 2i≥x. This is not a duplicate of this question. It is slightly different in that an input of 16 should yield an output of 4 whereas 16 returns 5 in the linked question.
Input
Input will be an unsigned 32-bit integer.
Output
Output will be an unsi... | stackexchange_codegolf |
Write a program that outputs the number 0.
That's a bit trivial, isn't it?
Let's sort all distinct permutations of your code in lexicographical order. When any of these codes are run, it should output the its location in the array (0-indexed or 1-indexed).
This means that your code must be the lexicographically smalles... | stackexchange_codegolf |
Let us play a little golfing game.
Given a single line of N space separated numbers from STDIN, one must output those numbers on N lines.
So far, I came up with the three following bash solutions :
xargs -n1 (9)
tr \ \\n (8)
fmt -1 (6)
Can anyone do better? I am eager to learn new tricks
| stackexchange_codegolf |
Tom is going to implement a new programming language of his invention. But before actually starting working on it, he wants to know whether his language should be case sensitive or not.
On one hand, case insensitivity seems more easy to implement to him, but he worries that it could cause a lack in the possibilities o... | stackexchange_codegolf |
All bots at the battle arena suddenly got brainfucked and no one can explain why. But who cares as long as they are still able to fight - although Brainfuck is the only language they understand anymore.
It's been a while since the last submission so I'll finally annouce the winner of BrainFuckedBotsForBattling: Congra... | stackexchange_codegolf |
Background
A super-prime is a prime number whose index in the list of all primes is also prime. The sequence looks like this:
3, 5, 11, 17, 31, 41, 59, 67, 83, 109, 127, 157, 179, 191, ...
This is sequence A006450 in the OEIS.
Challenge
Given a positive integer, determine whether it is a super-prime.
Test Cases
2: f... | stackexchange_codegolf |
Introduction to Numerical Mathematics
This is the "Hello, World!" of PDEs (Partial Differential Equations). The Laplace or Diffusion Equation appears often in Physics, for example Heat Equation, Deforming, Fluid Dynamics, etc... As real life is 3D but we want to say "Hello, World!" and not sing "99 bottles of beer,..."... | stackexchange_codegolf |
Because we haven't had enough of these, let's do another weird language!
+ increments the accumulator
- decrements the accumulator
# outputs the character with the codepoint of the accumulator modulo 127, and then resets the accumulator
$ is like # but it doesn't reset the accumulator
% reads a single character of inp... | stackexchange_codegolf |
Find the shortest function/algorithm to translate these numbers to the ones after the dash:
0 - 0
1 - 10
2 - 20
3 - 30
4 - 40
5 - 50
6 - 60
7 - 70
8 - 80
9 - 90
10 - 100
11 - 115
12 - 130
13 - 150
14 - 175
15 - 200
16 - 230
17 - 260
18 - 300
19 - 350
20 - 400
Every integer higher than 20 is calculated by subtracting 1... | stackexchange_codegolf |
A simple register calculator
This challenge involve a simple register calculator that works in the following way:
It has some registers named A,B,C,...,Z, each of them can contain an integer, they are all initialized to 0.
It executes instructions of 3 characters: The first character of any instruction is one of +,-,*... | stackexchange_codegolf |
Does your language have a maximum recursion depth (MRD)?
Let's say your language has MRD=500
Write a code that finds the recursion depth and outputs the exact value
For the case above your program (or function) should output 500
Code-Golf
Shortest answer wins!
| stackexchange_codegolf |
Write a function or program that accepts a date (as a string in YYYY-MM-DD format) as input and returns a truthy value if that date is "alphabetical," and a falsey value if it isn't.
An alphabetical date is a date whose month, day and year are in alphabetical order when expressed as a string (and when considered speci... | stackexchange_codegolf |
Your task is, given x, output 2*x. Easy right!? But there's a catch: x will be given as a (possibly infinite) continued fraction, and the output must be a continued fraction. The input is guaranteed to be a real algebraic number whose degree is at most 2.
Input: The continued fraction of x. This is split into 3 parts: ... | stackexchange_codegolf |
Monday, October 31st, is Halloween. And it got me thinking -- I wonder what other months have the last day of the month also be a Monday?
Input
A positive integer in any convenient format representing a year, 10000 > y > 0.
The input can be padded with zeros (e.g., 0025 for year 25) if
required.
Output
A list of the... | stackexchange_codegolf |
Background
I want to display rich, vibrant images on my theoretical fancy custom display, but due to budget constraints, it displays everything in 3-bit colour! Whilst Regular Dithering would work, I don't want to sacrifice resolution, so I would like my images to be dithered through time!
Specs
Provided an Input Image... | stackexchange_codegolf |
Let \$\sigma(n)\$ represent the divisor sum of \$n\$ and \$\sigma^m(n)\$ represent the repeated application of the divisor function \$m\$ times.
Perfect numbers are numbers whose divisor sum equals their double or \$\sigma(n) = 2n\$. For example, \$\sigma(6) = 12 = 2\times6\$
Superperfect numbers are numbers whose twic... | stackexchange_codegolf |
Consider a word/string of length \$n\$, only including the letters A-Z, a-z. A word/string is a double prime word if and only if n is prime and the sum of the letters, s, is also prime, using their numeric position in the alphabet (a=1, B=2, c=3, etc.).
Input can be any combination of upper or lower case alphabetic cha... | stackexchange_codegolf |
Write a program or function that prints or outputs this exact text (consisting of 142 characters):
()()()()()()
|\3.1415926|
|:\53589793|
\::\2384626|
\::\433832|
\::\79502|
\::\8841|
\::\971|
\::\69|
\::\3|
\__\|
Your program must take no input (except in languages where this is impossible... | stackexchange_codegolf |
Your task is to generate an emoticon of three characters, the first character being one eye, the second the mouth, and the third another eye. Each eye is a random one of these characters: $'*+-;O^`ox~, and the mouth is a random one of these: ,-._coux.
Each eye and the mouth must be on the same general level. These eyes... | stackexchange_codegolf |
Given \$x\$ distinguishable balls (say they have different colors), sample with replacement repeatedly until all the balls that have been seen, have been seen at least twice.
Challenge
The input is the integer value \$x \geq 2\$.
The challenge is to compute the probability that you would have seen all the balls when yo... | stackexchange_codegolf |
Introduction
Our goal is to efficiently find the maximum of a large amount of (redundant) data.
We define the outer product of vectors \$A\$ and \$B\$ as a matrix containing the products of all entries of \$A\$ with each entry of \$B\$. (see outer Product)
$$
A\otimes B := A\cdot B^T = \left(\begin{array}{rrr}
A(1)\cdo... | stackexchange_codegolf |
Given a string of printable ASCII text (including newlines and spaces) that contains at least one character that is neither a newline nor a space, output a truthy value if the string is rectangular, and a falsey value otherwise. Additionally, the source code for your solution must be rectangular.
A string is rectangula... | stackexchange_codegolf |
S. Ryley proved following theorem in 1825:
Every rational number can be expressed as a sum of three rational cubes.
Challenge
Given some rational number \$r \in \mathbb Q \$ find three rational numbers \$a,b,c \in \mathbb Q\$ such that $$r= a^3+b^3+c^3.$$
Details
Your submission should be able to compute a solution f... | stackexchange_codegolf |
Inspired by a challenge from the OUCC 2022 Seniors competition.
Background
Two teams are playing "capture the flag". They take turns invading each other's base and capturing their opposing team's flag in the shortest amount of time. The attacking players each have one soft ball they can throw at the defenders. Teams ge... | stackexchange_codegolf |
Challenge Taken with permission from my University Code Challenge Contest
For some years now, the number of students in my school has been growing steadily. First the number of students was increased by classroom, but then it was necessary to convert some spaces for some groups to give classes there, such as the gym s... | stackexchange_codegolf |
Inspired by this Puzzling challenge.
Challenge
Given a 2D rectangular grid where each cell is either an empty space or a wall, find the path (or one of the paths) from the top left cell to the bottom right, which satisfies the following:
Only movement to one of four adjacent cells is allowed.
The path breaks (or passe... | stackexchange_codegolf |
Let's say I have a condition expression x and that I want to check if it is TRUE or FALSE depending on the value of a boolean y:
y ? x : !x
Is there a way to express it without repeating x expression? Something like how we can get a number or its opposite depending on a bool, without repeating the number in the expres... | stackexchange_codegolf |
Challenge
Your task is to generate a string using this sequence:
1,1,2,1,1,2,3,2,1,1,3,2,4,2,3,1,....
Which is more understandable in this format:
1
1 2 1
1 2 3 2 1
1 3 2 4 2 3 1
1 4 3 2 5 2 3 4 1
The pattern increases the number of Digits in the string by two for each increment in the Value of N
For each integer val... | stackexchange_codegolf |
Something I found while looking through some old files. It seemed like a neat idea for a code golf challenge.
The intro
One of the most popular events at the annual Cyclist's Grand Competition for Charity (CGCC) is the rocket bike parcours. The rules are simple: Inspect the parcours and place a bet on wheather is it po... | stackexchange_codegolf |
As of 13/03/2018 16:45 UTC, the winner is answer #345, by Khuldraeseth na'Barya. This means the contest is officially over, but feel free to continue posting answers, just so long as they follow the rules.
As well, just a quick shout out to the top three answerers in terms of numbers of answers:
1. NieDzejkob - 41 ans... | stackexchange_codegolf |
Jellyfish is a two-dimensional esoteric programming language inspired by J and written in Python 3. It was inspired by a challenge on PPCG. The name was suggested in PPCG chat as a combination of Jelly, a golfing language inspired by J, and Fish, a two-dimensional esoteric language.
What general tips do you have for ... | 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 |
As we all know, negative press covfefe has been conspiring to bring down the American president for some months now.
There's also, definitely, an algorithm in play in that word. Covfe is a refreshing caffeinated beverage, and following the president's remarks it's clear the word can now be appended with successive f's ... | stackexchange_codegolf |
Your task: given a nonzero positive number i, calculate pi using the Nilakantha series unto i terms.
The Nilakantha series is as follows:
$$\text 3 + \frac{4}{2 \times 3 \times 4} - \frac{4}{4 \times 5\times 6}+\frac{4}{6 \times 7 \times 8} - ...$$
3 is the first term, 4/2*3*4 is the second, -4/4*5*6 is the third, and... | stackexchange_codegolf |
Challenge
Draw lines in ASCII corresponding to given inputs:
in the first line there are given size of rows and columns of the view and number of separators between each point
in the second line is given list of lines separated by space
a line contains the position of head and tail coordinates (within the size of colum... | stackexchange_codegolf |
Background
Famously, the acronym GNU stands for GNU's Not Unix. 1
It's recursive because, after expanding it once, it still contains the acronym GNU, and so must be exanded again:
(GNU's Not Unix)'s Not Unix
And so on, ad infinitum. Visualizing this, we get a kind of Droste effect:
┌─────────────────────────────────... | stackexchange_codegolf |
Input: an array of length \$n\$ containing integers in the range \$0\$ to \$2n\$.
For each integer \$x\$ in the array, compute the number of integers that occur before \$x\$ that are no larger than \$x\$.
As an example, if the array is
[3, 0, 1, 4, 3, 6]
the output should be equivalent to:
3: 0
0: 0
1: 1
4: 3
3: 3
6: ... | stackexchange_codegolf |
"A picture is worth a thousand words"—so the old saying goes. The average word is about four characters long, so a picture conveys 4kB of information. But how much entropy, rather than information, can a picture convey?
Your task is to generate an image, exactly 4,000 bytes in size, with the highest entropy possible. Y... | stackexchange_codegolf |
In the language Nim, the rules for differentiating identifiers are slightly more relaxed than most other languages. Two identifiers are equivalent or address the same variable if they follow these rules:
the first character of both are the same (case sensitive)
both strings are the same (case insensitive) after removi... | stackexchange_codegolf |
Prompt:
You are given two sets of XY coordinates along with two angles (all are floats): X1 Y1 A1 X2 Y2 A2. The angles are relative to world coordinates: 0 being straight up or north and going clockwise.
Your program or function has to return a set of two floats of the XY coordinates the two angles cross at.
Example:
... | stackexchange_codegolf |
There are 97 ASCII characters that people encounter on a regular basis. They fall into four categories:
Letters (52 total)
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
Numbers or Digits (10 total)
0123456789
Symbols & Punctuation (32 total)
!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
Whitespace (3 total)
Space , tab ... | stackexchange_codegolf |
The prospect of this challenge is:
If your program is run normally, all of the code in the speech marks (" - double quotes) should be printed.
If your program is wrapped in double quotes (in turn inverting the speech marks), the code that is normally not in quotes should be printed.
E.g:
Let's say you have the follow... | stackexchange_codegolf |
As you probably know, there is a war going on in Ukraine. I noticed that it seems nobody has posted a Ukrainian flag challenge yet, so I thought I'd do it myself in support of Ukraine.
The Challenge
Here is the flag:
The flag is divided horizontally across the middle into two equally sized stripes.
Stripe colors: (0,... | stackexchange_codegolf |
Martin Ender's 2D programming language Alice has two different modes depending on what orientation the IP has: orthogonal (Cardinal mode) or diagonal (Ordinal mode). Commands in Alice change their meaning depending on which mode the program is in when they're executed. One especially interesting implementation of this ... | stackexchange_codegolf |
This challenge is inspired by this other.
The challenge
Write a program or a function in any programming language that given as input a string representing a time in English (see below, for further details) it outputs or prints the equivalent in the 24 hours "digital" format HH:MM.
Shortest code in bytes wins, standard... | stackexchange_codegolf |
Prompt:
You are given two sets of XY coordinates along with two angles (all are floats): X1 Y1 A1 X2 Y2 A2. The angles are relative to world coordinates: 0 being straight up or north and going clockwise.
Your program or function has to return a set of two floats of the XY coordinates the two angles cross at.
Example:
... | stackexchange_codegolf |
The challenge, should you accept it, is to determine how much you win in the Bingo Golf Flax Lottery. Based on but not equal to the BingoFlax lottery
The input is two lists of numbers (positive non-zero integers).
The first list always contains 24 potentially non-unique numbers that make up your board, a 5 x 5 grid of ... | stackexchange_codegolf |
We have some new sheriffs moderators in town, Mego and DJMcMayhem. We need a challenge to properly honour them for their new positions, so there we go.
Here's something that has caught my attention when hovering over their profiles – their user IDs are \$31716\$ and \$45941\$. If you perform digit-wise subtraction, y... | stackexchange_codegolf |
What tips do you have for code-golfing in the V lang? I have been trying to find ways to shorten codegolfs on there but can't find any resources on it. Do you guys have any?
Please suggest tips that are at least somewhat specific to the V programming language (e.g. "remove comments" isn't helpful).
Please post one tip ... | stackexchange_codegolf |
Challenge
Write a program that takes an array of 4 integers (which represents a sequence of numbers generated by a certain algorithm) and returns the next integer that would follow.
We will only be using simple addition, subtraction, multiplication and division algorithms with a constant (i.e non-variable) variation.... | stackexchange_codegolf |
Background
Benford's Law is freaky!
Of all the numbers in the world, roughly 30% of them start with a 1! 17.6% start with a 2, 12.5% start with a 3, and so on, and so on.
For example, take a look at the following graph. Take the largest 120000 towns in the world, take their altitude, and voila - they obey Benford's law... | stackexchange_codegolf |
Related: Cleaning up decimal numbers
Background
A continued fraction is a way to represent a real number as a sequence of integers in the following sense:
$$
x = a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{\ddots + \cfrac{1}{a_n}}}} = [a_0; a_1,a_2,\cdots,a_n]
$$
Finite continued fractions represent rational number... | stackexchange_codegolf |
Here is a 1.2Mb ASCII text file containing the text of Herman Melville's Moby-Dick; or, The Whale. Your task is to write a program or function (or class, etc. -- see below) which will be given this file one character at a time, and at each step must guess the next character.
This is code-challenge. Your score will be
2... | stackexchange_codegolf |
I love BATCH, despite its shocking lack of functional commands, despite even due to its lack of non-integer support. Why? Because this works:
SET var=SET
%var% i=0
This would evaluate to:
SET var=SET
SET i=0
Fantastic, isn't it? I've used this technique in a BATCH program before, because it saves bytes!
Your challeng... | stackexchange_codegolf |
The task is to provide code that evaluates to 0.5 numerically, i.e. the output must be recognized by your chosen language as a numeric value (Number, float, double, etc), not as a string. The catch, the characters 0 through to 9 cannot be used.
PLEASE NOTE: This IS NOT a golfing challenge, this is a popularity contest,... | stackexchange_codegolf |
This is a relatively simple question. I'm trying to golf a Snake game I've written, and I'm trying to work out if there's a way to golf the following conditional assignments which control x and y coordinates of the snake ensuring a wrap around of the play area:
if (P<0) {
P = T-1;
}
if (P>T-1) {
P = 0;
}
if (Q<0) {... | stackexchange_codegolf |
Given a universe of \$v\$ elements, a Kirkman triple system is a set of \$(v-1)/2\$ classes each having \$v/3\$ blocks each having three elements, so that
every pair of elements appears in exactly one block
all classes are partitions of the universe.
Kirkman's schoolgirl problem corresponds to the \$v=15\$ case.
Fif... | stackexchange_codegolf |
Given two positive integers \$n\$ and \$b\$, such that \$n > 2\$ and \$n > b > 1\$, count the trailing zeros when converting \$n\$ to base \$b\$. Your program should be able to handle any value of \$b\$ within your integer maximum.
The digits of \$n = 18\$, \$b = 3\$ are \$[2,0,0]\$, so the correct output is \$2\$.
T... | stackexchange_codegolf |
Who doesn't absolutely love permutations, right? I know, they are amazing––so much fun!
Well, why not take this fun and make it funner?
Here's the challenge:
Given an input in the exact form: nPr, where n is the pool taken from and r is the number of selections from that pool (and n and r are integers), output/return t... | stackexchange_codegolf |
Given a rectangular grid of text, line up the diagonals that go from the upper-left to the bottom-right into columns such that the lowest-rightmost characters of all diagonals are on a level. Use spaces for indentation.
For example, if the input grid of text is
abcd
1234
WXYZ
then you'd line up the diagonals W, 1X, a2... | stackexchange_codegolf |
A boolean circuit in TCS is basically a DAG consisting of And, Or, Not gates, and by what is known is "functional completeness" they can compute all possible functions. eg this is the basic principle in an ALU.
Challenge: create a circuit to determine whether an 8-binary-digit number is divisible by 3 and somehow vis... | stackexchange_codegolf |
Skittles are colored candy where there are 5 distinct flavors; grape, green apple, lemon, orange, and strawberry represented by (p)urple, (g)reen, (y)ellow, (o)range, and (r)ed respectively. I used to eat skittles by sorting all the different colors, then eating them in sequence. After getting a few weird looks in the ... | stackexchange_codegolf |
Special thanks to Bubbler and AdmBorkBork for supplying feedback about this challenge
Keta (Keyboard tacit — clever naming, I know!) is a golfing language I’ve been working on recently. One of it’s features is it’s most probably unique bracket autocompletion system, which will hopefully allow for shorter programs.
The... | stackexchange_codegolf |
xkcd is everyone's favorite webcomic, and you will be writing a program that will bring a little bit more humor to us all.
Your objective in this challenge is to write a program which will take a number as input and display that xkcd and its title-text (mousover text).
Input
Your program will take a positive integer a... | stackexchange_codegolf |
Task
Given one non-whitespace printable character, make a 3x3 square representation of that input. For example, if the input is #, then the output is:
###
# #
###
Rules
The output format is strict, although a trailing newline is allowed. It means that the space in the middle is required, and also that the two newline... | stackexchange_codegolf |
Given a list of the populations of each state, output, from greatest to least, the number of votes that state gets in the electoral college.
Input: The first number represents the total number of votes to distribute; it is followed by a list of and populations. In this example, abbreviations for states are used, but an... | stackexchange_codegolf |
Inspired by this and this question
Challenge
Your challenge is to print any 100 consecutive digits of Champernowne's Constant. You must give the index at which that subsequence appears. The 0 at the beginning is not included.
For example, you could print any of the following:
+-----+------------------------------------... | stackexchange_codegolf |
My two kids like to play with the following toy:
The colored areas with the shapes inside can be touched and the turtle then lights the area and plays a sound or says the name of the color or the shape inside. The middle button changes the mode. There is one mode in which the areas play different musical notes when to... | stackexchange_codegolf |
A tower is made out of layers, each one being one unit shorter than the one below it. Every layer is completely on top of the previous layer. For example, here is a tower along with it's height map:
#
##
###
####
#####
14532
Because the lengths of the layers are the integers from 1 to n, and because the layers ar... | stackexchange_codegolf |
It is Halloween and Jimmy (/o\) has gone into a mysterious neighborhood for trick-or-treating (ask himself why). Now some evil ghosts are chasing him. Can Jimmy escape the ghosts?
Challenge:
Input:
A board showing position of Jimmy, ghosts, solid objects and empty spaces.
An example 10x5 board, o is Jimmy (we needed a ... | stackexchange_codegolf |
Definition
Let's call an (infinite) integer sequence universal if it contains every finite integer sequence as a contiguous subsequence.
In other words, the integer sequence (a1, a2, …) is universal if and only if, for each finite integer sequence (b1, …, bn), there is an offset k such that (ak+1, …, ak+n) = (b1, …, bn... | stackexchange_codegolf |
This is a Cops and Robbers challenge. For the Cops' thread, go here.
The Cops have three tasks.
1) Pick a sequence from the OEIS.
2) Pick a language (this is suggested to be a golflang, but doesn't have to be) that, when given input n, outputs A(n) (where A(n) is the sequence chosen) using all usual code-golf rules.
... | stackexchange_codegolf |
Web safe colors are in intervals of 51, they include 0, 3, 6, 9, c, and, f as digits in hex (such as #993333), or 0, 51, 102, 153, 204, 255 in decimal. Your task today is convert a given color to a web safe one. You may read more about web safe colors on Wikipedia.
Input
You will take in 3 integers between 0, 255 inclu... | stackexchange_codegolf |
Introduction
In the video the best way to count, binary is proposed as the best system of counting numbers. Along with this argument is a proposal on how to say numbers in this system. First, we give names to each "double power of two", \$2^{2^n}\$ for each \$n\$.
number = symbol = spoken
============================
2... | stackexchange_codegolf |
Given a string, your task is to collapse it into a zigzag-like structure as described below.
Folding into a Zigzag
We'll take the string "Mississippi" as an example:
First, output the longest prefix consisting of unique characters only:
Mis
When you reach the first duplicate character C, ignore it, and output the lo... | stackexchange_codegolf |
Background
You have again, again been given the task of calculating the number of landmines in a field. But this time, the field is foggy.
You must calculate the landmine score given a list/string of numbers, the landmine number, and the land distance (all are numbers).
The landmine number tells you where landmines are... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.