instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
In the face of some regrettable rules that turned the original into a glorified sorting task, I am posting a more challenging variant. Shout out to Luis Mendo for the suggestion of how to improve the original challenge.
You've inherited a server that runs several apps which all output to the same log.
Your task is to ... | stackexchange_codegolf |
Given two strings, find the translation table (substitution cipher) between the two, if the translation is not possible, output false. The answer must be minimized and created from left-to-right. The first character to be translated between words must be the first in the translation table. In addition to this, any lett... | stackexchange_codegolf |
Background
The newest version of the C standard, C23, adds preprocessor macros like INT_WIDTH, ULONG_WIDTH, and SIZE_WIDTH that tell you the bit width of various integer types (here, int, unsigned long, and size_t, respectively). However, while the majority of us are stuck with pre-C23 compilers/standard libraries, it... | stackexchange_codegolf |
The goal is, having taken a string as input, duplicate each latin letter and "toggle" its case (i.e. uppercase becomes lowercase and vice-versa).
Example inputs & outputs:
Input Output
bad bBaAdD
Nice NniIcCeE
T e S t Tt eE Ss tT
s E t sS Ee tT
1!1!1st! 1!1!1sStT!
n00b nN00bB
(e.g... | stackexchange_codegolf |
Or, "Swap the first and last letters of each word"
Your challenge is to, given a string of alphabetical ASCII characters as well as one other character to use as a delimiter (to separate each word), swap the first and last letters of each word. If there is a one-character word, leave it alone.
The examples/testcases us... | stackexchange_codegolf |
Part 2 of the challenge is here
Flags Mashup Bot is a small Twitter bot that generates a new flag based on two random flags and tweets the result every couple of minutes.
Task
Your task is to replicate what the bot does by writing a script or a function based on the following criteria:
The input is any two lossless i... | stackexchange_codegolf |
This question is the second of several Brain-flak Birthday challenges designed to celebrate Brain-Flak's first Birthday! You can find more information about Brain-Flak's Birthday here
Challenge
For this challenge you'll be generating all fully matched strings from a list of brackets. To borrow DJMcMayhem's definition... | stackexchange_codegolf |
The challenge
Given an input string, and an integer n - truncate any runs of consecutive characters to a maximum of n length. The characters can be anything, including special characters. The function should be case sensitive, and n can range from 0 to infinity.
Example inputs/outputs:
f("aaaaaaabbbccCCCcc", 2) //"aabb... | stackexchange_codegolf |
Cop's thread here
In this cops-and-robbers challenge cops will think of a positive integer. They will then write a program or function that outputs one value when provided the number as input and another value for all other positive integer inputs. Cops will then reveal the program in an answer keeping the number a... | stackexchange_codegolf |
Your challenge is to make an infinite loading screen, that looks like this:
Or, to be more specific:
Take no input.
Output Loading..., with a trailing space, but no trailing newline.
Infinitely cycle through the chars |, /, - and \: every 0.25 seconds, overwrite the last one with the next in the sequence. You can ov... | stackexchange_codegolf |
Your job is to write a program that rewrites and makes itself longer on each run of the program.
Challenge
The program will print Hello, World!\n (\n denotes a newline). Then, it will modify its own file so that the new program length is exactly 2x the length at runtime. This modified file when run, will print Hello, W... | stackexchange_codegolf |
(l, r) defines a line whose left end is at l and the right end is at r, on a 1-dimensional space.
Given 2 lines b = (0, bz) and f = (i, i + fz), v = (l, r) is the overlapping part of these lines. When b and f do not overlap (when v cannot have a positive length), v = (0, 0).
(input) -> (output)
bz, fz, i -> l, r
The... | stackexchange_codegolf |
Introduction
Aron Nimzowitsch was a leading chess master and a influential chess writer.
In his book 'My System', the first chapter deals about the importance of the center and why you should dominate it. The simple reason is that your pieces have more possible direct next moves when being in the center which again giv... | stackexchange_codegolf |
You are given two regexes and your task is to determine if the strings matched by the first regex are a subset of the strings matched by the second regex.
For this we are going to use a limited mathematical definition of a regex. A regex is defined recursively as one of:
ε - This matches only the string ""
0 - This ma... | stackexchange_codegolf |
Introduction
In this challenge, your task is to implement a collection of simple functions that together form a usable mini-library for simple probability distributions.
To accommodate some of the more esoteric languages people like to use here, the following implementations are acceptable:
A code snippet defining a c... | stackexchange_codegolf |
Let's for once do something useful.
Given the text from a Try It Online codegolf submission, produce the equivalent Chat Mini Challenge submission, which is of the form
Language, N bytes: [`code`](URL)
or (if submission is a single byte – TIO will add a trailing s on the first line only if needed)
Language, 1 byte: [`... | stackexchange_codegolf |
Party time! All of your guests are sitting around a round table, but they have very particular seating requirements. Let's write a program to organize them automatically!
Guests are represented by letters: Female guests are uppercase, males are lowercase. Couples have the same letter, one lower and one upper, like gG, ... | stackexchange_codegolf |
You have to write an interpreter for a cool language called Chicken!
You should read a Chicken program from a file, standard input, program or function arguments, or whatever is most convenient for your language, as well as input to the program.
You should print or return the result of interpreting the program accordi... | stackexchange_codegolf |
Suppose we want to encode a large integer \$x\$ as a list of words in such a way that the decoder can recover \$x\$ regardless of the order in which the words are received. Using lists of length \$k\$ and a dictionary of \$n\$ words, there are \$\binom{n+k-1}k\$ different multisets possible (why?), so we should be able... | stackexchange_codegolf |
You have played \$N\$ matches in some game where each match can only result in one of the two outcomes: win or loss. Currently, you have \$W\$ wins. You want to have a win percentage of \$P\$ or more, playing as few matches as possible. Output the minimum win streak that you need. Assume the current win streak is at \$... | stackexchange_codegolf |
Morpion solitaire
This is a game that I remember having learnt from my grandparents in my childhood. Initially I didn't know the name. G B has found it to be Join Five (or less ambiguously - Morpion solitaire) with a slightly different starting position.
NOTE: it seems that it's kinda known and this problem formulation... | stackexchange_codegolf |
Given a ragged list of positive integers find the size of the largest list contained somewhere in it.
For example:
[1,[1,[8,2,[1,2],5,4,9]],2,[],3]
Here the answer is 6 because one of the lists has 6 elements and all other lists have fewer.
[1,[1,[8,2,[1,2],5,4,9]],2,[],3]
^ ^ ^ ^ ^ ^
The length doesn't ca... | stackexchange_codegolf |
I'm not really sure if this is the right place to ask this.
Now, I know I can convert a float to an int with int, but is there some shorter way?
| stackexchange_codegolf |
Related
Explanation
Given a string such as DCBA, convert it to ASCII ordinals, such as 68 67 66 65. Then, take the differences between each value, eg 67 - 68 = -1, 66 - 67 = -1... giving -1 -1 -1 Now as long as there is more than 1 left over value, repeat getting the differences.
For a 3 letter string, your pathway sho... | stackexchange_codegolf |
Related
Sometimes when I use my microwave, I do a little trolling and enter times such as 2:90 instead of 3:30 because they end up being the same time anyway. The microwave happily accepts this and starts counting down from 2:90, displaying times like 2:86 and 2:69 until it gets back to a stage where it can count down... | stackexchange_codegolf |
Introduction
Write a program to output the outgoing spiral of the famous pangram following given rules.
Challenge
A pangram is a sentence using every letter of a given alphabet at least once. One of the most famous pangrams is the one used extensively in Windows font viewer, namely "The quick brown fox jumps over the l... | stackexchange_codegolf |
You may or may not remember Xeyes, a demo program that came with (and, as far as I know, still comes with) the X window system. Its purpose was to draw a pair of eyes that followed your mouse cursor:
Your challenge is to recreate Xeyes with ASCII art. Write a program or function that draws two ASCII art eyes (specifie... | stackexchange_codegolf |
The challenge: output this exact ASCII art of a spiderweb in a window:
_______________________________
|\_____________________________/|
|| \ | / ||
|| \ /|\ / ||
|| /\'.__.' : '.__.'/\ ||
|| __.' \ | / '.__ ||
||'. /\'---':'---'/\ .'||
||\ '. /' \... | stackexchange_codegolf |
Unsurprisingly, fibonacci primes are primes that are also Fibonacci numbers. There are currently 34 known Fibonacci primes and an additional 15 probable Fibonacci primes. For the purpose of this challenge, the Fibonacci numbers are the sequence \$F_n\$ defined as \$F_1 = 1\$, \$F_2 = 1\$, and \$F_n = F_{n-1} + F_{n-2}\... | stackexchange_codegolf |
Write a program or function (hereafter "function") that returns or prints the source code of four new functions: Increment, decrement, undo, and peek.
The initial function contains an internal integer value of 0. Each of the returned functions contains a value based on that value, and each behaves differently:
Increme... | stackexchange_codegolf |
Inspired by this.
Given a string as input consisting of only upper and lowercase alphabet characters, wicka-wub it.
How do I wicka-wub a string?
The example text used is "DJMcMayhem".
Split the string before each capital letter, so you get ["D", "J", "Mc", "Mayhem"].
Next, take the two halves of the list as sublists. T... | stackexchange_codegolf |
Your challenge is very simple: output the previous answer, in reverse.
However, as with this similarly-titled question, there's a catch: in this case, you can only use characters from the answer before the last. For example:
Let's say the first answer looks like this:
1 - Python
print('hi!')
And the second answer loo... | stackexchange_codegolf |
You are playing a famous game called \$1\text{D Array BattleGround}\$. In the game, the player can be stationed in any position from \$0\$ to \$10^5\$.
You are a Paratrooper in the game and have the ability to do two types of operation \$-\$
Advance, which would multiply your position by \$2\$
Fall-back, which would d... | stackexchange_codegolf |
I like card game challenges so I made this one for the Italian card game Scopa. My family has been playing this game since time immemorial. It has a very interesting scoring system that should be fun to golf. I will post an answer in R to get the fun started, that I am sure people will improve upon.
The challenge: figu... | stackexchange_codegolf |
Challenge: Add two numbers. In O(n^m) time, where n and m are the two numbers given. Sleeping, or your language equivalent, is not allowed.
Input: Two integers, separated by a space.
Output: The sum of the two integers.
Additional notes: The exact timing doesn't matter, as long as the input 1000 2 takes roughly 1/1000t... | stackexchange_codegolf |
A brace string is defined as a string consisting of the characters *()[] in which braces match correctly:
[brace-string] ::= [unit] || [unit] [brace-string]
[unit] ::= "" || "*" || "(" [brace-string] ")" || "[" [brace-string] "]"
This is a valid brace-string:
((())***[]**)****[(())*]*
But these are not:
)(
**... | stackexchange_codegolf |
Related: Interquine
Program A outputs program B's code when run, and B outputs C's source, and C outputs A's source.
This time you can't exchange two characters and exchange again :)
Requirements:
Only one language across all programs
Standard loopholes restrictions apply
All programs are different. One program th... | stackexchange_codegolf |
Your task is to write a program or function. Its output/return value must follow these rules:
The program outputs 1
The program repeated n times outputs n
The program backwards outputs -1
The program backwards and repeated n times outputs -n
A mix of forward and backward programs will output number_forward - number_ba... | stackexchange_codegolf |
Write a program that will test the primality of a specified number, and give the output as a Boolean value (True is prime). Your prime test can (but doesn't have to) be valid for the number 1.
Here's the catch: your program itself has to sum to a prime number. Convert every character (including spaces) to its Unicode/... | stackexchange_codegolf |
What general tips do you have for golfing in Racket / Scheme? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Racket / Scheme (e.g. "remove comments" is not an answer).
I'm aware Scheme and Racket (formerly PLT Scheme) are technically different language... | stackexchange_codegolf |
A little known fact about vampires is that they must drink the blood of victim that has a compatible donor blood type. The compatibility matrix for vampires is the same as the regular red blood cell donor/recipient matrix. This can be summarized by the following American Red Cross table
Type You Can Give Blood To... | stackexchange_codegolf |
Task
Given a list of nodes representing a binary tree of positive integers serialized depth-first, return a list of nodes representing the same tree serialized breadth-first. To represent an absent child, you may use null, 0, 'X', Nothing, [], or any other value that is distinct from your representation of a node's val... | stackexchange_codegolf |
In some parts of the world, phone numbers are fixed-length, apparently. That sounds boring, though.
For this challenge, your task is to take the digits of a what is presumed to be a valid phone number, and format it based on some simplified rules around what a phone number looks like.
Input format
Your input will consi... | stackexchange_codegolf |
Number to String
Instructions
Convert a signed 32-bit integer to a string (base-10 preferably) without any string formatting calls (or built in type coercion that will directly convert a number to a string).
Negative numbers must include leading -.
Score Calculation
Shortest byte length; Tie breaker by efficiency (exec... | stackexchange_codegolf |
Consider the positive integer powers of five in decimal. Here are the first 25, right aligned:
X 5^X
1 5
2 25
3 125
4 625
5 3125
6 15625
7 78125
8 390625
9 1953125
10 ... | stackexchange_codegolf |
Thanks to this question for some inspiration
In this challenge we will represent a line of dominoes as a string of |, / and \. You will be given a string of dominoes as input and you must determine what they look like when they have settled. Here are the rules for how dominoes fall over
A standing domino, |, left ... | stackexchange_codegolf |
Recently I asked for tips on improving some code-golf of mine. The code was supposed to output every third value of the Fibonacci sequence starting with 2:
2,8,34,144,610,2584,10946,46368,196418,832040
However, I made a mistake in deriving my formula, and my code output a different sequence which is accurate for the ... | stackexchange_codegolf |
I promise, this will be my last challenge about diamong tilings (for a while, anyway). On the bright side, this challenge doesn't have anything to do with ASCII art, and is not a code golf either, so this is actually completely different.
So just as a reminder, every hexagon can be titled with three different diamonds:... | stackexchange_codegolf |
I have a number like this:
n = 548915381
The output should be the sum of every second digit of that number. In this case 26:
4+9+5+8 = 26
Rules:
This is a code-golf, so the shortest code in bytes wins.
The input consists only of numbers bigger than 10 (at least 2 digits) but smaller than a 32-bit integer.
The input ... | stackexchange_codegolf |
The cumulative sum of a vector is calculated by simply taking the sum of all previous elements. For instance:
vec = [1 1 1 -1 -1 -1 -1 -1 1 1 1 1 -1]
cum_vec = [1 2 3 2 1 0 -1 -2 -1 0 1 2 1]
Now, impose an upper and a lower limit, meaning that you stop increasing the cumulative sum if it's at the up... | stackexchange_codegolf |
We define the hyper-average of an array / list (of numbers) the arithmetic mean of the sums of its prefixes.
For example, the hyper-average of the list [1, 4, -3, 10] is computed in the following manner:
We get the prefixes: [1], [1, 4], [1, 4, -3], [1, 4, -3, 10].
Sum each: [1, 5, 2, 12].
And now get the arithmetic m... | 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 |
Output a sequence of all the primes that are of the following form:
123...91011...(n-1)n(n-1)..11109...321. That is, ascending decimal numbers up to some n, followed by a descending tail, all concatenated.
Background
Recently, Numberphile posted a video about primes that follow this pattern.
Output
1 -> 123456789109876... | stackexchange_codegolf |
Randomness is fun. Challenges with no point are fun.
Write a function that, given integer input n, will output a set (unordered, unique) of exactly n random integers between 1 and n^2 (inclusive) such that the sum of all integers is equal to n^2.
Randomness does not have to be uniform, provided each valid set has a non... | stackexchange_codegolf |
My kids have an alphabet mat to play with, something like this:
After months with the tiles of the mat randomly placed, I got tired and placed all the tiles of the mat grouped by sections according to their background colors. So, if the letters represent the background color, I got a mat like this:
AABBCDDDE
ABBCCCDEE... | stackexchange_codegolf |
You will be given as input a non-empty list of positive integers. For example:
[1,2,2,2,1]
You want to produce a ragged list as output which has this as its "depth map". This list should have the same elements in the same order but each element n should be at the depth equal to its value.
[1,[2,2,2],1]
This is a li... | stackexchange_codegolf |
Inclusion-Exclusion lets you calculate the sizes of some unions and intersections between sets knowing some of the other values. I won't explain it exactly, but your challenge is to visualize inclusion-exclusion on a Venn Diagram.
Because I'm nice, you'll be using rectangles, not circles.
You will be given a list of re... | stackexchange_codegolf |
This is the robbers' thread, the cops' thread is here
A polyglot is a program, that without modification, can run in multiple languages.
Robbers' Challenge
First, find a vulnerable cop's answer, then try to find languages that the submission works in, if you found any that weren't listed by the cop, then you just cra... | stackexchange_codegolf |
Related to this question.
A room is defined to be a (not necessarily convex) non-intersecting polygon, expressed as an ordered list of 2-dimensional coordinates. A sufficiently bright lightbulb is placed at a specific point inside the room, and emits light in every direction. Your task is to find the total illuminated ... | stackexchange_codegolf |
The Universal Crossword has a set of guidelines for crossword puzzle submissions.
In this challenge we are going to be concerned with their rules for hidden word themes. A hidden word clue consists of a clue and a word. It can either be a
"word break" or a "bookend".
For a word break the word must not appear as a cont... | stackexchange_codegolf |
Task:
Return an array with all possible pairs between the elements of an array.
Example
From a=["a", "b", "c", "d"]; return b=[["a","b"],["a","c"],["a","d"],["b","c"],["b","d"],["c","d"]].
Pairs can be in any order as long as all possible combinations are included and obviously ["b","d"] is the same to ["d","b"].
Inpu... | stackexchange_codegolf |
Please note the special scoring for this challenge.
Given a non-empty string made of a-z, output the string immediately before it in the shortlex order.
Shortlex order
We enumerate strings in shortlex order by first listing the strings of length 0, then those of length 1, then length 2, and so on, putting them in alph... | stackexchange_codegolf |
First of all, this is more a challenge, than a serious programming question, I would like to share.
Some of you might know the game Kuku kube, where you have to identify a square in a grid, which has a different colour than the others and click it.
You can find it under http://kuku-kube.com/ .
As this seems to be an id... | stackexchange_codegolf |
You want to make a string where the (1-indexed) character at index n is n. When n is less than 10, this is easy: "123456789". When n is 12, for example, it becomes impossible, since numbers greater than 9 (in base 10) take up more than one character. We can compromise by dividing the string into two-character substring... | stackexchange_codegolf |
I'm surprised this hasn't been done yet, but here we go.
Create a program which prints some number of 1s (ideally as large as possible) before halting.
The rules are simple:
Your program is bounded to 50 bytes in size.
Your output must only be a continuous row of 1s (plus trailing newline if it has to be added), withou... | stackexchange_codegolf |
In this challenge, your input is an integer value. Your task is to find the sum of the range of the sum of the range of n.
Examples:
Input -> Output
1 -> 1
2 -> 6
3 -> 21
4 -> 55
5 -> 120
6 -> 231
7 -> 406
8 -> 666
9 -> 1035
10 -> 1540
This challenge should be fairly simple to co... | stackexchange_codegolf |
Write a program which will take for input 2 integer arrays and return a truthy value if there exists an element which is present in both of arrays, or a falsy one otherwise. The obvious solution to this problem would be to iterate through each element in the first array and compare it against each element in the second... | stackexchange_codegolf |
Task
Provide two programs/functions A and B (not necessarily in the same language) with the following properties:
Either program, when given its own source code as input, produces an accepting output.
Either program, when given the other program's source code as input, produces a rejecting output.
It doesn't matter w... | stackexchange_codegolf |
Write a program or function that takes in a positive integer N, and prints or returns an N×N ASCII art string whose top half is a semicircle made of ('s and whose bottom half is a downward-pointing triangle made of V's, with spaces used as padding.
In other words, make an ASCII ice cream cone: (output for N = 17)
... | stackexchange_codegolf |
I am making a customizable password generator.
But I (for some reason) thought it'd be better to let you guys do it.
Umm.. then?
You only get one integer. That will include all the information about the customization.
The first 4 bits (1,2,4,8) will be used for choosing which charsets will be used.
Each bit correspond... | stackexchange_codegolf |
Introduction
In order to prevent keyloggers from stealing a user's password, a certain bank account system has implemented the following security measure: only certain digits are prompted to be entered each time.
For example, say your target's password is 89097, the system may prompt them to enter the 2nd, 4th and 5th ... | stackexchange_codegolf |
Snaking Number Challenge
I wonder how many snaking numbers there are between 1 and 50,000?
Snaking Numbers, in this game, are numbers which can be typed out on a traditional numberpad (format below) by moving one key up, down, left, or right.
7 8 9
4 5 6
1 2 3
0
For example, if you start with the number 5, you could... | 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 |
When I write documentation, comments, etc. I love making ASCII tables. They usually end up looking pretty good, but I always feel that they could look even better - especially since UTF-8/Unicode includes the box drawing characters. However, these characters are very burdensome to use, requiring several key presses to ... | stackexchange_codegolf |
Your task is to implement integer sequence A130826:
an is the smallest positive integer such that an - n is an entire multiple of 3 and twice the number of divisors of (an - n) / 3 gives the nth term in the first differences of the sequence produced by the Flavius Josephus sieve.
Lost yet? Well, it's actually quite e... | stackexchange_codegolf |
Well, last time I asked for an arithmetic sequence, now comes the geometric sequence
Challenge
In this challenge, the input will be an unordered set of numbers and the program should be able to tell if the set of numbers is a Geometric Sequence.
Input
The input will be a set separated by ,(comma).
Output
The Output ... | stackexchange_codegolf |
Robber Thread here
The Challenge
Choose any numeric* formula, algorithm, or code challenge. Implement it in such a way that the math is correct, but at least one answer is wildly** wrong due to some defect in how computers/programs operate, e.g. floating point errors, uninitialized/corrupted memory, environment bugs, c... | stackexchange_codegolf |
Carry sort is an \$O(n)\$ "sorting" algorithm. Here's how it works. The algorithm moves left to right along a list. As it traverses a list it "carries" a single item, the largest item it has encountered so far. Once it encounters a larger item it picks up that item and drops the item it is already carrying in place. W... | stackexchange_codegolf |
This quite literally came to me in a dream.
A common combination padlock design has letters on the dials so you can set the combination to a word. Unfortunately, I can't read, but I can count. Considering I am in a hurry, send the shortest path around the dials to open the 4 letter lock, given the current letters and t... | stackexchange_codegolf |
A spoonerism is what you get when swap the beginnings of two adjacent words in a sentence. In this challenge, we'll try to find a plausible spoonerism based on one incorrect word.
So, given a list of words** and an input word that is NOT in the dictionary, return a string (not necessarily a dictionary word) for which t... | stackexchange_codegolf |
Background
When I was younger, I was taught a method of drawing a weird "S" shape, that I (along with my classmates) found fascinating. Today, I rediscovered it, and due to its formulaic approach to drawing it, thought it could lead to an interesting challenge :P
Drawing the "S"
The S can be drawn by following these si... | stackexchange_codegolf |
Write a function that gets as an input a sorted array of positive numbers A, and an additional number n. The Task is to print out all distinct subsets of A, that sum to n.
Example:
Input:
A = [1,2,2,4,4]
n = 9
Output:
[1,2,2,4]
[1,4,4]
Bonus:
-50% if your code doesn't store duplicate subset (the same subset but in d... | stackexchange_codegolf |
Create a function that accepts a list of dates (unsorted with possible duplicates) and returns the days of the week in one of the following formats:
A format similar to MTWTFSS or SMTWTFS (i.e. beginning with Monday or Sunday), with non-days replaced by an underscore _, illustrated below.
WEEKDAY if all the dates are ... | stackexchange_codegolf |
Create a program that, given an integer N, outputs the number of years we have to get to N A.D. or how many years it has been since N A.D, as a string or int. For example, given 2014, the program should output 5 as it has been that many years since 2014. Input of the year in which you run the program should result in 0... | stackexchange_codegolf |
This challenge is to take an alphabetical string as input and to apply the following conversion:
The first of each type of character of the string must stay, and must be immediately followed by an integer representing how many of these characters were in the original string. Any repeating characters must be omitted.
Al... | stackexchange_codegolf |
Consider the following spiral of positive integers:
We now define grambulation as a binary operation \$\lozenge : \mathbb N \times \mathbb N \to \mathbb N\$, using this grid. Some example inputs and outputs for grambulation are:
\begin{align*}
1 & \lozenge 9 = 25 \\
1 & \lozenge 2 = 11 \\
11 & \lozenge 10 = 25 \\
9 & ... | stackexchange_codegolf |
Write a program that, given a string of capital letters, output all possible phrases that could have been written originally, using any variant of the Oxford English Dictionary.
Input
There are two inputs:
A string \$s\$ of A-Z capital letters that is a phrase with certain letters removed. Example: THSSANEAMPLE
Anoth... | stackexchange_codegolf |
Bi-directional translator
The challenge is to create a translator that can translate a [a-zA-Z ] string into another string according to the mappings below. The translator should also be able to translate translated text back into its normal form (hence bi-directional). Case doesn't have to be maintained and can be eit... | stackexchange_codegolf |
A magic square is an n-by-n square grid, filled with distinct positive integers in the range 1,2,...n^2, such that each cell contains a different integer and the sum of the integers in each row, column and diagonal is equal.
Your task is to take an n-by-n matrix consisting of positive numbers, and a placeholder charact... | stackexchange_codegolf |
Challenge
Design a compression algorithm specialized for compressing ASCII mazes. You will need to create both a compression algorithm and a decompression algorithm. Your score will be based on the size of your compressed mazes.
Mazes
These mazes are made primarily of the characters (floors), +, -, |, and # (walls), a... | stackexchange_codegolf |
Overview
The cover of a book will be provided in the following ASCII format:
______
| |
| |
| |
| |
------
The input can be in any reasonable format (eg. a list of strings, a nested list of characters, etc.)
Inside the "borders" of the cover, other printable ascii characters might appear, which contribute ... | stackexchange_codegolf |
Your job is to output the html of the current version (at the time of this writing) of the Wikipedia page for Kolmogorov complexity: https://en.wikipedia.org/w/index.php?title=Kolmogorov_complexity&oldid=781950121&action=raw (backup)
This is code-golf, so the shortest code wins.
| stackexchange_codegolf |
Write a function (using as few bytes as possible) that takes a bi-dimensional array of any number of columns and rows in which:
0 represents empty block,
1 represents snake block.
The function must return the number of possible paths the snake traveled.
Example 1:
Input:
[
[1,1,1,1,1],
[0,0,0,0,1],
[0,0,0,0,1... | stackexchange_codegolf |
Powerball is an American lottery that has recently gained attention because the current jackpot (as of January 11, 2016) is the largest lotto prize in history, at about $1.5 billion (USD).
Powerball players choose 5 distinct numbers from 69 numbered white balls, and 1 one "Powerball" number from 26 numbered red balls. ... | stackexchange_codegolf |
The goal is to create a generator generator [...] generator generator comprehension.
The generator must be created via generator comprehension.
The following expression must be valid for any number of nestings: next(next(next(next(next(generator))))).
The winner is whoever achieves this with the fewest number of byte... | stackexchange_codegolf |
Challenge
Write a program or function that takes a number \$n\$ and returns the smallest \$k\$ such that concatenation \$n'k\$ is a square. This sequence is described by A071176 on the OEIS.
I/O Examples
input --> output
1 --> 6 (4^2)
10 --> 0 (10^2)
35 --> 344 (188^2)
164 --> 836 (406^2)
284 --> 2596 (168... | stackexchange_codegolf |
A palindrome is a word that is its own reverse. I will define the left palindromic root of a word as the shortest prefix of the word for which the shortest possible palindrome that begins with that prefix is the original word. So the left palindromic root of racecar is race and the left palindromic root of ABBA is ABB.... | stackexchange_codegolf |
Challenge
Given a Youtube playlist, output the number of videos in it.
I/O
The playlist will be given as an URL; for example, https://www.youtube.com/playlist?list=PL_3jnZNPYn7qUatgDYBS5NShkfXoehSRC (this is a playlist a friend sent me to try to get me to listen to K-Pop because she's obsessed with it and I don't like ... | stackexchange_codegolf |
Output the numbers 1-16 (or any other set of 16 distinct items). Then, repeatedly, output a random value chosen uniformly from the last 16 items outputted.
After the same item is printed 16 times in a row, halt.
If a number appears multiple times in the last 16 values, it should have proportionally more chance to be ch... | stackexchange_codegolf |
In the US, clothing size sometimes has rough designations like M, L, XXL, etc. The US designation of the "men's jacket" category depends on the height of the person. So, in this challenge, you should implement this conversion, which is defined by the following table, taken from this site:
US size Body height (cm)
XXXS... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.