instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Mike Bufardeci (Pyth) - 175 bytes
Leo (Retina) - 175 bytes
devRicher (Lua) - 182 bytes
Peter Taylor (CJam) - Waiting for clarification
Lyth (C++11) - Waiting for clarification
Edit: Several changes made, should not affect any already submitted answers.
Edit #2: Very few people are taking advantage of the 1024 b... | stackexchange_codegolf |
Introduction
If you're not familiar with Hexagony, it's an esoteric language created by Martin Büttner. The thing is that this language accepts multiple forms for the program. The following programs are all equivalent:
abcdefg
and
a b
c d e
f g
So basically, the code has been rolled up into a regular hexagon. But n... | stackexchange_codegolf |
Background
You're an attractive code golfer and quite a few people are asking you out.
You don't have time to think about which days exactly you're available, so you decide to create a function the accepts a date and returns the days of that week.
You then take those days of the week, insert it into your calendar progr... | stackexchange_codegolf |
Input
An integer k composed of 1 and 2, with at least 3 digits and at most 200 digits.
Output
Another integer k' obtained by removing at most one (could be none) digit from k, such that k' is composite, and then another integer p for a non-trivial (that is, not 1 or k') factor of k'.
Test Cases
121212 -> 121212 10101
1... | stackexchange_codegolf |
Your input is a ragged list of possibly empty lists of non-negative integers. For example, [[2,0],[[]],[[[],[1],[]],[]]] is a valid input. This input is a "compressed" ragged list. What this means is that when we have a list of numbers, we interpret those as a list of indices, indexing the output.
For example, if I=[[2... | stackexchange_codegolf |
Given two strings containing only 0 and 1, decide the probability that first appears earlier as a consecutive substring in an infinite random 0/1 stream.
You can assume that neither string is suffix of the other string, so 01, 1, 00, 0 are invalid. (*)
IO format flexible. Your answer should be precise given ideal float... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
An Elf is hopping on a chessboard which extends infinitely in all four directions. They move like a generalized chess Knight: on each step, they move X units horizontally and Y units vertically, or Y units horizontally and X units vert... | stackexchange_codegolf |
Convert a number to a sum of digits
Not any sum: we need the shortest sum
Not any digits: you can use only digits of the number
Example
You will be given as input an integer n>0
Let's say n=27. You have to express 27 as a sum, using only the digits [2,7], in the shortest way possible. You don't have to use all the digi... | stackexchange_codegolf |
Introduction and credit
Assume you're a bartender. You have many happy people in your bar at most times, but many only ever drink the very same drink and too few for your taste and you want to change that. So you introduce a system where the price of a drink is variable, depending on how many have already been sold, bu... | stackexchange_codegolf |
The challenge is simple: Print the last, middle, and first character of your program's source code, in that order.
The middle character is defined as follows, assuming a source length of n characters, and 1-indexing:
If n is even, print the n/2-th and n/2 + 1-th character. (abcdef == cd)
If n is odd, print (n-1)/2 + 1... | stackexchange_codegolf |
Have you been shooting gallery? We are recently.
In our shooting gallery cans and aluminum cans from under various drinks hang and stand. More precisely, they hung and stood.
From our shots, banks dangled from side to side on a rope, were torn off, rang, crumpled. This is not for you to shoot from your fingers.
Each ... | stackexchange_codegolf |
Find X
I was inspired by math questions in which one is asked to "Find X" for a given shape. Originally, I was just going to have the challenge be to print the x and y location of the character 'x' in a String. But I supposed that would be too simple. So I considered the context they were normally in, and decided findi... | stackexchange_codegolf |
Reversible computation refers to computation in which little or no information is deleted. Reversible computation a major component of quantum computation, and reversible computation is potentially many times more energy efficient than conventional computation. I want to know how easy it is to compute the conjugacy of ... | stackexchange_codegolf |
Introduction / Background
In a recent discussion in the crypto chat I was challenged to discuss / help with the Fermat primality test and Carmichael numbers. This test is based on the premise that a^(p-1) mod p==1 will always hold for primes p, but not always for composites. Now a carmichael number is essentially the F... | stackexchange_codegolf |
Challenge
Premise
It's 2006, and Alice is trying to send Bob their her completed notes on their newly ended expeditions into the labyrinthine school library, which the two of them found suffers from a bad case of non-Euclidean geometry.1
For some reason, Alice originally created her notes, which consist of black text o... | stackexchange_codegolf |
A magic word is a word whose Braille spelling contains precisely 26 dots (because the Morse code alphabet can be circularly encoded within). For example:
⠎ ⠝ ⠥ ⠛ ⠛ ⠇ ⠽ snuggly
⠏ ⠕ ⠇ ⠽ ⠛ ⠕ ⠝ polygon
⠝ ⠥ ⠛ ⠛ ⠑ ⠞ ⠽ nuggety
⠽ ⠕ ⠛ ⠓ ⠥ ⠗ ⠞ yoghurt
are all magic words.
Objective:
Craft a program to identify 77 such mag... | stackexchange_codegolf |
A recent SO question asks for a convenient one-liner to generate a list of numbers and their negative counterparts in Python.
Given two integers \$1≤a≤b\$, generate all the integers \$x\$ such that \$a≤|x|≤b\$. The result may be printed or returned in any order or structure, as putting the result into a list and sortin... | stackexchange_codegolf |
The problem:
Given a non-empty set of points in the Cartesian plane, find the smallest circle that encloses them all (Wikipedia link).
This problem is trivial if the number of points is three or less (if there's one point, the circle has a radius of zero; if there are two points, the line segment that joins the points ... | stackexchange_codegolf |
Redivosite is a portmanteau word invented for the sole purpose of this challenge. It's a mix of Reduction, Division and Composite.
Definition
Given an integer N > 6:
If N is prime, N is not a Redivosite Number.
If N is composite:
repeatedly compute N' = N / d + d + 1 until N' is prime, where d is the smallest diviso... | stackexchange_codegolf |
Task
Your task is to take a character in:
AÁÀÃÂBCÇDEÉÊFGHIÍJKLMNOÕÓÔPQRSTUÚVWXYZaáàãâbcçdeéêfghiíjklmnoõóôpqrstuúvwxyz
and turn it into a characters in:
AAAAABCCDEEEFGHIIJKLMNOOOOPQRSTUUVWXYZaaaaabccdeeefghiijklmnoooopqrstuuvwxyz
by the obvious operation: dropping the accents in the letters.
Input
A character in any se... | stackexchange_codegolf |
We will say a string \$x\$ is cyclic maximal if there is no way to cycle its elements to get a lexicographically larger string. In other words there is no \$a\$ and \$b\$ such that \$a \oplus b = x\$ and \$b \oplus a > x\$, where \$\oplus\$ is concatenation.
For example [3,2,3,3] is not cyclic maximal because you can c... | stackexchange_codegolf |
King of the Torus!
Your job is to conquer the torus, but wait, there are multiple other players banded together in teams facing you! You will need to use your wit's to conquer the torus.
There are three teams: red, blue and green. Teams are self-assigned arbitrarily. If the teams are even you may join the team of your ... | stackexchange_codegolf |
The goal of this challenge is to extend the On-Line Encyclopedia of Integer Sequences (OEIS) sequence A038375.
Maximal number of spanning paths in tournament on n nodes.
A tournament on \$n\$ vertices is a directed graph where for each pair of vertices \$(v_i, v_j)\$ there is either a directed edge \$v_i \rightarrow ... | stackexchange_codegolf |
Monday Mini-Golf: A series of short code-golf challenges, posted (hopefully!) every Monday.
True story1: The other day, I was playing around on my tablet when I had the idea to visit the page I normally use on my PC for testing JavaScript. After the page loaded, I entered this simple program:
alert("Hello!")
I then pr... | stackexchange_codegolf |
Just had a 'spirited' conversation with a co-worker about the succinctness of the following BASIC statement:
10 PRINT CHR$(205.5+RND(1)); : GOTO 10
It's the title of this book, and will simply print a sequence of / and \ characters, alternating between the two randomly, resulting in a pattern similar to this:
(Image ... | stackexchange_codegolf |
Inspired (like 2 others) by this chat message. (and to some extent, my CMC)
Given a string as an input, your task is to check whether or not that string is a number.
What is a number?
This is a list of all input formats that are "numbers":
Integers: An integer is a string made entirely of characters from 1234567890, w... | stackexchange_codegolf |
Introduction
In number theory, a number is considered evil if there are an even number of 1's in its binary representation. In today's challenge, you will be identifying whether or not a given number is evil.
Challenge
Your job is to write a full program or function which accepts a single, non-negative integer as input... | stackexchange_codegolf |
Given the name of a cation and anion, output "S" (soluble) or "I" (insoluble). The table we will be using is from wikipedia: https://en.wikipedia.org/wiki/Solubility_chart. It is copied at the end of the question for future reference.
Input: The cation, followed by the anion, separated by a space. The cation will be on... | stackexchange_codegolf |
Introduction
I crochet a lot, and lately I've started writing crochet patterns. However, while I work very well from notes such as rnds 2-6 (round number = x, original number of stitches = y): *dc x-2 stitches, 2 dc in next stitch* around (xy stitches), most published patterns spell out each row in more detail. I don't... | stackexchange_codegolf |
Here is a 1.2Mb ASCII text file containing the text of Herman Melville's Moby-Dick; or, The Whale. Your task is to write a program or function (or class, etc. -- see below) which will be given this file one character at a time, and at each step must guess the next character.
This is code-challenge. Your score will be
2... | 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 |
This is a CC-BY-SA challenge from the CCSC Mid-South Programming Contest 2018.
Author(s): Brent Yorgey
Source: Consortium for Computing Sciences in Colleges Mid-South Programming contest 2018
https://ccsc18.kattis.com/problems/ccsc18.mountainrange
Good news: you have been hired to do all the special effects for a fil... | stackexchange_codegolf |
This is a follow-up question to my Puzzling.SE question: I asked if there’s a function f mapping Boolean strings to Boolean strings, so that f(f(b)) = reverse(b) for all input strings b. (By reverse, I mean the function that reverses the order of bits.)
The above link contains a positive answer, with proof, by the grea... | stackexchange_codegolf |
Your program is supposed to create a full red screen in MSDOS. The source of the binary (.com file) must be 5 bytes or less. No wild assumptions, the binary must work in MsDos, DosBox, and FreeDos alike. For winning, you have to post x86 assembler code which can be assembled with NASM (FASM) or directly the hex code of... | stackexchange_codegolf |
To increase data safety at our company, we are planning to start using Gray code numbers (where successive values differ by only one bit) instead of classical binary ones.
Please help us to make a program that converts numbers to Gray code (single number to single number), but the program needs to be safe as well. This... | stackexchange_codegolf |
First 15 numbers of the A046173:
1, 99, 9701, 950599, 93149001, 9127651499, 894416697901, 87643708742799, 8588189040096401, 841554882220704499, 82463790268588944501, 8080609891439495856599, 791817305570802005002201, 77590015336047156994359099, 7603029685627050583442189501
Your task is simple, output the first 20 numbe... | stackexchange_codegolf |
Write an infinite list of triangle codes, defined as code where the i-th line has i bytes for all lines, such that the i-th code generates (i-1)th code and has 1 more line than the (i-1)th code.
The score is the number of lines in the initial code. Lowest score wins.
For example, if
.
..
...
....
is outputted by
.
..
... | stackexchange_codegolf |
There are a few questions on this site about balancing brackets, and checking whether brackets are balanced. I propose it's now time to use those balanced brackets for something!
In mathematics and programming, brackets are like bubbles, isolating everything inside form everything outside so that whatever's inside can ... | stackexchange_codegolf |
Inspired by this stack of little statues that are currently on my desk at work, given to me by my colleagues from Sri Lanka when they visited The Netherlands:
This is split into two different challenges due to popular demand:
Part 1) Determine the amount of statues (this challenge)
Part 2) Can the statues be stacked?
... | stackexchange_codegolf |
Use any programming language to generate two random digits between 1 and 9 (including both). Then your program should display:
in the first line: the first random digit,
in the second line: the second random digit,
in the third line: a number whose tens and units digits are the first and second random digits res... | stackexchange_codegolf |
Given a string that contains only lowercase letters, encode that string with the alphabet cipher.
To encode with the alphabet cipher (I will be using the example hello):
First, convert each letter in the string to a number depending on its position in the alphabet (a = 1, b = 2, etc.) Example: 8 5 12 12 15
Pad each nu... | stackexchange_codegolf |
Given a number from 1 to 24, output the kissing number to the best of current knowledge (some numbers will have more than one acceptable output). Knowledge of geometry is not essential as the outputs are all listed below.
From the Wikipedia page on the Kissing Number Problem:
a kissing number is defined as the number ... | 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 |
How many atoms in the hydrocarbon?
A hydrocarbon is a chemical compound which consists of only hydrogen and carbon atoms. For this challenge, we will only consider the three simplest kinds of hydrocarbons: alkanes, alkenes, and alkynes with no branches.
An alkane with \$n\$ carbon atoms contains \$2n+2\$ hydrogen atoms... | stackexchange_codegolf |
Of course, the SE network is very knowledgeable about how to be respectful in the restroom, but for those of you who need a recap, being respectful means flushing the toilet, etc. Most importantly, though, it means using the stall as far away from others as possible.
The challenge
Given a blueprint of a set of stalls ... | stackexchange_codegolf |
A lexicographically increasing number is an integer whose digits are in strictly increasing order. Print all lexicographically increasing numbers under 10000.
Here are lines of the expected output:
0
1
2
3
4
5
6
7
8
9
12
13
14
15
16
17
18
19
23
24
25
26
27
28
29
34
35
36
37
38
39
45
46
47
48
49
56
57
58
59
67
68
69
78... | stackexchange_codegolf |
The challenge is relatively simple, but will hopefully lead to some wonderfully creative answers. The task is to take a string as an input (via command line, function parameter etc.) and output/return a stringsploded version of it.
A stringsploded version of a string is its first letter followed by its first 2 letters,... | stackexchange_codegolf |
When I was in grade 3, we were taught how to solve a very simple math problem. It was equaling the denominators of two or more fractions.
Let's take two proper fractions:-
$$
\frac{1}{2},\frac{2}{3}
$$
First we will take the Least Common Multiple of the denominators of the two fractions, the LCM of \$2,3\$ are \$6\$. T... | stackexchange_codegolf |
The task
Given an ascii string, output a program in my esolang MAWP that outputs the inputted string when run.
Useful functions in MAWP
Numbers from 0-9: Pushes the number to stack
M Takes the top two numbers off stack and pushes the sum to stack
A Takes the top two numbers off stack and... | stackexchange_codegolf |
Challenge
Build the Wheat Wizard's stove using 2-input NAND gates. The solution with the fewest NAND gates wins.
Externally, it works in the following way: (the first line is added from the original spec for physical output)
It has 10 levels, from 0 to 9. The display has 9 lights, and if the current level is L, exactl... | stackexchange_codegolf |
Notice the pattern in the below sequence:
0.1, 0.01, 0.001, 0.0001, 0.00001 and so on, until reaching 0.{one hundred zeros}1
Then, continued:
0.2, 0.02, 0.002, 0.0002, 0.00002 and so on, until reaching 0.{two hundred zeros}2
Continued:
0.3, 0.03, etc, until 0.{three hundred zeros}3
Continued:
0.4, 0.04, etc, until 0... | stackexchange_codegolf |
I feel tired to do "find the pattern" exercise such as
1 2 3 4 (5)
1 2 4 8 (16)
1 2 3 5 8 (13)
Please write a program that finds the pattern for me.
Here, we define the pattern as a recurrence relation that fits the given input, with the smallest score. If there are multiple answers with the same smallest score, using... | stackexchange_codegolf |
The computational parity of an integer is defined as 1 if the integer has an odd number of set bits, and 0 otherwise. (src).
Input
You will receive one nonnegative integer that you will take the parity of. Optionally, you may take the size of the integer in bytes or bits as an argument, but you must specify this in yo... | stackexchange_codegolf |
Given 2 brainfuck code snippets A and B, output some brainfuck code C which has the same behavior as running B with the input of As result. Note that C must work for any input that match the following assumptions, as if it were given to A.
You can assume:
Finite input.
both A and B halt.
EOF is consistently 0 or consi... | stackexchange_codegolf |
Russian roulette
It's Russian roulette! The rules are simple. Shoot a revolver with n slots for bullets and one round inside at your head and you might not die!
This Question is different from other Russian roulette questions because it takes input to change the chance of exiting with an error.
Task:
Make a program tha... | stackexchange_codegolf |
Input
4 integers w, x, y, z from the range -999 to 999 inclusive where none of the values is 0.
Output
4 integers a, b, c, d so that aw + bx + cy + dz == 0 where none of the values is 0.
Restrictions
Your output should be the solution with the smallest sum of absolute values possible. That is the smallest value of \$|... | stackexchange_codegolf |
Your task is to write a program that outputs the exact string Programming Puzzles (trailing newline optional), but when all spaces, tabs, and newlines are removed it outputs Code Golf (trailing newline optional.)
Your byte count is the count of the first program, with spaces still there.
Notes
The spaces in Code Golf... | stackexchange_codegolf |
Write 2 programs in the same language which count the number of shared subsequences of consecutive elements from 2 given sequences.
For example, given "test" and "enter", there are 5 shared subsequences of consecutive elements:
t
t
e
e
te
One possible algorithm consists in counting, for each subsequence of consecutive... | stackexchange_codegolf |
Game of Game of Life
Conway's Game of Life is a 0-player game. But that's okay! We can make it a multi-player game.
This game is played on the smallest square grid that will accommodate a 6x6 square for each player (12x12 for 2-4 players, 18x18 for 5-9 players, etc). This grid is actually a torus, so it wraps in bot... | stackexchange_codegolf |
Your challenge, should you choose to accept it, is, given an integer K >= 1, find non-negative integers A and B such that at least one of the two conditions following hold:
K = 2^A + 2^B
K = 2^A - 2^B
If there does not exist such A and B, your program may behave in any fashion. (To clarify, A and B can be equal.)
Te... | stackexchange_codegolf |
Contest Finished! Read comments on blobs to view their score.
This KoTH is loosely inspired by Primer's Natural Selection Simulation. Your bot is a blob. In order to survive, you must eat pellets to regain energy, which is used to move. With extra energy, blobs can split into two.
Energy and Movement
Your blob starts o... | stackexchange_codegolf |
Pyth is a Python-inspired procedural programming language, created by PPCG user isaacg.
What general tips do you have for golfing in Pyth? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Pyth.
One tip per answer, please.
| stackexchange_codegolf |
The goal of this challenge is to write a program that will simulate a single round of Conway's Game of Life on an existing grid.
Input format:
Input will be read from stdin. The input will consist of a line containing two numbers, r and c, separated by a single space. These will be the number of rows and columns of the... | stackexchange_codegolf |
Write a program that takes in two non-negative integers S and N in that order. S represents the side length of a square grid of . characters. N represents the number of those .'s that need to be changed to x's. You may assume N is no greater than S squared.
Your program needs to output this S×S square of .'s and N x's ... | stackexchange_codegolf |
Challenge
Determine how many integer lattice points there are in an ellipse
$$\frac{x^2}{a^2} + \frac{y^2}{b^2} \leq 1$$
centered at the origin with width \$2a\$ and height \$2b\$ where integers \$a, b > 0\$
.
Input
The Semi-major \$a\$ and Semi-minor \$b\$ axes.
Output
Number of interior and boundary points.
Example
E... | stackexchange_codegolf |
Description of the problem
Imagine a quarter of an infinite chessboard, as in a square grid, extending up and right, so that you can see the lower left corner. Place a 0 in there. Now for every other cell in position (x,y), you place the smallest non-negative integer that hasn't showed up in the column x or the row y.
... | stackexchange_codegolf |
Lighthouses on an island have blink codes that let ships know which lighthouse they are seeing. Input should be strings of S and L. Here is a (Python) example of codes for 4 lighthouses as a list of strings:
['SLS', 'SLL', 'SSS', 'LSL']
where:
S = short ON (1 sec)
L = long ON (3 sec)
Long and short ON's are both follo... | stackexchange_codegolf |
I though this would be a good challenge : http://adventofcode.com/2016/day/1
Task description
Given a sequence of rotations and distances following the pattern (L|R)[1-9][0-9]*, give the manhattan distance between the start and the ending points, that is the minimal number of vertical and horizontal moves on a grid.
Ex... | stackexchange_codegolf |
Given an email address, the result of a transformation applied to that email address, and a second email address, return the output of the same transformation applied to the second email address.
The email addresses will all have the following structure:
A string of positive length containing alphanumeric characters an... | stackexchange_codegolf |
Introduction
Programmers have already solved the trolley problem (a classical problem in philosophy). In the usual trolley problem, we have a directed graph and each edge is weighted by the number of people tied to the track (edge). The objective of the usual trolley problem is to find a path through the graph that min... | stackexchange_codegolf |
Write an interactive program or function which allows the user to play The Coinflip Game! The object of the game is to repeatedly flip a coin until you get the same result \$n\$ times in a row.
Specific behavior of the program/function is as follows:
At the start of the game, the user inputs a positive integer \$n>1\$... | stackexchange_codegolf |
Given a number \$n ≥ 2\$, a blackbox function \$f\$ that takes no arguments and returns a random integer in the range 0...n-1 inclusive, and a number \$m ≥ n\$, your challenge is to generate a random integer in the range 0...m-1 inclusive. You may not use any nondeterministic builtins or behaviour, your only source of ... | stackexchange_codegolf |
Task
Given an \$m\times n\$ binary ascii "photo", return the negative of the photo
Example:
#
# #
# #
# #
#
->
## ##
# # #
###
# # #
## ##
General rules:
This is code-golf, so the shortest answer in bytes wins
Standard rules and default I/O rules apply
Your output characters must be the same as your in... | stackexchange_codegolf |
If you sort a string you'll typically get something like:
':Iaaceeefggghiiiiklllllmnnooooprrssstttttuuyyyy
Yes, that was the first sentence sorted.
As you can see, there are a lot of repeated characters, aa, eee, ttttt, 9 spaces and so on.
If we add 128 to the ASCII-value of the first duplicate, 256 to the se... | stackexchange_codegolf |
There's something (well, many things ) that really annoys me. It is when dictionaries (English, not Pythonic) use the defining word itself to define the word, also called circular definitions. Example:
reticence: the quality of being reticent
-- Apple Dictionary
Circular definition: a definition that is circular
--... | stackexchange_codegolf |
Introduction
As an example, let's take the number 7. We then duplicate this and place 7 spaces in between. We get this:
7_______7
After that, we are going to decrease the number, until there are no spaces left. We get the following for the number 7:
7_______7
6543210
Then, we just merge the two of them, so:
7___... | stackexchange_codegolf |
Given an integer \$N\$, you must print a \$N\times N\$ integer involute with the numbers increasing in a clockwise rotation. You can start with either 0 or 1 at the top left, increasing as you move towards the centre.
Examples
Input => 1
Output =>
0
Input => 2
Output =>
0 1
3 2
Input => 5
Output =>
0 1 2 3 4
1... | stackexchange_codegolf |
Your task is to output a square sandbox of size n+2 with / characters in the corners and | for the sides, and - for the top, with n**2 layers of sand (.) overflowing out of the sandbox of width n+2
Testcases
1
->
/-/
|.|
/./
...
2
->
/--/
|..|
|..|
/../
....
....
....
....
3
->
/---/
|...|
|...|
|...|
/.../
.....
...... | stackexchange_codegolf |
Inspiration. Posted with permission.
Print one of the possible XKCD calendar "facts":
You can get the raw text and structure from my APL reference implementation or from Explain XKCD's transcript (including the title text just under the illustration).
Rules
At every decision node, there must be an equal (pseudo-)rando... | stackexchange_codegolf |
Generate a cipher given a number and string
Your task is simple. Given a string s and a number 0 <= n <= 9 as inputs, insert a pseudo-random printable ASCII character between each character of the string n times. Such that for each character of s there are n random characters between them. Spaces should be trimmed.
Inp... | stackexchange_codegolf |
You are Desmond Hume. For the last 3 years, you and your partner, Kelvin, have been slave to a computer that requires a very specific sequence to be entered into it every 108 minutes to save the world.
4 8 15 16 23 42
Your partner died 40 days ago (due to an unfortunate accident involving Kelvin's head and a big rock)... | stackexchange_codegolf |
The challenge is to golf a program when given a string composed of any number of asterisks, then a comma, than any number of asterisks, say which side has more.
The asterisk-strings can be empty.
Output
0 for ties.
1 for the left.
2 for the right.
Examples
Input: ***,**** Output: 2
Input: ***, Output: 1
Input: ***,*** ... | stackexchange_codegolf |
The Challenge
It's quite simple really, sort a list of numbers.
Details
You must sort a list of numbers in ascending order, without using any built-in sorting functions/libraries/etc (i.e. list.sort() in Python).
Input/output can be done in any method you choose, as long as it is human readable.
Standard loopholes ar... | stackexchange_codegolf |
The simple part: Given an input string containing only printable ASCII-characters (space - tilde), count the number of occurrences of each character and return the result on any convenient format. The result for a string a%hda7a should be something like: a:3, %:1, h:1, 7:1, d:1. Sorting is unnecessary, the delimiters a... | stackexchange_codegolf |
Given a positive integer N ("virality"), your program should create an ASCII-art drawing of a tree with two branches of length N extending downwards and/or rightwards from the top-left corner.
The direction taken by each branch after the first asterisk can be either rightwards or downwards, and this choice should be ma... | stackexchange_codegolf |
Guidelines
Task
Given two non-negative integers, find the sum of both numbers... to the power of 4.
Examples
2, 3 -> 97 (2^4 + 3^4 = 97)
14, 6 -> 39712 (14^4 + 6^4 = 39712)
0, 25 -> 390625 (0^4 + 25^4 = 390625)
Rules
You will only ever receive two non-negative integers as input (bonus points if you get it to work wi... | stackexchange_codegolf |
We already have a challenge for computing the GCD of two Gaussian integers, but that challenge explicitly allows to choose any of the four possible values.
Your task now is to bring the Gaussian integer computed by the GCD in the following normal form:
The result differs from the original number by a factor of 1,i,-1 ... | stackexchange_codegolf |
Watch live | Active answers | Add new answer | Chat room | Source code | Leaderboard
New tournaments whenever needed. New players and new updates very welcome.
Not actual game footage.
Each player starts with one ant - a queen, who collects food. Each piece of food can be held or used to produce a worker. Workers also... | stackexchange_codegolf |
Before anyone says anything, similar and similar. But this is not a dupe.
Some positive integers can be written as the sum of at least two consecutive positive integers. For example, 9=2+3+4=4+5. Write a function that takes a positive integer as its input and prints as its output the longest sequence of increasing con... | stackexchange_codegolf |
What is the shortest way to check if two or more variables are equal to 0 in JavaScript?
I'm curious to know if there's something shorter than if(!x&&!y&&!z){...}.
| stackexchange_codegolf |
After seeing some impossibly short solutions in this SE, I began to wonder what code someone could come up with to build a pseudo-random number generator. Now given that I am new to programming, I have absolutely no idea what such generator should look like, or what language to write them in. But that did not stop me f... | stackexchange_codegolf |
I'm sure everyone has seen before that cups can be stacked into pyramids (and other shapes):
A
A A A
A A A A A
A A A A A A A A
Yes, A is definitely an adequate character to represent a cup.
New cups could be added either on the ground, to the right of the structure, or on top of two ad... | stackexchange_codegolf |
Print this text:
_________
| |
| |
| |
|_________|
Shortest code wins. Notice the space at the start of the first line.
| 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 cannot 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 looks... | stackexchange_codegolf |
This challenge is inspired by a series of young children's books by Fiona Watt and Rachel Wells, which I've recently been enjoying with my daughter.
In each book a mouse (illustrated, but not part of the text) complains that a succession of 5 things of the same type are not its thing. It then backs this up by declarin... | stackexchange_codegolf |
Your challenge is to find the file extension of a provided filename:
hi.txt -> txt or .txt
carrot.meme -> meme or .meme
lol (undefined behavior)
what..is..this..file -> file or .file
.bashrc -> bashrc or .bashrc
T00M@n3KaPZ.h0wC[]h -> h0wC[]h or .h0wC[]h
agent.000 -> 000 or .000
You must get the text from the last . ... | stackexchange_codegolf |
Strobogrammatic Numbers
Definition
A number which is rotationally symmetrical, i.e., it'll appear the same when rotated by 180 deg in the plane of your screen. The following figure illustrates it better,
(source: w3resource.com)
Task
Given a number as the input, determine if it's strobogrammatic or not.
Examples
Tr... | stackexchange_codegolf |
Create your smallest web server in your preferred language!
Requirements
Must respond to atleast 1 type of request (get,post,patch,delete), with a specified string.
Smallest implementation wins!
*String can be empty
You may use any library you want
My personal record for this was 56B in node
require('express')().use((r... | stackexchange_codegolf |
As you may or may not know, Valentine's day is getting close. So today, my task for you is:
Write a heart-shaped quine
Rules:
Code should look like an identifyable heart shape, i.e. Has two round parts on top and a pointy bottom. It does NOT have to be filled in, but this is not disallowed.
Standard Quine rules apply ... | stackexchange_codegolf |
Introduction
Arrays are usually used with for-loops or iterators. One different task might be the use as a cheap way to rotate through a set of items, so after reaching the last index, the next item would be the first item of the array. This is useful for cases like menus and physical controls.
Challenge
Given the size... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.