instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Imagine a text file where each csv record may have different numbers of fields. The task is to write code to output how many fields there are in each record of the file. You can assume there is no header line in the file and can read in from a file or standard input, as you choose.
You can assume a version of rfc418... | stackexchange_codegolf |
A jigsaw puzzle consists of (usually rectangular-ish) pieces. On each side of a piece, there is either an edge or a connector (a term I made up). A connector is either a tab sticking out (outie) or a slot facing inwards (innie). Two pieces can be joined if the outie tab can fit into the innie slot. The goal is to assem... | stackexchange_codegolf |
The following is inspired by a question that came up on Stack Overflow today.
Given a number of microseconds, 0 <= n <= 86400000000 (e.g. 12345678900), output a formatted string hh:mm:ss:000:000, e.g. 03:25:45:678:900.
0 -> '00:00:00:000:000'
12345678900 -> '03:25:45:678:900'
86400000000 -> '24:00:00:000:000'... | stackexchange_codegolf |
A number is whole if it is a non-negative integer with no decimal part. So 0 and 8 and 233494.0 are whole, while 1.1 and 0.001 and 233494.999 are not.
Input
A floating-point number in the default base/encoding of your language.
For example, the default integer representation for Binary Lambda Calculus would be Churc... | stackexchange_codegolf |
Number to String
Instructions
Convert a signed 32-bit integer to a string (base-10 preferably) without any string formatting calls (or built in type coercion that will directly convert a number to a string).
Negative numbers must include leading -.
Score Calculation
Shortest byte length; Tie breaker by efficiency (exec... | stackexchange_codegolf |
As it turns out, Python allows for 1j for to be compressed to 1jfor. However, jfor sounds like xnor. Since all similar-phonic phrases have something in common, there must be some property shared between jfor and xnor.
If we look at the ASCII representation of the first two characters of jfor in binary, we see:
j: 110... | 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 |
Can you recover a sequence of letters from a sequence of dots and dashes? In Morse code, x is represented by -..-, but without the help of spaces, -..---.-... could represent xmas, or dole, or teettteteee, etc.
I took the lyrics from "Rudolph, the Red-Nosed Reindeer" to make the following sequence of letters:
youknowda... | stackexchange_codegolf |
Your task is to write a program that receives a base 10 number from 0 to 99 and outputs the German name of that number with non-ASCII characters replaced with ASCII equivalents.
German number names
0 -> null
1 -> eins
2 -> zwei
3 -> drei
4 -> vier
5 -> fuenf
6 -> sechs
7 -> sieben
8 -> acht
9 -> neun
10 -> zehn
11 -> e... | stackexchange_codegolf |
Input: binary string
Output: binary string that represents the binary input + 1
Example: Given 10111 as an input, output 11000
Limitations: Can't use arithmetic operators or functions (like + - * /)
Criterion: code-golf, the shortest code wins the big imaginary award.
| stackexchange_codegolf |
Intro -
Nearest neighbour comparison between two arrays is something that can be done very efficiently when only 1 variable per array is involved, because it can be done by sorting and then performing a rolling comparison. However, for a 2 variable comparison this sort operation cannot be done anymore and another smart... | stackexchange_codegolf |
In an attempt to “liberate” their fellow birds, a group of highly intelligent hens are
attempting to compromise the zoo’s security system. To get access to the zoo’s mainframe,
the hens first need to guess the administrative password. The hens know that the password
is a string built from up to 62 possible characters: ... | stackexchange_codegolf |
Inspired by the challenge A pile of weights.
Challenge
Given an integer as a weight in pounds, output an ASCII barbell that can represent the weight. Weights will come in the form of the barbell (which will weigh 45lbs) and plates with the following weights: 45lbs, 35lbs, 25lbs, 10lbs, and 5lbs. Weights will be repre... | stackexchange_codegolf |
The lack of a social life drove a poor nerd into inventing another superfluous esolang called !+~%. For no good reason it initializes the accumulator with 6 and knows the following commands:
! (out(Accu); Accu = 6) prints the accumulator value as decimal string to stdout (without newline) and resets the accumulator to... | stackexchange_codegolf |
Challenge:
The challenge is to determine whether or not a color, given it's name, is one of the colors in the rainbow.
When supplied with a color, your program should output a truthy value if it is a color in the rainbow, and a falsy one otherwise.
Rules:
The possible input options are exhaustive, and defined in the t... | stackexchange_codegolf |
Introduction:
In general we usually speak of four dimensions: three space dimensions for x, y, and z; and one time dimension. For the sake of this challenge however, we'll split the time dimension into three as well: past, present, and future.
Input:
Two input-lists. One containing integer x,y,z coordinates, and one co... | stackexchange_codegolf |
You place a standard die at the origin of a 2D grid that stretches infinitely in every direction. You place the die such that the 1 is facing upwards, the 2 is facing in the negative y direction, and the 3 is facing in the positive x direction, as shown in the figure below:
You then proceed to execute a series of move... | stackexchange_codegolf |
Write a program that takes in an integer from 0 to 65535 (216-1) and generates a unique 500×500 pixel image that looks as similar as possible to these 6 real life images of cracked soil:
These are thumbnails, click them to see the full-size 500×500 images.
The goal here is to make your computer generated images a... | stackexchange_codegolf |
Background
So, nowadays the popular Prisoner's Dilemma variant is the Prisoner's Trilemma, where there are three options. I can easily see that being increased, so I figured
Why settle for three options, when we can have INFINITE options?
Therefore, I created the Floating Point Prisoner's ?Lemma.
Equations:
Each roun... | stackexchange_codegolf |
On December 4, 2017, the Google Doodle was a graphical programming game featuring a bunny. The later levels were nicely non-trivial and they seemed like a great candidate for an atomic-golf challenge.
Details
Game
There are four available moves: hop forward, turn left, turn right, and loop. Each of these moves is one ... | stackexchange_codegolf |
Related, but very different.
In the examples below, \$A\$ and \$B\$ will be \$2\times2\$ matrices, and the matrices are one-indexed.
A Kronecker product has the following properties:
A⊗B = A(1,1)*B A(1,2)*B
A(2,1)*B A(2,2)*B
= A(1,1)*B(1,1) A(1,1)*B(1,2) A(1,2)*B(1,1) A(1,2)*B(1,2)
A(... | stackexchange_codegolf |
The challenge here is to accurately depict the flower of life (which is a sacred geometrical figure according to some) in the language of your choice.
The design consists an arrangement of circles and partial circles of radius 1 as shown whose centres arranged on a triangular grid of pitch 1, plus one larger circle of... | stackexchange_codegolf |
In a programming language of your choice, write 95 programs, each of which outputs a different one of the 95 printable ASCII characters without that character occurring anywhere in the program.
For example, if your language was Python, your program that outputs the character P might be
print(chr(80))
because P has ASC... | stackexchange_codegolf |
The challenge is relatively simple, but will hopefully lead to some wonderfully creative answers. The task is to take a string as an input (via command line, function parameter etc.) and output/return a stringsploded version of it.
A stringsploded version of a string is its first letter followed by its first 2 letters,... | stackexchange_codegolf |
Given as input a list of positive integers, your task is to determine if every integer present has exactly two neighbors in the list. The neighbors of a integer \$x\$ are the distinct integers that appear next to an \$x\$ anywhere in the list. For example in the list:
[1,3,4,4,3,2,1]
The number 3 has 3 neighbors 1, 4... | stackexchange_codegolf |
Overview
The sharpness of a word is the sum of the sharpness of each of its letters, using the following rules:
Sharp letters
A, and V each have a sharpness of 1
N and Z each have a sharpness of 2
M and W each have a sharpness of 3
Dull letters
C and U each have a sharpness of -1
S has a sharpness of -2
O has a shar... | stackexchange_codegolf |
Input:
A string (or the closest thing to that in your language)
Output:
The same string but converted to sentence case
Rules:
For this challenge, sentence case can be considered "The first letter of each sentence is capitalized. The rest are lowercase." (i.e. proper nouns do not have to be capitalized)
If the input do... | stackexchange_codegolf |
An ***ameoba graph**** is a type of tree whose nodes all have values from 0 to some non-negative integer N, and any particular node with value x < N connects to x+1 distinct nodes with values x+1.
Ameoba graph for N = 3: (Denoted A3)
Note that the 2's are not allowed to share any of the 3's; exactly three 3's must "be... | stackexchange_codegolf |
Given a character, output (to the screen) the entire qwerty keyboard layout (with spaces and newlines) that follows the character. The examples make it clear.
Input 1
f
Output 1
g h j k l
z x c v b n m
Input 2
q
Output 2
w e r t y u i o p
a s d f g h j k l
z x c v b n m
Input 3
m
Output 3
(Program terminates witho... | stackexchange_codegolf |
Given two non-zero 16-bit integers a and b, decide the smallest number of shift operations needed to turn a into b. A shift is one of the following (big-endian) operations:
shl (shift left): move all bits to the left, adding a 0x0 bit to the right.
shr (shift right): move all bytes to the right, adding a 0x0 bit to th... | stackexchange_codegolf |
Given a number n, calculates BB(n) (the maximum number of 1s finally on the tape, among all halting 2-symbol n-state Turing machines with tape of zeros).
To solve the problem, you are given an extra (black-box) function H as input, which takes a function in your language (f) and returns a truthy/falsy value indicates w... | stackexchange_codegolf |
A number spiral is an infinite grid whose upper-left square has number 1. Here are the first five layers of the spiral:
Your task is to find out the number in row y and column x.
Example:
Input: 2 3
Out : 8
Input: 1 1
Out : 1
Input: 4 2
Out : 15
Note:
Any programming language is allowed.
This is a code-golf cha... | stackexchange_codegolf |
Your task is to write a computer program such that when it is cut up into lines (split on the newline character) every arrangement of the lines will output a different number between 1 and n! (where n is the total number of lines). No number should be output by two different arrangements and every arrangement should o... | stackexchange_codegolf |
In my previous bioinformatics challenge, I asked you to mutate a DNA sequence. This time, I'd like you to evaluate how likely a mutation, or a series of mutations, is.
The two types of substitutions are transitions and transversions, and due to the chemical structure of DNA bases, transitions are more likely to occur t... | stackexchange_codegolf |
Given an input string only containing the characters A-Z, a-z, and spaces, remove all occurrences of the uppercase and lowercase versions of the first character of the string (if the first character is A remove all As and as, if the first character is (space) remove all spaces), and print the output.
Example cases:
T... | stackexchange_codegolf |
Background
An almost regular hexagon is a hexagon where
all of its internal angles are 120 degrees, and
pairs of the opposite sides are parallel and have equal lengths (i.e. a zonogon).
The following is an example of an almost regular hexagon, with side lengths 2 (red), 4 (blue), and 3 (yellow).
A triangular domino ... | stackexchange_codegolf |
Given a string s, return the smallest contiguous substring you can remove to create a palindrome.
Examples:
800233008 -> 2
racecarFOOL -> FOOL
abcdedcba -> (empty string)
ngryL Myrgn -> "L " (or " M")
123456789 -> 12345678 (or 23456789)
aabcdbaa -> c (or d)
[[]] -> [[ (or ]])
a -> (empty stri... | stackexchange_codegolf |
I was browsing Stackoverflow and saw this question about tiling an MxN rectangle, and I thought it would be great for golfing. Here is the task.
Given the dimension M and N, write a program that outputs how many unique ways a MxN rectangle (N is the number of rows, not columns. Not that it really matters) can be tiled ... | stackexchange_codegolf |
World Time Conversion
Challenge:
Given an initial clock time in UTC and a list of countries: for each country in the list, output the local time it is in that country based on the initial time. In cases where a country is big enough to have multiple local time zones (like the United States), you may output any valid l... | stackexchange_codegolf |
In a 9 by 9 grid some points have been marked. The task is it to
make a program that counts all distinct squares that can be made
using four marked points. Note that squares can also be placed
diagonally (any angle).
Input can be one of the following:
A character string of length 81 containing two distinct characters
... | stackexchange_codegolf |
Write a program fragment so that, when repeated N times it prints the Nth Fibonacci number. For example, if your program is print(x) then:
print(x) should print 1
print(x)print(x) should print 1
print(x)print(x)print(x) should print 2
print(x)print(x)print(x)print(x) should print 3
print(x)print(x)print(x)print(x)prin... | stackexchange_codegolf |
We know that f is a polynomial with non-negative integer coefficients.
Given f(1) and f(1+f(1)) return f. You may output f as a list of coefficients, an ASCII formatted polynomial, or similar.
Examples:
f(1) f(1+f(1)) f
0 0 0
1 1 1
5 75 2x^2 + 3
30 3904800 4x^4 + 7x^3 + 2x... | stackexchange_codegolf |
Display the emoji of the eastern zodiac of given time, according to given country.
The eastern zodiac is a classification scheme that assigns an animal and its reputed attributes to each year in a repeating 12-year cycle. It is also assigned to hours.
Rules:
The country must be given as ISO 3166-1 alpha-3 code. The li... | stackexchange_codegolf |
Let's have a ragged list containing no values, only more lists. For example:
[[[],[[]],[],[]],[],[[],[],[]],[]]
And the list will be finite, meaning that eventually every path terminates in an empty list [].
It's simple enough to determine if two of these are structurally equal. Check each element in order for equali... | stackexchange_codegolf |
Please help me automate my discrete mathematics homework. Given a valid propositional formula, check if it is an instance of one of Łukasiewicz's axioms. Here's how it works.
A term can be defined inductively as follows:
Single lower-case letters of the Latin alphabet (a, b, c, etcetera) are terms.
Given a term ϕ, ¬ϕ ... | stackexchange_codegolf |
A basket is full with \$n\$ colored balls. For each color except one, there are at least 2 balls with that color. Find the color which only has one ball. in \$O(n)\$ space complexity.
What if each ball is repeated exactly twice?
You can consider the input to be an array or a list or any container of colors as strings ... | stackexchange_codegolf |
So task is simple, given array of numbers and result, you need to find what operations you need to use on numbers from array , to obtain requested result.
Let's make it simple for start, and allow only basic operations such as: addition, subtraction, multiplication and division.
Example:
Input : [5,5,5,5,5] 100
Outpu... | stackexchange_codegolf |
Challenge
Given a positive integer N, output the sum of the first N reciprocals as an exact fraction, which is represented as a pair of integers in a consistent order representing numerator and denominator.
Rules
Output must be exact.
Output should be as a pair of integers in a consistent order representing numerator ... | stackexchange_codegolf |
There is a table (the matrix one, not the one in your kitchen) called the "mex table". It has a left-top cell, at coordinates (0,0), but extends to infinity rightwards and downwards. The x-coordinate increases to the right and the y-coordinate increases downwards.
Every cell has a value >=0, and the cell at (0,0) has t... | stackexchange_codegolf |
In the 1990s, COBOL computer engineers worked out a way to extend six-digit date fields by converting them to YYYDDD where YYY is the year - 1900 and DDD is the day of the year [001 to 366]. This scheme could extend the maximum date to 2899-12-31.
In the year 2898, the engineers started panicking because their 900 yea... | 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 |
Inspired by this stack of little statues that are currently on my desk at work, given to me by my colleagues from Sri Lanka when they visited The Netherlands:
This is split into two different challenges due to popular demand:
Part 1) Determine the amount of statues
Part 2) Can the statues be stacked? (this challenge)
... | stackexchange_codegolf |
This challenge is completely ripped offheavily inspired by All Light, developed by Soulgit Games.
Challenge
You are an electrician, and it's your job to wire up all the lights to the battery.
The lights and battery are laid out in a grid.
You can connect a light or battery to the nearest light or battery to its north,... | stackexchange_codegolf |
Background
One of the commonly meme'd aspects of javascript is its incredibly loose type coercion that allows for +!![]+[+[]] == '10' this technique can also be used to create letters as seen in the following example:
[[][[]]+[]][+[]][-~[]] == 'n'
[undefined+[]][+[]][-~[]] // [][[]] -> undefined
['undefined'][+[]][-~[]... | stackexchange_codegolf |
I got inspired by this: Print every character your program doesn't have
But with the exception that the letters have to be between ASCII 32 to 126. We started fooling around with it at the office with PHP and this is the best we could come up with:
<? while($i++<95)if(!strstr(file(__FILE__)[0],$a=chr($i+31)))echo$a;
Is... | stackexchange_codegolf |
Consider a list of subject, grade pairs. E.g.
[("Latin", "A"), ("French", "A*"), ("Math", "B"), ("Latin", "A*")]
The task is to return the same list but with each subject given at most once. Where a subject occurred more than once originally, the returned list should have the highest grade for that subject.
Using th... | stackexchange_codegolf |
Here are the letters of the English alphabet in order by frequency:
e t a o i n s h r d l c u m w f g y p b v k j x q z
That is, e is the most frequently used letter, and z is the least common. (Data from Wikipedia.)
Your challenge is to take some ROT-n'd text, such as:
ocdndnvqzmtnzxmzohznnvbzocvodnqzmtnzxpmzviynvaz
... | stackexchange_codegolf |
It turns out that my toaster is a tad broken. It lost WiFi (You know, it's one of those newfangled smart toasters), and its been going bonkers! Since it no longer works, I've been having to hack into my breakfast's source code and run Plate.bread.toastAs(3); every morning. Will you help?
My toaster takes one input: the... | stackexchange_codegolf |
I am looking for tips to code in this golfing language Seriously, and was wondering what some of the ways for golfing this language is. "Remove comments" is not a tip. Actually is also included
| stackexchange_codegolf |
Task
The input consists of a JSON object, where every value is an object (eventually empty), representing a directory structure. The output must be a list of the corresponding root-to-leaf paths.
Inspired by this comment on StackOverflow.
Input specifications
You can assume that that the input always contains a JSON ... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
It's time to prepare an advent calendar, but I've only got a large sheet of rectangular paper, randomly colored red and green like this:
GRRRGRRGRG
GGRGGGRRGR
GRRGRGRGRG
GGRRGRGRGG
GRGGRGRGGG
RRGRGRGRRG
RRRGRGRGGG
RGGRGGRRRG
RGGGRRRRRG... | stackexchange_codegolf |
I once saw on the xkcd fora a format for expressing numbers in an odd way. In this "factor tree" format:
The empty string is 1.
Concatenation represents multiplication.
A number n enclosed in parentheses (or any paired characters) represents the nth prime number, with 2 being the first prime number.
Note that this ... | stackexchange_codegolf |
The flag of Bangladesh is very simple. It looks like below:
The flag will be in bottle green (#006a4e) and rectangular in size in the proportion of length to width of 10:6, with a red circle in near middle. The red circle (#f42a41) will have a radius of one-fifth of the length of the flag. This image will help you to ... | stackexchange_codegolf |
Introduction
Write a program or function that adds a drop capital to a paragraph. The program will input the text to format, the column width, and the number of lines to drop the capital. The drop capitals look like this:
Lines: 2 3 4
Drop capital: A| A.| A..|
~' ..| ...| e... | stackexchange_codegolf |
The Challenge
Given a rational number, determine the smallest number which is a positive integer multiple of it. Eg.
Given: 1.25
x1: 1.25
x2: 2.5
x3: 3.75
x4: 5
Thus: Answer is 5
Clarifications
Inputs will be a rational number in the range of (0,100] of which the Decimal Representation has no more than 4 ... | stackexchange_codegolf |
The objective of this programming puzzle is to reproduce the following gif.
Simplification: If you notice the geometric figures don't exactly touch each other. I think it's simpler if you make each vertex to touch the respective edge, and not to go beyond it. I'm not sure though of how this will alter the configuratio... | stackexchange_codegolf |
You work for a social media platform, and are told to create a program in a language of your choice that will automatically flag certain post titles as "spam".
Your program must take the title as a string as input and output a truthy value if the title is spam, and a falsey value if not.
To qualify as non-spam, a title... | stackexchange_codegolf |
Knight is the Language of the Month for August 2022, and I noticed that it didn't have a tips page, so here it is!
I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Knight (e.g. "remove comments" is not an answer).
Please post only one tip per answer.
| stackexchange_codegolf |
Entries for this challenge will display an animated rotating Lissajous figure. The appearance of 3d rotation occurs as the x parameter is successively phase-shifted in each frame.
Input:
The a and b parameters (as per the wikipedia article) will be specified at the command line, or read from stdin.
Output:
This is asc... | stackexchange_codegolf |
Consider the Tetris pieces, but made out of some number of (hyper)cubes instead of four squares, where two blocks are considered the same if one is a rotation, reflection, or translation of another. The goal of this challenge is to take two positive integer input values, n and k, and count the number of \$n\$-celled po... | stackexchange_codegolf |
We're going rootin' tootin' cow-poke shootin!
This is a simple contest, first program to draw their pistol wins.
How it works:
I require 2 things from you, an executable, and a command to be run
from a bash terminal.
The executable needs to do one thing: wait
until it receives 'draw!' from STDIN, and then print 'bang!... | stackexchange_codegolf |
Objective
Create a function to reverse string concatenation
Input
Two strings (alphanumeric + spaces), where one should be subtracted for the other.
You can assume that the string to be subtracted will never be larger than the other one.
Output
The result from the subtraction
Subtraction
You should remove one strin... | stackexchange_codegolf |
Given a string that is potentially boxed in, toggle the box. This becomes clearer in the test cases and explanation.
Input / Output
Input Format
The input will be either a single string separated by CR, LF, or CRLF, or a list of strings. The input format is up to you to decide.
Output Format
The output format must be i... | stackexchange_codegolf |
If we have a binary matrix then we will say that a \$1\$ is stable if it is in the bottom row or it is directly adjacent to a \$1\$ which is stable.
In other words there must be a path to the bottom row consisting only of \$1\$s.
So in the following matrix the \$1\$s highlighted in red are not stable.
$$
0110\color{red... | stackexchange_codegolf |
Background
You awake to find yourself lost in a one dimensional labyrinth! A mystical genie (or something) appears and explains that the exit lies in front of you, but that between you and the exit is a series of challenges. As you wander forward you realize that all of the so-called challenges are merely locked doors.... | stackexchange_codegolf |
Given a pattern and a ragged list of positive integers, your task is to decide whether the pattern matches the ragged list.
The pattern is also represented by a ragged list. But in addition to positive integers, it may contain a wildcard value.
Here is the rule for matching:
A positive integer matches the same positiv... | stackexchange_codegolf |
Task
Given two positive integers, output the number of carries needed to add them together in long addition in base 10.
Examples
¹¹¹ <-- carries
999
+ 1
----
1000
Three carries are needed.
¹
348
+ 91
----
439
One carry is needed.
Testcases
999, 1 -> 3
398, 91 -> 1
348, 51 -> 0
348, 52 -> 2
5, 15 -> 1
9... | stackexchange_codegolf |
A first order separable ordinary differential equation is (arguably) the easiest type of differential equation to solve, and takes the form of
$$N(y)\frac{dy}{dx} = M(x) \\
y(x_0) = y_0$$
For two given functions \$N(y)\$ and \$M(x)\$ and an initial condition \$y(x_0) = y_0\$.
Your task is to take \$N(y)\$, \$M(x)\$, \... | stackexchange_codegolf |
Whilst trying (and failing) have persuade my infant son to eat his dinner, I tried singing to him. Mid way through this song I realised the formulaic structure might lend itself well to code golfing!
The task is to write a program or function which accepts no input and produces the following text:
There's a hole in the... | stackexchange_codegolf |
Somehow, we don't yet have a challenge for finding the inverse of an arbitrarily-sized square matrix, despite having ones for 3x3 and 4x4, as well as a more complex version.
Your task is, given a square \$n\times n\$ non-singular matrix \$M\$, output the matrix \$M^{-1}\$ that satisfies
$$MM^{-1} = I_n$$
There are a nu... | stackexchange_codegolf |
Note: There was not a vanilla challenge to actually flip a coin, even though there were mentions about flipping coins a lot of places. Even though there is a challenge to generate a random number from 1 to N, I suspect this is not a dupe. These questions ask for random numbers from 1 to N, while this ask for just trut... | stackexchange_codegolf |
Input
A non-empty string or list of capital letters k with length between 3 to 5000.
Output
A value indicating whether k can be expressed as a+b+b, where a and b are non-empty.
Truthy test cases
SSS
SNYYY
SNYY
SNNYY
SNYNY
Falsy test cases
FALSYTESTCASES
FALSYFALSYTESTCASES
FALSYTESTCASESXFALSYTESTCASES
FALSYTESTCASESF... | stackexchange_codegolf |
It's simple, simply output text to STDERR containing the string EOF.
Input/Output
Your input will be none; however, you should output the message to STDERR.
Rules
Since this is code-golf, the shortest answer wins.
No standard loopholes please.
Any method approved by Standard I/O is allowed.
Your code may not contain t... | stackexchange_codegolf |
Win a K vs KQ endgame
Summary
The goal of this challenge is to create a program or function which will win a Chess game with a King and Queen against a lone King. The user will specify three squares, representing the locations of the computer's King, the computer's Queen, and the user's King. The computer will then a o... | stackexchange_codegolf |
Problem:
Given a string representing a mathematical expression with constants (pi, e, psi, i), basic arithmetic operations (+, -, *, /), parentheses, fractions, and exponentiation, write a program or function to convert a string to its equivalent LaTeX code. The input string will only contain digits, arithmetic operato... | stackexchange_codegolf |
Two numbers are considered amicable if the proper divisor sum of the first is the same as the second number, the second number's proper divisor sum is equal to the first number, and the first and second numbers aren't equal.
\$s(x)\$ represents the aliquot sum or proper divisor sum of \$x\$. 220 and 284 are amicable be... | stackexchange_codegolf |
The Jaccard index / similarity coefficient, also known as the Tanimoto index / coefficient, is a statistic used for gauging the similarity and diversity of finite sample sets. It was developed by Grove Karl Gilbert in 1884 for the field of weather forecasting [1] and later independently developed by Paul Jaccard [2] wh... | stackexchange_codegolf |
This challenge is based on this Stackoverflow question.
With a positive number as input, output it as the sum of each digit multiplied by its power-of-10 representation.
Input
A number, as an integer, a string or a list of digits/characters.
The number will be strictly positive.
If you accept the number as a string or... | stackexchange_codegolf |
The Problem:
This challenge comes from a real problem I was having. I have a dual monitor setup at work, and I wanted to use the following image as my wallpaper:
However, my monitors have quite significant bezels, and when I set my background, it looks something like this, where the pier appears (appiers?) to be broke... | 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 |
I'm currently converting a Float32Array to an Int32Array for input to a real-time audio raw PCM to MP3 recording application.
new Int32Array([...new Float32Array(b)].map(f=>f<0?f*32768:f*32767)
The examples in the wild I've seen convert each float individually to avoid static, gaps, glitches when the audio recording i... | stackexchange_codegolf |
Cops thread
Robbers, your task is to crack a cops answer. Reveal the character that should be changed and what it should be changed to too.
Please notify the cop if you cracked their challenge.
The robber winner is the user with the most cracks.
I will declare the winner cop and robber a week after this challenge is po... | stackexchange_codegolf |
Introduction
What you have to do is, given an an ASCII diagram of a chemical, output the chemical formula.
Rules
Your code must not access the internet and may not use a stored library of molecules. You may have a library of elements.
You must verify all of the elements included in the formula are real, with all elemen... | stackexchange_codegolf |
Input
A binary string \$s\$ of length \$n\$ and a positive integer \$k \leq n\$.
Output
The number of binary strings with Levenshtein distance exactly \$k\$ from the string \$s\$.
Example outputs
Each example gives the largest possible output for the given \$(n, k)\$ pair.
k=1, s=1010, output=14
k=2, s=1010, outupt=55... | stackexchange_codegolf |
Definition
For any \$a\equiv1\ (\text{mod }8)\$ and \$n\ge3\$, there are exactly 4 roots to the equation \$x^2\equiv a\ (\text{mod }2^n)\$. Now, let \$x_k(a)\$ be the smallest root to the equation \$x^2\equiv a\ (\text{mod }2^k)\$, then $$\{x_3(a),x_4(a),x_5(a),x_6(a),\cdots\}$$ is a smallest square root sequence (SSRS... | stackexchange_codegolf |
Introduction
I would like to drawn a nice spinner by using eight braille patterns on two lines, drawing a square of 8x8 pixel, for showing a kind of snake growing and reducing:
declare -a shapes=([0]=$'\E[A⠁⠀⠀⠀\E[B\E[4D⠀⠀⠀⠀' [1]=$'\E[A⠈⠀⠀⠀\E[B\E[4D⠀⠀⠀⠀' [2]=$'\E[A⠀⠁⠀⠀\E[B\E[4D⠀⠀⠀⠀' [3]=$'\E[A⠀⠈⠀⠀\E[B\E[4D⠀⠀⠀⠀' [4]=$'\E... | stackexchange_codegolf |
UPDATED SCORING: As this challenge is more difficult than I anticipated, I have adjusted the scoring. A program that can solve a single mirror input is a valid answer. More sophisticated programs get a bonus to their score.
There have been several puzzles on PPCG to find a laser path in a box of
mirrors. In this puzzle... | stackexchange_codegolf |
In the description of this challenge, the following board will be used as a reference for positions:
ABC
DEF
GHI
For instance, in a game of ordinary tic-tac-toe, B E A C G D F H I describes the following:
-X- -X- XX- XXO XXO XXO XXO XXO XXO
--- -O- -O- -O- -O- OO- OOX OOX OOX
--- --- ... | stackexchange_codegolf |
Implement a function or program which raises x to the power of y. Inputs are 16-bit signed integers. That is, both are in the range [-32768, 32767]. The output should be in the same range. I chose this range because it should make it possible to do exhaustive testing to ensure all edge-cases are covered.
If the output ... | stackexchange_codegolf |
Don't you hate it when you can't remember how to craft something in Minecraft? Well, time to remedy that!
Task
Your task is to take an input, either as a 1D or 2D list and output what item is a result of the crafting table!
Input
You may take input as either a string or a list of length 9 or a 2D nested array.
If you t... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.