instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
\$\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 |
Specification
Write the shortest possible code in any language that does the following:
It takes two arguments, x and y, and generates x + y lines of text.
The first x lines should consist of y nested pairs of square brackets separated by a space surrounding a single digit, which cycles from 1 to 9, then 0 to 9, etc. f... | stackexchange_codegolf |
It's a normal truth machine but instead of taking input, it uses the first character of the program. Thus, internal.
The 0 and 1 are plain characters, i.e. ASCII code 0x30 and 0x31 respectively.
Example: 0abcd prints 0 and halts, and 1abcd prints 1 infinitely. Then your submission is abcd, whose score is 4 bytes. The 0... | stackexchange_codegolf |
The idea of this challenge is to find all the words from a dictionary on a grid of letters. Your input should come from stdin or function arg and will come in the following format:
[your dictionary as a list of space sep words]
[a grid of letters]
Example:
The cool car
looc
thea
jopr
Rules for finding a match
A matc... | stackexchange_codegolf |
Inspired by Find the “unwrapped size” of a list.
Define the Recursive Size, RS, of a list containing no lists as its length (number of items contained) and the Recursive Size of a list containing any lists as the sum of its length and the Recursive Size of those lists.
Challenge
Write a program or function that outputs... | stackexchange_codegolf |
Steganographic Squares
Your job is to take in a string, and generate an NxN image that represents this string. You must also write the algorithm that takes in the image and turns it back into a string as well. The scoring will be will include the byte count of both algorithms:
"Encryption" Algorithm + "Decryption" Algo... | stackexchange_codegolf |
Your challenge is to make an infinite loading screen, that looks like this:
Or, to be more specific:
Take no input.
Output Loading..., with a trailing space, but no trailing newline.
Infinitely cycle through the chars |, /, - and \: every 0.25 seconds, overwrite the last one with the next in the sequence. You can ov... | stackexchange_codegolf |
Write a program which will take for input 2 integer arrays and return a truthy value if there exists an element which is present in both of arrays, or a falsy one otherwise. The obvious solution to this problem would be to iterate through each element in the first array and compare it against each element in the second... | stackexchange_codegolf |
An abelian sandpile, for our purposes, is an infinite grid with integer coordinates, initially empty of sand. After each second, a grain of sand is placed at (0,0). Whenever a grid cell has 4 or more grains of sand, it spills one grain of sand to each of its four neighbors simultaneously. The neighbors of (x,y) are (x-... | stackexchange_codegolf |
As you may know, the typical binary floating point numbers in a computer language are quite different than the typical integer numbers in a computer language. Floating point numbers can represent a much larger range, and can represent fractional amounts, however there is a trade-off that is frequently elided.
The dista... | stackexchange_codegolf |
Given a list of integers, your task is to output the second largest value in the first k elements, for each k between 2 and the length of the input list.
In other words, output the second largest value for each prefix of the input.
You can output an arbitrary value for the first element (where k = 1), or simply omit th... | stackexchange_codegolf |
Introduction
Write a program or function that, given the coordinates of where a dart lands on a dartboard, return the score of that dart. Dart coordinates are given as two integers, x,y measured from the center of the dartboard, with millimeter precision.
How to score a dart
Darts is a game played by throwing a dart at... | stackexchange_codegolf |
Most tip calculator apps simply take a flat percentage of the meal price. So, for example, if your meal is $23.45, you can leave a 15% tip = $3.52, or a more generous 20% tip = $4.69.
Convenient enough for credit card users. But not so if you prefer to leave cash tips, in which case these oddball cent amounts get in ... | stackexchange_codegolf |
Introduction
Everyone knows the FizzBuzz sequence. It goes something like this:
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
.
.
.
In case you don't know, if the number is divisible by 3, it's Fizz. If it is divisible by 5, it's Buzz. If it is divisible by both, it's FizzBuzz. If it is not divisible by bo... | stackexchange_codegolf |
What is the smallest possible runnable Mach-O executable on x86_64? The program can do nothing (not even returning a return code), but must be a valid executable (must run without errors).
My try:
GNU Assembler (null.s):
.text
.globl _main
_main:
retq
Compilation & Linking:
as -o null.o null.s
ld -e _main -macosx... | stackexchange_codegolf |
Input
Two non-negative floating point numbers \$x < y\$. You can assume they are close enough to each other that there is no integer between \$x\$ and \$y\$.
Output
A fraction with the smallest possible denomination that lies strictly between \$x\$ and \$y\$.
Examples
Input: 1 and 2
Output: 3/2
Input: 0 and 0.33
Output... | stackexchange_codegolf |
Inspired by this challenge, which got closed. This is meant to be an easier, but no less interesting version of that.
This is the cops thread of a cops-and-robbers challenge. For the robbers thread, see here.
Cops will provide a program/function and a flag. Robbers will try to guess a password such that, when the passw... | stackexchange_codegolf |
A hill number is a number that has the same digit in the first & the last, but that's not all. In a hill number the first digits are strictly increasing until the largest digit, and after the largest digit, the last digits are strictly decreasing. The largest digit can be repeated but consecutively only, meaning no gap... | stackexchange_codegolf |
Suppose we want to encode a large integer \$x\$ as a list of words in such a way that the decoder can recover \$x\$ regardless of the order in which the words are received. Using lists of length \$k\$ and a dictionary of \$n\$ words, there are \$\binom{n+k-1}k\$ different multisets possible (why?), so we should be able... | stackexchange_codegolf |
Semiperfect numbers
A semiperfect/pseudoperfect number is an integer equal to the sum of a part of or all of its divisors (excluding itself). Numbers which are equal to the sum of all of their divisors are perfect.
Divisors of 6 : 1,2,3
6 = 1+2+3 -> semiperfect (perfect)
Divisors of 28 : 1,2,4,7,14
28 = 14+... | stackexchange_codegolf |
This is a cops-and-robbers challenge. The robbers' thread is here.
An interesting question to think about is the following:
If I have a sequence of numbers how many of them do I have to provide before it is clear what sequence I am talking about?
For example if I want to talk about the positive integers in order star... | stackexchange_codegolf |
A perfect power is a number of the form \$a^b\$, where \$a>0\$ and \$b>1\$.
For example, \$125\$ is a perfect power because it can be expressed as \$5^3\$.
Goal
Your task is to write a program/function that finds the \$n\$-th perfect power, given a positive integer \$n\$.
Specs
The first perfect power is \$1\$ (which... | stackexchange_codegolf |
Introduction:
Every workday I read the newspaper in the morning while eating breakfast, and also do some of the puzzles at the back. When I do the word-search puzzles, I (almost) always go over the words in order, and strike them through one by one. The word-searches in the newspaper have two columns of words, and afte... | stackexchange_codegolf |
Given a list of activities and their start time/date, output an ASCII-art calendar showing the activities on the appropriate days. All activities are guaranteed to be in the same month, no two activities will be on the same day, and all activities are guaranteed to fit within the calendar box.
The calendar has the date... | stackexchange_codegolf |
Given a string of ASCII letters (upper and/or lower case), output the raw MathJax required to display that string bifurcating at each character, into superscripts and subscripts. For example, the inputs cat and horse would result in outputs which MathJax renders as the following, respectively:
Note that only one inpu... | stackexchange_codegolf |
A Rubik's cube has 6 colors: red, orange, yellow, white, blue, and green. Red and orange, yellow and white, and blue and green faces are on opposite sides.
Net of a solved Rubik's cube looks like this:
Y
BRGO
W
And the tiles look like this:
Y Y Y
Y Y Y
Y Y Y
B B B R R R G G G O O O
B B B R R R G G ... | stackexchange_codegolf |
Consider compass-and-straightedge construction, where you can construct new points from existing ones by examining intersections of straight lines and circles constructed with one of the following two options:
Draw the unique infinitely long straight line passing through points \$(x, y)\$ and \$(x', y')\$
Draw the uni... | stackexchange_codegolf |
Inspired by the Codewars Kata.
Your goal is to take an input string such as this one:
"'Twas a dark and stormy night..."
and return a string containing the position of each character in the alphabet, separated by spaces and ignoring non-alphabetical characters, like this:
"20 23 1 19 1 4 1 18 11 1 14 4 19 20 15 18 13 ... | stackexchange_codegolf |
Print integers 0 to 100 (inclusive) without using characters 123456789 in your code.
Separator of numbers can be comma or white space (by default <blank>, <horizontal tabulator>, <newline>, <carriage return>, <form feed> or <vertical tabulator>).
Shortest code wins.
| stackexchange_codegolf |
Inspired by Find the largest fragile prime
A recurring prime (or whatever you choose to call it) is a prime that, when removing leading digits, always remain prime regardless of how many digits are removed.
for example
6317 is a recurring prime because...
317 is a recurring prime because...
17 is a recurring prime beca... | stackexchange_codegolf |
Objective
Given an ASCII character, toggle its "shift-ness" on the standard US keyboard (ANSI-INCITS 154-1988 (R1999)), then output it.
Mapping
) ↔️ 0
! ↔️ 1
@ ↔️ 2
# ↔️ 3
$ ↔️ 4
% ↔️ 5
^ ↔️ 6
& ↔️ 7
* ↔️ 8
( ↔️ 9
" ↔️ '
+ ↔️ =
, ↔️ <
- ↔️ _
. ↔️ >
/ ↔️ ?
: ↔️ ;
(Capital Latin letters) ↔️ (Small Latin letters)
[ ↔️ {
\... | stackexchange_codegolf |
As you may or may not know, Valentine's day is getting close. So today, my task for you is:
Write a heart-shaped quine
Rules:
Code should look like an identifyable heart shape, i.e. Has two round parts on top and a pointy bottom. It does NOT have to be filled in, but this is not disallowed.
Standard Quine rules apply ... | stackexchange_codegolf |
The Challenge
Given a string containing a random sequence of unique characters A to Z (all upper case, no duplicates), determine the cut-and-paste" sort and output the sort sequence to a specific format (detailed below).
Definition of Cut-And-Paste Sort, by Example
Example string:
AKJCFEGHDBI
This string contains 11 ch... | stackexchange_codegolf |
Your challenge is to print the input, wait any amount of time, print the input, wait twice the time you initially waited, print the input again, and so on. The initial delay must be less than 1 hour, and you must have an accuracy of +/- 5% in the subsequent delays. Other than that, there is no restriction on the delay ... | stackexchange_codegolf |
In xkcd 1047, Randall Munroe lists "slightly wrong" approximations of assorted quantities and numbers with varying precision and complexity, such as that the number of liters in a gallon is very close to 3 + π⁄4. In the middle of the comic, he gives an intermission: a way to estimate the world (and United States) popul... | stackexchange_codegolf |
This is the inverse of negative seven's question.
Write a program or function which, given any single, possibly-empty string of printable ASCII (codes \$[32,126]\$) outputs or returns two strings of printable ASCII.
For any two ordered, possibly empty strings \$s_1\$ and \$s_2\$, there must be third string \$s_0\$, whi... | stackexchange_codegolf |
Your task is to build a bridge to connect two cliffs given an input d, the distance apart. d will always be even
However, the bridge needs columns to hold it up. Each column can hold a max of 6 spaces on each side.
For this example:
________ ________
| |
A | ... | stackexchange_codegolf |
Definition
The maxima and minima of a given function are the largest and smallest values of the function either within a given range or otherwise within the entire domain of the function.
Challenge
The challenge is to find the local maxima and minima of a given polynomial function using any method you may like. Don't w... | stackexchange_codegolf |
I'm trying to shorten a bash solution to a Code Golf challenge, which requires an output of true or false. I've managed to condense the key piece of the code down to a substring check, to determine if the provided argument, $1, is a substring of a particular hard-coded fixed string, of the form:
[[ FIXEDSTRING = *$1* ]... | stackexchange_codegolf |
This challenge is inspired by this app.
This is a much easier version of this challenge. This challenge is code-golf, while the other one is fastest-code.
You'll be given a square input grid, of dimensions 6-by-6 which is divided into 6 areas, where the cells of each area have a unique identifier (I'll use lower case... | stackexchange_codegolf |
Given an integral polynomial \$p\$, determine if \$p\$ is a square of another integral polynomial.
An integral polynomial is a polynomial with only integers as coefficients.
For example, \$x^2+2x+1\$ should gives truthy, because \$x^2+2x+1 = (x+1)^2\$.
On the other hand, \$2x^2+4x+2\$ should gives falsy: \$2x^2+4x+2 = ... | stackexchange_codegolf |
Today I installed MonoGame and ran the test application, which creates a basic colored window. I was surprised to see that the process was using 32.2 MiB of memory, and I thought it could be improved.
Your challenge is to write a program that creates a 640 by 480 window displaying only black pixels. Whatever program u... | stackexchange_codegolf |
Pipe a short stream to the following Java program run with accompanying command line options, such that it prints true.
class Code implements java.io.Serializable {
private static final long serialVersionUID = 0L;
private static long count;
@Override public int hashCode() {
++count;
return... | stackexchange_codegolf |
This challenge is one of the two challenges which were planned for Advent of Code Golf 2021, but didn't fit into the 25-day schedule.
Related to AoC2020 Day 22, Part 2.
Combat is a simple two-player card game played with a deck of cards. A unique positive integer is written on each card. The game proceeds as follows:
... | stackexchange_codegolf |
Bingo
Bingo is a numbers game where players match randomly drawn numbers to the numbers on their cards. Each bingo card is a square grid with 25 spaces, and the columns of the grid are labeled with letters such as "B", "I", "N", "G", "O". The letters help to identify the number range in each column, for example, the "B... | stackexchange_codegolf |
The wizard has a cunning cousin who is a witch. She looks down on the wizard, regarding him and his puzzles as mathematically naive. On reading his latest puzzle, she scorned him for always asking discrete problems with what she (unfairly) characterises as simple solutions, where the real, proper question should be co... | stackexchange_codegolf |
Title stolen inspired by Greg Hewgill's answer to What's the difference between JavaScript and Java?
Introduction
Java and JavaScript are commonly used languages among programmers, and are currently the most popular tags on Stack Overflow. Yet aside from similar names, the two have almost nothing in common.
In honor of... | stackexchange_codegolf |
You will need to evaluate the definite integral (bounded by \$a\$ and \$b\$) of a certain polynomial function that takes the form of:
$$\int_a^b \left( k_n x^n + k_{n-1} x^{n-1} + \cdots + k_2x^2 + k_1x + k_0 \: \right) dx$$
Normally, this can be done using the fundamental theorem of calculus and power rules. For examp... | stackexchange_codegolf |
A pandigital number is an integer which contains every digit from 0 to 9 at least once. 1234567890, 1902837465000000, and 9023289761326634265 are all pandigital. For the purposes of this challenge, numbers such as 123456789 are not pandigital, since they do not contain a 0, even though 123456789 = 0123456789.
A diverse... | 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 |
Just because the reverse and palindrome were not too challenging individually :)
Write a program (full program or function) that satisfies the following: given a string input,
the program as-is outputs the input string unchanged.
the program reversed outputs the input string reversed.
the program palindromized outputs... | stackexchange_codegolf |
Given an initial \$n\$-tuple \$t_0=(t_{0,1},...,t_{0,n})\$, we can obtain its corresponding Ducci sequence \$\{t_0, t_1, ...\}\$ by the recurrence \$\displaystyle t_{i+1}=\left(\left|t_{i,1}-t_{i,2}\right|,\left|t_{i,2}-t_{i,3}\right|,...\left|t_{i,n}-t_{i,1}\right|\right)\$.
That is, to obtain the next term of the seq... | stackexchange_codegolf |
The Task
This is my first challenge so apologies if it is very simple! In this challenge, your task is to write a program or function which takes in a list of integers and a desired sum and outputs a truthy or falsey value based on whether the list contains two numbers that can be summed together to achieve the desire... | stackexchange_codegolf |
TeaScript is a powerful JavaScript golfing language created by StackExchange, PPCG, user Downgoat. TeaScript compiles to JavaScript and contains many helpful features for golfing
This question is to list some TeaScript golfing tips
| stackexchange_codegolf |
Given a positive integer n, output the smallest base b >= 2 where the representation of n in base b with no leading zeroes does not contain a 0. You may assume that b <= 256 for all inputs.
Test Cases
1 -> 2 (1)
2 -> 3 (2)
3 -> 2 (11)
4 -> 3 (11)
5 -> 3 (12)
6 -> 4 (12)
7 -> 2 (111)
10 -> 4 (22)
17 -> 3 (122)
20 -> 6 (... | stackexchange_codegolf |
The 9 Billion Names of God is a short story by Arthur C. Clarke. It's about a group of Tibetan monks whose order is devoted to writing down all the possible names of God, written in their own alphabet. Essentially, they are devoted to writing every possible permutation of their alphabet, restricted by a few rules. In t... | stackexchange_codegolf |
You have to print out your username, by only using the characters in your username.
Standard loopholes are forbidden
This is not code-golf, so shortest does not win
Don't modify your username please
And each language be used one time
| stackexchange_codegolf |
Given a rectangular haystack of size at least 2x2 composed of all the same printable ASCII characters, output the location (counting from the top-left) of the needle which is a different character.
For example, if the following haystack is input:
#####
###N#
#####
#####
The output should be 3,1 when zero-indexed (what... | 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 |
Upon the rumor that Codegolf will have a Rock-Paper-Scissors tournament you look into the topic of square-free words. A word made of the letters R, P, S is square-free if it does not contain a sequence that repeats twice. That is to say, the word can not be written as
a x x b
where a and b are words of any length and ... | stackexchange_codegolf |
Based on the interpretation user @ThePirateBay made from the first version of my own challenge
Output diagonal positions of me squared
now I challenge you to make ASCII art that draws diagonal lines based on a square character matrix based on a given number n.
Input
A number n.
Output
A square matrix of size n^2 which... | stackexchange_codegolf |
Which language usually produces shorter golfed code: Pyth, CJam or Golfscript?
In asking this, I do not mean which has a prettier syntax or which has the most useful commands, I mean overall, which one is usually the shortest? What types of problems would we expect each language to have an advantage in?
| stackexchange_codegolf |
Write some code...
Write a program that takes no input and outputs an integer n which is a multiple of 3. So n=3k, where k is a positive integer.
Double the last character of your code.
Your code should then output k.
Examples
Here is my program hui#2(21+4)//lm, which outputs 81.
Because of that, hui#2(21+4)//lmm shoul... | stackexchange_codegolf |
tl;dr: Output the values where the reduced prime factorization leader changes.
Every positive integer has a unique prime factorization. Let's call the reduced prime factorization just the list of multiplicity of the prime factors, ordered by the size of the factors. For instance, the reduced prime factorization of 1980... | stackexchange_codegolf |
Jack is a little businessman. He found out a way to earn money by buying electricity on days when it's cheap and selling it when it's much more expensive. He stores the electricity in a battery he made by himself.
Challenge
You are given N (if required), the number of days Jack knows the cost of electricity for, and X,... | stackexchange_codegolf |
Related
Given a piece of ascii art and a factor to enlarge it by, which will always be an odd number >1, replace each character with the corresponding ascii-art, resized to fit on a grid the size of the input number:
Character
What to do
\
\ \ \A line of \ to the length of the enlarging factor, padded to fo... | stackexchange_codegolf |
Select any word from https://websites.umich.edu/~jlawler/wordlist with length greater than 1. For each letter on that word, remove it and check if any rearrangement of the remaining letters is present in the wordlist. If it is, this rearrangement is a child anagram of the original word.
For example, theism:
removing t... | stackexchange_codegolf |
This task builds on: Find all reflexicons using roman numerals
An autogram is a sentence that lists the count of its own letters. Below is one of the first documented autograms found by Lee Sallows in 1983:
This pangram lists four a’s, one b, one c, two d’s, twenty-nine e’s, eight f’s, three g’s, five h’s, eleven i’s,... | stackexchange_codegolf |
Given guaranteed strictly positive integers \$w\$ and \$n\$, output
An equilateral triangle array with side length \$w\$, filled with two distinct, consistent values. I'll call these 0 and 1 but they do not have to be equal to 0 and 1.
The number of 1s inside this array must be equal to \$n\$.
The output triangle must... | stackexchange_codegolf |
Given a 2D string as input, either as a string with newlines or a list of lines, output the coordinates (x, y) of all the hashes (#) in the list. The input will only contain hashes and spaces. (and newlines, if you choose to take input as a 2D string)
If there are no hashes, you can output anything.
Output should be... | stackexchange_codegolf |
Your task is to solve a new puzzle called Cubax. This toy is actually a Chinese puzzle whose expected “final” state is a simple cube. During the festivities, Cubax unfolded, because it cannot move when folded.
Cubax is composed of N³ smaller cubes (elements) linked together in a kind of doubly linked chain. The chain h... | stackexchange_codegolf |
Write, in as few characters as possible, a program that takes zero or six command-line arguments
menorah
menorah YEAR MONTH DAY HOUR MINUTE SECOND
(Both forms must be supported. The zero-argument version shall be equivalent to calling the six-argument version with the current system date and time in the local timezon... | stackexchange_codegolf |
In the tabletop RPG named Pathfinder, there is a feat that characters can take called Sacred Geometry, which allows a character who has it to buff their spells in exchange for doing some math: to use it, the character rolls a number of six-sided dice equal to their ranks in a particular skill, consults a table based on... | stackexchange_codegolf |
You are tasked with displaying the string "ABCDEFGHIJKLMNOPQRSTUVWXYZ" and only that, except for trailing newlines if they're unavoidable.
You must not output any homoglyphic characters like Cyrillic A. You can use non-Unicode encodings, but just to be sure, only output the Latin letters.
Regardless of the encoding you... | stackexchange_codegolf |
Background
This is a follow up question to the question: Will the Hydra finally die?
As before a dangerous A Medusa have released a dangerous Hydra which is revived unless the exact number of heads it have is removed. The knights can remove a certain number of heads with each type of attack, and each attack causes a sp... | stackexchange_codegolf |
Quipus are an ancient device used by the Inca in the Precolumbian era to record numbers in a base ten positional system of knots on a cord, which works as follows:
Each cluster of knots is a digit, and there are three main types of knots: simple overhand knots; "long knots", consisting of an overhand knot with one or ... | stackexchange_codegolf |
Your task is to write a program that takes an input image and run it through edge-detection to become an output image.
The edge-detection works as follows (if unclear, see sobel edge detection):
The value for a pixel is the total brightness of a pixel, so if it is in color, you will need to convert it to grayscale fir... | stackexchange_codegolf |
I personally love quines, but they all seem to be so... static. So why not create a quine that can do more.
Challenge
The challenge here is to create a quine that without any sort of input is a normal quine. Then if it receives a different input, it outputs a different quine in a different language. (basically like a p... | stackexchange_codegolf |
Write a program to generate a rectangular word-search of size 6x9. Words may go downwards, rightwards and diagonally (downwards and to the right), they may also overlap on the board.
The challenge is to include as many different English words as possible from https://www.ef.co.uk/english-resources/english-vocabulary/to... | stackexchange_codegolf |
Abracadabra is a magic word. To make it even more magical, let's make several alterations to how it may be written:
Change the casing for any subset of characters; for example: aBrAcAdAbRa
Append an exclamation mark to it: abracadabra!
Change each occurrence of a into a different vowel: ybrycydybry
Change any single c... | stackexchange_codegolf |
Introduction
As an example, let's take the number 7. We then duplicate this and place 7 spaces in between. We get this:
7_______7
After that, we are going to decrease the number, until there are no spaces left. We get the following for the number 7:
7_______7
6543210
Then, we just merge the two of them, so:
7___... | stackexchange_codegolf |
Background
Shadow transform of a 0-based integer sequence \$a(n)\$ is another 0-based integer sequence \$s(n)\$ defined with the following equation:
$$
s(n) = \sum_{i=0}^{n-1}{(1 \text{ if } n \text{ divides } a(i), 0 \text{ otherwise})}
$$
i.e. \$s(n)\$ is the number of terms in \$a(0), \cdots, a(n-1)\$ that are divis... | stackexchange_codegolf |
Aligning Lines!
Given a character and a multiline string, your job is to pad each line of the string so they line up among the given delimiter.
Examples
Input:
,
Programming, Puzzles
And, Code golf
Output:
Programming, Puzzles
And, Code golf
Input
The input will be a multiline string and a character (which yo... | stackexchange_codegolf |
A pyramidal matrix is a square matrix where all numbers increase or decrease from the center point, like the two matrices below:
1 1 1 1 1
1 2 2 2 1
1 2 3 2 1
1 2 2 2 1
1 1 1 1 1
Or:
3 3 3 3 3
3 2 2 2 3
3 2 1 2 3
3 2 2 2 3
3 3 3 3 3
Given a non-zero integer n, create a pyramida... | stackexchange_codegolf |
3var is a variant of deadfish which uses three variables called A, B and R.
A and B are accumulators, while R is used as a result variable.
In this code-golf challenge, you need to make an interpreter for a stripped-down version of this language.
Required Commands:
i Increments A
d Decrements A
s Squares A
p ... | stackexchange_codegolf |
The code lock for my garage has 5 buttons, labeled "1 2", "3 4", "5 6", "7 8", and "9 0". To open the garage door, you have to enter the correct 4-digit PIN.
As you can see, every button represents two numbers. Thus some PINs, like "1357" and "2367", are essentially identical because they require the same sequence of b... | stackexchange_codegolf |
Your goal is to determine whether a given number n is prime in the fewest bytes. But, your code must be a single Python 2 expression on numbers consisting of only
operators
the input variable n
integer constants
parentheses
No loops, no assignments, no built-in functions, only what's listed above. Yes, it's possible... | stackexchange_codegolf |
We start with a blank 1-indexed sequence:
_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,...
In the nth step, we fill in every a(n) blanks with the integers greater than 1 starting at the first remaining blank, where a(n) is the nth entry in the sequence.
After the first step:
2,_,3,_,4,_,5,_,6,_,7,_,8,_,9,_,10,_,11,... | stackexchange_codegolf |
Introduction to Bézout's identity
The GCD of two integers A, B is the largest positive integer that divides both of them leaving no remainder. Now because of Euclid's property that each integer N can be divided by another integer M as follows:
there exist pairs u,v such that ... | stackexchange_codegolf |
Test Driver • Challenge Discussion • Submit Adventurer
(Image Source)
Several rival adventurers are raiding the ruins for treasure, but they can only carry so much at a time and have their limits of endurance. They want to get the most valuable treasure and get out before they become too tired to continue. They are tr... | stackexchange_codegolf |
This challenge, if you accept it, is to write three functions or programs A, B, and C:
A is a quine that outputs all of A,B and C (which is also the whole content of the code in your submission).
B takes a parameter F and checks whether it is such a quine (outputting FBC), or doing something different.
C takes a param... | stackexchange_codegolf |
Based on a list of numbers and their equivalent letters, take a string input, replace the characters of that string with the equivalent number/letter and output the result.
List
1 = a
2 = b
3 = c
4 = d
5 = e
6 = f
7 = g
8 = h
9 = i
0 = j
Input
thisisastring1124
Output
t89s9s1str9n7aabd
Rules
Numbers are equiva... | stackexchange_codegolf |
Background
For the purposes of this challenge, an n-state cellular automaton is simply a binary function f that takes two numbers from the state set {0, 1, ..., n-1} as inputs, and returns another number from that set as output.
It can be applied to a list of numbers L = [x0, x1, x2, ..., xk-1] of length at least 2 by
... | stackexchange_codegolf |
In this challenge, players need to tamper with a time bomb as late as possible without getting blasted in the face.
Mechanics
Let N be the number of bots plus one. Each round, each bot receives the following arguments:
numbers played by all bots last round in ascending order.
number of points it received last round. N... | stackexchange_codegolf |
Challenge
This is a simple one: Given a positive integer up to 1,000,000, return the closest prime number.
If the number itself is prime, then you should return that number; if there are two primes equally close to the provided number, return the lower of the two.
Input is in the form of a single integer, and output sh... | stackexchange_codegolf |
Task
You're in charge of making a compass, of sorts.
Imagine your source code as the compass "needle" where running at different orientations produces distinct output.
Supported source code orientations are North, East, South, and West.
Example
Let's say you have source code:
ABCD
J K
WXYZ
We'll consider this the Nor... | stackexchange_codegolf |
This is a challenge inspired by Chebyshev Rotation. I suggest looking at answers there to get inspiration for this challenge.
Given a point on the plane there is a unique square (a rectangle with equal sides) that is centered on the origin and intersects that point (interactive demo):
Given a point p and a distance d,... | stackexchange_codegolf |
What all languages have a construct similar to python's eval, so you can write code during runtime and run it?
A list would be helpful for certain programming challenges - ones where it is obvious an eval is either necessary or highly efficient.
| stackexchange_codegolf |
Your challenge is to write a program to solve a 3x3x3 Rubik's Cube. This challenge is based on this one from 2013, rewritten to adhere to current community standards, and reposted with the original author's permission and help on meta.
Input
The input should represent an unsolved Rubik's Cube.
You may read this input v... | stackexchange_codegolf |
We all know that whenever a rational number is written in decimal, the result is either terminating or (eventually) periodic. For example, when 41/42 is written in decimal, the result is
0.9 761904 761904 761904 761904 761904 761904 761904 ...
with an initial sequence of digits 0.9 followed by the sequence 761904 repe... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.