instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Inspired by @AviFS.
Given a string containing brackets, e.g.
[xyz]]abc[[def]hij[
You can parse through it with a stack of brackets. When you find an open bracket, push a value to the stack, when you find a close bracket, pop from the stack. If you make these values indices, you know where you need to remove brackets.
... | stackexchange_codegolf |
The matrix tornado is just like any other tornado: it consists of things rotating around a center. In this case, elements of the matrix instead of air.
Here is an example of a matrix tornado:
First we start by sectioning the matrix into square rings, each section consists of elements that are farther away from the bor... | stackexchange_codegolf |
Introduction
A pure word (or perfect word), as defined by me, is a word where the sum of the position in the alphabet of each letter in the word is perfectly divisible by the total length of the word. For example, abcb is a perfect word because 1 + 2 + 3 + 2 = 8, and 8 / 4 = 2.
Your task
Given a word as input, output w... | stackexchange_codegolf |
Code a program or function to construct an interactive canvas on the screen of at least 400 pixels x 400 pixels in size. The canvas can be any color you wish, bordered or borderless, with or without a title bar, etc., just some form of obvious canvas.
The user will click on two distinct areas of the canvas and the prog... | stackexchange_codegolf |
In this challenge you will remove one of my least favorite features, operator precedence from traditional math notation, to acheive the syntax of one of my favorite languages, APL. The APL subset we will be working with includes only a few functions and single digit numbers. (No arrays!)
Here is the grammar of the inpu... | stackexchange_codegolf |
What is Typoglycemia?
Typoglycemia is a term that refers to the phenomenon where readers are able to understand text even when the letters in the middle of words are jumbled, as long as the first and last letters of each word remain in their correct positions. For example,
Aoccdrnig to a rscheearch at Cmabrigde Uinerv... | stackexchange_codegolf |
Quines have been around forever. It's a fun challenge: write a program that, when executed, generates its own source code as output. But how do you know it's actually producing its own source code? Generally, you have to look at it and compare it, but with quines generally being composed of tricky and intricate code... | stackexchange_codegolf |
FizzBuzz is so simple, bet you can do it backwards. In this challenge, you will be given the length of the FizzBuzz string and must give the positive integer that produced that string.
Description
To break this down, a FizzBuzz string for n is generated by the following algorithm.
Start with an empty string and, for e... | stackexchange_codegolf |
The task is simple. Write an interpreter for the language *.
Here's a bigger link to the wiki.
There are only three valid * programs:
* Prints "Hello World"
* Prints a random number between 0 and 2,147,483,647
*+* Runs forever.
The third case must be an infinite loop according to the specifications in this question... | stackexchange_codegolf |
A donut distribution (for lack of a better term) is a random distribution of points in a 2-dimensional plane, forming a donut-like shape. The distribution is defined by two parameters: the radius r and spread s, in which the distance to the origin follows a normal (Gaussian) distribution around r, with a standard devia... | stackexchange_codegolf |
Input:
An integer n
Output:
A string A * B
Example
12
Possible 2 divisible numbers: 12 * 1, 6 * 2, 4 * 3
12-1 = 11
6-2 = 4
4-3 = 1
4 and 3 has the minimal absolute difference of 1
Therefore, Output:
4 * 3
Order of the numbers does not matter
This challenge idea was taken from a puzzle in Clash of Code in https://www... | stackexchange_codegolf |
The task is to calculate the average "funniness" of a given number given the following scoring system:
1 point for each "420" in it
2 points for each "69" in it
3 points if its a palindrome (doesn't count if it's just a single digit)
4 points if it has (not for each) "800813"
5 points for ending in "420"
6 points for ... | 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 |
In the board game Pandemic, an outbreak occurs when a city contains more than 3 disease cubes. When the outbreak occurs, any disease cubes in the city in excess of 3 are removed, and each city connected to it gains one disease cube. This means that chain reactions can, and will occur.
Important note: Each city may onl... | stackexchange_codegolf |
Imagine we get a slice of some mountainous region, this would result in a shape similar to this:
4 _
3 _ _ __/ \
2 / \__/ \ _/ \_ /
1 / \ / \_/
0 \/
12322223210012233343221112
As we can see, we can represent this (to a certain degree) with a sequence o... | stackexchange_codegolf |
Motivated by this challenge
Background
Let we have a square sheet of flexible material.
Roughly speaking, we may close it on itself four ways:
Here the color marks the edges that connect and the vectors indicate the direction.
The sphere and torus are obtained without flipping the sides, Klein bottle — with one flippi... | stackexchange_codegolf |
Balanced ternary is a modified version of ternary (base 3), using the three digits 1,0 and -1 (written as T) to represent numbers.
The balanced ternary representation of -n can be obtained by replacing 1 with T and T with 1 in the balanced ternary representation of n.
Examples:
1 // decimal: 1
T // decimal: -1
... | stackexchange_codegolf |
You've been hired by a bomb defusing company to perform some "controlled" demolition of un-exploded ordnance. You are given a list of bombs represented by non-negative integers.
[3,2,4,0,3,1,2]
Every step you can set up and explode a bomb. When a bomb \$n\$ explodes, it destroys all bombs within \$n\$ places replacin... | stackexchange_codegolf |
This challenge is in honor of mathematician John Conway who passed away April 11, 2020 due to COVID-19. He was famous for coming up with the Game of Life cellular automaton and many other mathematical contributions such as the surreal numbers and the monster group.
The advanced math of those topics is out scope for thi... | stackexchange_codegolf |
Overview
Given a number of hexagons, arrange them into a connected shape within the confines of a 50 by 50 ASCII art image. The shape you choose can be arbitrary - whatever you find most amenable to golfing - as long as it is connected. It may have holes provided they are larger than one hexagon (otherwise the number o... | stackexchange_codegolf |
Background
Hello is a language "written" by Anne Veling, which errors if the program does not contain only h, and will print Hello World for every h
Task
You are to write an interpreter/compiler for Hello.
Example in Python
import os
i = input("Program: ")
for a in i:
if a != 'h':
print("err")
quit(... | stackexchange_codegolf |
Introduction
I have a lot of ASCII rocks. They are built with dashes, pipes, Vs, carets, angle brackets, slashes and spaces. Example:
/--\
| |
| |
\--/
I want to erode them, like this:
/\
/ \
\ /
\/
All of the corners have become rounder. A more complicated example:
/----\
| \------\
| |
| ... | stackexchange_codegolf |
In chess, fork means to target two pieces with just one piece, and one of the best pieces for forking is the knight.
In this challenge, you will be given three coordinates in a to h and 1 to 8 (like a8 or e7) format. The first and second coordinates are for two other random pieces, and the third is the knight's coordin... | stackexchange_codegolf |
Introduction:
When we think about Ladybugs, we usually think of a red or dark orange bug with black spots. Although this isn't necessary true, since there are also black with red/orange spotted ladybugs, or ladybugs without spots at all, we mainly picture ladybugs something like this Asian Ladybug:
Another thing to no... | stackexchange_codegolf |
In this challenge, the goal is to create a pristine truth machine in as few bytes as possible. For reference, a truth machine does the following:
Takes input, which is always 0 or 1
If the input is 0, it is printed and the program terminates
If the input is 1, it is printed forever
A pristine program is one that does... | stackexchange_codegolf |
I got inspired by this: Print every character your program doesn't have
But with the exception that the letters have to be between ASCII 32 to 126. We started fooling around with it at the office with PHP and this is the best we could come up with:
<? while($i++<95)if(!strstr(file(__FILE__)[0],$a=chr($i+31)))echo$a;
Is... | stackexchange_codegolf |
Please participate in the meta discussion about reopening this challenge before casting a vote.
Introduction
This challenge was inspired by semicolon-#.
Deadfish is a non-Turing-complete programming language, created by Jonathan Todd Skinner. It has an accumulator register and contains 4 commands, i, d, s, and o, sta... | stackexchange_codegolf |
The idea is simple. You've to create a "visualised" letter-replacement, by providing 3 strings (input can be comma separated, separate inputs, or as an array). The first segment is the word you want to correct, and the second segment is the letters you want to replace, and the third segment is the replacement for the l... | stackexchange_codegolf |
Definition
a(1) = 1
a(2) = 1
a(n) = a(n-a(n-1)) + a(n-a(n-2)) for n > 2 where n is an integer
Task
Given positive integer n, generate a(n).
Testcases
n a(n)
1 1
2 1
3 2
4 3
5 3
6 4
7 5
8 5
9 6
10 6
11 6
12 8
13 8
14 8
15 10
16 9
17 10
18 11
19 11
20 12
Reference
Obligatory OEIS A005185
| stackexchange_codegolf |
The task is to write code to identify which key is pressed on the keyboard. You can assume that only one key is pressed at a time and that there is a standard US keyboard layout. That is the layout with the @ over the 2.
Your code should output a unique identifier for any key pressed. This includes PrtScn, Scroll Lock,... | stackexchange_codegolf |
Background
With the success of Simple Boolean Algebra Calculator, I present a more difficult problem.
Boolean Algebra concerns representing values with letters and simplifying expressions. The following is a chart for the standard notation used:
Above is what actual boolean algebra looks like. For the purposes of this... | stackexchange_codegolf |
In combinatorics, the rook polynomial \$R_{m,n}(x)\$ of a \$m \times n\$ chessboard is the generating function for the numbers of arrangements of non-attacking rooks. To be precise:
$$R_{m,n}(x) = \sum_{k=0}^{\min(m,n)} r_k x^k,$$
where \$r_k\$ is the number of ways to place \$k\$ rooks on an \$m \times n\$ chessboard ... | stackexchange_codegolf |
I found another sequence not yet in the OEIS
The binary expansion sequence is defines as follows, assuming 0 indexing:
The even numbers of the sequence are how often 0 has appeared in the binary expansion of all previous items in the sequence
The odd elements are the same, but for 1s.
If you choose to 1-index, revers... | stackexchange_codegolf |
The International Phonetic Alphabet is a system of phonetic notation intended to be able to accurately represent every sound used in spoken language.
The alphabet contains 29 vowel letters iyɨʉɯuɪʏʊeøɘɵɤoəɛœɜɞʌɔæɐaɶäɑɒ and 81 consonant letters, although I missed three (ɦǀǂ) when I first posted this challenge, so you on... | stackexchange_codegolf |
Given two non-zero 16-bit integers a and b, decide the smallest number of shift operations needed to turn a into b. A shift is one of the following (big-endian) operations:
shl (shift left): move all bits to the left, adding a 0x0 bit to the right.
shr (shift right): move all bytes to the right, adding a 0x0 bit to th... | stackexchange_codegolf |
Your task is to write a program which given an array and a number, you need to split the array into chunks with size is number.
Rules
Your program will receive an array A , as well as a positive integer n. The array should then be split into chunks of length n, if the length of the string isn't divisible by n any left... | stackexchange_codegolf |
I have a bunch of boards I need to stack in as small a space as possible. Unfortunately, the boards fall over if I stack them more than 10 high. I need a program to tell me how to stack the boards to take as little horizontal space as possible, without stacking boards more than ten high, or having boards hanging out ... | stackexchange_codegolf |
Your goal in this code golf is to take two strings, language and code (if the golfed code you wrote for this is multiline, then this variable would be multiline.), and one integer, bytes. They represent the variables for a programming language, number of bytes it takes, and the code itself.
After that, you are going to... | stackexchange_codegolf |
A digit word is a word where, after possibly removing some letters, you are left with one of the single digits:
ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT or NINE (not ZERO).
For example, BOUNCE and ANNOUNCE are digit words, since they contain the digit one.
ENCODE is not a digit word, even though it contains an O,... | stackexchange_codegolf |
Quell is a single-player grid-based puzzle game. Pearls are scattered across a 2D map and the aim is to collect them all by rolling a drop of water over them. For this challenge we will only consider basic maps containing the drop, pearls, walls, and empty spaces. (The full game includes a variety of additional objects... | stackexchange_codegolf |
Print integers 0 to 100 (inclusive) without using characters 123456789 in your code.
Separator of numbers can be comma or white space (by default <blank>, <horizontal tabulator>, <newline>, <carriage return>, <form feed> or <vertical tabulator>).
Shortest code wins.
| stackexchange_codegolf |
Inspired by Find the largest fragile prime
A recurring prime (or whatever you choose to call it) is a prime that, when removing leading digits, always remain prime regardless of how many digits are removed.
for example
6317 is a recurring prime because...
317 is a recurring prime because...
17 is a recurring prime beca... | stackexchange_codegolf |
Challenge
In this challenge, all numbers are in \$\mathbb{N}_0\$.
Create a function or program that, when given a number \$N\$ and a tuple of \$k\$ numbers \$(n_i)\$ (all ≤ \$N\$), returns the number of ways \$N\$ can be written as a sum of \$k\$ integers (\$x_1 + x_2 + ... + x_k\$) such that \$n_i \le x_i \le N\$.
The... | stackexchange_codegolf |
I'm honestly surprised that this hasn't been done already. If you can find an existing thread, by all means mark this as a duplicate or let me know.
Input
Your input is in the form of any positive integer greater than or equal to 1.
Output
You must output the sum of all integers between and including 1 and the number i... | stackexchange_codegolf |
The other day, my son asked me to build him a staircase using Lego-ish blocks. And I came up with something like this:
Then my kid asked me for a program using the least number of bytes that generated a similar staircase in a computer screen. I am not that good at code-golf, so I need your help. I need a program that:... | stackexchange_codegolf |
Problem
Given input a where a is a grid of characters in any input format as long as it has only one element for each 'block' of the output.
And input b where b is a grid of numbers the same size as input a.
There are two types of road, a 1 represents a stone road marked by @ and a 2 represents a dirt road marked by #
... | stackexchange_codegolf |
(Just open 50 tabs in Google Chrome :D (just kidding, no you can't))
Shortest code for infinite disk I/O any language, C# example:
using System.IO;
namespace FileApp {
static class Program {
public static void Main() {
do {
File.WriteAllText("a", "a");
File.Delet... | stackexchange_codegolf |
Given a range and a list thereof, while keeping the existing intervals in the list unchanged, split the additional range into sub-intervals and add them to the list, such that all the ranges in the final list are disjoint and contain all numbers present in the input ranges.
The goal is to create an insertInterval(inte... | stackexchange_codegolf |
Challenge
You have been given a string of digits 0-9.1 Your task is to shuffle this string, but every index must have a different value than it did before the string was shuffled.
For example:
In : 287492
Out: 892247
If this is not possible, return false or something similar. (null, undefined, etc.)
In : 131
Out: fals... | stackexchange_codegolf |
This challenge was greatly inspired by this Stack Overflow post.
Challenge
Given a bunch of clients in terms of when they enter a room and when they exit it, determine the period(s) of time when the room has a maximum number of people. The time resolution should be to the minute.
For example, if there are three clients... | stackexchange_codegolf |
Related
Goal:
Given two creatures with optional combat abilities, return unique but consistent values that represent which creatures died, if any.
Input:
#Longest form:
[[P,T, "<abilities>"], [P,T, "<abilities>"]]
#Shortest form:
[[P,T], [P,T]]
Each creature will be given in the form of [P,T,"<abilities>"]. It will be... | stackexchange_codegolf |
Create a program that can be run in 4 different languages such that:
One language prints "Hello World!"
One language outputs its own source code
One language outputs 99 bottles of beer on the wall, that is:
99 bottles of beer on the wall
99 bottles of beer
Take one down, pass it around
98 bottles of beer on the wall
... | stackexchange_codegolf |
Explanation
Befunge is a two-dimensional program that uses stacks.
That means, to do 5 + 6, you write 56+, meaning:
56+
5 push 5 into stack
6 push 6 into stack
+ pop the first two items in the stack and add them up, and push the result into stack
(to those of you who do not know stacks, "push" just means add ... | stackexchange_codegolf |
Here are the first 100 numbers of a sequence:
1,2,33,4,55,66,777,8,99,11,111,12,133,141,1515,1,11,18,191,22,222,222,2232,24,252,266,2772,282,2922,3030,31313,3,33,33,335,36,377,383,3939,44,441,444,4443,444,4455,4464,44747,48,499,505,5151,522,5333,5445,55555,565,5757,5855,59559,6060,61611,62626,636363,6,66,66,676,66,666,... | stackexchange_codegolf |
There's a question with a comment with some code thats far too long.
For a site that has counting fetish, this code just seems so wrong.
Solve this meta-riddle, and explain it with a rhyme.
Winner is the shortest code in a fortnights time.
The challenge:
Open a file as input.
Count and output the number of digits (0... | stackexchange_codegolf |
Brief
Print an ASCII representation of a binary search tree.
You should write your own minimum implementation logic of a BST (node, left, right, insert)
(50,30,70,20,80,40,75,90) gives:
__50__70__80__90
| |
| |__75
|
|__30__40
|
|__20
Detailed requirements
Items are inserted ... | stackexchange_codegolf |
In this challenge, the goal is to find the values of some variables after a number of assignments are done. An example input:
a = 5
b = 4
c = a = b
a = 2
b = a
This would result in:
a = 2
b = 2
c = 4
Each statement will be one of the following:
A variable name ([a-z_]+)
A numeric value ([0-9]+)
An assignment operati... | stackexchange_codegolf |
The Challenge
Write two programs P and Q such that:
P and Q are written in the same language
The output of P is Q
The output of Q is P
P and Q are both non-empty
Simple enough. Surely that's been done here before. Where this gets interesting is the scoring.
Scoring
P and Q are selfish, they don't want to sheir their... | stackexchange_codegolf |
This was inspired by Apply gravity to this matrix
Your challenge is to input a matrix with non-negative one-digit integers and drop down the 1's down 1 column, the 2's down 2 columns, the 3's down 3 columns, and so on. Once a number has been moved down and there is no number to take its original place, replace that slo... | stackexchange_codegolf |
The Task
The task is easy: given an Alpha-2 country code, output the Alpha-3 equivalent. The input may be in any case you choose, and the output in any consistent case of your choosing. Here are the codes:
[["AF", "AFG"], ["AX", "ALA"], ["AL", "ALB"], ["DZ", "DZA"], ["AS", "ASM"], ["AD", "AND"], ["AO", "AGO"], ["AI", "... | stackexchange_codegolf |
The goal is to find a way better than the current best known way of encoding the index of a child HTML element, so that encoded indices have the following property.
if (index_i >= index_p) {
assert(encoding(index_i).indexOf(encoding(index_p)) == 0);
}
if (index_i < index_p) {
assert(encoding(index_i).indexOf(enco... | stackexchange_codegolf |
Introduction
On March 24th, 2015 @isaacg golfed his Pyth answer from 44 to 42 bytes. Since a crossed out 44 (44) looks a lot like a regular 44, @Optimizer made the following comment:
striked out 44 is still normal 44 :(
After that, on October 21st, 2015, @Doorknob♦ golfed his Ruby answer from 44 to 40 (and later 38) ... | stackexchange_codegolf |
This is a cake:
_========_
| |
+________+
| |
+________+
| |
+________+
It is 8 wide, 3 tall, and 1 deep.
You must write a program that makes a cake from 3 inputs. The first input controls how many underscores there are in the middle and =s on the top. Here's the first cake with a width of 10 inst... | stackexchange_codegolf |
Intro
The Tetris Guidelines specify what RNG is needed for the piece selection to be called a Tetris game, called the Random Generator.
Yes, that's the actual name ("Random Generator").
In essence, it acts like a bag without replacement: You can draw pieces out of the bag, but you cannot draw the same piece from the ba... | stackexchange_codegolf |
Sandbox
Your challenge is to write a program that when first run, will do one of the actions below at random with equal chances of both:
A cat program
A standard cat program: read everything from STDIN and put it on STDOUT (or your language's closest equivalent).
Do nothing and halt
This shouldn't output anything.... | stackexchange_codegolf |
Problem:
You are making a new phone where people can type in specialized phone numbers, for example, 1-800-program, and they would be converted automatically to a usable phone number, like 1-800-7764726 (for the previous example).
Your program will recieve a string if any length with numbers, letters and dashes, and c... | 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 |
Introduction
We all know the cool S (also known as Superman S, Stüssy S, Super S, Skater S, Pointy S, Graffiti S etc. etc.): billions of schoolchildren around the world drew this S and immediately felt proud of themselves. In case you've forgotten or had a completely uncool childhood, here is an image of said cool S:
... | stackexchange_codegolf |
Today in my statistics class, I found that some factorials can be simplified when multiplied together! For example: 5! * 3! = 5! *3*2 = 5! *6 = 6!
Your job:
Given a string containing only Arabic numbers and exclamation points, simplify my factorial to its shortest possible string, in the least amount of bytes for your ... | stackexchange_codegolf |
This is a cops and robbers challenge - Cop's Thread
Each of the cops have been tasked to write a program that terminates after exactly 60 seconds, or as close as possible. For example:
#include <unistd.h>
int main(int argc, char **argv){
sleep(60);
return 0;
}
Your goal is to take any of the uncracked submissi... | stackexchange_codegolf |
We have objects that oscillate between two integer points, [l, r], at the speed of one unit per time unit, starting at l on t=0. You may assume l < r. For example, if an object oscillates on [3, 6], then we have:
t=0 -> 3
t=1 -> 4
t=2 -> 5
t=3 -> 6
t=4 -> 5
t=6 -> 4
t=7 -> 3
t=8 -> 4
Etc. But objects oscillate continu... | stackexchange_codegolf |
Objective
You're on a nonempty list of integers that wraps around. You start at the leftmost entry of the list, and keep jumping to the right to the amount of the integer entry you're at.
Eventually, you'll end up in a cycle. The objective is to output the length of this cycle.
I/O format
Provided that the inputted lis... | stackexchange_codegolf |
Your code-golf challenge is to find all occurences of a word in the 3d matrix. There is no restriction on I/O format. In the samples below, the word is presented, then a blank line, then the 2-dimensional layers from top to bottom, and the output, for each line, consists of a coordinate and a direction (x, then y, then... | stackexchange_codegolf |
Choose a set of four bytes without replacement (i.e. no byte repeated), and not necessarily in any particular order, from any one of the following four sets:
The characters of any one single-byte encoding
The Unicode characters in the range 00–FF
The signed decimal integers in the range −128–127
The unsigned decimal i... | stackexchange_codegolf |
What am I?
As a plant cell, your program/function/etc. must undergo photosynthesis:
When the input is 6CO2+6H2O+light in any order, output C6H12O6+6O2 in any order. It does not have to be the same for each arrangement of the input.
When the input is just r, replicate (i.e. output your own code). quine rules apply.
Whe... | stackexchange_codegolf |
Given n=m^2, return a list of integers that do not border the m x m grid of integers from 1 to n.
Examples
n=1 (m=1)
Grid:
[1]
Return:
[]
n=4 (m=2)
Grid:
[1,2]
[3,4]
Return:
[]
n=9 (m=3)
Grid:
[1,2,3]
[4,5,6]
[7,8,9]
Return:
[5]
n=16 (m=4)
Grid:
[ 1, 2, 3, 4]
[ 5, 6, 7, 8]
[ 9,10,11,12]
[13,14,15,16]
Return:
[6,... | stackexchange_codegolf |
Background
Fibonacci trees \$T_n\$ are a sequence of rooted binary trees of height \$n-1\$. They are defined as follows:
\$T_0\$ has no nodes.
\$T_1\$ has a single node (the root).
The root node of \$T_{n+2}\$ has \$T_{n+1}\$ as its left subtree and \$T_n\$ as its right subtree.
T0 T1 T2 T3 T4
O ... | stackexchange_codegolf |
Goal
As the title suggests, write a radix sort function (either MSB or LSB is fine) that accepts two parameters:
an array of values of any type (you can assume that they are all of the same type / class, etc.)
a function (or function pointer, depending on your language) that takes a single parameter of the same type a... | stackexchange_codegolf |
Given year, month and optionally weekday of 1st, output the calendar of the month. The first week should remain nonempty.
For empty cell, fill it with the date where it's supposed to be, in last or next month, and add # to indicate gray. If last few days can't fit in 5 lines, then they share last line with 5th week, us... | stackexchange_codegolf |
The following puzzle was invented by Eric Angelini in September 2007.
As mentioned in A131744 :
the sequence is defined by the property that if one writes the English
names for the entries, replaces each letter with its rank in the
alphabet and calculates the absolute values of the differences, one
recovers the sequen... | stackexchange_codegolf |
I hate code bloat!
So I have decided to replace my Windows 7 system by a golfed version. However, I know that it is not easy, so let's build a prototype first. It will take a list of windows from the user and show them using a pseudo-graphic display on the standard output.
For example: user input:
0,0,15,10
15,10,20,1... | stackexchange_codegolf |
Code Golf Challenge
Given a string of 10 characters:
'abcdefghij'
I want to format it in this pattern and print it in the console in a minimum number of characters:
(abc) def-ghij
My solution:
print(f"({s[0:3]}) {s[3:6]}-{s[6::]}")
| stackexchange_codegolf |
Defenestration is the act of throwing someone or something out of a window.
—Wikipedia
Input
The input will consist of two parts:
A floor plan and a person inside the house/building.
v><^ represents a person, pointing in the direction signified by the arrow. The input will contain exactly one person.
- and | repres... | stackexchange_codegolf |
I know, a bit late.
Challenge
Your challenge is, given a date, output if it's not an Advent Sunday, or the Advent Sunday of the year.
Rules
The \$4^\text{th}\$ Advent is determined by the Sunday before Christmas day (the \$25^\text{th}\$ of December). The \$3^\text{rd}\$ Advent is the Sunday before the \$4^\text{th}\$... | stackexchange_codegolf |
Barbrack
Your task is to write a program or function that takes a non-negative integer (in decimal or any other convenient base for your language), and output a number in the numbering system Barbrack.
What's that?
Barbrack is a numbering system I made up that can represent non-negative integers. Zero is represented wi... | stackexchange_codegolf |
A pandigital number is an integer which contains every digit from 0 to 9 at least once. 1234567890, 1902837465000000, and 9023289761326634265 are all pandigital. For the purposes of this challenge, numbers such as 123456789 are not pandigital, since they do not contain a 0, even though 123456789 = 0123456789.
A diverse... | stackexchange_codegolf |
Pazaak is a card game from the Star Wars universe. It is similar to BlackJack, with two players pitted against each other trying to reach a total of twenty without going over. Each player has a "side deck" of four cards of their own that they can use to modify their score.
Leaderboard
As of 6/17/2015 @ 16:40 EDT
Edit: ... | stackexchange_codegolf |
To quote http://brainfuck.org/utm.b:
A tag-system transforms strings over an alphabet A = {a[1], a[2], ... a[n], a[n+1]} as follows: a positive integer m is chosen, and so is a function P that maps each a[i] for 1<=i<=n to a string P(a[i]) over the alphabet A. Now:
if the string being transformed has fewer than m ele... | stackexchange_codegolf |
Introduction
In Tennis, the server alternates serving on the left side or the right side of the court every point, starting on the right. It is possible to figure out which side to serve on for that point just based on the score; if there have been an even number of points you serve on the right, and after an odd numbe... | stackexchange_codegolf |
Cops thread
Robbers
Robbers, your job is to find the slices of the corresponding cop's code.
Scoring
The robber with the most cracks wins.
Example
Take this code:
iimmppoorrtt ssyymmppyy;;pprriinntt((ssyymmppyy..iisspprriimmee((iinnppuutt(())))))
The slice here is [::2], so the robber's post could look like this:
Crac... | stackexchange_codegolf |
Your regex will receive a string of the form
!XX!
#<extra>
where X is any hexadecimal digit (0-9 and A-F capital letters only), and <extra> is a character sequence to your choosing. (perhaps something like 0123456789ABCDEF0 could be useful?)
You may use any regex flavour.
Scoring will be calculated as: find regex len... | stackexchange_codegolf |
This challenge is partly an algorithms challenge, partly an optimization challenge and partly simply a fastest code challenge.
A cyclic matrix is fully specified by its first row r. The remaining rows are each cyclic permutations of the row r with offset equal to the row index. We will allow cyclic matrices which are n... | stackexchange_codegolf |
I can't believe we don't have this already.. It's one of the most important data-structures in programming, yet still simple enough to implement it in a code-golf:
Challenge
Your task is to implement a stack that allows pushing and popping numbers, to test your implementation and keep I/O simple we'll use the following... | stackexchange_codegolf |
If we have a list of integers we can "squish" one of them by:
decrementing it
replacing adjacent values with its new value
For example in this list:
[1,2,8,3,6]
If we squish the 8 we get:
[1,7,7,7,6]
The question is:
Given a starting array, what is the largest we can make its sum by repeatedly squishing values?
For... | stackexchange_codegolf |
Given an ASCII-art shape made of the characters /\|_, your challenge is to return the number of sides it has.
A side is a straight line of one of those, for example:
\
\
\
/
/
|
|
|
|
_____
Are all sides.
For example, this shape:
___
/ \
/_____\
Has four sides. You can assume the input will be a single va... | stackexchange_codegolf |
Inspired by this accidental misspelling
If you could read the title, then you already know what the challenge is about. If not, then I'll tell you. Easy: simply take each word (single space delimited), and swap the positions of the first two letters. You may assume that the input will contain only lowercase ASCII let... | stackexchange_codegolf |
Introduction
If \$\newcommand{\fib}{\operatorname{fib}}\fib(x)\$ calculates the \$x\$th Fibonacci number, write a program that calculates \$\fib(\fib(m))\$ for any integer value of \$m \ge 0\$. (Of course, there will be practical limits based on the language, so lesser limits are acceptable. Also, it's okay to stop at ... | stackexchange_codegolf |
Given a PPCG User ID, output that user's current username.
Examples
Input -> Output
61563 -> MD XF
2 -> Geoff Dalgas
12012 -> Dennis
foo ->
-3 ->
Rules
Input/output can be taken via any allowed means.
The output must be the full username with proper capitalization and spacing, nothing more and nothing less... | stackexchange_codegolf |
Inspiration. Inverse.
Evaluate a given omnifix expression.
Omnifix is like normal mathematics' infix notation, but with additional copies of each symbol surrounding the arguments. The outer symbols take the place of parentheses, and there is therefore no need for additional parentheses.
You must support addition, subtr... | stackexchange_codegolf |
Letter dice are common in word games. It can be fun to try to spell funny words with boggle dice, for instance. If you grab a handful of dice, chances are you won't be able to spell certain words. This challenge is a generalization of that idea.
Challenge
Given a list of dice which each have at least 1 face and a word,... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.