instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Challenge:
Given an NxN matrix where \$N\geq2\$ and one of eight distinct 'folding options', output a 2D array/list with the subtracted values.
The eight folding options are: left-to-right; right-to-left; top-to-bottom; bottom-to-top; topleft-to-bottomright; topright-to-bottomleft; bottomleft-to-topright; bottomright-t... | stackexchange_codegolf |
Universal Command Sequence
Definition
An \$n\$-maze is a \$n\times n\$ chessboard which has "walls" on some edges, and a "king" on the board that can move to the 4 adjacent cells, which cannot pass through any walls. Starting from any cell the king should be able to reach every cell on the board.
A command sequence is ... | stackexchange_codegolf |
In this challenge, you will write an interpreter for 2Ω (transcribed as TwoMega), a language based loosely on brainfuck with an infinite-dimensional storage space.
The Language
2Ω contains three pieces of state:
The Tape, which is an infinite list of bits, all initialized to 0. It has a leftmost element, but no rightm... | stackexchange_codegolf |
You are given a board position for a Go game and a move to play. You need to output whether the move is legal or not, and the new board position if it is legal.
A brief explanation of Go moves: the game consists of alternatively placing black and white pieces ("stones") in empty places on a square board. Sets of pieces... | stackexchange_codegolf |
This is a short one:
Only once in American history has there been a decade in which four of the years were prime numbers.
Your program has to output the decade after 1776 where four its years were primes. This is code golf so the shortest code wins.
The output must be like so:
1710s
or
1980s
Note: The answer must b... | stackexchange_codegolf |
Given a list of non-negative integers the function \$f\$ replaces every integer with the number of identical integers preceding it (not necessarily contiguously). So
f [1,1,2,2,1,3,3] = [1,2,1,2,3,1,2]
We will say that a list, \$X\$, is in a loop if there is some positive integer \$n\$ such that \$f^n X = X\$. That i... | stackexchange_codegolf |
Disclaimer: ModTen is a fictional card game which was created for the sole purpose of this challenge.
The rules of ModTen
ModTen is played with a standard 52-card deck. Because the full rules are yet to be invented, we're going to focus on the hand ranking exclusively.
A winning hand in ModTen. Graphics from Wikipedia... | stackexchange_codegolf |
Pyth is a golfing language based on Python. It uses prefix notation, with each command having a different arity (number of arguments it accepts).
Your task is to write a syntax checker for a (non-existent) Pyth-like language, Pith.
Pith's syntax
Pith only has 8 single-char commands:
01234()"
01234 each have arity of t... | stackexchange_codegolf |
Input
The input will be a year between 1583 and 2239. We just want to know when Hannukah was or will be in that year. This is information used by millions of people every year and put in calendars across the world. What could be easier?
Output
The Gregorian date of the first evening of Hannukah that year. That is the ... | stackexchange_codegolf |
A positive integer \$k\$ is a Loeschian number if
\$k\$ can be expressed as \$i^2 + j^2 + i\times j\$ for \$i\$, \$j\$ integers.
For example, the first positive Loeschian numbers are: \$1\$ (\$i=1, j=0\$); \$3\$ (\$i=j=1\$); \$4\$ (\$i=2, j=0\$); \$7\$ (\$i=2, j=1\$); \$9\$ (\$i=-3, j=3\$); ... Note that \$i, j\$ for... | stackexchange_codegolf |
Given a list of coordinate pairs, output the Trapezoidal Riemann Sum of the values given between the first and last x-coordinates.
You will be given a sorted list of coordinate pairs, like this:
[
[1,2],
[3,5],
[5,11]
]
Note that x-coordinates will always be in increasing order, ys may not.
My way to do this is ... | stackexchange_codegolf |
Given a positive input \$n\$, output a random pair of primes whose difference is \$n\$. It's fine if there's another prime between them.
Every pair should possibly appear and the program should have zero possibility to fall into infinite loop.
It's promised that such pair exist, but not always infinite, so beware. You ... | stackexchange_codegolf |
Last year, there was a very popular challenge to create an image containing every 24-bit RGB colour.
My challenge is to create a smooth animation (24 frames/s say), where the colour of every pixel of every frame is unique. I will also allow duplication of colours as long as every colour appears the same number of time... | stackexchange_codegolf |
Consider a n x n multiplication table and replace each item with its remainder of division by n. For example, here is a 6x6 table and its "modulo 6" structure: (The last column and row are ignored since both are null)
1 2 3 4 5 6 | 1 2 3 4 5
2 4 6 8 10 12 | 2 4 0 2 4
3 6 9 12 15 18 | 3 0 3 0 3... | stackexchange_codegolf |
I came up with a series of numbers the other day and decided to check what the OEIS number for it was. Much to my surprise, the sequence did not appear to be in the OEIS database, so I decided to name the sequence after myself (note that someone else who's a lot smarter than me has probably already come up with this, ... | 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 |
This is based off a previous deleted challenge of mine with the same name
Introduction
You are tasked with writing a program that returns a truthy or falsey value based on if the input has all its XML-like1 tags appropriately opened and closed and in the right order. Consider the following as input:
<Apple>
This would... | stackexchange_codegolf |
Given an integer N as input, output the Nth permutapalindromic number.
A permutapalindromic number is a strictly positive integer such that there is at least one permutation of its digits that results in a palindrome (i.e. a number that is its own reverse).
For example, 117 is a permutapalindromic number since its digi... | stackexchange_codegolf |
Ohm's law tells us that the current (I) in amps flowing through a resistance (R) in Ohms when a voltage (V) is applied across it is given as follows:
V = I / R
Similarly the power (P) in watts dissipated by that resistance is given by:
P = V * I
By rearrangement and substitution, formulae may be derived for calculati... | stackexchange_codegolf |
Given input of a positive integer n, write a program that completes the following process.
Find the smallest positive integer greater than n that is a perfect square and is the concatenation of n and some other number. The order of the digits of n may not be changed. The number concatenated onto n to produce a perfect... | stackexchange_codegolf |
Introduction
A childhood game designed to help children learn to count in french in Canadian schools is played as follows:
Students go around the room counting up to 11
A number greater than 11 cannot be said
A student can say either 1, 2, or 3 numbers
If a student says the number 11 then they are removed from the nex... | 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 |
A digit word is a word where, after possibly removing some letters, you are left with one of the single digits:
ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT or NINE (not ZERO).
For example, BOUNCE and ANNOUNCE are digit words, since they contain the digit one.
ENCODE is not a digit word, even though it contains an O,... | stackexchange_codegolf |
Your goal is to calculate the sum of Fibonacci series from n th term to m th term (including both terms).
No use of / * % or mathematically what they are in your language of choice.
No use of special functions or code language specialized in doing so !
You have to produce the series yourself and not by any special fun... | stackexchange_codegolf |
Definition
In Mathematics, Harmonic Sequence refers to a sequence where
$$a_n = \frac 1 n$$
i.e. the \$n_{th}\$ term of the sequence equals the reciprocal of \$n\$.
Introduction
In this challenge, given a positive integer \$n\$ as input, output the Partial Sum of first \$n\$ terms of the Harmonic Sequence.
Input
Yo... | stackexchange_codegolf |
Write two programs, each taking a string s and a number n ≥ 0, such that:
The first program prints s n times, separated by newlines.
The second program prints each character of s n times, with repeated characters separated by newlines.
Every character at column x, line y in one program equals the character at column y... | stackexchange_codegolf |
Do you remember my mat properly grouped by colors?
Yesterday I was looking at it and realized that some letters fit inside others. Example: a letter P fits in the place where the letter R goes. So here's a simple challenge: given two letters, return a truthy value if any one of the letters fits inside the other (direc... | stackexchange_codegolf |
Problem
Build an octal calculator that can do the following operations:
Add (+)
Subtract (-)
Multiply (*)
Divide (/)
Check is prime
Counting in octal is like this with decimal
(Octal) (Decimal)
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
10 8
11 9
and so on..... | stackexchange_codegolf |
Context
After attempting to program in Grass for the entire morning, you decide to go outside and mow some real grass. The grass can be viewed as a string consisting exclusively of the following characters: wWv. w denotes tall grass which takes \$ 1 \$ unit of energy to mow. W denotes extremely tall grass which takes \... | stackexchange_codegolf |
How much can you golf a program to print "An Old Irish Blessing" without using unprintable ASCII characters?
That restricts us to ASCII characters 32-126 (better still, 32,65-90,97-122 and 13(CR))
For reference that version of the proverb is 205 characters long (excl. newlines).
I'm curious if anything beats Huffman-en... | stackexchange_codegolf |
For today's challenge you have to take an input, and if your source code is reversed, then the input should be printed doubled.
Let's say your source code is ABC and its input is xyz. If I write CBA instead and run it, the output must be any of be xyzxyz or xyz xyz or
xyz
xyz
For any numerical input you should not mu... | stackexchange_codegolf |
Challenge
Given a number, x where -1 ≤ x ≤ 1, and the integers a and b, where b > a, solve the equation sin(θ) = x for θ, giving all solutions in the range a° ≤ θ ≤ b°.
Rules
x will have a maximum of three decimal places of precision. The output, θ, must also be to three decimal places, no more, no less.
Your output ma... | stackexchange_codegolf |
I was browsing Stack Overflow when I saw this post in Puzzling in the hot network questions and decided to make a challenge out of it (all credit goes to the creator of the challenge).
Overview
A Chess Number is a number that, when converted to base 18, results in a valid chess coordinate pair, where the first characte... | stackexchange_codegolf |
(The text asks how many boxes there are in the picture)
Now you are required to generate such a problem and its answer.
Input
an integer n
(optionally) random source of two values, in case you don't want to use the default random.
Output can be
a 3D array A[n][n][n] of booleans, where A[i][j][k] => (i==0 || A[i-1][... | stackexchange_codegolf |
The challenge, should you accept it, is to determine how much you win in the Bingo Golf Flax Lottery. Based on but not equal to the BingoFlax lottery
The input is two lists of numbers (positive non-zero integers).
The first list always contains 24 potentially non-unique numbers that make up your board, a 5 x 5 grid of ... | stackexchange_codegolf |
The event scheduler is a recurrent theme in event-driven architectures: something triggers an event that needs to be checked in the future one or more times. I has particular use in trading where you want to correlate one market event with price movements in the future at several time deltas (1ms, 100ms, 1s, 1 min, etc... | stackexchange_codegolf |
Program A outputs program B's code when run, and B outputs A's source.
Requirements:
Only one language across both programs
Programs are different. One program that outputs itself does not qualify.
Both programs are non-empty, or at least 1 byte in length. Trailing newlines in both source and output are ignored
st... | stackexchange_codegolf |
This is the robbers' thread to a cops-and-robbers challenge. Click the link to find the cops' thread.
In the cops' thread of this challenge, answerers will be writing programs which output two numbers, \$x\$ and \$y\$. As robbers, your goal will be to crack their submissions. To do this, you find a program in the ... | stackexchange_codegolf |
(Note: I know that the VSEPR method fails sometimes, and that there are exceptional molecules. The challenge is about the molecules which conform.)
Most people who have taken an introductory chemistry course know about molecules, and (probably) the VSEPR theory of chemical bonding. Basically, the theory predicts the ... | stackexchange_codegolf |
Programmers are often obsessed with drawing fractals. I think we need a new computer based medium.
The H tree is a fairly simple type of fractal made of horizontal and vertical lines. Here it is at it's tenth iteration (courtesy Wikipedia):
Now, imagine each of the lines in the image is a directory (folder) in a stand... | stackexchange_codegolf |
Background:
The current Perfect Numbers challenge is rather flawed and complicated, since it asks you to output in a complex format involving the factors of the number. This is a purely decision-problem repost of the challenge.
Challenge
Given a positive integer through any standard input format, distinguish between wh... | stackexchange_codegolf |
The game of Ghost is played between two players who alternate saying a letter on each turn. At each point, the letters so far must start some valid English word. The loser is the player to complete a full word first. So, for example, if the letters so far are E-A-G-L, then the only valid next letter to say is "E" an... | stackexchange_codegolf |
Jelly has compressed string literals, using the “...» delimiters. The way these work is by interpreting the ... as a base-250 integer, \$n\$, then repeatedly divmod-ing this integer until it reaches \$0 \newcommand{\d}[2]{ \left( \left\lfloor \frac {#1} {#2} \right\rfloor, #1 \text{ mod } #2 \right) }\$, building up th... | stackexchange_codegolf |
Robbers thread
Your task is to create a method for hiding information in an image. You will post three encoded messages of your choice (keep them classy), each with its associated image. Reveal the messages for the first two images and do not reveal the third. Robbers have the task of determining what your third hidden... | stackexchange_codegolf |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
Related to AoC2016 Day 1, Part 1.
You're airdropped near Easter Bunny Headquarters in a city somewhere. "Near", unfortunately, is as close as you can get - the instructions on the Easter Bunny Recruiting Document the Elves intercepted start ... | stackexchange_codegolf |
Introduction
In the game The Witness (possible spoilers ahead) there is a group of puzzles that involve drawing a Tetris piece with your line while making sure that the symbol for the Tetris piece your currently drawing stays contained within the shape you've drawn.
For the image above the drawing works because the ... | stackexchange_codegolf |
Background Information
Inspired by this answer on Arqade SE
Minecraft has rails which allow you to move minecarts around on them for transporting players, entities, and items. There are many types of rails, but today we're only interested in regular rails, which are also the only type that can curve.
When you place dow... | stackexchange_codegolf |
Fennel is a lispy language which compiles to Lua.
From its page:
Fennel is a programming language that brings together the speed, simplicity, and reach of Lua with the flexibility of a lisp syntax and macro system.
I am looking for general tips for golfing in this language. Tips should be specific to Fennel, "Remove ... | stackexchange_codegolf |
PPCG hasn't had enough of quines already...
Challenge:
Your task is to create a program "A0". When this program is run with no input, it outputs nothing. When this program is run with input, it outputs "A1". When "A1" is run with no input, it outputs "A0". When "A1" is run with input, it outputs "A2". Pretty much, "A(k... | stackexchange_codegolf |
Define the (unnormalised) Willmore energy of a surface as the integral of squared mean curvature over it:
$$W=\int_SH^2\,dA$$
For surfaces topologically equivalent to a sphere \$W\ge4\pi\$, and \$W=4\pi\$ iff it is actually a sphere. Thus the energy quantifies how spherical a surface is.
In September 2020 I asked on Ma... | stackexchange_codegolf |
Challenge:
Your job is to create a simple interpreter for a simple golfing language.
Input:
Input will be in the form of string separated by spaces.
You can replace space separation with what you want
Output:
Output the result (a number or a string) obtained after performing all operations. If there are more than on... | stackexchange_codegolf |
The newest "nice" OEIS sequence, A328020, was just published a few minutes ago.
Number of distinct tilings of an n X n square with free n-polyominoes.
This sequence counts tilings up to symmetries of the square. The sequence has six terms, but I'd like to see if folks here can extend it further.
Example
For n=4 there... | stackexchange_codegolf |
Squares looks symmetric, and so are the required codes.
Objective: Write a program whose source code is a solid square (N lines with N printable, non-whitespace characters each line) and prints a square of equal size. A program (or output) with inconsistent width and height is invalid. (e.g. 6x5)
Example (HQ9+)
QAA
AAA... | stackexchange_codegolf |
Write a program that, when run in different languages, outputs a different byte permutation of the code in each language. The exact source code is counted as one permutation.
Here "different language" can be different version(Py 2 and Py 3) or different standard flags. It's different output that forces different versio... | stackexchange_codegolf |
There is a well-known bijection between the permutations of \$n\$ elements and the numbers \$0\$ to \$n!-1\$ such that the lexicographic ordering of the permutations and the corresponding numbers is the same. For example, with \$n=3\$:
0 <-> (0, 1, 2)
1 <-> (0, 2, 1)
2 <-> (1, 0, 2)
3 <-> (1, 2, 0)
4 <-> (2, 0, 1)
5 <-... | stackexchange_codegolf |
This is a version of this question which should not have such a straightforward solution and so should be more of an interesting coding challenge. It seems, for example, very likely there is no easy to find closed form solution, even though we have only increased the bound by one from the previous version. Having said ... | stackexchange_codegolf |
Given a string as input, output a number of whitespace characters (0x0A and 0x20) equal to the length of the string.
For example, given the string Hello, World! your code would need to output exactly 13 whitespace characters and nothing else. These can be any mix of spaces and newlines.
Your code should not output any ... | 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 |
Given a non empty finite sequence of integers, return an arithmetic subsequence of maximal length.
If there are multiple of the same maximal length, any of them can be returned.
Definitions:
An arithmetic sequence is a sequence \$a(1),a(2),a(3),a(4),...\$ such that there is a constant \$c\$ such that \$a(m+1)-a(m) = c\... | stackexchange_codegolf |
As someone who can't be bothered to look at their pentominos to see if it makes a rectangular shape, I've decided to make you write a program that does it.
Your task
Given some input split by newlines containing 12 unique characters, decide if it is a valid solution.
A valid solution MUST
Have 5 of each character (exc... | stackexchange_codegolf |
It's very easy:
Create a program without writing a single line of code. The code may only consist of existing Stack Overflow questions and answers.
The program should create two random numbers and output the numbers
added to,
subtracted from,
multiplied with and
divided by
each other.
Rules
You must include lin... | stackexchange_codegolf |
Given a natural number n write a program or function to get a list of all the possible two factors multiplications that can be used to achieve n. To understand better what is pretended you can go to http://factornumber.com/?page=16777216 to see when n is 16777216 we get the following list:
2 × 8388608
4 × 41943... | stackexchange_codegolf |
Write a piece of code that takes a string as input, and outputs a piece of code in the same language that, when run, will output the initial input string.
It must be able to handle any combination of characters A-Z, a-z, and 0-9.
Example in Python:
import sys
print "print('" + sys.argv[1] + "')"
Given the input of te... | stackexchange_codegolf |
Introduction
My gnome friends are writing a programming language and have asked for my help. Due to their size, the gnomes can only handle small superscript numbers instead of big numbers. However, the language they're writing the interpreter in only accepts big numbers!
Your Challenge
Given an input of a superscript n... | 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 |
Write a program that takes in a string and spells that word out using the NATO Phonetic Alphabet.
The mapping is as follows:
'A' -> 'Alfa'
'B' -> 'Bravo'
'C' -> 'Charlie'
'D' -> 'Delta'
'E' -> 'Echo'
'F' -> 'Foxtrot'
'G' -> 'Golf'
'H' -> 'Hotel'
'I' -> 'India'
'J' -> 'Juliett'
'K' -> 'Kilo'
'L' -> 'Lima'
'M' -> 'Mike'... | stackexchange_codegolf |
I was messing around on my 'ol TI-84 CE and made a program that produced this output (it was actually bigger but that is not the point):
*
* *
* * *
* *
*
* *
* * *
* *
*
...
I evolved it to take input text and make the triangle waves out of that. The final step was to also take a number to specify th... | stackexchange_codegolf |
If you consider the following PHP+C polyglot snippet, there is a problem regarding class property access in the printf call:
#include <stdio.h>
#include <stdlib.h>
#define class struct
#define function
class Point {
#define public int
public $x;
public $y;
};
int
function main()
{
struct Point*
$p = ... | stackexchange_codegolf |
Given a string, find the first word starting with each letter (case insensitive).
Sample
Using Ferulas flourish in gorgeous gardens. as input:
"Ferulas flourish in gorgeous gardens."
^^^^^^^ ^^ ^^^^^^^^
| | |
| | --> is the first word starting with `g`
| --> i... | stackexchange_codegolf |
This code-golf challenge will give you two positive integers n and k as inputs and have you count the number of rectangles with integer coordinates that can be drawn with vertices touching all four sides of the \$n \times k\$ rectangle $$
\{(x,y) : 0 \leq x \leq n, 0 \leq y \leq k\}.
$$
That is, there should be:
at le... | 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 |
I have this problem where I listen to so much music that I can never remember what songs are called. But even if I remember the lyrics, I won't always know the song's name. But lucky for me, there's a pretty neat formula to determine¹ the title of a song just based on its lyrics.
I'll define the way a song title can be... | stackexchange_codegolf |
Introduction
The task is simple. When given a number, output the most logical rectangle. To explain what a logical rectangle is, I provided some examples:
Input: 24.
All possible rectangles have the form A x B, (A and B are both positive integers). So, all possible rectangles for 24 are:
1 x 24
2 x 12
4 x 6
From this... | stackexchange_codegolf |
Given a list of positive integers, give the longest contiguous sublist which contains at most 1 pair of identical items. In the case of a tie return any of the solutions.
This is code-golf so the goal is to minimize your source code with answers being scored in bytes.
Test cases
[] -> []
[1,2,3] -> [1,2,3]
[1,2,2,3] -... | stackexchange_codegolf |
This is alternate of a rip-off of a rip-off of a rip-off of a rip-off of a rip-off of a rip-off. Go upvote those!
Your task, if you accept it, is to write a program/function that outputs/returns its input/args. But again, The tricky part is that if I rot-13 your source code, the output must be returned rot-19.
Your co... | stackexchange_codegolf |
Inspired (you don't need to know them for this challenge) by the Pumping Lemma for various languages, I propose the following challenge:
choose some basis \$B \geq 2\$ and an integer \$n \geq 0\$
write a program/function \$P\$
partition* \$P\$ into some strings \$s_i \neq \epsilon\$, st. \$P = s_n | \cdots | s_i | \cd... | stackexchange_codegolf |
A great Python golfing tip is to omit needless spaces. But if you are like me, you don't always have the time to search for which spaces to remove. If only there was a way to speed up the process...
Task
Given a single line of Python, as input, return/output a new line which omits all needless spaces. The table below s... | stackexchange_codegolf |
Powers
We define an important power as a number that can be represented as \$ x^y \$ where \$ x ≥ 2 \$ and \$ y ≥ 2 \$.
Palindrome
We define an important palindrome as a number that is the same written forwards and backward, and is greater than 10. Thus, the last digit must not be 0.
Palindromic Power
We define a Palin... | stackexchange_codegolf |
Challenge
Premise
I've got multiple pretty numbers all in a row. Each is a decimal digit.
0s are weakly attracted to 0s, 1s are attracted to 1s a little more strongly and so on until 9. I don't know why — it must be something I ate. As a result, a sort of two-way sideways sedimentation occurs until the higher values ar... | stackexchange_codegolf |
Related
From Wikipedia:
In number theory, the Calkin–Wilf tree is a tree in which the vertices correspond one-to-one to the positive rational numbers. The tree is rooted at the number \$1\$, and any rational number expressed in simplest terms as the fraction \$\frac{a}{b}\$ has as its two children the numbers \$\frac{... | stackexchange_codegolf |
According to the Wikipedia page on the number 69, it is of note that \$69^2 = 4761\$ and \$69^3 = 328509\$ together use all decimal digits. The number 69 is in fact the lowest number that satisfies this property.
For a similar reason, \$32043\$ is remarkable: \$32043^2 = 1026753849\$ uses all decimal digits.
If we're g... | stackexchange_codegolf |
While implementing polynomial multiplication in Itr I found the following interesting operation on strings
To compute the convolution of two strings (for instance Hello and World) first combine all pairs of letters with indices that add up to the same number
(ordered by the index of the first element)
0 -> "HW"
1 -> "... | stackexchange_codegolf |
OG post
Task
In this challenge, you will be given an string emoticon, and your task will be to output its happiness.
How?
An emoticon will always have eyes and mouth. It can also include eyebrows and nose. Each part will influence the overall happiness rating, which is the sum of happiness ratings of all parts. Emotic... | stackexchange_codegolf |
Write a program or function that takes two inputs:
A text message
The dictionary of English language, as it appears in this Github file (containing about 60000 words)
and outputs the number of spelling errors in the message (see below for definition and test cases).
You can receive the dictionary as a parameter to yo... | stackexchange_codegolf |
The original 151 Pokemon, in an array format suitable for initializers:
["Bulbasaur", "Ivysaur", "Venusaur", "Charmander", "Charmeleon", "Charizard", "Squirtle", "Wartortle", "Blastoise", "Caterpie", "Metapod", "Butterfree", "Weedle", "Kakuna", "Beedrill", "Pidgey", "Pidgeotto", "Pidgeot", "Rattata", "Raticate", "Spear... | stackexchange_codegolf |
Background
The systematic chemical symbol is defined as such for \$ 118 < n < 1000 \$:
The first letter corresponds to the first digit, capitalized.
The second letter corresponds to the second digit.
The third letter corresponds to the third digit.
This can be generalized for all \$ n > 0\$:
For each digit, get the ... | stackexchange_codegolf |
Do you know the book Murderous Maths, in the Horrible Science series? In the book, the Laplace Princess' "ridiculous" cipher might be interesting enough and simple enough to be a code-golf challenge.
Task
The original cipher looks like this:
Please read primes elephant help you me like cold
The nth word is only meani... | stackexchange_codegolf |
Spherical excess of a triangle
As we all know, the sum of angles of any planar triangle is equal to 180 degrees.
However, for a spherical triangle, the sum of angles is always greater than 180 degrees. The difference between the sum of the spherical triangle angles and 180 degrees is called spherical excess . The task ... | stackexchange_codegolf |
Introduction
Factorials are one of the most frequently used examples to show how a programming language works.
A factorial, denoted \$n!\$, is \$1⋅2⋅3⋅…⋅(n-2)⋅(n-1)⋅n\$.
There is also the superfactorial (there are other definitions of this, but I chose this one because it looks more like the factorial), denoted \$n$\$,... | stackexchange_codegolf |
In my language Pyramid Scheme, there is a slightly funny construct: the empty triangle:
^
-
When given no arguments, it returns 0. To generate 1 using this construct, we could use this:
^
/!\
^---
-
This simply passes 0 to the negation function. We can continue negating this result:
^
/!\
---^
/!\
^---
-
... | stackexchange_codegolf |
Take the string of brackets ]][][[. When you rotate it to the right once, you get []][][. If you rotate it again, you get [[]][]. All brackets in this string are balanced.
The Task:
Your program (or function) will be given a string of brackets, represented in any reasonable format (including using other things in place... | stackexchange_codegolf |
You’re given two \$r×c\$ grids. Each cell contains either 0 or 1. What are the minimum number of swaps (between horizontally and vertically adjacent cell elements, no wrapping i.e no swapping between last and first element of a row) are required in the first grid for it to match the second. If the matched arrangement c... | stackexchange_codegolf |
We define \$a(n)\$ as the 1-indexed position of \$n\$ in the sequence of positive integers with the same binary weight, i.e. the same number of 1's in their binary representation. This is A263017.
Given a positive integer \$n\$, your task is to determine how many positive integers \$k\$ satisfy:
$$k-a(k)=n$$
For instan... | stackexchange_codegolf |
Guidelines
Scenario
John has an important number, and he doesn't want others to see it.
He decided to encrypt the number, using the following steps:
His number is always a non-decreasing sequence (ie. "1123")
He converted each digit into English words. (ie. "123" -> "ONETWOTHREE")
And then, rearrange the letters random... | stackexchange_codegolf |
Introduction
Last year was my birthday (really!) and sadly I had to organise my own party. Well, now you know, couldn't you at least make the cake?
Challenge
Given an integer n as input, write a full program to output a birthday cake with n candles on.
Output
A piece of cake with one candle on is:
$
|
---
~~~
---
An... | stackexchange_codegolf |
Consider two sorted arrays of integers \$X\$ and \$Y\$ of size \$m\$ and \$n\$ respectively with \$m < n\$. For example \$ X = (1,4)\$, \$Y = (2,10,11)\$.
We say that a matching is some way of pairing each element of \$X\$ with an element of \$Y\$ in such a way that no two elements of \$X\$ are paired with the same el... | stackexchange_codegolf |
I'm sure most of us have heard of zip bombs and similar decompression bomb tricks, where a maliciously crafted input creates a massively disproportionate output. We even had a question on here to do that to a compiler at one point.
Well, it occurs to me that Markdown is a compression format of sorts, replacing bulky H... | stackexchange_codegolf |
Challenge
Predict the distance between the Sun and the nth planet when using any formula that gives the same result as the Titius–Bode law: d=(3*2^n+4)/10.
BUT WAIT... there is one restriction:
Your source code can not include any of the Titius–Bode law's digits
So, your program can not contain the characters 0, 1, 2,... | stackexchange_codegolf |
Your task is to display the below letter "E" shaped ASCII art, given five inputs.
Examples:
Input: 7,2,+,|,- (Note: You don't have to follow this exact input format, and if you don't use it, then you must explain how your own input format works)
Explanation:
7 total width, including the left and right edge characters.... | stackexchange_codegolf |
Challenge:
Given an array of non-negative whole numbers numbers in the range of 0 to Infinity, Check whether all of them are primes or not. (You can take input as a string too if you want)
Input:
Input: An array of numbers
Output: The array with every element replaced by one of these:
-1 -----> If 0, 1
... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.