instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Challenge Make a triangle of numbers like below. How to? Let say we get a numbers in the form of ab, for example 12. We then create a triangle like below: Sorry for my bad drawing! First we have 12, and we take sum of the two numbers 1 and 2, which is 3. In case the sum of two numbers are greater than 9, we just take ...
stackexchange_codegolf
Imagine a continuous 2-dimensional path that can only turn left, right, or go straight, cannot intersect itself, and must fill a rectangular grid such as the grid of pixels in an image. We'll call this kind of path a snake. This enlarged example shows a snake path in a 10×4 grid that starts out red and increases in hu...
stackexchange_codegolf
We once made a Hexagony template without actually knowing it. But after a bit of experience with Hexagony, it becomes apparent that it is not enough; sometimes the source code is too short for the given hexagon, and you get totally unexpected results. So I came up with an idea: a template that gives a hint when the cod...
stackexchange_codegolf
This is the robbers' challenge. The cops' one is here. In Fewest (distinct) characters for Turing Completeness, the goal is to find the minimum number of characters which make a language Turing Complete...in other words, allow it to do any computation possible with any other language. In this challenge, we'll be doing ...
stackexchange_codegolf
Backstory [which is not true] A piano is set up like this: However, on my piano, all of the black keys are broken! I still want to be able to play some chords on my broken piano though. In music, a chord is a group of notes that are played together. To allow for input of chords, I will first define what a semitone is....
stackexchange_codegolf
There are one hundred members of the United States Senate. Assuming that nobody filibusters and that the Vice President isn't cooperating, at least fifty-one members are necessary to pass a bill. But some members work together better than others, entropy-wise. Your task: Output the last names of at least 51 of the US s...
stackexchange_codegolf
The word "levencycle" is inspired by cyclic levenquine challenge. Definitions A 1-dup permutation of order \$n\$ is some permutation of \$1, \cdots, n\$ plus one duplicate number in the range. For example, 1-dup permutations of order 3 include 1, 3, 2, 2 and 3, 2, 1, 3. There are 36 distinct 1-dup permutations of order...
stackexchange_codegolf
I thought it might be fun to throw this on here. Generate an ASCII-art for one of your favorite videogames. What you want to generate is up to you but it should meet 2 requirements. It should be able to identify the game. So either a logo or something familiar like the triforce in Zelda. a pokeball for pokémon or an...
stackexchange_codegolf
During the 49 days between Passover and Pentecost, Jewish liturgy provides four numerical problems that I've here phrased as code golf problems. Input/Arguments These four, in any order, and by any means: A text \$L\$ consisting of exactly 7 sentences. The first and last sentences have 7 words each, the middle one ha...
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
There's a satirical song called Little Boxes, originally by Malvina Reynolds, about suburban sprawl that has lyrics as follows: Little boxes on the hillside, Little boxes made of ticky-tacky, Little boxes on the hillside, Little boxes all the same. There's a green one and a pink one And a blue one and a yell...
stackexchange_codegolf
You are given an \$ 25 \times 25 \$ square lattice graph. You are to remove certain nodes from the graph as to minimize your score, based on the following scoring system: Your score will be the \$ \text{number of nodes removed} \$ \$ + \$ the \$ \text{size of the largest connected component} \$. In the smaller \$ 4 \ti...
stackexchange_codegolf
Chameleon challenges are a bad thing, apparently. Too bad, chameleons are beautiful creatures. Time for a change! As we all know, many chameleons posses a remarkable ability to blend in with their surroundings by changing the color of their skin. Which is also the objective of this challenge. Challenge Imagine a squar...
stackexchange_codegolf
Given a positive number n, rotate its base-10 digits m positions rightward. That is, output the result of m steps of moving the last digit to the start. The rotation count m will be a non-negative integer. You should remove leading zeroes in the final result, but not in any of the intermediate steps. For example, for t...
stackexchange_codegolf
7-segment digits can be represented in ASCII using _| characters. Here are the size 1 digits: _ _ _ _ _ _ _ _ | _| _| |_| |_ |_ | |_| |_| | | | |_ _| | _| |_| | |_| _| |_| Larger sizes are formed by making each segment proportionately longer. Here are a couple size 3 digits. ___ ...
stackexchange_codegolf
Given a the name of a state of the United States as a string (with case), return the number of votes the state has in the Electoral College. Write a full program or function, and take input and output through any default I/O method. A list of all inputs and outputs (source): [['Alabama', 9], ['Alaska', 3], ['Arizona', ...
stackexchange_codegolf
This is a pretty simple challenge, but (I hope) a fun one. Task If right now either the month is 4 and the day is 20, the hour (on a 12 hour clock) is 4 and the minute is 20, or the minute is 4 and the second is 20, print this ascii art: . .:. :|: ...
stackexchange_codegolf
Jimmy has had a busy last week with all these platforms and ropes, and poor Jimmy doesn't even have legs or feet to stand on! Your job is to take a string containing multiple Jimmys and give them legs and shoes! Get input in the form of a Jimmy String Jimmy String => /o\ /o\ /o\ containing only /o\ and give each ...
stackexchange_codegolf
Expand a number Your task is to expand an integer greater than 0 in the following manner: Split the number into decimal digits and for each digit generate a list according to these rules: if the digit is odd, the list starts with the digit and goes down to 1; if the digit is even, the list starts with the digit and go...
stackexchange_codegolf
We've recently reached the threshold of 10,000 questions on PPCG. Hooray! Let's celebrate this with a simple challenge. Input Two integers \$A\$ and \$B\$, both in \$[1..9999]\$, such that \$A+B<10000\$. Task Your task is to add one single digit to one of these integers or one single digit to both of them such that \$A...
stackexchange_codegolf
Introduction: Some times using a 24-hour clock are formatted in a nice pattern. For these patterns, we'll have four different categories: All the same (pattern A:AA or AA:AA): 0:00 1:11 2:22 3:33 4:44 5:55 11:11 22:22 Increasing (pattern B:CD or AB:CD, where D==C+1==B+2==A+3): 0:12 1:23 2:34 3:45 4:56 12:34...
stackexchange_codegolf
Alternate Title: Tally Your Prison Sentence on the Wall Given a number n, output tallies grouped into the traditional 5-per-group and 50 per row. Examples 1 | | | | 4 |||| |||| |||| |||| 5 |||/ ||/| |/|| /||| 6 |||/ | ||/| | |/|| | /||| | 50 |||/ |||/ |||/ |||/ |||/ |||/ |||/ |||/ |||/ |||/ ||/| ||/| ||/| ||/| ||/...
stackexchange_codegolf
What general tips do you have for golfing in V? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to V (e.g. "remove comments" is not an answer). Since V is heavily based on vim, most of the tips for golfing vim would apply too. But there are some features in...
stackexchange_codegolf
There's already a comprehensive list of tips for python here, so what I'm asking for are tips that specifically apply to using the numpy, scipy or pylab libraries. These can be either ways to shorten code already using numpy, or ways to shorten common python operations by using these libraries. One tip per answer, plea...
stackexchange_codegolf
When you leave, my challenges fade to grey, 0A0AE16, 0A0A0AE16... A while ago, I made this programming language (https://esolangs.org/wiki/Dragostea_din_tei) which uses an interesting number system. It is base two for integers, but for decimals it divides a base two integer by a power of ten. The input should be a floa...
stackexchange_codegolf
For a while now, I've been running into a problem when counting on my fingers, specifically, that I can only count to ten. My solution to that problem has been to count in binary on my fingers, putting up my thumb for one, my forefinger for two, both thumb and forefinger for three, etc. However, we run into a bit of ...
stackexchange_codegolf
Challenge The goal of this challenge is to generate and output a \$16 \times 32\$ (height \$\times\$ width) grid where all cells contain a decoy character, except for a random single cell that contains the target character. The input will be a pair of ASCII (32-126) characters: [target,decoy], where target is the chara...
stackexchange_codegolf
So I got kinda bored and was wondering if it was possible to make this code shorter without modifying anything except a file named coin.py... from random import*;c=['heads','tails'];print('u win'if choice(c)==input(' / '.join(c)+': ')else'u lose') The program asks the user for either "heads" or "tails", if the result ...
stackexchange_codegolf
Story My local pizza delivery introduced new discount. You get 50% discount from every second item on your order. But being greedy capitalists, they forgot to mention that they will rearrange items the way they need to give you as little as possible. Example Imagine you ordered - Pizza $20 - Pizza $20 - Coke $2 - Coke ...
stackexchange_codegolf
Introduction Logic gates! Everyone knows them, everyone loves them (unless you're starting to learn them). Take two booleans, compare them, get a single boolean in return. AND, NAND, OR, NOR, XOR, XNOR. Fun! But, what if you only had the inputs and output, but not the operator? Challenge Given a three digit number, xy...
stackexchange_codegolf
The Fabius function is an example of a function that is infinitely differentiable everywhere, yet nowhere analytic. One way to define the function is in terms of an infinite number of random variables. Specifically, given a sequence of independent random variables \$\{U_n\}\$, where each \$U_n\$ is uniform on the inter...
stackexchange_codegolf
You find yourself in a strange place. A frighteningly dark maze, lit only by dim candles resting in the occasional hallway. Numerous paths lie only in impassable darkness, foreboding and-- ...Hm? What? Pick up a candle and carry it with you? No, no, that would be extremely rude. The Task Given a maze as input, output t...
stackexchange_codegolf
I've invented an SQL-like language. Let's call it SelectQL. You can't INSERT anything, you can only SELECT, and I don't have the time for an interpreter. How about you help? The Challenge Write a full program or a function that takes in a database of tables and a valid SelectQL SELECT string, interprets the string, and...
stackexchange_codegolf
This challenge is from a game, Keep Talking And Nobody Explodes. This is like one of those toys you played with as a kid where you have to match the pattern that appears, except this one is a knockoff that was probably purchased at a dollar store. – From the manual Objective The Simon Says module consists of 4 colored ...
stackexchange_codegolf
Given a list of at least two words (made only of lowercase letters), construct and display an ASCII ladder of the words by alternating the direction of writing first to the right, then to the left, relatively to the initial direction from left to right. When you finish writing a word, change the direction and only then...
stackexchange_codegolf
The TV series "Breaking Bad" replaced the letters Br and Ba with a periodic-table like representation, printing [Br35]eaking [Ba56]d. Create a program that takes a string input, does a replacement and prints an output. The replacement shall subsidize any substring that matches an element symbol with the notation demons...
stackexchange_codegolf
Given a list of strings, output a single string formed by taking a character from each string at each position, sorting them by ASCII ordinal, and appending them in order to the output string. In other words, for n input strings, the first n characters of the output will be the first characters of each of the inputs so...
stackexchange_codegolf
NOTE: Since I'm Dutch myself, all dates are in the Dutch dd-MM-yyyy format in the challenge description and test cases. Challenge: Inputs: Start date \$s\$; End date \$e\$; Digit \$n\$ Outputs: All dates within the range \$[s,e]\$ (including on both sides), which contain \$n\$ amount of unique digits in their date. Exa...
stackexchange_codegolf
Time for you to implement my new stack based language! It's called StackyMath. This will be a stack based language with 8 operations on the stack and ways to add numbers to the stack. List of operations: /: Division. Performed on the top 2 numbers of the stack. Pushes the result back on the stack. *: Multiplication. P...
stackexchange_codegolf
Rotonyms 2 A "Rotonym" is a word that ROT13s into another word (in the same language). For this challenge, we'll use an alternate definition: a "Rotonym" is a word that circular shifts/rotates into another word (in the same language). For example: 'stable' < 'tables' < 'ablest' 'abort' > 'tabor' 'tada' >> 'data' The C...
stackexchange_codegolf
Introduction Try to convert words to two different unicode fonts. Challenge Your task is to transform your input string into the and unicode characters. All uppercase words should become lowercase words. For Example: WORD -> All lowercase words should become words For example: other words -> All mixed ...
stackexchange_codegolf
Your goal is to compute the set intersection of two lists of integers. The intersection is defined as the unique un-ordered group of integers found at least once in both input list. Input The input may be in any format desired (function parameter, stdio, etc.), and consists of two lists of integers. You many not assume...
stackexchange_codegolf
You will receive an integer less than 2000000000 and bigger than -2000000000 and you have to test what type(s) of number this is out of: Factorial Square Cube Prime Composite Triangular Positive Negative Here is a definition of all the different types of numbers: Factorial - A number That is equal to the product of a...
stackexchange_codegolf
Let's say you have a stack, which at the start contains a b c in this order (a is on the top). You are given the required output stack, in any reasonable format (a list, a string, etc.), e.g. [a, c, b] (here a is on the top, below it c and below it b). You can also take the input reversed if you want, e.g. [b, c, a] wh...
stackexchange_codegolf
Although there was a hangman competition before, I don't feel it was beautiful enough. The challenge is to implement a clone of http://inventwithpython.com/chapter9.html but as in the previous competition you can input the list of words in any way you want. The main difference is therefore just that you have to draw ...
stackexchange_codegolf
Introduction The Hausdorff distance measures the difference between two subsets of a metric space. Intuitively, a metric space is just some set with a built-in distance function; in this challenge, we will use natural numbers with the ordinary distance d(a, b) := abs(a - b). The Hausdorff distance between two non-empty...
stackexchange_codegolf
"Buzzing" Bill is a well respected beaver. He is the hardest working in his home dam. He was a strong beaver and was able to lift more logs than anyone at the dam. Unfortunately Buzzing Bill's career came to an end in a tragic accident. Being such a prominent figure in his town, the Beaver newspaper wanted to write a ...
stackexchange_codegolf
Your challenge is simple: write as long of a pristine program as possible in the language of your choice using only unique bytes. (The full definition of a pristine program, copied from that link, is at the bottom of this question.) That's right, no strings attached. Your code doesn't have to do anything at all, just r...
stackexchange_codegolf
The new weather predicting supercomputer has arrived, and it doesn't work. In the meantime your boss wants you to buy the technicians some time by faking the daily wind maps. Your task is to draw a grid of arrows representing wind direction. The grid is: made up of 15px square tiles 8 tiles by 8 tiles 120px square tot...
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
Input A single hex 6-digit colour code, capital letter, without #. Can also be a 24-bit integer if you prefer. Output The closest HTML color name (e.g red, or dark-salmon, as defined as https://www.w3schools.com/colors/colors_names.asp or see below). Distance is defined by summing the difference in red, green and blue ...
stackexchange_codegolf
An office (let's call it "The Office") is going to cut down on wasted time in 2019 by consolidating office birthday parties. Any two people with a birthday between Monday and Friday (inclusive) of the same week will be celebrated with a Shared Birthday Party some time that week. People whose birthdays fall on a Saturda...
stackexchange_codegolf
Note This is the encryption challenge. The decryption challenge can be found here. Challenge The challenge is to encrypt a given string, using the rules as specified below. The string will only contain lowercase alphabets, digits, and/or blank spaces. Equivalent of a Character Now, firstly you would need to know how to...
stackexchange_codegolf
This challenge is based on Downgoat's Adjust your chair. Challenge You just adjusted your new chair! It fits you perfectly. However, the wheel is squeaky and you know the repair people will change the adjustment. Problem is, you don't have a ruler, so you'll have to write a program to measure it for you. The repair pe...
stackexchange_codegolf
Qat is a tool that lets you search for words matching a given pattern, often used by crossword and other word puzzle writers and solvers. In this challenge, you will have to implement a specific part of Qat, namely a subset of the "equation solver". Equations The output of a Qat query depends on the dictionary you use ...
stackexchange_codegolf
An old test for programmers, taken from here (Note: in italian). Along a road (denoted by '_'), there is a Magical Piper (denoted by 'P') and several mice (represented by the two characters 'o' and '~', that denote respectively the head and the tail of the small rodents). Write a program that prints how many mice are g...
stackexchange_codegolf
Let's say we have a non-negative integer that is "hefty" (that is, "heavy") if its average digit value is greater than 7. The number 6959 is "hefty" because: (6 + 9 + 5 + 9) / 4 = 7.5 The number 1234 is not, because: (1 + 2 + 3 + 4) / 4 = 2.5 Write a function, in any language, HeftyDecimalCount(a, b) which, when prov...
stackexchange_codegolf
Write a program that converts a decimal to a mixed, simplified fraction. Sample input: 5.2 Sample output: 5 + (1/5) The code with the shortest length in bytes wins.
stackexchange_codegolf
Do you know Icy Tower ? Here is a gameplay example of what i'm talking about The game concept is simple : you play as Harold the Homeboy, and your goal is to jump from floors to floors to go as high as possible without falling and getting off-screen ( the camera goes higher following you or at a speed that gets faster ...
stackexchange_codegolf
In this code-golf challenge, you must output an ascii-art of a random die roll. like this: ________ /\ \ / \ 6 \ { 4 }-------} \ / 5 / \/_______/ Please note that: ________ /\ \ / \ 3 \ { 4 }-------} \ / 5 / \/_______/ is invalid output, because that is not a possib...
stackexchange_codegolf
Input A string s of printable ASCII characters, newlines, and spaces (0x20 ( ) to 0x7E (~)), and a non-negative integer n. Challenge To write a program that outputs either another program, or s depending on n. If n = 1, Then your code should output code which outputs s. If n = 2, Your code should output code which outp...
stackexchange_codegolf
Related, but this only requires positive integers and does not have to be commutative The Cantor Pairing Function is described in this Wikipedia article. Essentially, it is an operation such that when it is applied to two values X and Y, one can obtain the original values X and Y given the result. Your task is to desig...
stackexchange_codegolf
/o\ Jimmy has been receiving a lot of attention on this site recently and it has caused Jimmy to get a little stressed. The bodybuilder Jimmys /-o-\ started bad mouthing the OG / acrobat /o\ Jimmys saying they are way cooler because they are bigger. But of course the acrobat Jimmys thinks they are way cooler since afte...
stackexchange_codegolf
Overview Given a list of fireworks a-z and times 3-78, arrange them with fuses to make them all light up at the correct time. A line of input is given as space separated letters and numbers: a 3 b 6 c 6 d 8 e 9 f 9 That example shows that firework a need to light at time 3, b and c both at 6, d at 8, with e and f both...
stackexchange_codegolf
The riddle In yesterday's newspaper, I found a puzzle in which a Rook should start in the lower-left corner of a 12x12 checkerboard and then, during a round trip, visit each field exactly once except for a selection which must be avoided. The puzzle came with a picture that identified the fields to be avoided as black:...
stackexchange_codegolf
Input _ _ _ _ _ _ _ _ | _| _||_||_ |_ ||_||_|| | ||_ _| | _||_| ||_| _||_| output 1234567890 Rules Code golf - shortest code wins. Input will be given as a 3-line string with each line separated by a newline, or as 3 separate strings. Each line is guaranteed to be a multiple of 3 characters lo...
stackexchange_codegolf
Dotcomma is a simple esolang I made a while ago that only uses four operators: [.,]. In this challenge, you'll determine if a dotcomma program consisting only of [.] halts. Without ,, there is no input, output, or queue, making this challenge possible. Blocks: Any code wrapped in [] is a block. All blocks and operators...
stackexchange_codegolf
This year my age is a prime number, and so is this year. This conjunction will repeat in 10 years and again in 12. If I live to 100, I will lived exactly 11 years in which my age and the year are both prime. My condolences to those of you born in odd-numbered years, who will experience this phenomenon at most once if a...
stackexchange_codegolf
Last time when I tried to come up with something easy that wasn't a duplicate, it ended up being way too hard.. So hopefully this time it's indeed something newcomers can try as well. Input: An array/list with integers/decimals. (Or a string representing an array with integers/decimals.) Output: Loop through the number...
stackexchange_codegolf
Define a 1-indexed sequence as follows: A083569(1) = 1 A083569(n) where n is an integer greater than 1, is the smallest integer m not occurring earlier such that m+n is a prime number. Your task is to take in n and return A083569(n). n A083569(n) 1 1 2 3 3 2 4 7 5 6 6 5 7 4 8 9 9 8 10 13 11 12 12 ...
stackexchange_codegolf
It's obviously ellipsisessieses. Inspired by a chat message. Your challenge Given a list or space or comma-separated string of words, ellipsisessiesesify them. To ellipsisessieses-ify a word: Start with the word. Add the first letter of the original word to the end. Add 2 of the last letter of the original word to the...
stackexchange_codegolf
Input will consist of the following characters: ^: Go up one v: Go down one ▲ or k: Go up two ▼ or j: Go down two For example, the following input: ^^▲^v▼▲^^v would produce the following output: ^ ^ ^ v ▲ v ▲ ^ ▼ ^ Escape sequences that move the cursor such as \e[B are not allowed. You must produ...
stackexchange_codegolf
If you have ever looked at an objdump of a C++ program, you have likely seen something like this: _ZN3foo3bar3bazI6sampleEE3quxvi3foo This is a C++ mangled symbol, which encodes the namespaces, classes, and function/template arguments, using the Itanium ABI. Specifically, it is for the following function: void foo::ba...
stackexchange_codegolf
Santa's Decision: In this challenge, you will help Santa Claus decide whether somebody on their list has been naughty or nice, and subsequently get coal or toys. But unfortunately, Santa is unorganised, in some of his entries, the naughty, nice and name fields are in the wrong order. Input Input will come in the follo...
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
The task is to to compete for the shortest regex (in bytes) in your preferred programming language which can distinguish between English and Spanish with minimum 60% 90% accuracy. Silvio Mayolo's submission (pinned as Best Answer) has secured his spot as the winner of original contest against any chance of being contes...
stackexchange_codegolf
Task Your task is to draw these beautiful oak trees: 1 -> @@@ @@@@@ @|.|@ _|_|_ 2 -> @@ @@@@@@ @@@@@@@@ @@| .|@@ | | __|__|__ 3 -> @@@@@ @@@@@@@@@ @@@@@@@@@@@ @@@| |@@@ @| .|@ | | ___|___|___ 4 -> @@ @@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@@ @@@@| |@@@@ @@| .|@@ | | | ...
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
Write a program or function that takes in a positive integer N and outputs the first N numbers of this amplifying zigzag pattern, using only the lines needed: 26 25 27 . 10 ...
stackexchange_codegolf
The input for the continuous knapsack problem is as follows. For each item 1...n we are given a positive weight and profit. Overall we are also given a positive capacity which is the maximum weight we can carry. The goal is to pick items so that the profit is maximized without exceeding the capacity. This is hard if ...
stackexchange_codegolf
Given a positive integer input N, output the two non-negative numbers, a and b, where a < b, with the lowest possible mean value that will result in the number N being part of the recurring relation sequence: f(0) = a f(1) = b f(n) = f(n-2)+f(n-1) In case there are more than one solution where the mean of a and b are ...
stackexchange_codegolf
Since I saw the first one a few years ago, I always was subjugated by this kind of word clock where the time is actually spelled out by words being lit up or not into a meaningful sentence. The text displayed on that clock is the following. IT IS HALF TEN QUARTER TWENTY FIVE MINUTES TO PAST TWO THREE ONE FOUR FIVE SIX...
stackexchange_codegolf
Given a lower case string. Ex: s = 'abcdefghijklmnopqrstuvwxyz' The goal is to make every other vowel uppercase. Desired output here: abcdEfghijklmnOpqrstuvwxyz As you can see, from aeiou, \$`e`\$ and \$`o`\$ get uppercased. For aeiou, the desired output is: aEiOu There are only lowercase characters in the strings i...
stackexchange_codegolf
If \$R\$ runners were to run a race, in how many orders could they finish such that exactly \$T\$ runners tie? Challenge Given a positive integer \$R\$ and a non-negative integer \$0\leq T\leq {R}\$ produce the number of possible finishing orders of a race with \$R\$ runners of which \$T\$ tied. Note, however, that run...
stackexchange_codegolf
It's my friend's birthday soon and since he is a programmer and ASCII art lover, I thought I'd make him some ASCII cake! Sadly, I keep forgetting his current age, so I would like to have a program for my ASCII oven, that bakes a cake with a specified number of candles, so I don't have to do it myself again if I am wron...
stackexchange_codegolf
A positive integer \$x\$ is an \$n\$-perfect number if \$\sigma(x) = nx\$, where \$\sigma(x)\$ is the divisor sum function. For example, \$120\$ is a \$3\$-perfect number because its divisors sum to \$360\$: $$360 = 3\times120 = 1+2+3+4+5+6+8+10+12+15+20+24+30+40+60+120$$ and $$926073336514623897600 = 6\times1543455560...
stackexchange_codegolf
Given a ASCII string containing control characters, compute what it should look like when printed to a terminal. Imagining the behaviour of a cursor, this is how to treat each character in the input: 0x08 backspace (\b): go left one (if already at the start of a line, do not go up) 0x09 horizontal tab (\t): go right o...
stackexchange_codegolf
You love lunch. However, you are on a diet and want to make sure you don't accidentally eat lunch twice in one day. So you need to make a program to help you make sure. However, one complication is that you eat lunch on a very weird schedule. The time you eat lunch at is MONTH:DAY PM (you can use UTC or localized time ...
stackexchange_codegolf
Introduction A radix tree, also known as compressed trie or compressed prefix tree, is a tree-like data structure for storing a set of strings. The edges of the tree are labeled by nonempty strings, and each node is either terminal or nonterminal. The strings that the tree contains are exactly the labels of all paths f...
stackexchange_codegolf
Objective Given a date, spell it out in Romanized Japanese. I/O Format The input format is flexible. The output format is <month spelling> <day spelling>; note the space. You can freely mix cases in output. You may output trailing newline. Mapping Months Month Spelling January Ichigatsu February Nigatsu Mar...
stackexchange_codegolf
Inspired by the challenge A pile of weights. Challenge Given an integer as a weight in pounds, output an ASCII barbell that can represent the weight. Weights will come in the form of the barbell (which will weigh 45lbs) and plates with the following weights: 45lbs, 35lbs, 25lbs, 10lbs, and 5lbs. Weights will be repre...
stackexchange_codegolf
Consider a square of printable ASCII characters (code points 0x20 to 0x7E) for side length N, like the following (here, N = 6): =\ g \ 7 m+y "g L ~ e> PHq We also require each row and each column to contain at least 1 space and 1 non-space character. (The above example satisfies this.) We define the neg...
stackexchange_codegolf
You work at a bakery, and every day you make pastries. You make 100 of each of several different types. However customers are less predictable. Some days they order all of one kind of pastry and you run out, some days they order hardly any and you have some left over. So your boss has made up a chart which tells you ho...
stackexchange_codegolf
Write the shortest possible program to remove all partial matched duplicates from a list and only retain the longest lines. Sort order does not matter. For following inputs, the intent is to search for the string reminder followed by a number and retain the longest unique reminder + number lines. Some rules reminder i...
stackexchange_codegolf
Cyclically self-describing lists A list \$L\$ of positive integers is cyclically self-describing, if the following conditions hold. \$L\$ is nonempty. The first and last elements of \$L\$ are different. If you split \$L\$ into runs of equal elements, the element of each run equals the length of the next run, and the e...
stackexchange_codegolf
Given an integer \$ n \ge 2 \$, you need to calculate \$ \lfloor n \log_2(n) \rfloor \$, assuming all integers in your language are unbounded. However, you may not ignore floating-point errors - for example, in python lambda n:int(n*math.log2(n)) is an invalid solution, because for example for n=10**15, int(n*math.log2...
stackexchange_codegolf
I honestly can't believe this challenge does not already exist. The challenge Write a function. The specifics Your program must define some sort of callable function. This includes anything commonly known as a function, a lambda function, or a subroutine. All of these types of callables will be referred to as a "funct...
stackexchange_codegolf
Two numbers are considered amicable if the proper divisor sum of the first is the same as the second number, the second number's proper divisor sum is equal to the first number, and the first and second numbers aren't equal. \$s(x)\$ represents the aliquot sum or proper divisor sum of \$x\$. 220 and 284 are amicable be...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. challenge idea by emanresu A Santa has a bunch of presents wrapped in cuboid boxes of various sizes. As his sled flies above a chimney, a stack of presents will be automatically dropped through it. Santa wants to carefully choose the p...
stackexchange_codegolf
Challenge Given a positive integer, determine whether that number is currently being used to represent a question on PPCG. The question must not have been removed, but may be open or closed. The number is the one being used in the URL of the question, such as: https://codegolf.stackexchange.com/questions/[input] Note...
stackexchange_codegolf