instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Ungolfed, ugly, horrible proof to help you make progress on this challenge: https://gist.github.com/huynhtrankhanh/dff7036a45073735305caedc891dedf2
A bracket sequence is a string that consists of the characters ( and ). There are two definitions of a balanced bracket sequence.
Definition 1
The empty string is balanc... | stackexchange_codegolf |
Background
Roman numeral is a simple number system with the following properties:
Each symbol in the system maps to a specific value. (e.g. I = 1, V = 5, X = 10, C = 100)
The value of a Roman numeral can be evaluated as follows:
First, find all occurrences of adjacent pairs of symbols where a strictly smaller-valued ... | stackexchange_codegolf |
dary!
In events entirely unrelated to what will hopefully happen to me in the next couple of days, I task you to write code that does the following:
Print
Legen... wait for it...
immediately, with a trailing newline.
Wait until the next full hour (when the cron job for awarding the badge runs).
Print
dary!
with an o... | stackexchange_codegolf |
Quylthulg is a language by Chris Pressey that attempts to solve the problem of infix notation using what it calls panfix:
like postfix, panfix does not require the deployment of arcane contrivances such as parentheses to override a default operator precedence. At the same time, panfix allows terms to be specified in t... | stackexchange_codegolf |
A ragged array is an array where each element is an array of unknown number of positive integers.
For example, the following are ragged arrays:
[[1,2,3],[4],[9,10]] Shape: 3,1,2
[[1],[2],[3]] Shape: 1,1,1
[[1,2,3,4,5,6,8]] Shape: 7
The following are not ragged arr... | stackexchange_codegolf |
Given the spiral of size S and the step N, output the "square" S*S spiral having N asterisks, built from the outer to inner radius clockwise.
Test cases (examples) below.
Input: 4 3
Output:
***
Input: 4 6
Output:
****
*
*
Input: 4 11
Output:
****
*
* *
****
Input: 6 18
Output:
******
*
*
* *
... | stackexchange_codegolf |
Many people know what a truth machine in programming is. But is time we kick things up a notch. Introducing, the extended truth machine! An extended truth machine takes two things as input, a integer n and a nonempty string s. It outputs s n times with optional trailing whitespace. However, if n is equal to 0, you must... | stackexchange_codegolf |
Given a list of case-insensitive ASCII letter strings ("words"), output whether the entire list can be found on some four-by-four configuration ("board") of letter squares, in which no square can be used more than once in a word, and in which words are formed by moving from any square to any adjacent square including d... | stackexchange_codegolf |
The Challenge
Your task is to create a program or function that outputs the following with no input:
a
bb
ccc
dddd
eeeee
ffffff
ggggggg
hhhhhhhh
iiiiiiiii
jjjjjjjjjj
kkkkkkkkkkk
llllllllllll
mmmmmmmmmmmmm
nnnnnnnnnnnnnn
ooooooooooooooo
pppppppppppppppp
qqqqqqqqqqqqqqqqq
rrrrrrrrrrrrrrrrrr
sssssssssssssssssss
tttttttttt... | stackexchange_codegolf |
This question is the first of several Brain-flak Birthday challenges designed to celebrate Brain-Flak's first Birthday! You can find more information about Brain-Flak's Birthday here
Last summer we had the Brain-flak Integer Metagolf, and the answers it generated have been very useful to the Brain-Flak community sinc... | stackexchange_codegolf |
Slightly more than an inverse of this.
In: Multi-line DSV data and a single delimiter character. The DSV may be taken as a file, a filename, line-break separated string, list of strings, etc. All records have the same number of fields, and no field is empty. Data does not contain the delimiter character and there is no... | 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 |
Introduction
A "lobster number", by my own designation, is a number that contains within itself all of its prime factors. The "lobster" description was inspired by the recent question "Speed of Lobsters". The basic idea is that each prime factor can be made by lobsters munching away digits of the number until you are... | stackexchange_codegolf |
2019 has come and probably everyone has noticed the peculiarity of this number: it's in fact composed by two sub-numbers (20 and 19) representing a sequence of consecutive descending numbers.
Challenge
Given a number x, return the length of the maximum sequence of consecutive, descending numbers that can be formed by t... | stackexchange_codegolf |
Input: from STDIN number of vertices in Graph \$2 \leq N \leq 100\$.
Rules: [Code size] = max ([code length without spaces, tabs and newlines], [total code length divided by 4])
Math formulation: In the graph of N vertices, between each pair of vertices can be 3 road states:
there is no road
there is a road from A to ... | stackexchange_codegolf |
Graph theory is used to study the relations between objects. A graph is composed of vertices and edges in a diagram such as this:
A-----B
| / \
| / \
| / E
| / /
|/ /
C-----D
In the above diagram, A is linked to B and C; B is linked to A, C, and E; C is linked to A, B, and D; D is linked to C and... | stackexchange_codegolf |
There's a satirical song called Little Boxes, originally by Malvina Reynolds, about suburban sprawl that has lyrics as follows:
Little boxes on the hillside,
Little boxes made of ticky-tacky,
Little boxes on the hillside,
Little boxes all the same.
There's a green one and a pink one
And a blue one and a yell... | stackexchange_codegolf |
You are working as an intern for a mathematician who really hates TeX, LaTeX, etc. So much so that he has decided to abandon all typesetting whatsoever and make you do all the formatting in ASCII. You got tired of this after a while and decided to start automating parts of it, starting with square roots.
Here's how a s... | stackexchange_codegolf |
A rotation "is made by splitting a string into two pieces and reversing their order". An object is symmetrical under an operation if the object is unchanged after applying said operation. So, a "rotational symmetry" is the fact that a string remains unchanged after "rotation".
Given a non-empty string s consisting of o... | stackexchange_codegolf |
I am trying to use C# to find the index of the first 1 (right to left) in the binary representation of a number. For example, since 100 in binary is:
0b1100100
The first 1 is in the third position from the right, so it should yield 3.
234 should yield 2, 0 should yield 0, etc.
Here is my current solution:
k < 1 ? 0 :(... | stackexchange_codegolf |
You want to draw a regular polygon but you have limited space! In this challenge, you should draw a polygon with n sides which is as big as possible for a given square container image.
I found surprisingly little information on the Internet about inscribing a polygon into a square. To save you the hassle, I verified th... | stackexchange_codegolf |
Write a quine that outputs the complement of the source code from the smallest containing power of two. Here's an example:
IN : source
OUT: \r\x11\x0b\x0e\x1d\x1b
The largest code point in the string "source" is the letter u, which is 117. The smallest containing power of 2 would be 128, so all the code points are tak... | stackexchange_codegolf |
The McGill Billboard Project annotates various audio features of songs from a random sample of the Billboard charts. I scraped this data to produce the following file of chord progressions:
chords.txt
Write the shortest code that outputs the above file (or its contents).
Edit: Here's a quick description of the notation... | stackexchange_codegolf |
Write a function which takes a list or array, and returns a list of the distinct elements, sorted in descending order by frequency.
Example:
Given:
["John","Doe","Dick","Harry","Harry","Doe","Doe","Harry","Doe","John"]
Expected return value:
["Doe","Harry","John","Dick"]
| stackexchange_codegolf |
Given an \$n\times m\$ matrix \$A\$ and two integers \$w,h\$, output a matrix of \$w\times h\$ called \$B\$, such that $$B_{i,j} = \int_{i-1}^i\mathbb dx\int_{j-1}^j A_{\left\lceil \frac xw\cdot n\right\rceil,\left\lceil \frac yh\cdot m\right\rceil}\mathbb dy\text{ (1-index),}$$ $$B_{i,j} = \int_i^{i+1}\mathbb dx\int_j... | stackexchange_codegolf |
You have to make something that takes in one input from a default I/O method (as an integer), and prints out the sum of all the permutations of that number (not necessarily unique)
For example:
10 would return 11 because 10 can have 2 permutations (10 and 01), and the sum of those two numbers would be 11
202 would have... | stackexchange_codegolf |
Given a string of printable ASCII, output the frequency of each character in that string.
The Challenge
Input is given as a string of printable ASCII characters (decimal [32-126] inclusive).
Output the frequency of each character, in ASCII order.
The output must have a format similar to [character][separator][count]. ... | stackexchange_codegolf |
...at least for some definition of "self-modification".
The Task
In this challenge, your task is to write three strings A, B and C that satisfy the following properties.
The string B has length at least 1.
For every n ≥ 0, the string ABnC is a valid program (meaning full runnable program or function definition) in you... | stackexchange_codegolf |
Challenge
Given a single word as input, determine if the word is odd or even.
Odd and Even words
Assume the general rules:
odd + odd = even
even + odd = odd
odd + even = odd
even + even = even
In the alphabet, the odd letters are:
aeiou
And the even letters are:
bcdfghjklmnpqrstvwxyz
The same applies to capital lett... | stackexchange_codegolf |
The Fibonacci polynomials are a polynomial sequence defined as:
\$F_0(x) = 0\$
\$F_1(x) = 1\$
\$F_n(x) = x F_{n-1}(x) + F_{n-2}(x)\$
The first few Fibonacci polynomials are:
\$F_0(x) = 0\$
\$F_1(x) = 1\$
\$F_2(x) = x\$
\$F_3(x) = x^2 + 1\$
\$F_4(x) = x^3 + 2x\$
\$F_5(x) = x^4 + 3x^2 + 1\$
When you evaluate the Fibo... | stackexchange_codegolf |
Warning: This challenge is only valid for languages with a compiler.
Make a program (which is perfectly valid code) that outputs Hello, World, even before runtime.
How? Let me explain.
Many languages have a compiler. Some operations are made in the compile-time, and others, in runtime. You trick the compiler to outpu... | stackexchange_codegolf |
Generate the following list of lists consisting of the unique last digits of the powers from 1 to 9 for the numbers [0..9]
[[0], [1], [2, 4, 8, 6], [3, 9, 7, 1], [4, 6], [5], [6], [7, 9, 3, 1], [8, 4, 2, 6], [9, 1]]
e.g. For the number 2 we have:
\$2^1,2^2,2^3,2^4,2^5,... \to 2,4,8,16,32,64,128,... \to 2,4,8,6,4,8,..... | stackexchange_codegolf |
We define the hyper-average of an array / list (of numbers) the arithmetic mean of the sums of its prefixes.
For example, the hyper-average of the list [1, 4, -3, 10] is computed in the following manner:
We get the prefixes: [1], [1, 4], [1, 4, -3], [1, 4, -3, 10].
Sum each: [1, 5, 2, 12].
And now get the arithmetic m... | stackexchange_codegolf |
In this king-of-the-hill challenge, you will program a bot, consisting of a python function of the form
def BOTNAME(info, me, round):
pass # ... main body
Specifically, the function must run in python3.9. Each bot will be entered into the contest 10 times.
The arguments it take in are info, me, round. The three ar... | stackexchange_codegolf |
Task
Given a string of English names of digits “collapsed” together, like this:
zeronineoneoneeighttwoseventhreesixfourtwofive
Split the string back into digits:
zero nine one one eight two seven three six four two five
Rules
The input is always a string. It always consists of one or more lowercase English digit nam... | stackexchange_codegolf |
Lucky dice rolls
In pen and paper roleplaying games dice are used for various chance calculations. The usual way to describe a roll is \$n\textbf{d}k\$ where \$n\$ is the number of dice and \$k\$ is the number of faces on a die. For example \$3d6\$ means that you need to roll the classical 6-sided die 3 times (or roll ... | stackexchange_codegolf |
For this challenge a "binary tree" is a rooted tree where each node has 0 children (leaf) or 2. The children of a node are unordered, meaning that while you might draw the tree with left and right children there isn't a distinction between them and mirroring the tree or a sub-tree does not produce a new tree.
In this... | stackexchange_codegolf |
Challenge
Create a function or program that, when given an integer size, behaves the following way:
If size is equal to 1, output
┌┐
└┘
If size is greater than 1, apply the following substitutions :
Source
Target
┌
┌┐└┌
┐
┌┐┐┘
└
┌└└┘
┘
┘┐└┘
Note: this is basically a Unicode box-drawing version of the... | stackexchange_codegolf |
Please participate in the meta discussion about reopening this challenge before casting a vote.
Introduction
This challenge was inspired by semicolon-#.
Deadfish is a non-Turing-complete programming language, created by Jonathan Todd Skinner. It has an accumulator register and contains 4 commands, i, d, s, and o, sta... | stackexchange_codegolf |
This is a tips question for golfing in Python, which is on topic for main.
I'm looking for the shortest way to get all of the most common elements of a list in Python, in the shortest way possible. Here's what I've tried, assuming the list is in a variable called l:
from statistics import*
mode(l)
This throws an error... | stackexchange_codegolf |
Given a positive integer N, output this doubling pattern of slash squares/rectangles.
For N=1, the base is:
/\
\/
The next square is added in the bottom right direction for N=2:
/\
\/\
\/
After that, a 2x1 rectangle is added in the bottom left direction for N=3:
/\
/\/\
\ \/
\/
Then a 2x2 square is added in the t... | stackexchange_codegolf |
Introduction
Little Jimmy is going trick or treating. He lives in an odd neighborhood: some houses give out candy, and some give out toothbrushes. Now, Jimmy does not want to get too many toothbrushes. He wants candy! You must help him get some.
Challenge
Each street in Jimmy's neighborhood has a number. Each house on... | stackexchange_codegolf |
In this challenge you will be given an alphabetic string as input. We will define the "anti-string" of a given input to be the string with the case of all the letters inverted. For example
AaBbbUy -> aAbBBuY
You should write a program that takes a string as input and searches for the longest contiguous substring who... | stackexchange_codegolf |
This challenge was inspired by the game Flood.
Challenge
Given a grid of colors, determine the optimal list of moves to take to convert the whole grid to the same color.
First of all, let us say that a pixel is in the "top left chunk" if and only if it is either the top left pixel or it shares an edge with a pixel of t... | stackexchange_codegolf |
Write a program which takes two arrays of positive integers as input. One of them (your choice which) will have one item missing compared to the other. Your program must figure out what is missing.
Rules
You can choose which array has one missing: You can take ordinary then missing or vice versa.
Arrays may contain dup... | stackexchange_codegolf |
In physics, like electric charges repel, and unlike charges attract.
The potential energy between two unit charges separated by a distance d is 1/d for like charges and -1/d for unlike charges. The potential energy of a system of charges is the sum of the potential energies between all pairs of charges.
Challenge
Deter... | stackexchange_codegolf |
And then the King said: You fought bravely, Knight, and your deed will not be forgotten for centuries. For your valor I grant you this castle and the lands around it. Things rush me, and I can not take you to the castle. Therefore, I will give you the way from this place to the castle. Now go and come back after the de... | stackexchange_codegolf |
A rigid transformation of a square array is a mapping from square arrays of a certain size to square arrays of the same size, which rearranges the elements of the array such that the distance to each other element remains the same.
If you printed out the matrix on a sheet of paper these are the transforms you could do ... | stackexchange_codegolf |
Challenge
Given a user's name (not ID, we have that challenge already), output their current reputation and their ID.
Input
Input will be a single string which is the user's username. You may assume that this user exists.
Output
Output will be two integers to either STDOUT or STDERR which will be the user's reputation ... | stackexchange_codegolf |
Challenge
You will be given a string as an argument. You need to convert that string to upper case. But you can't use any built in method or function nor any external programs.
Rule
No use of built in methods or functions or external programs. Only arithmetic, bitwise, logical operators, regex, replace, split, join, A... | stackexchange_codegolf |
Input
An integer \$n\$ greater than or equal to 1.
Output
The number of bits in the binary representation of the integer that is the product of the first \$n\$ primes.
Example
The product of the first two primes is 6. This needs 3 bits to represent it.
Given unlimited memory and time your code should always output the ... | stackexchange_codegolf |
Background
We all know about distributivity, i.e. \$a(b+c) = ab + ac\$. This is a property on 2 different operations, namely addition and multiplication. But indeed, nothing can stop us from studying distributivity of 1 operation. In this challenge, you will be studying a kind of left-distributive operation.
Task
Given... | stackexchange_codegolf |
Background
Conway's Soldiers is a version of peg solitaire played on an infinite checkerboard. The board is initially full of pegs below an infinite horizontal line, and empty above it. Following the ordinary peg solitaire rules (move a peg by jumping over another one horizontally or vertically, removing the one that w... | stackexchange_codegolf |
Goal
Create a program or pair of programs that collectively disrupt and fix files with the intent of preventing LZMA2 from working effectively. The disrupt and fix routines must be reciprocal, so you can recover the original file exactly.
Targets
The collected works of Shakespeare in plain UTF-8 (5,589,891 bytes)
Wik... | stackexchange_codegolf |
I want to write 7 assembly instructions (28 bytes) that runs a logical equivalent of this C snippet:
c = a + b + 6;
while (c > 5) {
c = c - a;
b = b + 1;
}
However, there are restrictions to the allowed instructions:
add, addi, sub, subi, slt, slti, bne
a, b, and c are located in registers $t0, $t1, and $s0 respe... | stackexchange_codegolf |
I am trying to find the shortest code in python 3, to solve this problem:
You are driving a little too fast, and a police officer stops you.
Write code to take two integer inputs, first one corresponds to speed, seconds one is either 1 or 0, corresponding to True and False respectively to indicate whether it is birthd... | stackexchange_codegolf |
Let's write the shortest code to perform a simplified variant of the DoD 5220.22-M Wipe Method with only two writing passes.
Any programming language accepted, but the use of disk-wiping-oriented libraries is prohibited.
Here's how we are to implement it in pseudocode:
Set x to 0
[Start]
'Write Pass
For each sector in... | stackexchange_codegolf |
In the musical rendition of Les Miserables, a song appears called "Red and Black." Here is part of that song:
Red - the blood of angry men!
Black - the dark of ages past!
Red - a world about to dawn!
Black - the night that ends at last!
Source.
Your task is to turn input into a resounding "Red and Black" anthem.
Inpu... | 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 |
Print the phrase And she said, 'But that's his.' using only the following characters: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ No punctuation or non-alphabetic characters whatsoever. You can use whatever programming language you want. Whitespace is completely allowed. Shortest program wins.
| stackexchange_codegolf |
...Ordinal numbers (or ordinal numerals) are words representing position or rank in a sequential order.
From Wikipedia.
Your task is, using 2 separate programs (of which can be made from 2 different languages), to output the ordinal sequence from first to nth. You will be outputting the full word second as opposed t... | stackexchange_codegolf |
Randall Munroe (author of XKCD) held a survey to give names to colors. The main outcome is a list of names for the 954 most common RGB monitor colors.
For ease of programming, here is the list in plain text: http://xkcd.com/color/rgb.txt. Beware, the first line is not data, but contains the license.
Write a program or ... | stackexchange_codegolf |
Given a \$n\$-dimensional vector \$v\$ with real entries, find a closest permutation \$p\$ of \$(1,2,...,n)\$ with respect to the \$l_1\$-distance.
Details
If it is more convenient, you can use permutations of \$(0,1,...,n-1)\$ instead. If there are multiple closest permutations, you can output any one or alternativel... | stackexchange_codegolf |
Robbers' Thread
Your challenge is to find an existing challenge, and implement it in a way such that certain inputs fail. At least one input must not produce the correct output (use the other submissions on the challenge as a reference for this, but be sure to double-check). This must fail consistently, and you must kn... | stackexchange_codegolf |
Just for fun, I wanted to see how little lines I could solve this problem in, using python. I managed to condense my code into 9 lines.
size = int(input("Size: "))
a = [x for x in range(size-2, -1, -1)] if size % 2 == 0 else [x for x
in range(size-2, 0, -1)]
b, counter = a[::-1], 0
print("\n"+"\\"+"#"*size+"/") #top
f... | stackexchange_codegolf |
Challenge:
Given a list of integer, sort descending by their single largest digit(s). The order for numbers with the same largest digit are then sorted by second largest digit, etc.
We ignore duplicated digits in numbers. And if all digits in a number are the same, the order of those numbers in the list can be in any w... | stackexchange_codegolf |
This might be a very simple challenge, but I am surprised it hasn't been done on code-golf yet:
Print all Integers from 1 to 10 inclusive in ascending order to standard output.
Your output format can be whatever your language supports. This includes arbitrary separators (commas, semicolons, newlines, combinations of th... | stackexchange_codegolf |
Introduction
I don't see many regex challenges on here, so I would like to offer up this deceptively simple one which can be done in a number of ways using a number of regex flavours. I hope it provides regex enthusiasts with a bit of fun golfing time.
Challenge
The challenge is to match what I've very loosely dubbed a... | stackexchange_codegolf |
from Wikipedia, a number is called B-powersmooth if all prime powers \$p^v\$ that divide the number satisfy \$p^v \leq B\$. B-powersmoothness is important, for example, for Pollard's p-1 factorization algorithm.
Task
your task is to get two numbers, \$n\$ and \$B\$, and output if \$n\$ is \$B\$-powersmooth.
Rules
You ... | stackexchange_codegolf |
You are provided with a non-empty array \$A\$ of integers, all greater than 0. But what good is an array if the elements do not sum up to the number \$N\$ (also provided as input)...
So to change that, you can pick any integer of your choice present in the array and replace any of its digits with a different digit betw... | stackexchange_codegolf |
Your task, is simply to multiply 2 integers given in input, separated by a ",". The catch is, you cannot use the multiplication operator "*", even if it is being used differently, or any loops whatsoever
This is code-golf, so shortest code wins!
Test cases: i dont know if you even need it! lol
1,0 -> 0
5,6 -> 30
3920,5... | stackexchange_codegolf |
The aim of this challenge is to find an impossibly short
implementation of the following function p, in the langage of your
choosing. Here is C code implementing it (see
this TIO link that also prints its outputs) and a wikipedia page containing it.
unsigned char pi[] = {
252,238,221,17,207,110,49,22,251,196,250,2... | stackexchange_codegolf |
Your task is to write a program, which takes a binary input and converts it to plain text. For Example:
01100001 01100010 01100011 = "abc"
Rules
Input can come from STDIN, function arguments, command line argument, file, whatever suits you.
The program can be a function, full program, whatever works, really, as long... | stackexchange_codegolf |
Given three non-negative integers y, m, and d (of which at least one must be positive) and a valid date with a positive year (in any reasonable format that includes the year, month, and day, and no additional information), output the date that is y years, m months, and d days after the original date.
The Gregorian cale... | stackexchange_codegolf |
Given two non-negative integers e.g. 27, 96 their multiplication expression would be 27 x 96 = 2592.
If now each digits is replaced with a symbol, such that
two digits are replaced with the same symbol if and only if they are equal
we could get something like AB x CD = AECA or 0Q x 17 = 0Z10 or !> x @^ = !x@!.
(follo... | stackexchange_codegolf |
You will choose m languages and write n programs in each language, each with length n*m. The kth program should output the kth character of each program, ordered by the program number.
For example, in this submission (for demonstration only; they can be any characters including newlines and tabs):
ABC
DEF
GHI
Program ... | stackexchange_codegolf |
Your challenge is to create the longest run of characters with incrementing Unicode codepoints in a pristine program as you can. To keep things simple, I'll abridge the definition for this challenge to be "any program which produces no errors but will error if any one character is removed".
Let's define a codepoint run... | stackexchange_codegolf |
The Challenge
Write a program or function that takes two input integers, i and j, and outputs their greatest common divisor; calculated by using the Euclidean algorithm (see below).
Input
Input may be taken as a space-delimited string representation of i and j or as two separate integers. You can assume that integers ... | stackexchange_codegolf |
Introduction
The \$n\$-ellipse is a generalization of the ellipse with possibly more than two foci. Specifically, given \$n\$ points on the plane, called foci, the \$n\$-ellipse is the set of points of the plane whose sum of distances to the \$n\$ foci is equal to a constant \$t\$.
This challenge is about plotting the ... | stackexchange_codegolf |
Introduction
A normal checkers board contains 8 x 8 = 64 squares:
You can see that in total, there are 12 white pieces. Black and white always have the same amount of pieces. If there are any more pieces on the board, the pieces would neighbouring, which is not allowed for this challenge. To clarify things, here are s... | stackexchange_codegolf |
or: Build a vertical quine
Inspired by Take a stand against long lines.
Your task is to build a vertical quine with as short a line length as possible.
Scoring
Shortest line length (excluding newlines) wins, with code-golf criteria as a tie-breaker.
Line length is determined as the longest line in your program excludin... | stackexchange_codegolf |
You've recently made an account on a dodgy gambling site, where for a fee of 25 dollars, they will pay you back a random amount between 0 and 50 dollars. After getting around 5 dollars twice, you decide to prove the site is a scam. After accessing their external firewall with the default password, you find your way ont... | stackexchange_codegolf |
Background
Summer is well over in the Northern Hemisphere, and a lot of us miss the sun, the beaches, the waves of the ocean... This challenge aims at cheering them up by reminding them of the sea.
The challenge
Here is the sea :
** ** ** ** **
... | stackexchange_codegolf |
A histogram is an array of integers that counts the number of times a symbol occurs. For example, for the string "aaabbbabbdebabbbebebdbaaabbabaaaaeebeaabaaba" a histogram is a: 18, b: 18, c: 0, d: 2, e: 6, or [18, 18, 0, 2, 6] in short.
If we were to pick a random character out of this string, what would the chance be... | stackexchange_codegolf |
In this challenge, you are going to take a number and turn it into a string, but not in the common way. You will use the aaaaa way!
The aaaaa way is simply replacing each digit of the input number with the letter at that position in the alphabet. For example, 11111 would become aaaaa and 21223 would become babbc. If th... | stackexchange_codegolf |
The Prisoner's Dilemma, but with 3 choices, and the payoffs are random!
Each round, your bot recieves a 3x3 grid and chooses a row to play. The grid might be this:
4 5 7
3 1 9
9 9 0
Each number in the grid is between 0 and 10 (inclusive). Your score for the round is grid[your_play][their_play], and your oppone... | stackexchange_codegolf |
Given a positive integer n.
Generate a JSON array (can be a string, or your language's built-in JSON representation as long as we can get valid JSON, (your code does not need to include outputting the string, you can just use the built-in JSON representation)) containing two empty JSON arrays, then, add a set of 2 empt... | stackexchange_codegolf |
Specifically, this references JavaScript, a programming language that happens to be one you can run on StackExchange/StackOverflow. However, you may use any programming language to do this challenge. This is not actual JS golfing, but merely a "code-golfable" challenge. Actual complete parsing of JS is not needed.
An e... | stackexchange_codegolf |
In the arcade version of the game, Pac-Man eats pac-dots. However, in this challenge, he's hungry for alphanumeric characters and punctuation in a string.
Your task is to create a function that feeds Pac-Man a string, evaluates if he can eat it or not, and returns the string with Pac-Man's location in it.
Pac-Man (<) e... | stackexchange_codegolf |
Objective
Given a date, spell it out in Romanized Japanese.
I/O Format
The input format is flexible. The output format is <month spelling> <day spelling>; note the space. You can freely mix cases in output. You may output trailing newline.
Mapping
Months
Month
Spelling
January
Ichigatsu
February
Nigatsu
Mar... | stackexchange_codegolf |
The challenge is to implement a function or program that takes two numbers, \$x\$ and \$y\$ and return the result of \$x^y\$.
The program cannot use any other mathematical operation other than \$+\$ or \$-\$, so no multiplication or division. Functions built into languages are also not allowed.
The code in the least a... | stackexchange_codegolf |
Your task is to write a RoboZZle interpreter. If you're not familiar with the game, please watch the video at robozzle.com or read my description below.
A robot lives on a rectangular grid of squares coloured red, green, blue, or black. Black squares are inaccessible. The others are accessible and some of them contain ... | stackexchange_codegolf |
Inspired by this blog post.
Write a program that outputs 99 distinct programs (in the same language) that output the string I love you.
How the programs are separated from one another in the output will be defined by you. However, Each byte of output can only belong to at most 1 of the 99 programs.
Constraints for Out... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
Happy Hanukkah!
A beloved Hanukkah tradition for many, the game of Dreidel (s'vivon in Hebrew) is a betting game (for money or for chocolate gelt (coins)) centered on the titular spinning tops called dreidels. Dreidels have four sides:... | stackexchange_codegolf |
This is a cross-post of a problem I posted to anarchy golf: http://golf.shinh.org/p.rb?tails
Given two integers \$ n \$ and \$ k \$ \$ (0 \le k \le n) \$, count the number of combinations of \$ n \$ coin tosses with at least \$ k \$ tails in a row.
For example, if \$ n = 3 \$ and \$ k = 2 \$, the answer is \$ 3 \$:
HHH... | stackexchange_codegolf |
This is inspired by an 05AB1E answer by Magic Octupus Urn.
Given two arguments, a positive integer and a string/list of characters:
Translate the number to base-n, where n is the length of the string.
For each character, replace every appearance of the index of that character in the base-n number with that character.
... | stackexchange_codegolf |
Normally, I'd open with some flavor text here about being bored and/or lazy but looking through the stack-exchange-api questions that would be far from original. So instead I'm going to open with a meta and self-referential flavor text describing this lack of originality that then describes itself and how meta and self... | stackexchange_codegolf |
Your task is simple: given two integers \$a\$ and \$b\$, output \$\Pi[a,b]\$; that is, the product of the range between \$a\$ and \$b\$. You may take \$a\$ and \$b\$ in any reasonable format, whether that be arguments to a function, a list input, STDIN, et cetera. You may output in any reasonable format, such as a retu... | stackexchange_codegolf |
This challenge is inspired by this app. The test cases are borrowed from that app.
This is a fastest-code challenge, where the objective is to solve the largest test cases in the least amount of time. There are provided some smaller test cases, so that people might test their algorithms faster.
You'll be given a squa... | stackexchange_codegolf |
A Math.SE user have a funny game explained as such:
Pick a random positive integer X.
Add +1, 0, -1 to make it divisible by 3Keep track of how much you've added and subtracted. That is your "score"..
Divide by 3 to create a new X.
Repeat steps 2 and 3 until you reach one.
I'm expecting the shortest code to give the... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.