instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Mary has given John two sticks of lengths a and b respectively, where a and b are positive integers.
John is very curious.
He would like to know how many triangles with integer perimeter can be formed, by having one additional side.
Please help him find it out.
(This is my first time composing this kind of stupid stori... | stackexchange_codegolf |
Non-associative operators (for example the subtraction-operator) often are either left- or right associative, such that one has to write less parentheses. Consider for example the following:
$$
a-b-c
$$
Probably everybody read that as \$(a-b)-c\$, by default (usually) subtraction is left-associative.
Now let us conside... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
Santa and the Elves are secretly preparing for a new tourist train service, called "North Pole Railroads". The train will travel through various sightseeing spots near the North Pole.
As a part of this project, they want to know how ma... | stackexchange_codegolf |
You will receive an integer less than 2000000000 and bigger than -2000000000 and you have to test what type(s) of number this is out of:
Factorial
Square
Cube
Prime
Composite
Triangular
Positive
Negative
Here is a definition of all the different types of numbers:
Factorial - A number That is equal to the product of a... | stackexchange_codegolf |
Programs often list outcome statistics, such as this:
54% of participants received an award
69% of participants got a promotion
85% of participants increased their salary
These percentages are the result of dividing a/x, where both a and x are whole numbers, and the result is rounded to the nearest hundredth.
Your ta... | stackexchange_codegolf |
A reflexicon is a self-descriptive word list that describes its own letter counts. Take for example the one found by Ed Miller in 1985 in English:
Sixteen e’s, six f’s, one g, three h’s, nine i’s, nine n’s, five o’s, five r’s, sixteen s’s, five t’s, three u’s, four v’s, one w, four x’s
This reflexicon contains exactl... | stackexchange_codegolf |
Bobby's booby-trapped safe requires an n-digit code to unlock it. Alex has a probe which can test combinations without typing them onto the safe. The probe responds Fail if no individual digit is the same as that in its corresponding position in Bobby's code. Otherwise it responds Close, including when all digits are c... | stackexchange_codegolf |
The picture:
Sick of the same old grid where the answer is simply a square pyramidal number?
Accept the challenge and write a program that given a positive integer \$n\$ counts how many squares are in the \$n^{\text{th}}\$ iteration of the Harter-Heighway dragon!
The sequence of squares of size 1 is A003230
Your cod... | stackexchange_codegolf |
Task
Given two positive integers \$m,n\$, imagine a chessboard of size \$m \times n\$. A chess queen is on the upper-left corner. In how many ways can it reach the lower-right corner, by moving only right, down, or diagonally right-down (possibly moving many steps at once, because it's a queen)?
The resulting 2D sequen... | stackexchange_codegolf |
Scala isn't a very commonly used language around here. Most of those who know it like it[citation needed], but some go :\ when they encounter its user-defined operators, saying they're too complicated.
However, they're governed by a very simple set of rules, outlined here. Their precedence depends on the first characte... | stackexchange_codegolf |
Introduction:
Inspired by a discussion that is already going on for many years
regarding the expression \$6÷2(1+2)\$.
With the expression \$6÷2(1+2)\$, mathematicians will quickly see that the correct answer is \$1\$, whereas people with a simple math background from school will quickly see that the correct answer ... | stackexchange_codegolf |
I was wondering if there is any way to assign 2 values (G and H) to say a list of ["egg", "chicken"] in Pyth. In python it would be something along the lines of
G, H = ["egg", "chicken"]
At the moment the shortest way I can think of would be something like
=N["egg""chicken")=G@N0=H@N1
which uses the lookup function t... | stackexchange_codegolf |
disclaimer: I'm not aware of any non-bruteforce solutions
A Graeco-Latin square is, for two sets of same length \$n\$, a \$n \times n\$ arrangement of cells, each containing a unique (across the entire square) pair of a element of the first set and a element of the second set, such that all first elements and all sec... | stackexchange_codegolf |
Introduction and credit
Assume you're a bartender. You have many happy people in your bar at most times, but many only ever drink the very same drink and too few for your taste and you want to change that. So you introduce a system where the price of a drink is variable, depending on how many have already been sold, bu... | stackexchange_codegolf |
Given no input, output the following:
_
| ~-_
| o ~-_
| ~ ~-_
| \~~~~~~
| * \
| \
|~~~~~~~~~~\
Note the backslashes are actually \, which is U+FF3C
Trailing whitespace is allowed, however leading whitespace is not.
This is code-golf so fewest bytes in each language wins!
| stackexchange_codegolf |
A prime gap is the difference between two consecutive primes. More specifically, if p and q are primes with p <q and p+1, p+2, ..., _q_−1 are not primes, the primes p and q define a gap of n = q_−_p. The gap is said to be started by p, and to have length n.
It is known that arbitrarily large prime gaps exist. That is, ... | stackexchange_codegolf |
Vim is a great text editor for unix systems, but it's notorious for being difficult to exit.
Write a full program that will output :q to exit Vim. It should then read a single line of input, as it will then either be given a bash prompt, in which case the exit was successful, or an error, in which case there are unsave... | stackexchange_codegolf |
Farmer Jack is very poor. He wants to light his whole farm but with minimum of cost. A lamp can illuminate its own cell as well as its eight neighbors . He has arranged the lamps in his field but he needs your help in finding out whether or not he has kept any extra lamps.
Extra lamps : Lamps which on removing from the... | stackexchange_codegolf |
UTF-9 was an April Fool's Day RFC joke specifications for encoding Unicode suitable for 9-bit nonet platforms.
Challenge
Your task is to implement a program or a function or a subroutine that takes one integer, who represents the codepoint of a character, to return a sequence of integers that represents its correspondi... | stackexchange_codegolf |
A regular dodecahedron is one of the five Platonic solids. It has 12 pentagonal faces, 20 vertices, and 30 edges.
Your task is to output the vertex coordinates of a regular dodecahedron. The size, orientation, and position of the dodecahedron are up to you, as long as it is regular.
You may output the coordinates in a... | stackexchange_codegolf |
This challenge is inspired by Mathematics is fact. Programming is not.
The mathematical notation for a factorial, or a fact is an exclamation mark !. The exclamation mark is also a common symbol for not in many programming languages.
Challenge:
Take a string, containing numerals, and the characters: + ! as input and o... | stackexchange_codegolf |
Results are now out here!
Congratulations offset prediction for winning the challenge!
Don't worry if you missed out, the controller code as well as all the bots that competed are all in the Github repo, so you can always test your bot against those that competed in the challenge yourself.
(Hover for more info)
This c... | stackexchange_codegolf |
Introduction
Let's define a ternary function as a function from the three-element set S = {0,1,2} to itself: it associates to each element of S another element of S.
One example of a ternary function f is
f(0) = 0; f(1) = 2; f(2) = 0
There are exactly 27 different ternary functions, and we represent them with integers... | stackexchange_codegolf |
The code on this site is rapidly being depleted. We need to invest in renewable strings. So you must write a program that takes a string and converts it into a windmill.
The Challenge
Let's take a simple wind-mill string as an example. Take the string abc. The pivot is the center character, in this case b. Since the st... | 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 |
Given the Dowker notation of a knot and its crossing signs, calculate its bracket polynomial.
Although there are more technical definitions, for this challenge it is enough to think of a knot as something made physically by attaching the two ends of a string together. Since knots exist in three dimensions, when we draw... | stackexchange_codegolf |
Given two arbitrary integers \$a\$ and \$b\$, count how many numbers are divisible by perfect numbers in that given range (\$a\$ and \$b\$ both are inclusive).
In mathematics, a perfect number is a positive integer that is the sum
of its proper positive divisors, that is, the sum of the positive
divisors excluding the... | stackexchange_codegolf |
There is a sentence with many cats:
there is a cat house where many cats live. in the cat house, there is a cat called alice and a cat called bob. in this house where all cats live, a cat can be concatenated into a string of cats. The cat called alice likes to purr and the cat called bob likes to drink milk.
The Task
... | stackexchange_codegolf |
I need to construct a functor that iterates over the linear representation of a sub-lattice of size \$d_x,d_y,d_z,d_q\$ embedded in a lattice of size \$n_x,n_y,n_z,n_q\$. The sub-lattice corner is shifted by \$(l_x,l_y,l_z,l_q)\$.
Since the functor can be called million of times, the goal is to produce the most effici... | stackexchange_codegolf |
Note: In this post, the terms 'character' and 'color' mean essentially the same thing
This image:
can be represented as
....'''333
.eeee'''3e
..dddd33ee
%%%dd####e
(mapping colors to ascii characters)
The four color theorem states that
"given any separation of a plane into contiguous regions, producing a figure cal... | stackexchange_codegolf |
The following is an unfolded milk carton:
+-----+-\|/-+-----+-\|/-+-+
| | / \ | | / \ | |
+-----+/---\+-----+/---\+-+
| | | | | |
| | | | | |
| | | | | |
+-----+-----+-----+-----+-+
\ / \ / \ / \ /
\_/ \_/ \_/ \_/
This is a code-golf kolmo... | stackexchange_codegolf |
Your task is to make a bidirectional compressor. It takes a list of bytes as input and returns a list of bytes as output. It has the property than whenever it is iterated twice it returns the original input.
In other words, if f is your program as a function, then f(f(x))=x for all x.
Now, since this is a "compressor",... | stackexchange_codegolf |
it's a-me!
Today's task is simple: write a program, or a function that displays the idle small Mario sprite, from Super Mario Bros, on NES, over a blue background.
Any kind of entry is valid as long as it displays those 12 * 16 pixels anywhere on the screen / window / browser.
(EDIT: the displayed image can be scaled u... | stackexchange_codegolf |
Challenge
The goal of this challenge is to make a function that takes an input string, a start keyword and a end keyword. The output extracted result is from (but excluded) the given start keyword to (but excluded) end keyword. The output sub-string follows the rules as below.
In all cases, the leading/trailing spaces... | stackexchange_codegolf |
Background (skip to definitions)
Euler proved a beautiful theorem about the complex numbers: \$e^{ix} = \cos(x) + i \sin(x)\$.
This makes de Moivre's theorem easy to prove:
$$
(e^{ix})^n = e^{i(nx)} \\
(\cos(x) + i\sin(x))^n = \cos(nx) + i\sin(nx)
$$
We can plot complex numbers using the two-dimensional Euclidean plane... | stackexchange_codegolf |
I'm not a 100% sure if this qualifies under this stack exchange; however, I asked this question on the stats stackexchange with no answers. I wonder if you can solve it:
Traffic light synchronization nowadays is not a tedious project, Image:
For a personal research project I'm trying to build a statistical model to s... | stackexchange_codegolf |
There are lots of different ways to explain matrix multiplication. I'll stick with a single figure since I believe most people here are familiar with it (and the figure is very descriptive). If you want more detailed information, I suggest you visit the Wikipedia-article, or the explanation on WolframMathWorld.
Simple ... | stackexchange_codegolf |
Your mission, if you choose to accept it, is to create a stack that can do basic math operations.
Explanation:
Your stack must be able to do basic arithmetic (+-*/) and must support normal base 10 numbers (0123456879); numbers will only be one character long.
Programming:
Input from stdin will be loaded as a program. ... | stackexchange_codegolf |
When you look at the last decimal digit of each power of a non-negative integer a repeating pattern forms. For example, 3:
3^1 = 3
3^2 = 9
3^3 = 27
3^4 = 81
3^5 = 243
3^6 = 729
3^7 = 2187
3^8 = 6561
3^9 = 19683
The last digits go 3971 which repeats indefinitely. In fact any number we choose that en... | stackexchange_codegolf |
Introduction (may be ignored)
Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive numbers. This is the second challenge in this series. The first challenge can be found here.
In this challenge,... | stackexchange_codegolf |
Challenge
Given a plot with broken paths, return the plot with all paths connected in the minimum number of changes.
Explanation
This problem deals with graphs on the Cartesian plane. Every node has 8 possible edges, extending vertically, horizontally, or diagonally. Each direction is represented by a number 0-7 as fol... | stackexchange_codegolf |
In the plane (\$\mathbb R^2\$) we can have at most five distinct points such that the distances from each point to every other point (except itself) can assume at most two distinct values.
An example of such an arrangement is a regular pentagon - the two different distances are marked with red and blue:
Challenge
Give... | stackexchange_codegolf |
What general tips do you have for golfing code in Pascal?
I know this is a tricky language very few people use this but I would like to know any tips from the professionals out there :)
I'm looking for tips that can reduce code size (every byte counts!) with special functions or even crazy combinations
Please post each... | stackexchange_codegolf |
The Levenshtein distance between two strings is the minimum number of single character insertions, deletions, or substitutions to convert one string into the other one. Given a binary string \$S\$ of length \$n\$, we are a interested in the number of different strings of length \$n\$ which have distance at most \$3\$ ... | stackexchange_codegolf |
In number theory, a strong prime is a prime number that is greater than the arithmetic mean of the nearest prime above and below (in other words, it's closer to the following than to the preceding prime).
Given an input integer, n, where n >= 0, your task is to generate the first n strong primes. For example, the six... | stackexchange_codegolf |
The challenge is to write a program which will find the shortest (least number of characters) command which will navigate to a target directory, given a starting directory, assuming a standard linux file system.
Take the following file system as an example, starting from ~:
.
├── target
└── test
└── starting
If th... | stackexchange_codegolf |
According to legend, almost everyone is outgolfed by Dennis. If not, they will be.
Now I'm curious if I'm one of those 'almost everyone'.
You will be given a link to an answer in the format of https://codegolf.stackexchange.com/questions/[QUESTION ID]/[QUESTION NAME]/#[ANSWER ID].
Find the length of the code, which we ... | stackexchange_codegolf |
In some parts of the world, phone numbers are fixed-length, apparently. That sounds boring, though.
For this challenge, your task is to take the digits of a what is presumed to be a valid phone number, and format it based on some simplified rules around what a phone number looks like.
Input format
Your input will consi... | stackexchange_codegolf |
Oh, No!
the sentences are out of balance.
Quick! balance them.
A word is defined as follows:
A sequence of letters [A-Za-z] separated by any non-letter character ([0-9] ~+- etc.)
A word is BaLanCeD if its capitalization is the same forwards as it is backwards.
Given a sentence with words, balance each word by capita... | stackexchange_codegolf |
Input
verb, a string that matches the regular expression ([a-pr-vyzıöüçğş]*[aeıioöuü][bcçdfgğhj-nprsştvyz]+|([a-pr-vyzıöüçğş]*[aeıioöuü]){2})(mak|mek)
plural, a truthy or falsy value
person, an integer having value either 1, 2, or 3
tense, an integer having value either 1, 2, or 3
Output
The conjugated form of the Tu... | stackexchange_codegolf |
I have a problem at work. I need to compare two numbers that come as strings from two different databases. The numbers may come with leading zeroes and/or leading/trailing spaces. So I may have "0001 " from one database and " 1 " from the other one.
I solved the problem in C# with the following code:
Func<string, st... | stackexchange_codegolf |
I'm looking out of my attic window into my neighbor's yard. They have a dog chained to a post in the center of the yard. The dog runs around the yard but is always on the end of its chain, so it ends up leaving a track in the dirt. Normally this track would be perfectly circular, but my neighbors have some other pole... | stackexchange_codegolf |
Your task is to find the length of the coastline of a map of islands provided in
an ASCII map. The input map will consist of 1 or more # characters that
indicate land, and spaces which indicate water. The coastline is considered to
be any edge between land and water, including inland lakes and islands.
Your solution sh... | stackexchange_codegolf |
Background
When I was in elementary school, we used to play a game in math class that goes as follows.
All kids sit in a big circle and take turns counting, starting from 1.
However, the following numbers must be skipped while counting:
Numbers that are multiples of 3.
Numbers that have a 3 in its decimal representat... | stackexchange_codegolf |
Lots of people on this site use esoteric languages, and since these languages are unusual and hard to understand, they will frequently write an explanation in a certain format. For example, if the code was
abcdefghijklmnop
And this languages uses # for comments, they would write an explanation like this:
a ... | stackexchange_codegolf |
Toki Pona is a constructed language with 137ish words, designed to constrain the speaker to expressing ideas in a simple and straightforward manner, reducing ideas to more essential forms.
Often, people attempt to avoid directly expressing numeric quantities in Toki Pona, opting to express them in more practical terms.... | stackexchange_codegolf |
I thought it'd be interesting to turn AoC day 3 puzzle into a Golfing Challenge, so here it is.
Task
Find the number of # you'd encounter in an 11x11 grid (consisting of # and .) that repeats itself (to the right side), starting at the top left corner, which is always a .. You will need to check the position that is \$... | stackexchange_codegolf |
A very simple golf this time, but should be fun to do.
Challenge
Output your code, but rotated 45 (or -45) degrees. E.g:
lorem ipsum dolor sit amet
becomes
t
e
m
a
t
i
... | stackexchange_codegolf |
Warning
The answers to this challenge test for a specific version of the patch that helps stop WannaCrypt/WannaCry attacks. Depending on your operating system, you may have a different patch. The best way to protect yourself is to make sure your PC is fully up to date and be careful when opening attachments and web lin... | stackexchange_codegolf |
Challenge
The cops created code challenges which result in certain wildly incorrect answers despite correct math. Choose an uncracked, not safe formula from the cop thread.
Your task is to find an incorrect answer and describe its underlying cause. The challenge author has the responsibility to confirm whether the expl... | stackexchange_codegolf |
Given two strings, output a third string that is not equal to either of the two inputs, but has the same length (in characters) as either of the inputs. There is guaranteed to be at least one valid output.
Test Cases
Test cases are quoted to show they are strings. Outputs are one of many possible.
input, input -> outpu... | stackexchange_codegolf |
Back in 2018, there has been introduced new law in Poland to ban trading on sundays,
but certain exceptions have been made (listed below). The task today is to determine,
can one trade on the sunday provided by the user (according to these rules).
Rules
You can trade only if one of the following is satisfied:
The day ... | stackexchange_codegolf |
Create an analogue clock
Goal: To create a working analogue clock using any programming language.
Requirements:
Your clock should feature at least the hour and minute pointers.
The produced clock could be in the form of an image, an animation or ASCII-art.
It is expected that the clock shows local time.
Optional:
Yo... | stackexchange_codegolf |
Here’s how to backspace-and-retype from one string to another:
Start from the first string.
Remove characters at the end until the result is a prefix of the second string. (This may take 0 steps.)
Add characters at the end until the result equals the second string. (This may take 0 steps, too.)
For example, the path ... | stackexchange_codegolf |
Introduction
We all know the cool S (also known as Superman S, Stüssy S, Super S, Skater S, Pointy S, Graffiti S etc. etc.): billions of schoolchildren around the world drew this S and immediately felt proud of themselves. In case you've forgotten or had a completely uncool childhood, here is an image of said cool S:
... | stackexchange_codegolf |
A truth-machine (credits goes to this guy for coming up with it) is a very simple program designed to demonstrate the I/O and control flow of a language. Here's what a truth-machine does:
Gets a number (either 0 or 1) from STDIN.
If that number is 0, print out 0 and terminate.
If that number is 1, print out 1 forever.... | 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 |
Introduction:
Inspired by both Perfect License Plates and How many points does my license plate give?
Just like in the challenges above, me and my little brother had a game of our own with license plates as kids. We tried to create (random/funny) sentences with the (numbers and) letters of the license plates.
For examp... | stackexchange_codegolf |
Jelly is a tacit, golf-oriented programming language by our very own Dennis. It’s popping up in answers here more and more often, beating other golf-y languages like Pyth and CJam, both by using its own code page and its powerful chain system to succinctly express programs.
Let’s collect some useful tips for golfing in... | stackexchange_codegolf |
Given a list (array) of names, your challenge is to join the items using some glue and abbreviate the longest items first until the joined string fits a maximum length. And output that string. Since the glue is part of the final string, the length of the glue is included too
Abbreviation is done using the … character
... | stackexchange_codegolf |
Task
Your task is to take a character in:
AÁÀÃÂBCÇDEÉÊFGHIÍJKLMNOÕÓÔPQRSTUÚVWXYZaáàãâbcçdeéêfghiíjklmnoõóôpqrstuúvwxyz
and turn it into a characters in:
AAAAABCCDEEEFGHIIJKLMNOOOOPQRSTUUVWXYZaaaaabccdeeefghiijklmnoooopqrstuuvwxyz
by the obvious operation: dropping the accents in the letters.
Input
A character in any se... | stackexchange_codegolf |
Your task: Print or return a conversion table with every byte from 00 to ff's value as an unsigned integer, to its value as a signed one (using two's complement).
For example:
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
1... | stackexchange_codegolf |
Introduction
This challenge was inspired by a seemingly simple task requested at work that couldn't easily be done in Microsoft Teams. At least not from what we could find!
Task
Your task, if you choose to accept it, is to output the last week day of any month in any year.
Input
You can input the desired month/year in ... | stackexchange_codegolf |
I've got some Java pseudocode that uses whitespace instead of curly braces, and I want you to convert it.
I/O
Your program should take an input file along with a number designating how many spaces are used to indent a block. Here's an example:
$ convert.lang input.p 4
// Convert using 4 spaces as the block delimiter
$... | stackexchange_codegolf |
Real-world programs often use libraries like ICU to support Unicode.
The puzzle is to create the smallest possible function that can determine whether a given Unicode character is lowercase, uppercase, or neither (a commonly used Unicode character property).
You may indicate the property in any way (whatever is shortes... | 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 |
Given a positive integer N, output the innermost N×N square of an ASCII art spiral made of -|/\ that spirals clockwise inward.
The - is used for horizontal portions, | for vertical portions, and / and \ for corners. The first character is - and the spiral proceeds left and down.
Specifically, when N is 1 the output is:... | stackexchange_codegolf |
Given required values for an expression with 2 variables, output a short expression which fulfill these values
Input
You may take the input in any reasonable format, e.g. f(x,y)=z, {(x, y): z}, [[[x,y],z]], but please write what format is your input is taken in
Output
Your output needs the be a valid infix expression f... | stackexchange_codegolf |
So what might be the shortest language for this simple task?
Task:
You are given an input of type String - the string is a valid hexadecimal number ([0-9A-F]).
Convert it to a decimal number and print it to the console.
Tests:
HEX -> DEC
1 -> 1
98 -> 152
539 -> 1337
1337 -> 4919
A5F9 > 42489
F -> 15
Win Condition:
Th... | stackexchange_codegolf |
The "prime frog" is a strange animal that jumps between integers, until it arrives on 3 or 19...
Your program should accept an integer n as input and output the result of the below algorithm (3 or 19).
For a given integer n >= 2:
Let f be the position of the frog. It is initially set to n
if f = 3 or f = 19 : the fro... | stackexchange_codegolf |
zipwith is a functional construct that takes three arguments: one binary function and two lists of the same length, and returns a single list where each element is constructed by applying the binary function to each pair of elements from the two lists:
zipwith (a+b) [1,2,3] [4,5,6] = [5,7,9]
You are to take a black-bo... | stackexchange_codegolf |
Quines are fun. Polyglots are fun, too. Polyglot Quines exist, but we can raise the bar even higher.
Write a file that contains a valid program for languages α, β, and γ. When the file is executed (possibly after compiling it) as a language α or β program, the program's output shall be of the same form as a valid submi... | stackexchange_codegolf |
It's holiday season. A mall is empty except of air, money, and a very clever thief that is you.
The mall consists of n floors. Each floor can be represented as a rectangular 2D grid. All floors have the same 2D dimensions. You are somewhere inside the building. Your job, as a hard-working thief, is to collect c coins a... | stackexchange_codegolf |
Background
Perfect shuffle algorithms like Fisher-Yates shuffle don't produce great results when it comes to music playlist shuffling, because it often produces clusters of songs from the same album. In an attempt to solve this problem, Spotify introduced an interesting shuffle algorithm in 2014. At the end of the arti... | stackexchange_codegolf |
The Collatz Conjecture
The famous Collatz Conjecture (which we will assume to be true for the challenge) defines a sequence for each natural number, and hypothesizes that every such sequence will ultimately reach 1. For a given starting number N, the following rules are repeatedly applied until the result is 1:
While N... | stackexchange_codegolf |
Intro
Blur's song Girls & Boys featured the lines
girls who are boys who like boys to be girls
who do boys like they're girls, who do girls like they're boys
in the chorus. These lines have a pretty uniform structure: you have a subject, which is either girls or boys, a relative clause, either who are, who like, or wh... | stackexchange_codegolf |
Objective
Given a matrix of connected box drawing characters, count its genus, the number of plane sections it encloses.
Valid input
The box drawing characters are ─│┌┐└┘├┤┬┴┼╴╵╶╷ (U+2500 U+2502 U+250C U+2510 U+2514 U+2518 U+251C U+2524 U+252C U+2534 U+253C U+2574 U+2575 U+2576 U+2577). The matrix shall contain these c... | stackexchange_codegolf |
The Premise:
You are writing a C driver for a screen for use on an embedded system. The screen uses a tortured version of SPI that requires data to be sent LSb (least-significant-bit) first, but MSB (most-significant-byte) first.
A fast way to do this (if you have the memory) is to use the integer value of each byte to... | stackexchange_codegolf |
The keitai input method is a method for writing Japanese kana on a 12-key phone keypad. Similar to Western keypads, each kana is assigned to a key; when the key is pressed multiple times, it cycles between all kana assigned to that key.
You will be using the following key-kana assignments, with this order of kana (base... | stackexchange_codegolf |
Given two positive numbers N >= 2 and N <= 100 create a matrix which follows the following rules:
First Number starts at position [0,0]
Second Number starts at position [0,1]
Third number goes below First Number (position [1,0])
Following numbers goes in "slash" direction
Range of numbers used is [1, N1 * N2]. So, num... | stackexchange_codegolf |
Objective
Given a matrix of connected box drawing characters, count its genus, the number of plane sections it encloses.
Valid input
The box drawing characters are ─│┌┐└┘├┤┬┴┼╴╵╶╷ (U+2500 U+2502 U+250C U+2510 U+2514 U+2518 U+251C U+2524 U+252C U+2534 U+253C U+2574 U+2575 U+2576 U+2577). The matrix shall contain these c... | stackexchange_codegolf |
Consider the following list:
expected = [
'A',
'B',
'AB',
'C',
'D',
'CD',
'ABCD',
'E',
'F',
'EF',
'G',
'H',
'GH',
'EFGH',
'ABCDEFGH',
'I',
'J',
'IJ',
'K',
'L',
'KL',
'IJKL',
'M',
'N',
'MN',
'O',
'P',
'OP',
'MNOP',
'IJKLMNOP',
'ABCDEFGHIJKLMNOP',
...
]
Here's one way to look at it - you're learning how to write Chinese... | stackexchange_codegolf |
Can't see emoji? Click here.
You will simulate a vending machine. The items are 56 different emojis, which can be represented as two surrogate UTF-8 characters, from: (U+D83C U+DF45) to
(U+D83C U+DF7C). In HTML these emojis can be represented in UTF-16 form as 🍅 through 🍼. In base 10 the first UTF-8 char... | stackexchange_codegolf |
Pascal's Rhombus (which is actually a triangle) is obtained by adding in the pattern:
*
***
x
instead of
* *
x
This means that each cell is the sum of the three cells on the row directly above it and one cell on the row 2 above it. Just like Pascal's triangle the zeroth row has a single 1 on it that generates... | stackexchange_codegolf |
Challenge
Write a program which, using the XML data from the site here, display the name of the programme which is currently showing on BBC 1.
Information
All times are given at London time (GMT+1 at the time of posting and GMT+0 after the 30th October). Therefore, you should convert your local time to London time.
Eac... | stackexchange_codegolf |
Background
The summary of a non-negative integer \$n\$ is the concatenation of all digits that appear in \$n\$ in increasing order, with each digit being preceded by the number of times it appears in \$n\$.
Some Examples:
n -> summary(n)
1221 -> 2122 (2 ones, 2 twos)
1212 -> 2122 (2 ones, 2 t... | stackexchange_codegolf |
We all know that the Euler's number, denoted by \$e\$, to the power of some variable \$x\$, can be approximated by using the Maclaurin Series expansion:
$$e^x=\sum_{k=0}^{\infty}{\frac{x^k}{k!}}=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\frac{x^4}{4!}+\dots$$
By letting \$x\$ equal \$1\$, we obtain
$$\sum_{k=0}^{\infty}{\frac{... | stackexchange_codegolf |
Use any programming language to display numbers divisible by 1000000 that are greater than 1 and less than 10000000. Each number should be displayed in new line. Your program should display exactly:
1000000
2000000
3000000
4000000
5000000
6000000
7000000
8000000
9000000
| stackexchange_codegolf |
Inspired by this question.
Champernowne's constant is an infinite decimal number that consists of "0." followed by all natural numbers concatenated together. It begins like so: 0.123456781011121314151617181920212223242526272829303132333435363738394041424344454647484950, etc. The digits of Chamernowne's constant are se... | stackexchange_codegolf |
I just created a language on the spot, and it's called "interpreter". Called as such because the only valid word is "interpreter"!
A sample program in "interpreter" looks like this:
interpreter interpreterinterpreter interpreterinterpreterinterpreter interpreterinterpreterinterpreterinterpreter interpreterinterpreterin... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.