instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Write a non-empty program or function that when called outputs a single value, 1 or 0, and when called
multiple times, the output numbers produce the binary representation of your program's source code
(in the same code page from which your code is compiled/interpreted).
For instance, if your source code was abc (in AS... | stackexchange_codegolf |
Introduction:
A typical cartoonish cactus usually looks like this:
One big stem in the middle, with some L-shaped branches sticking out.
We'll use this general shape for this challenge.
Challenge:
Given a pair of words, create an ASCII-art cactus with two upside down alphabets as stem. The first word is the left branc... | stackexchange_codegolf |
Task:
Take a string as input and if it meets the requirements, accept the password.
Input: a string, e.g. someString, asjk23t89h, 123456789abcdef.
Output: two distinct values representing "secure" and "insecure", e.g. 0/1, true/false, secure/insecure.
Password requirements:
In order for a password to be determined as s... | stackexchange_codegolf |
Background
SKI combinator calculus, or simply SKI calculus, is a system similar to lambda calculus, except that SKI calculus uses a small set of combinators, namely S, K, and I instead of lambda abstraction. Unlike lambda calculus, beta reduction is possible only when a combinator is given enough arguments to reduce.
T... | stackexchange_codegolf |
An "Egyptian fraction" is a list of distinct fractions with a numerator of \$1\$. For example:
\$
\frac 1 1+ \frac 1 2 + \frac 1 3 + \frac 1 6
\$
The "size" of an Egyptian fraction is just the number of terms involved.
Your task is to take a positive integer \$n\$ and output the smallest Egyptian fraction that sums t... | stackexchange_codegolf |
Challenge
Given a time and a timezone as input, output the time in that timezone.
Time
The time will be given in 24 hour format like so:
hh:mm
Where hh is the two digit hour and mm is the two digit minute. Note that the hour and the minute will always be padded with zeroes like so:
06:09
All the times given are at UT... | stackexchange_codegolf |
I love math. But I can't find a single calculator that can multiply correctly. They seem to get everything right except 6*9 (It's the question to life, the universe, and everything! How could they get that wrong?!). So I want you all to write a function for me that can multiply 2 numbers correctly (and 6*9 equals 42 in... | stackexchange_codegolf |
You are Odysseus, and are finally free from Calypso (who has kept you captive for many years) after you drugged her while she was sleeping1. You wish to return to your homeland of Ithaca, but the ship you've stolen is a bit damaged and cannot steer. However, you have also stolen a map which contains the location of Cal... | stackexchange_codegolf |
This challenge is inspired by xkcd:
Challenge:
You'll simulate the copying a large file (1 Gigabyte). The transfer rate will vary between 10 kB/second to 100 MB/second.
Your task is to output the time remaining of the file transfer. The output should look like:
Time remaining: 03:12 (meaning it's 3 minutes and 12 s... | stackexchange_codegolf |
JavaScript has no direct support for keyword arguments, but it supports argument object destructuring. It is standard to use a destructed final argument for keyword arguments. Here is an example:
function f(x, { a = 7, b = 2}){
return [x, a, b];
}
You would then call this function like:
f(9, {}); // ==> [9, 7, 2]
... | 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 |
Given an integer N from 1-9, you must print an NxN grid of NxN boxes that print alternating 1s and Ns, with each box having an alternating starting integer.
Examples
Input: 1
Output:
1
Input: 2
Output:
12 21
21 12
21 12
12 21
Input: 3
Output:
131 313 131
313 131 313
131 313 131
313 131 313
131 313... | stackexchange_codegolf |
Golomb rulers are sets of non-negative integers such that no two pairs of integers in the set are the same distance apart.
For example, [0, 1, 4, 6] is a Golomb ruler because all distances between two integers in this set are unique:
0, 1 -> distance 1
0, 4 -> distance 4
0, 6 -> distance 6
1, 4 -> distance 3
1, 6 -> di... | stackexchange_codegolf |
Produce Graham's Number in Magic the Gathering using the fewest number of cards and without using any infinite combos.
Rules:
Producing Graham's number means do anything that requires Graham's number to represent the game state. For example, you could produce Graham's number 2/2 zombie tokens, have Graham's number li... | stackexchange_codegolf |
using Prefixed Length Code
We are going to implement a compression of text (string, array/list of characters/bytes) by simple substitution of each character by a binary code, based on the frequency of that character in the text. The characters that occur more frequently will be replaced by shorter codes. The resulting ... | stackexchange_codegolf |
This is the robbers thread of this cops and robbers challenge. The cops thread is here.
Related, but hashes numbers instead of strings and uses a different scoring system.
Definitions
A hash collision is when two different strings produce the same hash.
Summary
In this challenge, the cops will make a hash function, wit... | stackexchange_codegolf |
Since tomorrow is the 4th of May, here's a little Star Wars themed post to prepare you mentally to all the bad jokes coming tomorrow.
BACKSTORY
During a session of the galactic senate all the senators are sitting in an n*n grid.
A sudden outbreak of JarJar flu (which lasts forever and causes the infected to speak like ... | stackexchange_codegolf |
Where am I now?
Given a string d, containing only the letters NSWE, determine the coordinates I've traveled (from left to right, consuming greedily) and the final coordinate where I reside.
The rules for reading coordinates from left-to-right:
If the next character is N or S:
If the character after the N or S is anot... | stackexchange_codegolf |
Task
Implement a kind of "some users are typing" system, which can be found in Discord and some other chat clients.
If 1 user (say, Bubbler) is typing, output Bubbler is typing...
If 2 users (say, Bubbler and user) are typing, output Bubbler and user are typing...
If 3 or more users are typing (say, Bubbler, randomuse... | stackexchange_codegolf |
Your Programs:
You'll write two programs (both in the same language). The storage program takes a string from STDIN and stores it somewhere persistent (see below) and then exits without error. The retrieval program takes no input, retrieves the string that was stored, and prints it to STDOUT.
Objective test of Persiste... | stackexchange_codegolf |
I do not believe this question to be a duplicate of this one, since this one requires more string manipulation, if it is still a duplicate feel free to close this question
Introduction
Your challenge today is to output the lyrics of "99 bottles of beer":
99 bottles of beer on the wall, 99 bottles of beer.
Take one down... | stackexchange_codegolf |
Make me an icecream cone please
We have a ton of great ice cream places here in New England. Most of them are closed for the winter now, so...
.-@@-.
(======)
(--------)
(==========)
(__________)
\/\/\/\/\/
\/\/\/\/
\/\/\/
\/\/
\/
GOAL
Output the above icecream cone exactly. (or return it from ... | stackexchange_codegolf |
Goal:
Given any natural number k such that k<256, produce an deadfish program that gives the smallest solution possible.
Background:
Deadfish is a joke esoteric programming language. It has a single unsigned byte of memory, called the accumulator, initialized at 0. There are four commands which form a string.
i = accu... | stackexchange_codegolf |
Introduction
I have a room full of magic mirrors.
They are mysterious artifacts that can duplicate any item, except another magic mirror.
More explicitly, a duplicate version of the item will appear on the other side of the mirror, at the same distance.
However, if there is another magic mirror in the way on either sid... | stackexchange_codegolf |
Write code that when given a positive number \$x\$ as input, outputs the largest positive divisor of \$x\$ less than or equal to the square root of \$x\$.
In other words find the largest \$n > 0\$ such that
\$\exists m\geq n:m\cdot n=x\$
(Exists \$m\$ greater than or equal to \$n\$ such that \$m\$ times \$n\$ is \$x\$)... | 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 |
Here is a list of 1000 basic English words. Yes, I'm aware that there are only 997 words in the list! It was taken from Wiktionary so blame them!
Your task is to write a program that accepts a word and returns TRUE or FALSE (or 0 or 1) depending on whether the word is in the list or not. You must use the spelling as it... | stackexchange_codegolf |
A two-dimensional array of size n×n is filled with n*n numbers, starting from number 1. Those numbers are to be sorted per row in ascending order; the first number of a row must be greater than the last number of the previous row (the smallest number of all (1) will be in [0,0]). This is similar to the 15 puzzle.
This ... | stackexchange_codegolf |
We've all seen the signs on motels telling us if there's a vacancy or not:
Typically, these will permanently have the letters of VACANCY lit up, and have the letters of NO lit up if there isn't any room in the motel.
The challenge
The average motel in the U.S. has 200 rooms.
You will write a program/function that take... | stackexchange_codegolf |
Introduction
"Muhuhuhahahah!" The mad scientist laughs. "You're trapped in my own little game!"
In front of you is a deadly pit of snakes, while behind you is a bottomless chasm. There's no way out, you're stuck!
"Two steps in front of you is the snake pit, and two steps behind you is the chasm. But! Before you move, y... | stackexchange_codegolf |
Okay, I propose a shortest-key-logger challenge. As explained by the gentleman at "Are key-logger questions allowed?", strict rules have to be imposed in order to make this challenge valid for PPCG.
The key-logger has to run on Windows, Linux or Mac OSX (any programming language is welcome).
Upon execution, it has to ... | stackexchange_codegolf |
Introduction
cowsay is a Unix command made by Tony Monroe, written in Perl. It outputs a picture of a cow saying given text. For example:
________________________
< Typical cowsay output! >
------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
... | stackexchange_codegolf |
Something unusual: a code golf question with a purpose.
I occasionally find myself in scenarios resembling the following:
Suppose you have two computers, A and B. Both of them have a fresh copy of Windows 10 installed. It comes with all the usual stuff, like notepad and paint and a browser, but no extras, like a Linu... | stackexchange_codegolf |
Inspired from Is this site down or is it just me?
Challenge
You have to print if a website server is online or not, for you.
Input
The domain name, like codegolf.stackexchange.com
Output
1/True if online
0/False if offline
Rules
Any kind of web access is allowed
URL shorteners allowed
Except 2 no. Rule, all standa... | stackexchange_codegolf |
Challenge
Return the full contents of your program, but inverted. How do your invert something? Well,
Letters: Take the position of the letter in the alphabet, subtract from 26, and use the letter at that position and flip the case of the letter. E.g A becomes z, and p becomes J.
Digits: Subtract from 9. E.g 6 becomes ... | stackexchange_codegolf |
Given a word list, find all sets of five words of five letters each, such that the words of each set have 25 distinct letters in total.
This challenge was inspired by this video by Matt Parker.
Testcases
Use this file if you want to test your code against the English vocabulary. Sample output sets:
["fjord", "vibex", ... | stackexchange_codegolf |
Given a string \$ x \$, we say another string \$ y \$ is half of it, if both of the following properties are true:
\$ y \$ is a (not necessarily continuous) subsequence of \$ x \$ - there exists a strictly increasing sequence \$ a_i \$ such that \$ y_i = x_{a_i} \$
Each character appears in \$ x \$ exactly twice as ma... | stackexchange_codegolf |
Given any unsigned 16 bit integer, convert its decimal form (i.e., base-10) number into a 4x4 ASCII grid of its bits, with the most-significant bit (MSB) at the top left, least-significant bit (LSB) at bottom right, read across and then down (like English text).
Examples
Input: 4242
+---+---+---+---+
| | | | # |
... | stackexchange_codegolf |
Given a paragraph of text, and a list of k words, write a program to find the first shortest sub-segment that contains each of the given k words at least once. The length of a segment is the number of words included. A segment is said to be shorter than another if it contains less words than the other structure.
Ignor... | stackexchange_codegolf |
A followup to this challenge by Jeremy Collprav, inspired by DLosc solving this in Regenerate. Some sections copied from the linked challenge.
Linking chains
We define a chain to be a string containing exactly one or more of only the - character, or 1 or more of only the _ character, or two chains linked by a =. More f... | stackexchange_codegolf |
Your program is supposed to create a full red screen in MSDOS. The source of the binary (.com file) must be 5 bytes or less. No wild assumptions, the binary must work in MsDos, DosBox, and FreeDos alike. For winning, you have to post x86 assembler code which can be assembled with NASM (FASM) or directly the hex code of... | stackexchange_codegolf |
Inspired by this video by tecmath.
An approximation of the square root of any number x can be found by taking the integer square root s (i.e. the largest integer such that s * s ≤ x) and then calculating s + (x - s^2) / (2 * s). Let us call this approximation S(x). (Note: this is equivalent to applying one step of the ... | 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 |
Imagine enumerating the elements of rhombi which grow [1],[1,3,1],[1,3,5,3,1],… (only odd numbers such that they align nicely). This would look like as follows, note that you always begin enumerating with 1:
01
1 02 03 04
1 2 3 4 05 06 07 08 09 …
5 10 11 12
... | stackexchange_codegolf |
Write one/two program(s)/function(s):
The first one should return a truthy value if given your Stack Exchange username.
~~Optional~~
An obfuscated one (as explained below) that does the same thing.
Rules for number 2:
May be no more than ten times the byte-count of number 1 or 100 bytes, whichever is higher.
Must ... | stackexchange_codegolf |
Consider the following standard 15×15 crossword puzzle grid.
We can represent this in ASCII art by using # for blocks and (space) for white squares.
# #
# #
#
# #
### ## ##
## #
# #
# ##
## ## ###
# #
# ... | stackexchange_codegolf |
Challenge
Given a valid goo.gl shortened link, output the original URL.
Example
goo.gl/qIwi3N would give something like https://codegolf.stackexchange.com/. For input, you can choose to have the https?:// at the beginning, you can choose to have www. before the goo.gl, and you can also choose to get rid of the goo.gl i... | stackexchange_codegolf |
(Note: This is my first ever code golf question, but as far as I can tell, nobody else has done exactly this, so I should be good.)
Your task is to make a program or function that takes in a string s and an integer n, and returns or outputs that text wrapped into multiple lines. Each word must be wholly on a line; i.e.... | stackexchange_codegolf |
We've all seen the pictures captioned "How many squares are in this image? 98% will not get this right!" Well, here's your chance to laugh at that 98%.
Input
A rectangular block made of only 2 characters. In a general form, this is defined by m lines, each containing n characters.
Example:
0000xxx
00x00xx
00000xx
xxxxx... | stackexchange_codegolf |
Taken from this question at Stack Overflow. Thanks also to @miles and @Dada for suggesting test inputs that address some corner cases.
The challenge
Given an array of integer values, remove all zeros that are not flanked by some nonzero value.
Equivalently, an entry should be kept either if it's a nonzero or if it's a ... | stackexchange_codegolf |
Your job is to write a program that takes a number N as input and outputs all 2-by-N mazes that are solvable.
Output format can be in the form of any two distinct values representing wall and empty - I use x and . here but you can use anything. You can have a matrix, array, string, ascii art, whatever is convenient, an... | stackexchange_codegolf |
A person has to complete N units of work; the nature of work is the same.
In order to get the hang of the work, he completes only one unit of work in the first day.
He wishes to celebrate the completion of work, so he decides to complete one unit of work in the last day.
He is only allowed to complete x, x+1 or x-1 uni... | stackexchange_codegolf |
Most Unicode characters have full names, for example ” is "RIGHT DOUBLE QUOTATION MARK". You can find a useful reference here, just type in the character you want to find the full name of and look in the DESCRIPTION column.
Your challenge is to write a program or function that outputs itself as a string of these. You c... | stackexchange_codegolf |
It's a common problem to navigate in a 2D matrix. We've seen it many times and will see again. So let's help future us and develop the shortest solutions to generate all eight possible steps in a 2D matrix.
Challenge
Your code must output the following 8 pairs of -1,0,1 in any order:
(0,1)
(0,-1)
(1,0)
(-1,0)
(1,1)
(1,... | stackexchange_codegolf |
This is a quine variation.
Introduction
We all write short code, because some obscure reasons, but whatever we do, the'll take up at least 144 pixels/byte (with a 12px font). But what would happen, if we would encode our code in images? This is your task today.
Challenge
You task is to read in your own source code (non... | stackexchange_codegolf |
Use any programming language to display numbers between 1 and 99 (including both) in such a way, so that:
the numbers are separated by single space,
if a number is divisible by 3, it should be in parentheses,
if a number is divisible by 4, it should be in square brackets,
if a number is divisible by both 3 and 4, it s... | stackexchange_codegolf |
This year my age is a prime number, and so is this year. This conjunction will repeat in 10 years and again in 12. If I live to 100, I will lived exactly 11 years in which my age and the year are both prime. My condolences to those of you born in odd-numbered years, who will experience this phenomenon at most once if a... | stackexchange_codegolf |
Challenge:
Take a vector / list of integers as input, and output the largest number that's adjacent to a zero.
Specifications:
As always, optional input and output format
You may assume that there will be at least one zero, and at least one non-zero element.
Test cases:
1 4 3 6 0 3 7 0
7
9 4 9 0 9 0 9 15 -2
9
-4 -6... | stackexchange_codegolf |
Challenge
Given an integer \$Q\$ in the range \$-2^{100} ≤ Q ≤ 2^{100}\$, output the number of digits in that number (in base 10).
Rules
Yes, you may take the number as a string and find its length.
All mathematical functions are allowed.
You may take input in any base, but the output must be the length of the number i... | stackexchange_codegolf |
Today you will be doing another palindrome challenge!
So, your task today is to take a string, and determine the minimum amount of letters required to insert to turn it into a palindrome.
For example, let's take the string fishes.
In this, case the best way would be to add h if, so the result would be 3.
fishe s
h... | stackexchange_codegolf |
Given the equation of a non-parabolic conic section, output its characteristics.
Spec
Some info on conic sections:
for more info visit Wikipedia
From an equation of the form \$ax^2+bx+cy^2+dy+E=0\$, it is possible to derive the type of conic section using a combination of square completion and simple arithmetic.
For t... | stackexchange_codegolf |
As you probably know, there is a war going on in Ukraine. I noticed that it seems nobody has posted a Ukrainian flag challenge yet, so I thought I'd do it myself in support of Ukraine.
The Challenge
Here is the flag:
The flag is divided horizontally across the middle into two equally sized stripes.
Stripe colors: (0,... | stackexchange_codegolf |
Description
a typeracer is an apps where user could type and evaluate their typing speed and accuracy.
Criteria
User could type "A quick brown fox jumps over the lazy dog."
A visual indicator of each wrong character typed.
A visual indicator of what characters to type.
A visual indicator of what has been typed
A visua... | stackexchange_codegolf |
We already generated Minesweeper fields, but someone really has to sweep those generated mines before PCG blows up!
Your task is to write a Minesweeper Solver that is compatible with a slightly modified version of the accepted solution of “Working Minesweeper” (actions are separated by spaces to allow for larger fields... | stackexchange_codegolf |
Your task is to print out this exact text:
-
||
-|-
|---
|-|--
-|-|--
-|-----
|-|-----
|---|-|--
-|-----|--
---|-|-----
|---|-|-----
|---|-----|--
-----|---|-|--
-|-|---|-------
------|---|-----
|-|---------|-|--
---|-----|---|----
-|-----|-|---------
|-|---|-|-----------
|-----------|---|-|--
-|-----|-|---------|--
--... | stackexchange_codegolf |
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 |
To mark the anniversary of World IPv6 day, the Internet Society has published a campaign to Turn Off IPv4 on 6 June 2014 for One Day.
IPv6 addresses may be represented in their long form as eight colon-separated 16-bit hex values. Depending on the address, they may also be shortened as described in item 2 of section ... | stackexchange_codegolf |
You host the Olympic Games, and need to build a fantastic pool for the sake of the occasion, but the supervisors often change their mind regarding the dimensions, and need a quick way to rebuild it with the requested size!
Given two integers, L and x, your task is to build a swimming pool of length L and x lanes.
How ... | stackexchange_codegolf |
Subleq is a Turing-complete esolang with only one instruction, SUBLEQ. This instruction takes in three parameters, A, B, and C, all of which are memory addresses. The instruction subtracts the value in memory address A from that in memory address B, storing it in address B. If the value at B is now less than or equal t... | stackexchange_codegolf |
Background
Boggle is a board game where the players have to find English words on a 4-by-4 board of random alphabets. Words can be constructed by selecting sequentially adjacent cells on the board. ("adjacent" means horizontally, vertically or diagonally adjacent.) Also, same cell can't be used more than once in a word... | stackexchange_codegolf |
(Inspired by this challenge)
Given two input strings, one of which is exactly one character longer than the other, arrange the strings into ASCII art as if they are two halves of a zipper that is only halfway zippered. The longer word forms the bottom of the zipper, and is the first and last character of the combined z... | stackexchange_codegolf |
Contest permanently opened - Updated August 10th 2017
Even though on June 5th 2017 I declared a winner (who will be kept as the best answer) I'll be rnning new bots and updating the results.
June 5th Results
Congratulations user1502040
Since there are no ties, I only show the % of matches won.
Statistician2 - 95.7%
Fit... | stackexchange_codegolf |
In computer science, a suffix automaton is the smallest partial deterministic finite automaton that recognizes the set of suffixes of a given string. (Wikipedia)
Given a string \$S\$ consisting of lowercase letters (a-z), construct the suffix automaton for it.
A suffix automaton is an array of states, 0-indexed or 1-... | stackexchange_codegolf |
Given:
a 12 hour time t in hours and minutes,
a rotation r in degrees,
return the time shown when an analog clock that is displaying the time t is rotated r degrees clockwise.
After rotation, the hour hand will not line up with the new position of the minute hand. To correct for this, the new hour can be derived fro... | stackexchange_codegolf |
When I was a lad, kids would wander into computer stores and play Hunt the Wumpus until the staff kicked us out. It was a simple game, programmable on the home computers of the mid-1970s, machines so rudimentary that instead of chicklet-sized microprocessors, I think some of them probably had real chicklets in there.
L... | stackexchange_codegolf |
You're organizing a treasure hunt for your friends. To conduct things more easily, you want to draw a map of all locations where you hid the precious objects.
Input
Any form of input denoting a list of points consisting of (nonnegative) x- and y-coordinate, 0 0 being the upper left corner is permitted (Note: You may al... | 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 |
The challenge is to golf a program when given a string composed of any number of asterisks, then a comma, than any number of asterisks, say which side has more.
The asterisk-strings can be empty.
Output
0 for ties.
1 for the left.
2 for the right.
Examples
Input: ***,**** Output: 2
Input: ***, Output: 1
Input: ***,*** ... | stackexchange_codegolf |
Given a string as input find the longest contiguous substring that does not have any character twice or more. If there are multiple such substrings you may output either. You may assume that the input is on the printable ASCII range if you wish.
Scoring
Answers will first be ranked by the length of their own longest ... | stackexchange_codegolf |
\$ 1089 \$ is a very special number. To prove why, select any 3-digit number whose first and last digits differ by at least 2. Then, reverse the digits, and take the difference of these two numbers. Reverse the digits once more, and add these two numbers together. You will get \$ 1089 \$. The magic is left as an exerci... | stackexchange_codegolf |
Challenge
Given a list of SI base units, a list of equations and a target, you must derive the units of the target using only the base units.
Derived Units
From Wikipedia:
The International System of Units (SI) specifies a set of seven base units from which all other SI units of measurement are derived. Each of these ... | stackexchange_codegolf |
Codidact post, CGCC Sandbox, Codidact Sandbox
Given three positive integers as input, animate an ascii-art polygonal loading symbol on the screen.
Intro
You will be given three inputs, \$n\$, \$l\$, and \$d\$...
\$n\$ (one of \$3\$, \$4\$, \$6\$, or \$8\$), is the number of sides of a polygon:
... | stackexchange_codegolf |
Consider an arbitrary set of letters \$L\$. It may either be \$\{A, B, C\}\$, \$\{M, N, O, P\}\$, \$\{N, F, K, D\}\$, or even contain all the 26 letters. Given an instance of \$L\$ and a positive integer \$n\$, how many \$n\$-letter words can we build from \$L\$ such that no adjacent letters are the same (so for exampl... | stackexchange_codegolf |
"nimi ale lon toki pona" is a song by YouTuber jan Misali which lists 137 common words in the constructed language Toki Pona. This challenge is not a duplicate of "How high can you count?" or "Alphabet printing challenge" because instead of numbers or single characters, it outputs random (to many programming languages)... | stackexchange_codegolf |
The Euclidean GCD Algorithm is an algorithm that efficiently computes the GCD of two positive integers, by repeatedly subtracting the smaller number from the larger number until they become equal. It can be visualised as such:
We start with a MxN grid, where M and N are the numbers. In this example I'll use M=12, N=5:
... | 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 |
Objective
Given two Chinese ideographs meaning basic colors, output the ideograph that means the color resulting from mixing them.
Basic colors
The basic colors are:
靑(U+9751; blue)
赤(U+8D64; red)
黃(U+9EC3; yellow)
白(U+767D; white)
黑(U+9ED1; black)
Mixed colors
Mixing 靑(blue) and 赤(red) yields 靘(U+9758; purple).
Mix... | stackexchange_codegolf |
A sturdy square (akin to a magic square) is an arrangement of the integers 1 to \$N^2\$ on an \$N\$ by \$N\$ grid such that every 2 by 2 subgrid has the same sum.
For example, for \$N = 3\$ one sturdy square is
1 5 3
9 8 7
4 2 6
because the four 2 by 2 subgrids
1 5
9 8
5 3
8 7
9 8
4 2
8 7
2 6
all sum to the same amoun... | stackexchange_codegolf |
A recent SO question asks for a convenient one-liner to generate a list of numbers and their negative counterparts in Python.
Given two integers \$1≤a≤b\$, generate all the integers \$x\$ such that \$a≤|x|≤b\$. The result may be printed or returned in any order or structure, as putting the result into a list and sortin... | stackexchange_codegolf |
Given a string that is one of the directions on a 16-point compass rose
output the two directions that are immediately adjacent to the input direction, in clockwise order.
Specifically, you need to handle these (and only these) input/output pairs:
Input Output
N NNW NNE
NNE N NE
NE NNE ENE
ENE NE E
E ... | stackexchange_codegolf |
Given a sequence of three integers, determine if the sequence is arithmetic (of the form [a, a+d, a+2*d]) or geometric (of the form [a, a*r, a*r^2]) by outputting a fourth term that completes it (a+3*d for arithmetic, a*r^3 for geometric).
Examples:
[1, 2, 3] -> 4 (This is an arithmetic sequence with a difference of 1)... | 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 |
Introduction
How to prove that 1 = 2:
1 = 2
2 = 4 (*2)
-1 = 1 (-3)
1 = 1 (^2)
You can just multiply both sides by 0, but that's cheating. This is just bending the rules a little bit.
Your challenge:
Write a program/function that, when given two integers, outputs a "proof" that the two are equal.
Rules
Your program's... | stackexchange_codegolf |
Code Python 3, 245 bytes
E=print
def F():
B,C,A=1,1,1;yield 0
while True:yield B;B,C,A=B+C+A+1,C+A+1,A+1
C=int(input())
D=0
for A in range(C):
E(end='*'*(C-(C-A)+1));B=A
while 0<B:E(end=' '+chr(42+B)*B);B-=1
E();D+=1
for A in F():
if D==0:E(end=str(A));break
D-=1
Try it online!
What it does?
Takes a number from... | stackexchange_codegolf |
In this challenge, your past self comes back to help or hurt someone else!
The task is simple: write a full program, not a function, that prints the first code submission on this site submitted by the previous user, in the language of your first answer. (In the case that your first answer was purely prose, for example ... | stackexchange_codegolf |
My little kid has a toy like this:
This toy consists of 10 stackable little buckets, that we are going to number from 1 (the smallest one) to 10 (the biggest one). Sometimes he makes small piles and the toy ends up like this:
We can represent schematically the piles like this:
1 6
4 9 2 7
5 10 3 8
-------... | stackexchange_codegolf |
Challenge
You have been given a string of digits 0-9.1 Your task is to shuffle this string, but every index must have a different value than it did before the string was shuffled.
For example:
In : 287492
Out: 892247
If this is not possible, return false or something similar. (null, undefined, etc.)
In : 131
Out: fals... | stackexchange_codegolf |
Your task is to implement a program similar to the nl command-line tool from the GNU core utilities.
Standard loopholes are banned.
You may not use any built-in or external function, program or utility for numbering the lines of a file or string, such as nl itself or the = command in GNU sed.
Specification
Input
The pr... | stackexchange_codegolf |
I have been going to puzzling.se, and people over there write stuff in rot13 a lot, sot this gave me an idea:
Write a program that takes 2 inputs, a string and integer:
the message to encode or decode
how far to shift
You can input in a function call, and output in any legal way
twist:
it must work with any printable... | stackexchange_codegolf |
Two ambassadors at a UN conference want to speak to each other, but unfortunately each one only speaks one language- and they're not the same language. Fortunately, they have access to several translators, who each understand and speak a few languages. Your task is to determine the shortest chain of translators (since ... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.