instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Example
Input -> 5
Output -> 55555
Input -> 12
Output -> 121212121212121212121212
Criteria
Least number of bytes wins!
| stackexchange_codegolf |
This question wants you to golf batch programms. In Batch you can use
set x=averylongbatchcommand
%x% arg1
which expands to
set x=averylongbatchcommand
averylongbatchcommand arg1
Your task is it to expand these statements.
As you can also use set for arithmetic purposes like this:
set x = 0
set /a x= %x%+1
you sho... | stackexchange_codegolf |
Inspired by Digits in their lanes and 1, 2, Fizz, 4, Buzz
Introduction
Your task is to generate exactly the following output:
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
... | stackexchange_codegolf |
disclaimer: the Mean mean is made up by me
Define the arithmetic mean of \$n\$ numbers as
$$M_1(x_1,...,x_n)=\frac{x_1+x_2+...+x_n}{n}$$
Define the geometric mean of \$n\$ numbers as
$$M_0(x_1,...,x_n)=\root{n}\of{x_1x_2...x_n}$$
Define the harmonic mean of \$n\$ numbers as
$$M_{-1}(x_1,...,x_n)=\frac{n}{\frac{1}{x_2} ... | stackexchange_codegolf |
Stackylogic is a programming language I made up in a previous challenge: Run Stackylogic. Read that post for full details and examples, but here is how it works paraphrased:
Stackylogic takes 0's and 1's for input and outputs a single 0
or 1 upon completion.
A program consists of lines that only contain the characte... | stackexchange_codegolf |
Context
At Hogwarts School of Witchcraft and Wizardry, students are sorted into 4 houses, Gryffindor, Ravenclaw, Slytherin and Hufflepuff. This sorting is done by a magical hat, called the Sorting Hat.
Task
Your task is to code a sorting hat. In other words, you should create some deterministic rule that, given the nam... | stackexchange_codegolf |
Non-associative operators (for example the subtraction-operator) often are either left- or right associative, such that one has to write less parentheses. Consider for example the following:
$$
a-b-c
$$
Probably everybody read that as \$(a-b)-c\$, by default (usually) subtraction is left-associative.
Now let us conside... | stackexchange_codegolf |
Inspired by this challenge (or, more specifically, by misreading it), I've come up with the following challenge:
Given an input string S, reverse the order of all uppercase characters, and all lowercase characters. Leave all non-letter characters in place. For instance:
Note that the uppercase W (the first uppercase l... | stackexchange_codegolf |
Introduction:
I have loads of different ciphers stored in a document I once compiled as a kid, I picked a few of the ones I thought were best suitable for challenges (not too trivial, and not too hard) and transformed them into challenges. Most of them are still in the sandbox, and I'm not sure yet whether I'll post al... | stackexchange_codegolf |
On CodingGame, there is a Puzzle that ask to write words with ascii art.
I solve the puzzle then tried to golf it. What improvement can I do on it?
INPUT
>>> 20
>>> 11
>>> MANHATTAN
>>> .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------... | stackexchange_codegolf |
A Munchausen Number in base \$b\$, also known as a Perfect digit-to-digit invariant or PDDI is a peculiar type of positive integer where the sum of its base-\$b\$ digits raised to themselves is equal to the number itself. They are named for the fictional Baron Munchausen, who apparently hoisted himself up via his own p... | stackexchange_codegolf |
Huge omega thanks to @wasif for emailing me this challenge idea in its basic form
Everyone knows that questions on StackExchange require tags - labels that allow posts to be grouped together by category. However, most of the time, I barely know which tags exist, because there's just so many of them.
Henceforth, today's... | stackexchange_codegolf |
Background
The fixed-point combinator \$\textsf{fix}\$ is a higher-order function that computes the fixed point of the given function.
$$\textsf{fix}\ f = f\ (\textsf{fix}\ f)$$
In terms of programming, it is used to implement recursion in lambda calculus, where the function body does not normally have access to its ow... | stackexchange_codegolf |
The flag of Bangladesh is very simple. It looks like below:
The flag will be in bottle green (#006a4e) and rectangular in size in the proportion of length to width of 10:6, with a red circle in near middle. The red circle (#f42a41) will have a radius of one-fifth of the length of the flag. This image will help you to ... | stackexchange_codegolf |
Challenge
Train a single perceptron with 2 inputs and 1 output.
Step 1: Initialize the weights
Step 2: Calculate the output
For inputs: [i1, i2, ..., in] and weights: [w1, w2, ..., wn] the output is:
i1 * w1 + i2 * w2 + ... + in * wn
Step 3: Apply activation function on the output (i.e sigmoid)
Step 4: Update the we... | stackexchange_codegolf |
This is the robbers' thread. For the main rules to this challenge see the cops' thread
In this challenge, robbers will choose a cop's vulnerable or safe post and try to figure out a pair of languages such that they print the correct results for the 4 programs.
When you find a solution post an answer of it here and lea... | stackexchange_codegolf |
Produce Graham's Number in Magic the Gathering using the fewest number of cards and without using any infinite combos.
Rules:
Producing Graham's number means do anything that requires Graham's number to represent the game state. For example, you could produce Graham's number 2/2 zombie tokens, have Graham's number li... | stackexchange_codegolf |
Related.
Given a positive integer \$n\$, output all integers \$b\$ (such that \$1<b<n-1\$) where \$n\$ can be written as the sum of any number of consecutive powers of \$b\$.
Example:
Let's say \$n=39\$.
\$3^1+3^2+3^3\$
\$= 3 + 9 + 27\$
\$= 39\$
This does not work for any other \$b\$, so our output is [3].
Test cases... | stackexchange_codegolf |
Objective
Design a modulator/demodulator pair to accurately transmit data as quickly as possible over simulated plain old telephone service (POTS).
Steps
Generate some random (/dev/random or the like) data that will take 3-4 seconds to transmit
Modulate the data with your modulator to produce an audio file
Pass the au... | stackexchange_codegolf |
The Biham-Middleton-Levine traffic model is a self-organizing cellular automaton that models simplified traffic.
It consists of a number of cars represented by points on a lattice with a random starting position, where each car may be one of two types: those that only move downwards (shown as blue in this article), a... | stackexchange_codegolf |
In this challenge, you will write a bot that play's the prisoner's dilemma. Here's the catch: you will not have access to the history of previous games. Instead, you will have access to the opponent itself. In this version, both players get +2 points if they both cooperate, +1 points if they both defect, and if one coo... | stackexchange_codegolf |
Validate a codice fiscale
Every Italian resident/citizen is given a 16-character alphanumeric codice fiscale
Challenge
The final letter is a check code, which is calculated as follows :
Characters of the code are split up into even and odd character according to their positions (check letter excluded)
Both sets are re... | stackexchange_codegolf |
Given a black and white image with a white background and a set of black dots, paint a set of white pixels red, such that there is a path between each pair of black pixels.
Details
A path is a set of connected pixels (8-neighbourhood connectivity). Black pixels can be used as part of the paths. The goal is trying to ... | stackexchange_codegolf |
You want to see how quickly the ratio of two consecutive Fibonacci numbers converges on φ.
Phi, known by the nickname "the golden ratio" and written as \$φ\$, is an irrational number, almost as popular as π and e. The exact value of \$φ\$ is \$\frac {1 + \sqrt 5} 2 = 1.618...\$
The Fibonacci sequence is a recursive ser... | stackexchange_codegolf |
Given an input string S, print S followed by a non-empty separator in the following way:
Step 1: S has a 1/2 chance of being printed, and a 1/2 chance for the program to terminate.
Step 2: S has a 2/3 chance of being printed, and a 1/3 chance for the program to terminate.
Step 3: S has a 3/4 chance of being printed,... | stackexchange_codegolf |
I'm at position (0, 0) of an infinite two-dimensional city, which is perfectly divided into blocks centered at each lattice point, some of which contain buildings. A building at a certain point (x, y) takes up the entire square with opposite corners at (x-.5, y-.5) and (x+.5, y+.5), including its border. A building is... | 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 |
Goal: This goal to take a string and output how many contributions should be made on which days in order to display a message.
Specification
Input
Support letters plus space (i.e. [A-Za-z ] )
Space is a blank 3X7
The letters are defined in this 5x7 DOT Matrix font provided below
The size of each letter is the minim... | stackexchange_codegolf |
Jellyfish is a two-dimensional esoteric programming language inspired by J and written in Python 3. It was inspired by a challenge on PPCG. The name was suggested in PPCG chat as a combination of Jelly, a golfing language inspired by J, and Fish, a two-dimensional esoteric language.
What general tips do you have for ... | stackexchange_codegolf |
This challenge is related to a project I did last year (in Ruby). To make it more fun I decided to do it in as few bytes as possible. I didn't know about code golf back then so now that I found out about it and found this community I was wondering if anybody can beat me :)
The program should return the current time if ... | stackexchange_codegolf |
A traveler needs to stay for n days in a hotel outside town. He is out of cash and his credit card is expired. But he has a gold chain with n links.
The rule in this hotel is that residents should pay their rent every morning. The traveler comes to an agreement with the manager to pay one link of the golden chain for e... | stackexchange_codegolf |
When making a Minecraft data/resource pack, you need to include a pack.mcmeta file, which specifies information about it. pack.mcmeta contains a description, but it also contains a pack_format number, which tells Minecraft which versions this pack is for.
Your task is to take a version string, and output what pack_form... | stackexchange_codegolf |
Your task is to take two single-variable integer polynomial expressions and multiply them into their unsimplified first-term-major left-to-right expansion (A.K.A. FOIL in the case of binomials). Do not combine like terms or reorder the result. To be more explicit about the expansion, multiply the first term in the firs... | stackexchange_codegolf |
Introduction to Mahjong tiles
Mahjong (麻雀) is a board game that originates from China. Mahjong tiles used in this challenge are in Unicode points U+1F000 – U+1F021:
They are categorized as:
Winds (風牌): (East Wind), (South Wind), (West Wind), (North Wind)
Dragons (三元牌): (Red Dragon), (Green Dragon), (White Dragon)
Te... | stackexchange_codegolf |
There is a Sioux village. It has a totem:
__
___| |___
\/ \ / \/
/\ ``| |`` /\
/^^\ | | /^^\
/ /\ \ | | / /\ \
''''''''''''''''''''''''''''
The totem lets the Sioux mastering the weather for helping in their different tasks. Help the villagers p... | stackexchange_codegolf |
Given a base type T, this can be augmented with * or [], each meaning pointer and array. For example, []*T means "array of pointer to T" and *[]T means "pointer to array of T".
Let's call * and [] type modifiers. C has a way of ordering these modifiers tied to the evaluation order. []*T in C-style becomes T *[], and *[... | stackexchange_codegolf |
Task
Given a non-empty string of lowercase ASCII letters a-z, take its first character, and:
Surround it with a square of copies of the second character,
Surround that with a diamond of copies of the third character,
Surround that with a square of copies of the fourth character…
…alternating between square and diamon... | 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 |
The Challenge
Given an integer n>0 output a n+1 X n+1 matrix containing all integers from 1 to 2n as shown in the test cases bellow
Test Cases
n=1
1 2
2 2
n=2
1 2 4
2 3 4
4 4 4
n=5
1 2 3 4 5 10
2 3 4 5 6 10
3 4 5 6 7 10
4 5 6 7 8 10
5 6 7... | stackexchange_codegolf |
Isn't it annoying when you find a piece of code and you don't know what language it was written in? This challenge attempts to somewhat solve this.
Challenge
You will have to write a program that when run in two different languages, will output the string:
This program wasn't written in <language program compiled/inte... | stackexchange_codegolf |
The TAK function is defined as follows for integers \$x\$, \$y\$, \$z\$:
$$
t(x, y, z) = \begin{cases}
y, & \text{if $x \le y$} \\
t(t(x-1,y,z), t(y-1,z,x), t(z-1,x,y)), & \text{otherwise}
\end{cases}
$$
Since it can be proved that it always terminates and evaluates to the simple function below,
$$
t(x, y, z) = \begin{... | stackexchange_codegolf |
Definition
The Alternating Power Fibonacci Sequence is formed as follows.
Start with the empty sequence and set n to 1.
Compute fn, the nth non-negative Fibonacci number, with repetitions.
0 is the first, 1 is the second and the third, 2 is the fourth. All others are obtained by summing the two previous numbers in the... | stackexchange_codegolf |
Given a dictionary of 4-letter words that have no repeated characters (from this list of words), you must choose ONE of those words, and output that specific word using the following dictionary of block letters:
.----------------. .----------------. .----------------. .----------------.
| .--------------. || .----... | stackexchange_codegolf |
Your challenge is to compute the Lambert W function. \$W(x)\$ is defined to be the real value(s) \$y\$ such that
$$y = W(x) \text{ if } x = ye^y$$
where \$e = 2.718281828...\$ is Euler's number.
Sometimes, \$y\$ may not be real.
Examples
W(-1) = non-real
W(-0.1) = -0.11183, -3.57715
W(1) = 0.56714
W(2) = 0.85261
Here'... | stackexchange_codegolf |
There are 8 Australian states and territories, each with a 2 or 3 letter abbreviation:
ACT: Australian Capital Territory
NSW: New South Wales
NT: Northern Territory
QLD: Queensland
SA: South Australia
TAS: Tasmania
VIC: Victoria
WA: Western Australia
Your task is to write a function/program which takes a valid Austr... | stackexchange_codegolf |
Derived from this, now deleted, post.
Given a string, answer (truthy/falsy or two consistent values) if it constitutes a good Bishop password, which is when all the following conditions are met:
it has at least 10 characters
it has at least 3 digits ([0-9])
it is not a palindrome (identical to itself when reversed)
Y... | stackexchange_codegolf |
You place a standard die at the origin of a 2D grid that stretches infinitely in every direction. You place the die such that the 1 is facing upwards, the 2 is facing in the negative y direction, and the 3 is facing in the positive x direction, as shown in the figure below:
You then proceed to execute a series of move... | stackexchange_codegolf |
A bronze plaque in the pedestal of the Statue of Liberty displays the poem "The New Colossus" by Emma Lazarus, part of which reads:
Give me your tired, your poor,
Your huddled masses yearning to breathe free,
The wretched refuse of your teeming shore.
Send these, the homeless, tempest-tost to me,
I lift my lam... | stackexchange_codegolf |
Introduction
When you are given a boring text, you just want to get it over with as quick as possible. Let's observe the following text:
Ens colligi timenda etc priorem judicem. De quascunque ii at contingere
repugnaret explicetur intellectu. Adjuvetis hoc fortassis suspicari opportune
obversari vix eam? Dei praemia ... | stackexchange_codegolf |
A huge storm is ravaging the world and as you and your family run away from it, you come across a gigantic shelter run by a girl. She tells you that "she sells sanctuary" and that different types of rooms are offered at different prices.
A room may only house one person.
The challenge
Write a program which takes in two... | stackexchange_codegolf |
Your function must accept three numbers in any order:
A signed real number (or ±Infinity) - The number (N) for which you have to generate a number from the range
A signed integer - Minimum of the range
A signed integer - Maximum of the range
Input:
The minimum of the range will always be less than the maximum of the... | stackexchange_codegolf |
NOTE
This problem was taken from this reddit thread (spoiler alert!), and I have adjusted it to make it fit with this site's format. All credit goes to reddit user "Coder_d00d".
In this problem, we will simulate a forest.
For this simulated forest we will be dealing with 3 aspects.
Trees which can be a Sapling, Tree o... | stackexchange_codegolf |
Idea
From a given word dictionary (containing only plain letters, i.e: no accent or other special chars), with a given fixed word length, find every same when a given number letters are missing.
For sample: un--ed could match: united, untied or unused
Using my dictionnary: /usr/share/dict/american-english, searching f... | stackexchange_codegolf |
RLE Brainfuck
(related to BF-RLE)
The hypothetical RLE (Run-Length Encoding) dialect of Brainfuck accepts the symbols for the 8 commands and also accepts digits. The digits are used to represent the number of successive repetitions of a command, thus allowing run-length encoding of the source code.
8> is equal to >>>>>... | stackexchange_codegolf |
If you haven't played the game Baba is You, I think you really should. Whether you’ve played it or not, have a go at implementing it as a code golf.
The idea behind this challenge is to have a bit more complicated, non-standard task with a bit longer answers.
Game rules
Alas, the challenge is not to implement the entir... | stackexchange_codegolf |
This challenge is pretty simple. As input, you take in a regular expression.
Then, you output a truthy/falsey of whether or not your source code matches the regular expression. It's that simple! Just two more things:
No quine builtins; you may, however, access the code's source code by file IO, etc.
This is code-golf,... | stackexchange_codegolf |
You probably know the game mastermind:
The player tries to guess a code of 4 slots, with 8 possible colors - no duplicates this time.
Let's call those colors A through H, so possible solutions could be ABCD or BCHD.
Each time you place a guess, the game master will respond with two information: how many slots you got r... | stackexchange_codegolf |
You'll be given the name of one of the 20 biggest objects in the Solar System. Your task is to return an approximation of its radius, expressed in kilometers.
This is a code-challenge where your score consists of the length of your code (in bytes) multiplied by a penalty ratio \$\ge 1\$, based on your worst approximati... | stackexchange_codegolf |
In the absurdist play Rosencrantz and Guildenstern are Dead, the two main characters Rosencrantz and Guildenstern(or are they?) are always mixing up which of them is who—or sometimes which of their own body parts is which—because of a perceived lack of individual identity. Wouldn't it be absurd if they even shuffled ar... | stackexchange_codegolf |
The challenge is simplistic, given an input time as a string in any one of the following formats:
hh, hh:mm or hh:mm:ss with 0 ≤ hh ≤ 23, 0 ≤ mm ≤ 59 and 0 ≤ ss ≤ 59.
Output what time it currently is using the following symbols:
AA LABEL FOR CHARACTER CODE POINT HEXADECIMAL
== ==================== ==========... | stackexchange_codegolf |
Let's say you've got a table of data:
meter_id date 0000 0600 1200 1800
0 030915 10 20 30 40
1 030915 15 7 49 2
where the last four columns are meter readings at different times. You want to output
meter_id date time reading
0 030915 0000 10
0 030915 0600 20
etc.
Your inpu... | 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 |
Consider a NxN pixel grid with up to M objects drawn on it, either squares or diamonds:
square
diamond
The objects may overlap, so recognition is hard. The task is to give the minimal possible numbers of objects per shape that can be "seen" in the picture and tell how many squares, how many diamonds, and how many ob... | stackexchange_codegolf |
If an integer has a digit/sequence of digits in it which repeats continuously (You will understand why I said "continuously") 5 or more times, we call It "Boring".
For example, 11111 is Boring, whereas 12345 is not.
Instructions
Take an Integer as Input
Output a truthy value if the integer is boring, and a falsey value... | stackexchange_codegolf |
The challenge is to write a program which will find the shortest (least number of characters) command which will navigate to a target directory, given a starting directory, assuming a standard linux file system.
Take the following file system as an example, starting from ~:
.
├── target
└── test
└── starting
If th... | stackexchange_codegolf |
As a couple of people may have noticed lately, I've largely abandoned development of Braingolf because it's boring and uninspired, and moved on to 2Col which is a little more interesting, and not designed to be a golfing language.
The defining feature of 2Col is that every line of code must be exactly 2 characters long... | 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 |
Someone I know has no coding experience, but has proposed an algorithm* to determine the character limit of text fields they find online. They copy a string containing the numbers from 1 to 1,000 inclusive, not separated in any way, and they read the last few digits it displays.
For example, after pasting, they might s... | stackexchange_codegolf |
A "simple circular" word is a word whose chords do not intersect. The chords of a word may be seen by laying out the alphabet in a circle, and then connecting the word's consecutive letters.
Examples of Simple Circular Words
ROLE
LAKE
BALMY
Failing Example
A word fails to be simple circular if any of its chords in... | stackexchange_codegolf |
(Inspired quite heavily by this challenge)
In the original challenge you were to make a horizontal zipper, however, looking down at my hoodie, my zipper is much more vertical (and a little bit broken) :P
Input
You will be given a single string (s), and a pair of integers (a and b) in any format. Where:
a < (length-of-... | stackexchange_codegolf |
Background
This challenge is about Convolutional neural networks, and its two main building blocks, namely Convolutional layer and Pooling layer.
For simplicity, we ignore the "depth" of the images and intermediate tensors, and just look at the width and height.
Convolutional layer
A convolutional layer works like a ke... | stackexchange_codegolf |
Inspired by the Codewars Kata.
Your goal is to take an input string such as this one:
"'Twas a dark and stormy night..."
and return a string containing the position of each character in the alphabet, separated by spaces and ignoring non-alphabetical characters, like this:
"20 23 1 19 1 4 1 18 11 1 14 4 19 20 15 18 13 ... | stackexchange_codegolf |
Intro
Blur's song Girls & Boys featured the lines
girls who are boys who like boys to be girls
who do boys like they're girls, who do girls like they're boys
in the chorus. These lines have a pretty uniform structure: you have a subject, which is either girls or boys, a relative clause, either who are, who like, or wh... | stackexchange_codegolf |
Given a ruler length in inches and fractions of an inch, and a granularity in fractions of an inch, output the values of all marks on the ruler, starting from 0, in ascending order.
Input ruler length will be a mixed fraction (integer and proper fraction)
Input granularity will be a proper fraction in the form 1/(2ⁿ), ... | stackexchange_codegolf |
The 16-color CGA palette (also known as the HTML colors) is a set of 16 colors used by early graphics adapters. The goal of this challenge is to output all 16 of them, in hex format (RRGGBB), in ascending order by hex value, separated by newlines. Thus, the output should be exactly this:
000000
000080
0000FF
008000
008... | stackexchange_codegolf |
Two strings are "Caesar equivalent" if the distance (counting up) between the corresponding characters are the same. Yes, I made this term up. Here's an example:
"Abc" and "Cde" are equivalent because
distance from a-c == 2
distance from b-d == 2
distance from c-e == 2
The capitalization doesn't make any difference.
"... | stackexchange_codegolf |
I'm looking out of my attic window into my neighbor's yard. They have a dog chained to a post in the center of the yard. The dog runs around the yard but is always on the end of its chain, so it ends up leaving a track in the dirt. Normally this track would be perfectly circular, but my neighbors have some other pole... | stackexchange_codegolf |
Blokus is a board game in which players take turns placing pieces on a \$ n \times n \$ square grid. In this version of the game, there will be just one person playing. The person is given \$ 21 \$ unique polyominoes, ranging from \$ 1 \$ to \$ 5 \$ tiles each. They then proceed to place down a subset of the pieces ont... | stackexchange_codegolf |
In this task you will take as input a non-negative integer \$n\$, and output the number of pairs of non-negative integers \$a,b\$ such that both are palindromes*, \$a \leq b\$, and \$a+b = n\$. For example if \$n\$ is \$22\$ then the valid pairs are
\$
\begin{array}{c|c}
a & b \\
\hline
0 & 22 \\
11 & 11 \\
\end{arra... | stackexchange_codegolf |
I have a specific number in mind, but it's part of a challenge I'm doing, and I don't want people to do (all) the work for me.
Here is a number which has the same digits, but shuffled:
5713167915926167134578399473447223554460066674314639815391281352328315313091488448321843
8892917486601064146636679920143691047671721184... | stackexchange_codegolf |
Intro
You like cats. Naturally, you like cat’s games in tic-tac-toe. So, you’ve come up with a little party trick.
You ask someone what square on the board they want you to make a move in. And you ask someone else on which turn they want you to make that move. You also let that person decide whether you play Xs or Os. ... | 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 |
There are some ways which cause an endless high CPU usage such as catching recursion exception. e.g. the following script in Python causes that problem:
def main():
try:
main()
except:
main()
main()
This is an obvious and simple example, but there might be some strange ways to arise such probl... | stackexchange_codegolf |
Description
Imaginary programming language (IPL) uses Polish Reverse Notation. It has the following commands:
i -- input number and push it to the stack
o -- non-destructive output top of the stack (number stays on the stack)
d -- discard top of stack
integer number -- push this number to the stack
+-* -- pop two num... | stackexchange_codegolf |
Starting with 1, output the sequence of integers which cannot be represented as the sum of powers of earlier terms. Each previous term can be used at most once, and the exponents must be non-negative integers.
This sequence starts:
1, 2, 6, 12, 25, 85, 194, 590, 1695, 4879, 19077, 83994, 167988
For example, after 1 an... | stackexchange_codegolf |
Task
Haskell's and Scala's standard libraries have an unfold function that builds a list from an initial state s and a function f. This is done with the following steps (explained in an imperative way to be simpler):
Apply f to s.
If the result
is empty, we're done building the list!
Otherwise, the result should cont... | stackexchange_codegolf |
your task is to write a program that uses the Lucas-Lehmer primality test to check whether an input number is prime or not. This prime number candidate has the form 2p-1 with p being prime. (Mersenne prime number)
The Lucas-Lehmer-test
The n-th Mersenne number is prime if it is a divisor of the (n-1)-th Lucas-Lehmer nu... | stackexchange_codegolf |
Pip is an imperative golfing language with infix operators. It also borrows some features from functional and array programming.
What general tips do you have for golfing in Pip? I'm looking for approaches and tricks that are commonly useful for code golf and are specific to Pip (e.g. "remove comments" is not an answer... | stackexchange_codegolf |
Program: To count the sum of all Unicode characters of a given input.
(No need to display the output. The final answer can be calculated in any base no need to convert back to hexadecimal.)
Test case : XyZ= 0058+0079+005A=012B
Condition: If the program is inputted, then its output must be an integral multiple of 1729 (... | stackexchange_codegolf |
Related
Your goal, is to write a set of programs, that progresses from one to the other, one character at a time. For example. Given the starting program abcd and the ending program wxyz, you should have 5 valid programs, with the respective outputs.
abcd -> wbcd
wbcd -> wxcd
wxcd -> wxyd
wxyd -> wxyz
wxyz -> wxyz
As ... | stackexchange_codegolf |
This challenge is from a game, Keep Talking And Nobody Explodes.
It's hard to say how this mechanism works. The engineering is pretty impressive, but there must have been an easier way to manage nine wires. — from the manual
Input
Exactly 9 "wires", each which is labeled 'A', 'B', or 'C', and is colored red, blue, or b... | 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 |
Every digital clock contains a small creature that has to advance the time every minute [citation needed]. Due to the popularty of digital clocks and the popularity of catching them in the wild, they are nearly extinct in nature which is why in this challenge we try to automate this task:
Given your string of a given t... | stackexchange_codegolf |
Reading the text of the millitext font
There is a font here that fits each character into a single, 1x5 pixel block. It does this (assuming you're using an LCD screen) by using the RGB channels of each pixel to expand the one pixel into three subcolumns, one for each channel. Your task is to take in a string of text en... | stackexchange_codegolf |
You will be given a positive integer N as input. Your task is to build a Semi-Zigzag, of N sides, each of length N. Since it is relatively hard to clearly describe the task, here are some examples:
N = 1:
O
N = 2:
O
O O
N = 3:
O O
O O
O O O
N = 4:
O O O O O
O O
O O
O ... | stackexchange_codegolf |
Given two inputs, a distance \$d\$ and a number \$n\$ output a list of \$n\$ random colors which each have distance \$d\$ from the previous.
Background
A random walk is a path which is defined by choosing a random direction and (usually) fixed distance to go at each step. We will be taking a random walk through the RGB... | stackexchange_codegolf |
Given a word, decide if it is an ambigram.
When rotated:
b > q
d > p
l > l
n > u
o > o
p > d
q > b
s > s
u > n
x > x
z > z
Assume only lowercase letters as input.
Test input:
this,
another,
lll,
lol,
dad,
dab,
dap,
wow,
ooi,
lollpopdodllol,
Ones That Should Return Truthy Values:
lll,
lol,
lollpopdodllol,
Note tha... | stackexchange_codegolf |
Challenge
Given two strings in any default I/O format, do the following:
NOTE: The challenge will refer to the first string as the "data" and the second referred to as the "program".
Change the program to an infinite string which is just the program repeated infinitely (e.g. 10 --> 1010101010...). The challenge will r... | stackexchange_codegolf |
Story (skip, if you prefer the naked task): You need five skills for an imaginary sport: Speed, strength, endurance, accuracy and tactics. If you achieve a score in each of these disciplines, you can work out how well you have mastered the sport as a whole. But, as your coach always says: concentrate on your strengths,... | stackexchange_codegolf |
The pyramid begins with the row 1 1. We'll call this row 1. For each subsequent row, start with the previous row and insert the current row number between every adjacent pair of numbers that sums to the current row number.
$$
1\quad1\\
1\quad\color{red}{2}\quad1\\
1\quad\color{red}{3}\quad2\quad\color{red}{3}\quad1\\
1... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.