instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Background
A magic square is an n×n matrix consisting of one of each of the integers from \$1\$ to \$n^2\$ where every row, column, and diagonal sum to the same value. For example, a 3×3 magic square is as follows:
4 9 2
3 5 7
8 1 6
Here, each row, column, and diagonal sum to the magic sum of 15, which can be calculat... | stackexchange_codegolf |
Thanks to @KritixiLithos for helping me out with this challenge!
V is a programming language that I wrote so that I could use and extend vim for code-golf challenges. The very first commit was on March 3rd, 2016, meaning that today V turns one year old! Woo-hoo
Over V's first year of existence, there have been 176 com... | stackexchange_codegolf |
Introduction
Finding the closest power to a number is a common enough problem. But what if you need both the next-highest and next-lowest power? In this challenge you must find the closest powers to a given number - the 'power sandwich' if you will, where the given number is the filling and the powers are the bread. Mm... | stackexchange_codegolf |
The task
Given an image as input, your task is to do the following:
Resize the image so it is At least 2 times smaller, but still has the same width/height ratio by taking every second (if resized to 2x) pixel in both horizontal and vertical directions and using those in the pixel art image. Example:
a 4x4 image
[a... | stackexchange_codegolf |
Given an integer N, count how many ways it can be expressed as a product of M integers > 1.
Input is simply N and M, and output is the total count of distinct integer groups. Meaning you can use an integer more than once, but each group must be distinct (3 x 2 x 2 would not count if 2 x 2 x 3 is present).
Constraints
1... | stackexchange_codegolf |
Task
A reverse checkers position is a chess position where every piece for one player is on one colour and every piece for the other player is on the other colour. Your task is to find if the given (valid) position meets these criteria.
For example, this position does (click for larger images). Every white piece is on ... | stackexchange_codegolf |
Introduction
The well-known "Die Hard with a Vengeance" water jugs puzzle challenges the two heroes to get 4L of water in a 5L container, provided an unlimited supply of water and another container of 3L. This problem has a solution because 4 is less or equal than the largest container and is a multiple of the gcd(5, 3... | stackexchange_codegolf |
Now that other users have helped Trump build the wall, its time for you to climb it.
This is an ascii art challenge where you need to output a climbing wall with randomly placed holds.
A climbing wall is made up of panels each of which has between 3 and 10 holds and is 5 panels high. Each panel is 4 characters high and... | stackexchange_codegolf |
Rotonyms 2
A "Rotonym" is a word that ROT13s into another word (in the same language).
For this challenge, we'll use an alternate definition: a "Rotonym" is a word that circular shifts/rotates into another word (in the same language).
For example:
'stable' < 'tables' < 'ablest'
'abort' > 'tabor'
'tada' >> 'data'
The C... | stackexchange_codegolf |
Given a positive integer, write it as the sum of numbers, where each of them is in \$\{kt|k\in{1,9,81},t\in{1,2,3,...,64}\}\$. How many numbers at least are used? Shortest code win.
Samples:
Input Output Method
1 1 1
2 1 2
64 1 64
65 2 64+1
72 1 72
343 2 342+1
576... | stackexchange_codegolf |
Today is Tax Day!
Oops.
Well, today is tax day if you are a resident of Maine or Massachusetts.
So you're probably still completing your return and need a calculator for when you get to Line 44.
Given an input of taxable income (US$, accurate to 2 decimal places) and a string representing filing status, output the amou... | stackexchange_codegolf |
Description :
Given an input (a string , array , integer) , Your job is to append one of the following to it.
st , nd , rd , th .
Examples :
1 ---> 1st
2 ---> 2nd
3 ---> 3rd
4 ---> 4th
11 ---> 11th
12 ---> 12th
13 ---> 13th
14 ---> 14th
and so on and so forth
This is code golf so shortest code will win in each langua... | stackexchange_codegolf |
Sometimes when you're lying in bed and reading a message, your phone screen will pop into landscape mode right in the middle of a sentence. Only being able to read left to right, you find yourself incapacitated, unable to process the text in front of you.
To ensure that this won't happen again, you decide to make every... | stackexchange_codegolf |
Your challenge is to turn input text to brain-flak code that will output the text.
Tutorial taken from here with permission here
Brain-Flak has two stacks, known as 'left' and 'right'. The active stack starts at left. If an empty stack is popped, it will return 0. That's it. No other variables. When the program starts,... | stackexchange_codegolf |
You wake up and find out that your computer has been stolen! You have a few sensors and scanners, but unfortunately, the footage is incomplete, so you want to find and rank your suspects for further investigation.
Your computer is a rectangle, and your camera caught a bunch of people walking around with packages; howev... | stackexchange_codegolf |
Introduction
The childhood song Eeny, meeny, miny, moe was often used to select who was "it" when playing tag. Everyone would stand in a circle and point at one person selected at random. They would sing:
Eeny, meeny, miny, moe,
Catch a tiger by the toe.
If he hollers, let him go,
Eeny, meeny, miny, moe.
As t... | stackexchange_codegolf |
When this question was posted, it was caird coinheringaahing's birthday! (source: 1, 2, 3, 4) (It was also World Emoji Day.)
As a bit of some CGCC lore, caird's name came from a Jelly answer by Dennis (source) - the compressed form of "Code Golf" in Jelly is “½ċṭ6Ỵ», and if you insert a space (“½ċṭ6 Ỵ»), it becomes "ca... | stackexchange_codegolf |
I was challenged by one of my friends to solve this coding problem:
Given a non-negative number represented as an array of digits, add one to the number. The digits are stored such that the most significant digit is at the head of the list. Return the value as a new list.
This was my solution, which does not work if [9... | stackexchange_codegolf |
In this challenge you will write a function that takes a list (ordered set) containing real numbers (the empty list is an exception, as it has nothing) and calculates
$$f(x)=\begin{cases}1 & \text{if } |x|=0 \\ x_1+1 & \text{if } |x|=1 \\
\log_{|x|}\sum_{n=1}^{|x|}{|x|}^{x_n} & \text{otherwise}
\end{cases}$$
where \$|x... | stackexchange_codegolf |
Palindromic dates are dates that appear as palindromes: the string of digits can be read the same way backwards as forwards. For the North American date format (MM/DD/YYYY), the next few palindromic dates are:
02/02/2020
12/02/2021
03/02/2030
The Challenge
Create a function that returns all palindromic dates in a consi... | stackexchange_codegolf |
This is the robbers' thread. The cops' thread goes here.
In the cops thread, the task was to write a program/function that takes a positive (or non-negative) integer and outputs/returns another number (not necessarily integer). The robbers task is to unscramble the code the cops used to produce this output.
The cracked... | stackexchange_codegolf |
SVG is an XML vector graphics markup language embeddable in web content.
Your tips should be at least somewhat specific to SVG.
Please post one tip per answer.
| stackexchange_codegolf |
Yesterday at work, the Google Doodle convinced me to share my rather long gender swap script here, but the code-golf criteria of the question i asked were not clear. As my question still got downvoted after giving examples, i changed the tag to popularity-contest, as suggested before i clarified it.
Here's a more golfy... | stackexchange_codegolf |
The Len(language,encoding) family of languages is a variety of Lenguage derivatives. To encode a program into a Len language, you replace every character with its representation in a certain encoding, then turn that into a giant integer.
Your challenge is to write a function or program that encodes your language into a... | stackexchange_codegolf |
Given a UTF-8 string, give a string that represents byte counts of each characters.
Rules:
As long as the input string is encoded in UTF-8 (without BOM), its type doesn't matter. In C++, it can be char[] or std::string. In Haskell, it can be [Int8] or [CChar].
The output must be (in usual case) a string of ASCII digit... | stackexchange_codegolf |
Your task: given a number n, generate a '+' sign that is n characters away from its center. If this is confusing, check out the test cases.
Standard methods of input: output must be a string or printed. Standard loopholes apply.
Input: 1
Output: + ] 1 away from center `+`.
Input: 2
Output: + ] 2 a... | stackexchange_codegolf |
Write program or function which will take left and right value of dice as integers (1-6) and return value on top.
Dice layout:
+---+
| 1 |
+---+---+---+---+
| 2 | 3 | 5 | 4 |
+---+---+---+---+
| 6 |
+---+
,^.
<´ 5 `> <-- Top value
|`._,´|
.6 | 4, <-- Side values
`.|,´
So inputting 6 4 will return... | stackexchange_codegolf |
What tips do you have for golfing in (,)? I've found that there are so many ways to make code shorter, and I want more ways. I doubt there even are any tips for (,) that are applicable in the majority of programming languages, but if there are, feel free to include them.
Please, one tip per answer.
| stackexchange_codegolf |
Similar to this, this, and this question...
What general tips do you have for golfing in VBA? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to VBA (e.g. "remove comments" is not an answer). Please post one tip per answer.
While I have worked with other l... | stackexchange_codegolf |
Your Task: Print "Hello, World!" using a palindrome.
Simple, right?
Nope.
You have one restriction: you may not use comments.
"Comments" include
Normal // or # comments
Adding extraneous characters to a string literal
Triple-quoted string comments
Creating a string literal to hide characters
You may not use a pre-de... | stackexchange_codegolf |
You are given 6 numbers: 5 digits [0-9] and a target number. Your goal is to intersperse operators between the digits to get as close as you can to the target. You have to use each digit exactly once, and can use the following operators as many times as you want: + - * / () ^ sqrt sin cos tan. For example, if I'm give... | stackexchange_codegolf |
Task
Write a program or function that takes an image of width w and height h, and two integers a <= w/2 and b <= h/2, and outputs an ascii art representation of the image, with the dimensions a x b.
The ascii art should be generated through the following steps (or another process with the same output):
Resize the w x ... | stackexchange_codegolf |
Deserializing binary trees depth-first is pretty easy, but doing it breadth-first is (hopefully) harder. Your mission, should you choose to accept it, is to do the latter.
The input will be a 1-D list of positive integers representing node values and some other consistent value representing the absence of a child (I'll... | stackexchange_codegolf |
Challenge
Make a triangle of numbers like below.
How to?
Let say we get a numbers in the form of ab, for example 12. We then create a triangle like below:
Sorry for my bad drawing!
First we have 12, and we take sum of the two numbers 1 and 2, which is 3. In case the sum of two numbers are greater than 9, we just take ... | stackexchange_codegolf |
Write a sorting algorithm for a list of integers that has an average performance of O(n^2).
This is code-golf, so the shortest code in bytes wins.
RULES:
The characters wasted for the declaration of the list are not counted
(e.g. var c = new List<int>() { 4, 2, 1, 3 }; is not counted)
Builtins to sort a list are not ... | stackexchange_codegolf |
Given a boolean function with inputs, check if it's possible to only use IMPLY gate to express it.
There's no extra limitation on how you use this gate, and you can use each input for any amount of times. See examples below:
\$\begin{matrix}
\text{Expression}&&&&&\text{Solution}&\text{Your output}\\
a&0&0&1&1&a&\text{t... | stackexchange_codegolf |
The Juggler sequence is described as follows. Beginning with an input \$a_1\$, the next term is defined by the recurrence relation
$$a_{k+1} = \begin{cases}
\left\lfloor a_k ^ \frac 1 2 \right\rfloor,\text{ if } a_k \text{ is even} \\
\left\lfloor a_k ^ \frac 3 2 \right\rfloor,\text{ if } a_k \text{ is odd} \\
\end{cas... | stackexchange_codegolf |
Figuring out whether a given number is prime, while not very complicated, is kind of hard. But making a guess doesn't need to be.
Seeing whether a number is a multiple of 2 or 5 is easy - you can just look at the last digit. Multiples of 3 isn't much harder, just add up the digits and see if you end up with a multiple ... | stackexchange_codegolf |
In one of our projects at work, we recently discovered a particularly large method for generating a 6 character string from a 15 character alphabet. A few of us claimed "I bet we can get that in one line" which started a little internal game of code golf.
Your task is to beat us, which I have no doubt won't take long!
... | stackexchange_codegolf |
Your task
In your language of choice: create a program that outputs 1
This 1 may either be a string or value equivalent to the number one.
The shifting catch
If you take the unicode codepoint (or whatever codepoint encoding your languages uses if not UTF) for each character in your program, and shift each of those valu... | stackexchange_codegolf |
Game
In this challenge you will play a made-up turn-based game.
The game is made up of the following elements:
A 8x8 grid with each spot containing nothing (space), a robot (*), a wall (#), or HP (@)
A public stack
Robots
In this challenge, you will be playing as a robot. Each robot has health (starts at 10HP and ca... | stackexchange_codegolf |
You are given an \$ 25 \times 25 \$ square lattice graph. You are to remove certain nodes from the graph as to minimize your score, based on the following scoring system:
Your score will be the \$ \text{number of nodes removed} \$ \$ + \$ the \$ \text{size of the largest connected component} \$. In the smaller \$ 4 \ti... | stackexchange_codegolf |
We know that not all fractions have a terminating binary representation. However every fraction can be written as a leading portion followed by a repeating portion. For example \$1/3\$ starts with \$0.\$ and then just repeats \$01\$ endlessly. This corresponds to the bar notation taught in primary school. For examp... | stackexchange_codegolf |
Sometimes I make bad jokes... And a bad joke I like to make involves interpreting exclamation marks in sentences as the factorial sign.
Task
Your task is to write a program that receives a sentence and applies the factorial joke to the sentence.
The "factorial joke" consists of looking for exclamation marks "!" and doi... | stackexchange_codegolf |
Here is the code which I want to shorten.
n=input()
while n:
s=raw_input()
x,r,g,b=(int(x) for x in s.split())
a=x/r%2
c=x/g%2
d=x/b%2
r=((a*10+c)*10)+d
if r==0:e="black"
elif r==100:e="red"
elif r==1:e="blue"
elif r==10:e="green"
elif r==101:e="magenta"
elif r==11:e="cyan"
elif r==110:e="yellow"
else:e="... | stackexchange_codegolf |
You're at integer coordinates \$(x,y)\$ facing one of North, South, East, or West. Your goal is to walk home to \$(0,0)\$. At each step, you may do one of:
Walk one step in the current facing direction, that is to whichever of \$(x+1,y)\$, \$(x-1,y)\$, \$(x,y-1)\$, or \$(x,y+1)\$ you're facing.
Rotate 90 degrees left,... | stackexchange_codegolf |
Background
A Medusa have released a dangerous Hydra which is revived unless the exact number of heads it have is removed. The knights can remove a certain number of heads with each type of attack, and each attack causes a specific amount of heads to regrow. The knights have hired you to write a program or function that... | stackexchange_codegolf |
A screen consists of some LED segments like such:
The screen can be split into several(maybe one) component. Each component is a segment like above, with varying lengths. These components can be used to display any amount, including 0, of digits, as long as the component is large enough.
Every digit except 1 needs two... | stackexchange_codegolf |
The challenge:
Assuming you have \$ X \$ collections, each collection \$ C_i \$ has a name \$ N_i \$ and a capacity \$ N_i \$ of elements - Determine which collection will be overflowed first while counting the occurrences of the names in a cyclic list. Also print how many cycles of the list occurred.
Example:
4 Collec... | stackexchange_codegolf |
In this challenge, your bot has landed on an island with the stereotypical knights and knaves. Knights always tell the truth, and knaves always lie. The objective is to find the correct 32 digit hexadecimal string before anyone else, by asking knights and knaves and trying to trick other bots into giving you answers or... | stackexchange_codegolf |
Note that this is similar to my other challenge, but it is widened to be similar to most challenges (input -> truthy/falsey), instead of asking you all to brute force something. If this makes it a dupe, let me know, but I posted it on Sandbox and asked on chat, and didn't get any negative responses.
Input
Input will be... | stackexchange_codegolf |
Given a positive integer, output a truthy/falsy value as to whether the number can eat itself.
Rules
Leftmost is the head, rightmost is the tail
If the head is greater than or equal to the tail, the head eats the tail and the new head becomes their sum.
If \$sum \ge 10 \$ then the head is replaced by \$sum \mod 10\$.
\... | stackexchange_codegolf |
It's simple, simply write the shortest code to raise a TypeError.
In Python you can do:
raise TypeError
However it should be shorter with a code that gives a TypeError without raising it.
| stackexchange_codegolf |
This challenge was originally posted on codidact.
You are a low-level censor working for the Ministry of Media Accuracy. Part of your job is to make sure that certain words don't appear in publications. Every morning you get a fresh stack of next week's newspapers and its your job to comb through them and fix any of ... | stackexchange_codegolf |
Write a program/function that finds the amount of fuel needed to escape Earth's gravity well given the exhaust velocity of the fuel and the amount of mass to transport using the Tsiolkovsky rocket equation:
$$\Delta v = v_\text{exhaust}\ln\dfrac{m_\text{start}}{m_\text{end}}$$
where
\$\Delta v\$ is the change in veloc... | stackexchange_codegolf |
Task
Your task is to make the smallest function/program that can, when gives an number N, return/print:
the number of possible choices a, b such that \$1 \leq a < b < N\$ and a and b have exactly one common digit in base 10 (there exists a digit, and only one digit, which appears both in a and b, for example 12 and 23,... | stackexchange_codegolf |
A Geiger counter is a device that is used to detect radiation.
We will be making a Geiger counter program.
As we all know, when radiation hits a computer program it removes exactly 1 byte at random. So a Geiger counter program is a program that itself does nothing, but when any byte is removed the modified program pri... | stackexchange_codegolf |
Before reading this I suggest reading this little puzzle: https://puzzling.stackexchange.com/questions/11408/longest-word-with-adjacent-letters-on-a-keyboard
I want you to make a program that takes one argument, a word (only lowercase letters), and outputs "Yes" if the word can be typed with adjacent keys on the keyboa... | stackexchange_codegolf |
Task
The task is to write a program that outputs a consistent but otherwise arbitrary positive integer \$x\$ (so strictly greater than 0). Here's the catch: when the source is repeated \$N\$ times (the code is appended/concatenated \$N-1\$ to itself), the program should have a \$\dfrac{1}{N}\$ probability of outputting... | 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 |
I recently solved a coding challenge in one of the challenge papers that my IT teacher gave to us. It was a seemingly simple, but fun challenge, so I thought it will make fun golfing.
The task
Given an input of a 2x2 matrix that contains 4 strictly positive integers (i.e. non-negative and non-zero), like this:
$$\begin... | stackexchange_codegolf |
Challenge
Premise
Euler diagrams consist of simple closed shapes in a 2-D plane that each depict a set or category. How or whether these shapes overlap demonstrates the relationships between the sets.
I'm a spoilt brat who thinks Euler diagrams are hard to draw. For any Euler diagram, I want to know the minimum number ... | stackexchange_codegolf |
If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
Output how many letters would be used if all the numbers from 1 to 1000 (one thousand) inclusive were written out in words.
NOTE: Do not count spaces or hyphens. For example, 342 (th... | stackexchange_codegolf |
A space cleaner is a special character which removes all spaces between it and the first non space character to its left and it is represented by a '!' character.
If it reaches the beginning of the string it stops.
Given a string output the string in any reasonable format after the cleaning process.
Trailing spaces at ... | stackexchange_codegolf |
When one performs a search query using Google, one of the first things you see is an approximation of how many results were found. Today, you'll be simulating this in as few bytes as possible.
Input
A short string of length at most 10 with characters from a-z.
Output
The approx count that Google reports for the number ... | stackexchange_codegolf |
Given a series of numbers for events X and Y, calculate Pearson's correlation coefficient. The probability of each event is equal, so expected values can be calculated by simply summing each series and dividing by the number of trials.
Input
1 6.86
2 5.92
3 6.08
4 8.34
5 8.7
6 8.16
7 8.22
8 7.68
9 12.... | stackexchange_codegolf |
Your favourite programming language has just had a birthday. Be nice and sing it the Happy Birthday song.
Of course you should accomplish this by writing a program in that language.
The program takes no input, and writes the following text to the standard output or an arbitrary file:
Happy Birthday to You
Happy Birthda... | stackexchange_codegolf |
You know how many and which kinds of chess pieces were murdered. Can you come up with any possibility for who killed whom and how?
Background
During the course of a game of chess, there are between 2 and 32 pieces on the board. Call the collection of all pieces on the board (both white and black), without regard to p... | stackexchange_codegolf |
Write a program that takes a string as input and modifies it by reversing the string in its place by mirroring the position. The first position goes to last, second to second last and so it goes on. In simple words, the string would be mirrored.
"In Place" means the program should use \$O(1)\$ additional memory regardl... | stackexchange_codegolf |
This challenge will have you count pseudo-polyforms on the snub square tiling.
I think that this sequence does not yet exist on the OEIS, so this challenge exists to compute as many terms as possible for this sequence.
Update: this is now on the OEIS as A309159: Number of generalized polyforms on the snub square tiling... | stackexchange_codegolf |
Your program should print the following:
**Language, XXX bytes**
```
CODE
```
or its equivalent. XXX should be substituted by the actual number of bytes your program takes, and CODE should be substituted by the source code of your program. Language should be substituted by the actual language your program is in.
Your... | stackexchange_codegolf |
Given a string of digits or an integer as input, you will have to indexize it.
This is how you modify the input. We will use 30043376111 as an example:
First, find the sum of the indices of each occurrence of the respective digits:
0: 1 + 2 = 3
1: 8 + 9 + 10 = 27
3: 0 + 4 + 5 = 9
4: 3
6: 7
7: 6
Then, construct a new... | stackexchange_codegolf |
Given a non-empty string (or an integer, or a list/array if you prefer) composed exclusively of digits in the range [1-9], your task is to write a function (or a whole program) that applies a "Match-3 type of rule" from left to right and outputs the resulting string, like this :
[parameter] "12223" -> [returned value] ... | stackexchange_codegolf |
I had fun solving this, so I offer this golf challenge.
The objective of this golf is to find the largest prime number that can be constructed using the given instructions.
You should accept 3x3 grid of single digits as input. (It's up to you how you want to do that, but specify that in your program.)
You can move alon... | stackexchange_codegolf |
Given a list of N integers, each with N digits, output a number which differs from the first number because of the first digit, the second number because of the second digit, etc.
Example
Given this list:
1234
4815
1623
4211
The number 2932's first digit is different from the first number's first digit, its second dig... | stackexchange_codegolf |
A Pythagorean triple consists of three positive integers a, b, and c, such that a2 + b2 = c2. Such a triple is commonly written (a, b, c), and a well-known example is (3, 4, 5). If (a, b, c) is a Pythagorean triple, then so is (ka, kb, kc) for any positive integer k. A primitive Pythagorean triple is one in which a, b... | 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 |
The Background Future
In the year 2017, you and your opponent will face off in a futuristic gun battle where only one may survive. Are you experienced enough to defeat your opponent? Now is the time to polish your guns skills in your favorite programming language and fight against all odds!
Tournament Results
This tour... | stackexchange_codegolf |
Emmet is a text-editor and IDE plugin for writing HTML code using much fewer keypresses. You might think of it like a code-golfing HTML preprocessor. Its syntax is based on CSS selectors.
Your challenge is to code-golf an implementation of Emmet. Given some Emmet code, output the resulting HTML.
Note that for the purpo... | stackexchange_codegolf |
An Abecedarian Word is a word whose letters are in alphabetical order. Your goal is to write a program that outputs all abecedarian words from a given lexicon.
Rules:
Standard Loopholes are forbidden.
If a word contains punctuation, diacritical marks, or any characters other than ASCII alphabet characters (A-Za-z), r... | stackexchange_codegolf |
Imagine you are sitting at a park. Suddenly your car gets hijacked and being driven in different directions. Here are the directions, arrows show which direction goes towards where:
South
|
V
East-> <-West
^
|
North
After being driven, the car stops. Now you have to find out ho... | stackexchange_codegolf |
In your favorite programming language, create an application that restarts itself once, after n seconds.
You need to find a way to restart after exiting the program. EG: run cmd to do it for you. Make sure it waits an amount of seconds specified by the user before restarting
For clarification: You can run a second prog... | stackexchange_codegolf |
There are 10 types of people in the world, those who understand binary and those who do not.
Where are you? Let's see!
Challenge
Your task is to convert a decimal integer to binary, only using a set of arithmetic operators (+, -, *, / and %). You can use conditional statements, loops and variables. (No bitwise operator... | stackexchange_codegolf |
Your task is to generate an emoticon of three characters, the first character being one eye, the second the mouth, and the third another eye. Each eye is a random one of these characters: $'*+-;O^`ox~, and the mouth is a random one of these: ,-._coux.
Each eye and the mouth must be on the same general level. These eyes... | stackexchange_codegolf |
The cosine similarity of two vectors \$A\$ and \$B\$ is defined using their dot product and magnitude as:
\$\frac{A\cdot B}{\|A\|\|B\|}\$
Or in other terms
\$\frac{\sum_{i=1}^nA_iB_i}{\sqrt{\sum_{i=1}^nA_i^2}\sqrt{\sum_{i=1}^nB_i^2}}\$
Challenge
Given two nonempty, nonzero vectors containing only integers (can be taken... | stackexchange_codegolf |
Task
Define a simple regex as a non-empty regular expression consisting only of
characters 0 and 1,
grouping parentheses ( and ),
one-or-more repetition quantifier +.
Given a non-empty string of 0s and 1s, your program should find the shortest simple regex matching the full input string. (That is, when matching a sim... | stackexchange_codegolf |
In this challenge you will remove one of my least favorite features, operator precedence from traditional math notation, to acheive the syntax of one of my favorite languages, APL. The APL subset we will be working with includes only a few functions and single digit numbers. (No arrays!)
Here is the grammar of the inpu... | stackexchange_codegolf |
Here's a nice easy challenge:
Given a string that represents a number in an unknown base, determine the lowest possible base that number might be in. The string will only contain 0-9, a-z. If you like, you may choose to take uppercase letters instead of lowercase, but please specify this. You must output this lowest p... | stackexchange_codegolf |
Guidelines
Scenario
John has an important number, and he doesn't want others to see it.
He decided to encrypt the number, using the following steps:
His number is always a non-decreasing sequence (ie. "1123")
He converted each digit into English words. (ie. "123" -> "ONETWOTHREE")
And then, rearrange the letters random... | stackexchange_codegolf |
Write a program that outputs Hell0 W0rld!. It must match this output exactly, including capitalization, zeroes instead of o's, exactly one space, etc. Trailing new lines are allowed.
Lowest score wins. Scoring is based on the sum of the values of each character in the language's code page - otherwise Unicode values ... | stackexchange_codegolf |
I have just tried a game called Couch 2048.
(Note: You should have a look to better understand this question.)
Since it wasn't very exciting for me, I've been asking myself 'How much more till 2048!?'
That inspired me to post a challenge, because calculating this in not as easy as I thought.
Your goal:
Given a list of ... | stackexchange_codegolf |
Challenge:
Given a list of non-negative integers, determine by how much you should increase each item to create the closest binary box with the resulting integer-list.
What is a binary box?
A binary box is where the first and last rows consists of 1-bits; the first and last columns consist of 1-bits; and everything els... | stackexchange_codegolf |
This is a cops-and-robbers challenge based around defining languages and proving they are Turing complete.
This is the robbers' thread. The cops' thread is here.
Robbers
The cops will post definitions of Turing-complete languages. Your task is to crack them by proving that they are indeed Turing complete. See the cops'... | stackexchange_codegolf |
You have given an array from which we need to remove duplicates.
Rules:
First or immediate duplicates gets removed first.
Array contains natural numbers a[i]>0 for i>=0
no. of elements in the array is greater than 1 i.e. n>1
e.g.
{1,2,3,4,5,5,4,6,6,7,8}=> {1,2,3,7,8}
{1,2,3,3,4,5,6,7,7,8} => {1,2,4,5,6,8}
{1,1,3,3,... | stackexchange_codegolf |
Design a function or program that, when run normally, outputs the triangular numbers. However, when any single character is deleted, the program/function should not function in the original programming language, but instead produce the triangular numbers in one other programming language.
Scoring
Your score will be the... | stackexchange_codegolf |
The ordinal number system is a system with infinite numbers. A lot of infinite numbers. So many infinite numbers that it literally does not have an infinity to represent its own infiniteness. The image above gives a little idea of how they work. An ordinal number (Von Neumann construction) is a set of previous ordinal... | stackexchange_codegolf |
This challenge is about finding the smallest disk that contains some given points. This is made somewhat trickier, however, by the fact that in this challenge, the disk's coordinates and radius must both be integers.
Your input will be a list of points with integer coordinates x and y. You can take this as a list of tu... | 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 |
An old test for programmers, taken from here (Note: in italian).
Along a road (denoted by '_'), there is a Magical Piper (denoted by 'P') and several mice (represented by the two characters 'o' and '~', that denote respectively the head and the tail of the small rodents).
Write a program that prints how many mice are g... | stackexchange_codegolf |
Summary
The task is to navigate the Mars rover and tell its final coordinates and direction.
Input:
First input:
First your program must take the input which will be in the following format:
[X-Coordinate],[Y-Coordinate],[Direction]
The direction must be: N or S or E or W (Starting letters of North, South, West, East)... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.