instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
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 |
Each day you put up a new word on a marquee sign with movable letters, buying just the letters you need to write it. You re-use letters you've bought for earlier words whenever possible. Given the words you want to write each day in order, output the letters you buy each day.
Example
Input: ['ONE', 'TWO', 'THREE', 'S... | stackexchange_codegolf |
The absolute value of a number \$x\$ is normally written as \$|x|\$. The left and right side of the absolute value uses the same symbol, so it is not immediately obvious how to parse nested absolute values e.g. \$||1-2|+|3-|4-5|||\$
Your goal is to parse such an expression containing nested absolute values:
The express... | stackexchange_codegolf |
A square-free word is a word consisting of arbitrary symbols where the pattern \$XX\$ (for an arbitrary non-empty word \$X\$) does not appear. This pattern is termed a "square". For example, squarefree is not square-free (using the lowercase letters as the alphabet), as the square ee appears; but word is square-free. A... | stackexchange_codegolf |
The Task
The task is easy: given an Alpha-2 country code, output the Alpha-3 equivalent. The input may be in any case you choose, and the output in any consistent case of your choosing. Here are the codes:
[["AF", "AFG"], ["AX", "ALA"], ["AL", "ALB"], ["DZ", "DZA"], ["AS", "ASM"], ["AD", "AND"], ["AO", "AGO"], ["AI", "... | stackexchange_codegolf |
Given a list of positive integers that contains at least 3 distinct entries, output a permutation of that list that isn't sorted in ascending or descending order.
Examples
1,2,3 -> 2,1,3 or 3,1,2 or 1,3,2 or 2,3,1
1,2,3,3 -> 2,1,3,3 or 3,1,2,3 or 1,3,2,3 etc..
Thanks @Arnauld and @NoOneIsHere for the title!
| stackexchange_codegolf |
Given a non-empty set of strings and a list of strings, find out how many times the set occurs in the list, i.e. how many times you could create the set with items from the list. Every element from the list can only be used once.
Hint: a set is an unordered list of unique items.
Default input/output rules apply.
No e... | stackexchange_codegolf |
This was inspired by a now removed CS.SE question.
Task
Given two non-empty input strings A and B, output the smallest distance from A to a palindrome that contains B as a substring. Distance is defined by the number of character replacements (Hamming distance).
Restrictions
Sensible input: a palindrome exists. This m... | stackexchange_codegolf |
Chat room: https://chat.stackexchange.com/rooms/106513/easter-bunny-challenge
Git repo: https://github.com/AJFaraday/easter_bunny_hunt
The garden is a 2-dimensional grid with 49 rows and 49 columns.
The Easter Bunny™️ is in the center of the garden, minding his own business, holding on to 100 Easter eggs. He'll hop awa... | stackexchange_codegolf |
Introduction
Bob runs a deli. His deli serves sandwiches to its customers. However, it is a bit unusual. At Bob's deli, instead of telling Bob what they want, customers show Bob an ASCII art drawing of their sandwich. Bob must find the pattern in their sandwich so he knows what ingredients to prepare. However, Bob does... | stackexchange_codegolf |
(Note: I'm not in the army so feel free to correct me if my formation is wrong, but I will not be changing the question. I will change any terminology mistakes though, because I'm trying to avoid air-cadet-specific wording choices)
(Note: this follows the standards for Canadian Air Cadets, not any actual army thing)
Ch... | stackexchange_codegolf |
In this fastest-code challenge, you are provided with a set of \$n\$ identical blocks and need to determine how many unique buildings can be constructed with them. Buildings must satisfy the following rules:
No overhangs - each block must either be on the ground or supported by one or more blocks directly underneath i... | stackexchange_codegolf |
A triangular number is a number that is the sum of n natural numbers from 1 to n. For example 1 + 2 + 3 + 4 = 10 so 10 is a triangular number.
Given a positive integer (0 < n <= 10000) as input (can be taken as an integer, or as a string), return the smallest possible triangular number that can be added to the input to... | stackexchange_codegolf |
Gringotts isn't just a vault, but a reputable financial institution and wizards need loans too. Since you don't want to be screwed over by the Gringotts goblins, you decided it would be a good idea to write a program to calculate interest. Interest is compounded only yearly.
Your task is to calculate total owed amount ... | stackexchange_codegolf |
In the Anno video game series there are 6 games with a 7th one announced for early 2019. Their titles always feature a year in a specific pattern:
Anno 1602, Anno 1503, Anno 1701, Anno 1404, Anno 2070, Anno 2205, Anno 1800
The digital sum is always 9.
The years are four digits long.
They contain at least one zero.
Wi... | stackexchange_codegolf |
Everyone knows that C is a lovely, safe, high level programming language. However you, as a coder are set the following task.
Write a program to add two numbers.
Input: Two space separated integers.
Output: The sum of the two numbers in the input.
The twist is that your code must be 100% safe. In other words, it m... | stackexchange_codegolf |
Write a program or function which takes a string of text as input and outputs the number of non-alphabetical characters in it (standard I/O rules apply). A non-alphabetical character is any character not appearing in this string:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
In terms of ASCII character codes, t... | stackexchange_codegolf |
Problem
Starting from n=2 dice:
Roll n dice, with each number 1 to 6 equally likely on each die.
Check if their sum equals the most probable sum for n dice, that is 3.5*n.
If they're equal, terminate.
Otherwise, print n, and repeat from the start with n+2 dice
Your code doesn't have to do this procedure exactly... | stackexchange_codegolf |
A mountain is defined to be a set of line segments whose first point has coordinates (0,a) where a > 0, and whose last point has coordinates (b,0), where b > 0. All intermediate points have a y-coordinate (ordinate) strictly greater than 0. You are given the points on the mountain sorted in ascending order of x-coordin... | stackexchange_codegolf |
A fun pair of equivalences is 1 + 5 = 2 · 3 and 1 · 5 = 2 + 3. There are many like these, another one is 1 + 1 + 8 = 1 · 2 · 5 and 1 · 1 · 8 = 1 + 2 + 5. In general a product of n positive integers equals a sum of n positive integers, and vice versa.
In this challenge you must generate all such combinations of positive... | stackexchange_codegolf |
When learning to factorise quadratics in the form \$x^2 + ax + b\$, a common technique is to find two numbers, \$p, q\$ such that
$$pq = b \\
p + q = a$$
as, for such numbers, \$x^2 + ax + b = (x + p)(x + q)\$
You are to take two integers \$a, b \in (-\infty, +\infty)\$ and output the two integers \$p, q\$ such that
$$... | stackexchange_codegolf |
Challenge
Given an ASCII art shape, you must find out whether the shape is a regular hexagon or not.
Hexagons
A regular hexagon is defined using two rules:
It has six sides
Each side has equal numbers of characters
For example, the following shape is regular but it doesn't have six sides and so is not a regular hexag... | stackexchange_codegolf |
We define whitespace to be any of the three characters, tab (0x09), newline (0x0A) or space (0x20).
For this challenge, you're to write two programs or functions in the same programming language, which perform the following tasks:
Count the whitespace characters in a given string. For instance, the input
123 -_- a... | stackexchange_codegolf |
This challenge is to golf an implementation of SKI formal combinator calculus.
Definition
Terms
S, K, and I are terms.
If x and y are terms then (xy) is a term.
Evaluation
The following three steps will be repeated until none of them apply.
In these, x, y, and z must be terms.
(Ix) will be replaced by x
((Kx)y) will be... | stackexchange_codegolf |
A little known fact is that if you turn on enough language extensions (ghc) Haskell becomes a dynamically typed interpreted language! For example the following program implements addition.
{-# Language MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances #-}
data Zero
data Succ a
cl... | stackexchange_codegolf |
Write a program that precisely clones GNU cat version 8.32, which is
installed on my computer.
In any case, if called with the same arguments, same stdin, and same files,
your program's output to both stdout and stderr must by byte-for-byte identical
to that of GNU cat, and the exit code must be the same. This applies ... | stackexchange_codegolf |
A binary multiple of a positive integer k is a positive integer n such that n is written only with 0s and 1s in base 10 and n is a multiple of k. For example, 111111 is a binary multiple of 3.
It is easy to show that a positive integer has infinitely many binary multiples. See here for a construction proof of one binar... | stackexchange_codegolf |
Given two positive integer fractions \$x\$ and \$y\$ such that \$x < y\$, give the fraction \$z\$ with the smallest positive integer denominator such that it is between \$x\$ and \$y\$.
For example \$x=2/5\$, \$y=4/5\$, the answer is \$1/2\$. Other fractions such as \$3/5\$ are also in between the two, but \$1/2\$ has... | stackexchange_codegolf |
You're given a hexagonal grid of the characters . and #, like this:
. . . . . . . .
. . . . # . . .
. # . . . # . .
. . . # . . . .
. . . . . # . .
. . . . . . . .
Your task is to fill the entire axis-aligned bounding box of the # with further #:
. . . . . . . .
. . # # # # . .
. # # # # # . .
. . # # # # # .... | stackexchange_codegolf |
Given two numbers, the first is greater than the second, check whether the first number is divisible by the second without a remainder. If divisible, answer "yes"(or any other string), otherwise "no"(or any other string you like).
Conditions: You cannot use conditional operators, loops, arrays, bitwise operations, func... | stackexchange_codegolf |
Introduction
In Tennis, the server alternates serving on the left side or the right side of the court every point, starting on the right. It is possible to figure out which side to serve on for that point just based on the score; if there have been an even number of points you serve on the right, and after an odd numbe... | stackexchange_codegolf |
This time, you are working on a regex. Your regex is meant to approximately full-match the base-10 representations of primes \$0 \le p < 1000\$, while ignoring any non-numeric string or composite in the range. You can full-match 2, 53 or 419, but not 0, 82 or example.
The approximately is important -- a minimum of 900 ... | stackexchange_codegolf |
I'm letting this one out of the sandbox. Hopefully it is well-written and make sense, feel free to improve.
So in order to make 1+ more popular (and ease the creation of golfed 1+ text-printing programs) here comes the metagolf challenge:
The 1+ Language
1+ is a fun deque-based esolang where 1 is the only literal, and ... | stackexchange_codegolf |
A knight's tour is a sequence of moves of a knight on a chessboard such that the knight visits every square only once. For those who are not aware of how knights in chess work, knights are capable of moving in an L shape (see fig. 1). (Or a ߆ shape, or even a \ shape depending on who you ask.) Essentially, in one move,... | stackexchange_codegolf |
Context
Just look around! Whenever someone posts an answer, the same template is followed over and over again! A first line with the byte count and language name. Then the code. Then the TIO link. This is the basic skeleton almost everyone follows.
Task
Your task, should you choose to accept it, is to write a program/f... | stackexchange_codegolf |
Task
Suppose that p pepole have to split a bill; each of them is identified by a triple (Name, n, k) made up of:
Name: the name;
n: the amount she/he has to pay;
k: the amount she/he actually paid.
The challenge here is to find out how much who owes whom.
Assumptions
Input and output can be in any convenient format.... | stackexchange_codegolf |
I have the following Haskell code to generate the the values of the Fibonacci sequence which are even as an infinite list:
z=zipWith(+)
g=z((*2)<$>0:0:g)$z(0:g)$(*2)<$>scanl(+)1g
This works by starting with 0,2 and then defining every following term to be the sum of:
twice all prior terms
the previous term
twice the ... | stackexchange_codegolf |
Challenge:
Input:
You take two inputs:
- A string only containing printable ASCII (excluding spaces, tabs or new-lines)
- A printable ASCII character
Output:
The first line will contain the string-input. Every i-modulo-3 first occurrence of this character will move in a South-East direction; every i-modulo-3 second occ... | stackexchange_codegolf |
What tips do you have for code-golfing in the V lang? I have been trying to find ways to shorten codegolfs on there but can't find any resources on it. Do you guys have any?
Please suggest tips that are at least somewhat specific to the V programming language (e.g. "remove comments" isn't helpful).
Please post one tip ... | stackexchange_codegolf |
It's laundry day, and you have lots of clothes that need to be washed. Wanting to have as much time left over for code golf as possible, you hope to optimize how quickly you wash and dry them all.
You have three types of appliances:
Washing machines: Take dirty clothes and turn them into wet clothes
Dryers: Take wet c... | stackexchange_codegolf |
In this fastest-code challenge, you are provided with a set of \$n\$ identical blocks and need to determine how many unique buildings can be constructed with them. Buildings must satisfy the following rules:
No overhangs - each block must either be on the ground or supported by one or more blocks directly underneath i... | stackexchange_codegolf |
Given a 7-segment display with some segments switched on and some off, find a sequence of digits (0-9), such that after toggling the corresponding segments for each digit, all segments are switched off.
Example
_
_ [3] => | [1] => [OFF]
_ |
Numbers and their corresponding segments:
_ ... | stackexchange_codegolf |
The challenge is simple: Read 3 letters from a system input¹ and convert them to numbers (A-1, B-2, C-3...Z-26)². Print each of those numbers in the order the letters were inputted in, each on a new line and then the sum of all 3 numbers, on its own line as well.
NOTE: There will be no extra input characters, only 3 le... | stackexchange_codegolf |
Challenge
Create a function or program that, when given an integer size, does the following:
If size is equal to 1, output
H H
HHH
H H
If size is greater than 1, output
X X
XXX
X X
where X is the output of the program/function for size - 1
(If you prefer, you may have the base case correspond to 0, so long as you spe... | stackexchange_codegolf |
For this challenge, you need to compress a diff. A diff is some data that represents the difference between two strings. For this challenge, you need to provide one or more programs that can:
Input A and B, and output a diff, C
Input A and C, and output B
Input B and C, and output A
The goal is to make the diff, C,... | stackexchange_codegolf |
Okay, so everyone is familiar with the ASCII-table, correct? I'd hope so. I've been going to that site for my asciitable reference for as long as I can remember needing one. We'll be doing some fun source-code manipulating using the ASCII keyspace.
The Task
Your task is to write a program that, when executed, prints t... | stackexchange_codegolf |
Given the input of n and value. The code is supposed to nest the single element list with value repeated n times. The final output should be a multilevel nested list with single repeated values in all sublists.
This is code-golf, so the shortest code in bytes wins!
Test cases:
n = 1, value = 'a': ['a']
n = 2, value = '... | stackexchange_codegolf |
I like Tetris a lot, but I'm not very good at it. Just once I'd like to see that spaceship take off in front of my own eyes! And since computers are oh-so great at everything, the only possible solution is to make a program to play it for me... except you're going to do that bit for me!
Given a tetromino (shape made of... | stackexchange_codegolf |
Chinese Hearts, also known as Gong Zhu (拱猪, Chase the Pig), is a variance of the Hearts game. It is a 4 player card game with the aim to earn the highest amount of points. You may read more about it on Wikipedia. This time, we want implement a program (full or function) to calculate ones score.
Scoring
The player who p... | stackexchange_codegolf |
Warning: Wouldn't you rather answer a challenge about ponies?1
If you have read The Hostile Hospital, you would know that the Baudelaire orphans, from one of the scraps of paper recovered from the Quagmire's notebooks, they discover a name, "Ana Gram". Later on, they realize that means the word "anagram", not a name.... | stackexchange_codegolf |
Given a strictly positive integer, N, produce an output satisfying the following:
Produce an array of length N.
Every string (i.e. "word") in the array is of length N.
Every letter in the word is unique.
Every first letter of the words are unique between each other.
The remaining items of each word are equal to each o... | 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 a nonempty list of nonnegative integers, consider rewriting it as an arithmetic problem where:
A plus sign (+) is inserted between pairs of numbers that increase from left to right (a.k.a. from the start of the list to the end).
A minus sign (-) is inserted between pairs of numbers that decrease from left to rig... | stackexchange_codegolf |
You should write a program or function which receives a list of distinct integers as input and outputs or returns the number of occurrences of the input numbers in the following upside-down number pyramid.
Starting from the original list in every step we create a new one with the maximal values of every pair of adjacen... | stackexchange_codegolf |
Suppose there are 5 positive integers in an array or list as 14, 12, 23, 45, 39.
14 and 12 cannot be taken in the subset as 1 is common in both. Similarly {12, 23}, {23, 39}, {14, 45} cannot be included in the same subset.
So the subset which forms the maximum sum is {12, 45, 39}. The maximum sum such formed is 96.
the... | stackexchange_codegolf |
I came up with this challenge independently, but it turns out to be the inverse to this challenge by Doorknob. As I really like his spec, I decided to steal large parts of it instead of cooking up my own explanations.
The Challenge
Given the abbreviation of one of the 32 points on the compass, print the corresponding d... | stackexchange_codegolf |
It's time for CGCC to demonstrate our musical talent! In this challenge, you're going to compose songs while keeping your byte count as small as possible.
On Day 0, multiple answerers will post a function or program that outputs nothing/an empty string. They will also give a single line that next day's answers must out... | stackexchange_codegolf |
Goal: Create the smallest possible code to open a separate window, in which there are 100 circles of random sizes and colors.
Rules: All circles must be visible to the unassisted, naked eye, so in other words more than 2 pixels across, the background must be black, at least 5 different colors must be recognizable, and ... | stackexchange_codegolf |
Challenge:
Create a program or function that takes an integer input, which outputs a new program/function as specified below.
Input:
Integer n: Time in seconds before the Time Bomb explodes.
Output:
The original program which had the time in seconds n as input, will output a new program/function that does the following... | stackexchange_codegolf |
There's a minigame in Super Mario 3D World known as the Lucky House. It consists of a slot machine with 4 blocks.
Each block may be one of 5 different icons (Flower, Leaf, Bell, Cherry or Boomerang) and the goal of the player is to get as many identical icons as possible (see a video).
The player is rewarded with coin... | stackexchange_codegolf |
Your task
You must write a program, to print a reverse Fibonacci series, given a number.
Input
A non-negative integer N.
Output
You must output all the Fibonacci numbers from Fk to F0, where k is the smallest non-negative integer such that Fk ≤ N ≤ Fk+1.
Example
IN: 5
OUT: 5 3 2 1 1 0
If input isn't a Fibonacci numbe... | stackexchange_codegolf |
Introduction
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.
The first challenge in this series is to output a(n) for a given n as input, where a(n) is A064413, also known as the EK... | stackexchange_codegolf |
Setup:
A block is any rectangular array of squares, specified by its dimensions \$(w,h)\$. A grid is any finite ordered list of blocks. For example, \$\lambda = ((3,2),(3,1),(1,2))\$ defines a grid.
Let \$\lambda\$ and \$\mu\$ be two grids with equal area.
A tiling of \$\lambda\$ by \$\mu\$ is any rearrangement of the ... | stackexchange_codegolf |
Each element on the periodic table of the elements has an atomic weight. For example, boron (element 5) has an atomic weight of 10.81. Your challenge is to write a program which takes as input the atomic number of an element and outputs its atomic weight.
Your program only needs to support elements up to and including ... | stackexchange_codegolf |
Given two non-zero 16-bit integers a and b, decide the smallest number of shift operations needed to turn a into b. A shift is one of the following (big-endian) operations:
shl (shift left): move all bits to the left, adding a 0x0 bit to the right.
shr (shift right): move all bytes to the right, adding a 0x0 bit to th... | stackexchange_codegolf |
Objective:
The task is to create a chatbot with whom you can spend your time discussing your deepest thoughts with. Create a chatbot with an AI that learns from your input. Your bot should inspire you to releave your darkest inner truths.
Inspiration:
http://en.wikipedia.org/wiki/Chatterbot
http://io9.com/5901579/10... | stackexchange_codegolf |
The point of this challenge is to find the smallest positive integer that uses up at least all of the digits supplied in the input after it is squared and cubed.
So, when provided an input such as 0123456789 (i.e. a number that finds the result):
69² = 4761
69³ = 328509
It means that 69 is the result of such an input.... | stackexchange_codegolf |
Ulam's spiral is a truly fascinating, yet puzzling, topic in mathematics. How it works in detail can be found here, but a short summary can be explained as so:
I start off by writing a one, then I write a two to the right of it. Above the two, I write a three, and to the left of that I write four. I continue this patte... | stackexchange_codegolf |
It's a well-known fact that Fermat's Last Theorem is true. More specifically, that for any integer \$n \gt 2\$, there are no three integers \$a, b, c\$ such that
$$a^n + b^n = c^n$$
However, there are a number of near misses. For example,
$$6^3 + 8^3 = 9^3 - 1$$
We'll call a triple of integers \$(a, b, c)\$ a "Fermat n... | stackexchange_codegolf |
Inspiration
Given a positive integer \$1 \le n \le 9\$, output all positive \$n\$-digit integers \$i\$ for which the following is true:
Each digit from \$1\$ to \$n\$ appears exactly once in \$i\$. Therefore, \$i\$'s digits are a permutation of the digits from \$1\$ to \$n\$.
\$i\$ is divisible by \$n\$
Removing the r... | stackexchange_codegolf |
The Golfer Adventure
This is the first challenge ! There will be more challenges later that will require data from the previous challenge :)
Chapter 1 : The Vase
Let's imagine a minute.. You are a powerful God, your powers are limitless but require one thing : Souls.
Each soul is here represented by a byte, each byte y... | stackexchange_codegolf |
Imagine that a list of integers describes the heights of some two-dimensional terrain as seen from the side.
Stamina: [ 4 4 4 4 4 4 3 3 3 3 2 2 2 - ]
O
/|\
/ \
+---+ +---+
| | | |
+---+ ... | stackexchange_codegolf |
I have so many secrets and nowhere to keep them!
The goal is simple: write a program that lets you save a string and have it be protected by a password.
The program will take an alias, password and (optional) secret as parameters.
If this is the first time the program is called with a given alias, then it will store/re... | 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 |
Introduction
What you have to do is, given an an ASCII diagram of a chemical, output the chemical formula.
Rules
Your code must not access the internet and may not use a stored library of molecules. You may have a library of elements.
You must verify all of the elements included in the formula are real, with all elemen... | stackexchange_codegolf |
The task is to provide code that evaluates to 0.5 numerically, i.e. the output must be recognized by your chosen language as a numeric value (Number, float, double, etc), not as a string. The catch, the characters 0 through to 9 cannot be used.
PLEASE NOTE: This IS NOT a golfing challenge, this is a popularity contest,... | stackexchange_codegolf |
Do you have any tips for code-golfing in 05AB1E, a golfing language created by Adnan?
Your tips should be at least somewhat specific to 05AB1E.
Please post one tip per answer.
| stackexchange_codegolf |
In Chess, a Knight on grid \$(x, y)\$ may move to \$(x-2, y-1)\$, \$(x-2, y+1)\$, \$(x-1, y-2)\$, \$(x-1, y+2)\$, \$(x+1, y-2)\$, \$(x+1, y+2)\$, \$(x+2, y-1)\$ or \$(x+2, y+1)\$ in one step. Imagine an infinite chessboard with only a Knight on \$(0, 0)\$:
How many steps is required for moving a Knight from \$(0, 0)\$... | stackexchange_codegolf |
For each character in your program, the program with that character removed must produce a number smaller than the program with the next character removed. Your base program isn't required to do anything, and may be invalid.
An example submission could be abcd, where bcd outputs 1, acd outputs 4, abd outputs 5, and abc... | stackexchange_codegolf |
Introduction
Super Mario 64 has a heavily overcomplicated RNG, ably explained here by Pannenkoek.
I thought it might be interesting to implement it.
Challenge
Implement the RNG function, except for the two special cases. (Not part of the below description; everything below is what you should implement.)
Input and outp... | stackexchange_codegolf |
Introduction:
I collect twisty puzzles, so I'm quite the fan of rubiks-cube-challenges (even though most are fairly difficult). So, let's try a fairly easy rubiks-cube-challenge for a change.
When an NxNxN Cube gets scrambled during a WCA (World Cubing Association) competition, the cube is always held in the same way b... | stackexchange_codegolf |
Your task is to form an expression equaling \$ 11111111111 \text{ (11 ones)} \$ using only the following characters: 1+(). Keep in mind that the result is in base 10, and not some other base like binary. Of course, these expressions should follow the order of operations. Furthermore, the only operations which should be... | stackexchange_codegolf |
This is a challenge of practicing golf optimization in Python -- reusable tricks and shortcuts to shave off a few characters. Many will be familiar to Python golfers and use common ideas from the Python Tips. Some of these use Python-specific features that you might not know exist unless you've seen them, so do take a ... | stackexchange_codegolf |
What general tips are these for golfing in Lisp (any dialect)? Please post one tip per answer, and only answers that are specific to a dialect of Lisp (e.g. "remove comments" is not an answer).
Please post the dialect of Lisp your tip applies to with your tip.
| stackexchange_codegolf |
All those busy beavers made quite a mess. They wrote all over the tape. At this rate, our neighbour will stop lending us unbounded tapes.
We need a new way to play the busy beaver game, one that doesn't ruin every tape we use.
The Rules
Brainfuck only. Memory tape is unbounded both ways. Input instruction will always r... | stackexchange_codegolf |
This question is about abelian sandpiles. Read this previous challenge and watch this numberphile video to learn more.
An abelian sandpile of size n by n is a grid containing the number 0, 1, 2 and 3 (representing the number of grains of sand). Adding two sandpiles works by first adding element by element, and then to... | stackexchange_codegolf |
Task
As input you have:
a positive integer N
And you should output:
The number of integers in \$[1,N]\$ (an inclusive range) which end with the digit \$2\$ in base ten.
Test cases
1 -> 0
2 -> 1
5 -> 1
10 -> 1
12 -> 2
20 -> 2
30 -> 3
54 -> 6
97 -> 10
100 -> 10
Rules
It is a code-golf so the lowest score in bytes wi... | stackexchange_codegolf |
The Challenge
Your task is to create a program that takes any given string input, and outputs the input in a squared format. Empty strings should return an empty string.
Examples
Given the input:
golf
Your program should output:
golf
o l
l o
flog
Input:
123
Output:
123
2 2
321
Input:
a
Output:
a
Input:
Hello, w... | stackexchange_codegolf |
As the title says, you are to create a pristine program in as many languages as possible. A pristine program, taken from here, is:
Let's define a pristine program as a program that does not have any errors itself but will error if you modify it by removing any contiguous substring of \$N\$ characters, where \$1 \le N ... | stackexchange_codegolf |
This is the cops' thread. The robbers' thread goes here.
The last cops-and-robbers thread was already 4 months ago.
The cop's task
The cop's task is to write a program/function that takes a positive (or non-negative) integer and outputs/returns another integer.
The cop must state it if the program is intolerant toward... | stackexchange_codegolf |
This is the robber's thread of a cops-and-robbers challenge. You can view the cop's thread here
A pretty common beginner style question is to print some string, but, there's a catch!, you need to do it without using any of the characters in the string itself!
For this challenge we will find out who is the best at prin... | stackexchange_codegolf |
This function should take four integer inputs (a,b,c,d) and return a binary word based on which values equal the maximum of the four.
The return value will be between 1 and 0xF.
For example:
a = 6, b = 77, c = 1, d = 4
returns 2 (binary 0010; only 2nd-least significant bit is set corresponding to b being sole max value... | stackexchange_codegolf |
For a given positive integer, try to find out the smallest possible rotation resulted by rotating it 0 or more bits.
For example, when the given number is 177, whose binary representation is \$10110001_{(2)}\$:
\$ 10110001_{(2)}=177 \$
\$ 01100011_{(2)}=99 \$
\$ 11000110_{(2)}=198 \$
\$ 10001101_{(2)}=141 \$
\$ 00011... | stackexchange_codegolf |
There's a river and there are wolves and chickens on one side of the river. They have a raft and they all need to get to the other side. However, the raft cannot travel on its own. The raft will sink if more than two animals are on it. None of the animals want to get wet because the river's cold and dirty. None of the ... | stackexchange_codegolf |
There are some iron particles on a board. We pass a current carrying wire through that board and the particles form circles. Show these circles if input given is the position of the wire.
Consider the board to be a grid of size 7x7 (fixed)
No extra white spaces are allowed.
Input can be 0-indexed or 1-indexed. (0-index... | stackexchange_codegolf |
Given a string of ASCII letters (upper and/or lower case), output the raw MathJax required to display that string bifurcating at each character, into superscripts and subscripts. For example, the inputs cat and horse would result in outputs which MathJax renders as the following, respectively:
Note that only one inpu... | stackexchange_codegolf |
Given two words, spoonerise them by switching their initial consonant clusters. Fewest bytes wins.
plaster man -> master plan
blushing crow -> crushing blow
litigating more -> mitigating lore
strong wrangler -> wrong strangler
def ghi -> ghef di
few years -> yew fears
The consonants appearing before the first vowel (a... | stackexchange_codegolf |
A long period prime is a prime number \$p\$ such that decimal expansion of \$1/p\$ has period of length \$(p-1)\$. Your task is to output this number sequence. For purposes of this challenge we will consider only odd primes.
Period of a decimal expansion of a rational number is the smallest period \$k\$ that makes the ... | stackexchange_codegolf |
In chess, a knight can only move to the positions marked with X relative to its current position, marked with ♞:
A Knight's Graph is a graph that represents all legal moves of the knight chess piece on a chessboard. Each vertex of this graph represents a square of the chessboard, and each edge connects two squares th... | stackexchange_codegolf |
The barbells at my gym look like this:
=========[]-----------------------[]=========
They can hold plates of five different sizes, 2.5 pounds, five pounds, ten pounds, 25 pounds, and 45 pounds:
.
. ! |
. ! | | |
| | | | |
' ! | | |
' ! |
'... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.