instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
The magic music box (MMB) This explains the motivation for the challenge, feel free to ignore. The magic music box is a word game played by a group of people, where one is the owner of the magic music box and the other people are trying to put words inside the magic music box. Rules for the game with humans: the game g...
stackexchange_codegolf
Let's solve the same task as in this challenge but faster! Input: a non-empty string containing letters a-z Output: the length of a longest (contiguous) substring in which all letters are different Time and space complexity: O(n). The number of letters in the alphabet is 26, or O(1). Make sure you understand how your l...
stackexchange_codegolf
Task Given a winning Wordle play results (clues), the target ("secret") word and a list of words, output a possible sequence of words leading to such results. The words in the list will be distinct and so should be the output. You may assume that for given inputs a solution exists. If there is more than one, you may ou...
stackexchange_codegolf
Challenge Description: Write a program that asks the user for input. The user will enter Good or Bad. You do not have to support any other input. If the user enters Good, print Bad and vice versa (to stdout etc). Notes: 1) You cannot use any other pair of two words. 2) Your program only has to ask and print once. 3) Yo...
stackexchange_codegolf
If you don't know what a queen is in chess, it doesn't matter much; it's just a name :) Your input will be a square of arbitrary width and height containing some amount of queens. The input board will look like this (this board has a width and height of 8): ...Q.... ......Q. ..Q..... .......Q .Q...... ....Q... Q..........
stackexchange_codegolf
Background You know how in text editors and just text fields in general, there's always that blinking bar where you type? Yeah, simulate typing there. You'll be given 3 inputs: The current text field, the position of the cursor, and the input sequence. Here's an example: Hello, World! 5 [U];[U];[B];[B];[B];[B];[B];[U];...
stackexchange_codegolf
Given a positive input \$n > 0\$, output the amout of two types based on their rarity. The two types are called \$A\$ and \$B\$, we know the followings: \$n\$ is a limited input and the maximum is \$nmax\$ At the start \$B\$ is twice as rare as \$A\$ As the presence of \$A\$ increade the rarity of \$B\$ decreases When...
stackexchange_codegolf
It's time for CGCC to demonstrate our musical talent! In this challenge, you're going to compose songs while keeping your byte count as small as possible. On Day 0, multiple answerers will post a function or program that outputs nothing/an empty string. They will also give a single line that next day's answers must out...
stackexchange_codegolf
Who doesn't love action movies with fast noisy cars, especially those with a lot of crashes? Who doesn't love action shots in ascii art? The scene is: Two cars are starting at opposite sides of a straight road (with 60 spaces between). They start driving towards each other at constant speeds. The car to the left drives...
stackexchange_codegolf
Some numbers, such as \$14241\$, are palindromes in base 10: if you write the digits in reverse order, you get the same number. Some numbers are the sum of 2 palindromes; for example, \$110=88+22\$, or \$2380=939+1441\$. For other numbers, 2 palindromes are not enough; for example, 21 cannot be written as the sum of 2 ...
stackexchange_codegolf
Related to this question. A room is defined to be a (not necessarily convex) non-intersecting polygon, expressed as an ordered list of 2-dimensional coordinates. A sufficiently bright lightbulb is placed at a specific point inside the room, and emits light in every direction. Your task is to find the total illuminated ...
stackexchange_codegolf
Take an array which consists of positive integers or arrays, output if it only contains 2s. Output should be a truthy or falsey value (Sorry if this destroys answers) Truthy Test Cases [2] [2,2] [[2],[2,2],2] [] [[],[]] Falsey Test Cases [1] [22] [2,2,2,1] [[1,2],2] Standard Loopholes Are forbidden. Default IO rules ...
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
Background SKI combinator calculus, or simply SKI calculus, is a system similar to lambda calculus, except that SKI calculus uses a small set of combinators, namely S, K, and I instead of lambda abstraction. Unlike lambda calculus, beta reduction is possible only when a combinator is given enough arguments to reduce. T...
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
Every programmer knows that rectangles □ are really fun. To exacerbate this fun, these cute and fuzzy diagrams can be transformed into groups of interwoven brackets. This challenge is the inverse of my previous. Let's say you have a group of interlocking rectangles like so: +------------+ | | +--+-+ ...
stackexchange_codegolf
What are some tips on how to shorten this code even further? The code is meant to compute the parallel resistance of an electric circuit. Using scanf float r;main(){float a;scanf("%f",&a);r+=1/a;printf("%f",1/r);main();} Using command-line arguments #include<stdlib.h> float r;main(c,v)char**v;{for(int i=1;i<c;)r+=1/at...
stackexchange_codegolf
Chained Binary Operations Here's a challenge involving truth tables and binary operations. For this specific challenge, your task is to use the following table of operations: To create a function that takes in two inputs f(p,a), where p is the initial truthy/falsy value and a is a list of tuples representing multiple ...
stackexchange_codegolf
Are you tired of languages with built in quining techniques? Your challenge, should you choose to accept it, is to add a built-in quine feature to the language of your choice. Task Given some programming language X, you should define A language X′ that is a subset of X. A quine command string Q. (This is a string of ...
stackexchange_codegolf
Sometimes when writing brainfuck code, you feel the need to make it longer than needed to encourage debugging. You could do it by just plopping a >< in there, but what fun is that? You'll need something longer and less NOPey to confuse anybody reading your code. Quick introduction to Brainfuck Brainfuck is an esoteric...
stackexchange_codegolf
Unless you have a userscript that modifies the site's design (or even if so), you should have noticed that we have our site design! (It's November now) So, to celebrate, let's make a program that retroactively applies this design (oversimplified, of course)! So, the most important changes are: our new name is now Code...
stackexchange_codegolf
In this challenge, we render Ascii user interfaces. +----------------------+ |+-----------++-------+| ||<- Previous||Next ->|| |+-----------++-------+| |== The title == | | | |Lorem ipsum dolor | |sit amet... | |+--------------+ | ||Post a comment| | |+--------------+ ...
stackexchange_codegolf
Consider the function Remove(n, startIndex, count) that removes count digits from the number n starting from the digit at position startIndex. Examples: Remove(1234, 1, 1) = 234 Remove(123456, 2, 3) = 156 Remove(1507, 1, 2) = 07 = 7 Remove(1234, 1, 4) = 0 We will call the prime number X fragile if every possible Remov...
stackexchange_codegolf
This challenge will be based on an R language trivia: every release is named and it's a reference to Peanuts comic strips (see here and here). Task Given a release name, output its number. For reference, use the below list: Great Pumpkin 2.14.0 December Snowflakes 2.14.1 Gift-Getting Season 2.14....
stackexchange_codegolf
This question is tricky (and in particular harder than Which big number is bigger?), for those who like more challenging puzzles. Input Integers a1, a2, a3, a4, a5, b1, b2, b3, b4, b5 each in the range 1 to 10. Output True if a1^(a2^(a3^(a4^a5))) > b1^(b2^(b3^(b4^b5))) and False otherwise. ^ is exponentiation in this...
stackexchange_codegolf
Background You are planning your trip away from the Diamond City, and must travel through Diamond Road. However, Diamond Road branches away from Diamond City to different locations. Out of curiosity, you'd like to measure the total distance of unique roads used for all paths. We define a path as a string that only cont...
stackexchange_codegolf
Inspiration Given a positive integer \$1 \le n \le 9\$, output all positive \$n\$-digit integers \$i\$ for which the following is true: Each digit from \$1\$ to \$n\$ appears exactly once in \$i\$. Therefore, \$i\$'s digits are a permutation of the digits from \$1\$ to \$n\$. \$i\$ is divisible by \$n\$ Removing the r...
stackexchange_codegolf
Background You are sitting in chemistry class and your friend keep sending you these strange letters. It is your job to decrypt the messages into words. This is the inverse of this challenge. The Challenge Input: A list or a string of integers from 1 to 118. Output: The words for each chemical element if possible. Ot...
stackexchange_codegolf
Given a list (array) of names, your challenge is to join the items using some glue and abbreviate the longest items first until the joined string fits a maximum length. And output that string. Since the glue is part of the final string, the length of the glue is included too Abbreviation is done using the … character ...
stackexchange_codegolf
This construction is a way of representing the Natural Numbers. In this representation, 0 is defined as the empty set and for all other numbers, n is the union of {0} and {n-1}. For example to construct 3 we can follow the algorithm: 3 = {ø, 2} = {ø, {ø, 1}} = {ø, {ø, {ø}}} Task As you may have guessed your task is t...
stackexchange_codegolf
Introduction The EKG sequence begins with 1 and 2, then the rule is that the next term is the smallest positive integer not already in the sequence and whose common factor with the last term is greater than 1 (they are not coprimes). The first terms are: 1, 2, 4, 6, 3, 9, 12, 8, 10, 5, 15, ... It's called EKG because...
stackexchange_codegolf
A polyiamond of size \$n\$ is a contiguous shape formed by joining \$n\$ equilateral triangles side by side. Your output should consist of two distinct characters, plus whitespace as necessary (▲ and ▼ work great!). Trailing whitespace is acceptable. You may use any other characters - but you may count ▲▼ as 1 byte e...
stackexchange_codegolf
Sandbox For the purposes of the current task, a cube of unit length is rendered in oblique projection with ASCII symbols as follows: +-----+ / /| +-----+ | | | + | |/ +-----+ + for the vertices. - for the X edges. The unit length along X is represented by five - between two vertices. | for the Y edges....
stackexchange_codegolf
...and real golf for my code friends. This is a challenge based on a one year old XKCD comic which consists mostly of toasts (parodies of the first in the comic) following a distinct pattern, but with some slight variation. Your task is to write a program (or function) that takes the first half of any toast from the ...
stackexchange_codegolf
In atomic physics and quantum chemistry, the electron configuration is the distribution of electrons of an atom in atomic orbitals. For example, the electron configuration of the neon atom is 1s2 2s2 2p6 (From Wikipedia) Challenge Your challenge is to take a number representing the atomic number of an element and out...
stackexchange_codegolf
John, a knight wants to kill a dragon to escape the castle! The dragon has A heads and B tails. He knows, that: if you cut off one tail, two new tails grow if you cut off two tails, one new head grows if you cut off one head, one new tail grows if you cut off two heads, nothing grows To defeat the dragon, John needs ...
stackexchange_codegolf
I asked random.org for 128 random integers between 0 and 232 - 1. Since the random number generator was so eager to give the first 64 numbers first, they're obviously more random than the other 64. Write a full program or function that returns a truthy result when one of the following 64 integers is input: [1386551069,...
stackexchange_codegolf
Fizz Buzz is a common challenge given during interviews. The challenge goes something like this: Write a program that prints the numbers from 1 to n. If a number is divisible by 3, write Fizz instead. If a number is divisible by 5, write Buzz instead. However, if the number is divisible by both 3 and 5, write FizzBuzz...
stackexchange_codegolf
Print the dates of all the Sundays in 2017 in the following format : dd.mm.yyyy. Expected Output: 01.01.2017 08.01.2017 15.01.2017 22.01.2017 29.01.2017 05.02.2017 12.02.2017 19.02.2017 26.02.2017 05.03.2017 12.03.2017 19.03.2017 26.03.2017 02.04.2017 09.04.2017 16.04.2017 23.04.2017 30.04.2017 07.05.2017 14.05.2017 21...
stackexchange_codegolf
Write a program or function that, given an integer n, construct an array with n dimensions of n length, where each element is an identifier of its own coordinates. That is, starting with one array, populate it with n arrays, where each of those contain n more arrays, up to a depth of n-1. The elements of the deepest ar...
stackexchange_codegolf
Problem Description We all love a Twix (because it is the best candy), but this is the kids' first Halloween --- we gotta grab at least one of each type of candy for them. Each Halloween all the residents of Numberline avenue send out an email saying what types of candy they'll be giving away this year. Oh! And we live...
stackexchange_codegolf
Ah, Tinder . . . the app that takes the code golf approach to online dating. With just a few well-chosen right swipes and a bit of luck (or a cute puppy pic), you too could have more matches than /(?!)/. This code-golf challenge involves Tinder dates of a very different kind. Given a Tinder version number as input, hoo...
stackexchange_codegolf
Task Write a program/function that when given 3 positive integers \$a, b\$ and \$m\$ as input outputs a positive integer \$x\$ such that \$a^x\equiv b\ (\text{mod}\ m)\$ or that no such \$x\$ exists. A reference implementation can be found here. Constraints You can expect \$a\$ and \$b\$ to be less than \$m\$. Scoring ...
stackexchange_codegolf
(language-specific challenge) Specification: Language: ECMAScript, any version[1] Challenge: Somewhat like python's itertools.groupBy: Your function Array.group(f) should take as input an "equivalence function" f whose output defines our notion of an "equivalence key" for array elements (like a sort key). The return va...
stackexchange_codegolf
Introduction: Let's take a look at a standard Calculator in Windows: For this challenge, we'll only look at the following buttons, and ignore everything else: 7 8 9 / 4 5 6 * 1 2 3 - 0 0 . + Challenge: Input: You will receive two inputs: One is something to indicate the rotation in increments of 90 degrees The other...
stackexchange_codegolf
Definition Given some string return an integer whose digits are the number ocurrences of a-z (case insensitive, in alphabetical order) in that string. Any character with 0 instances is skipped. Characters with 10 or more instances will define 2 or more digits of the returned integer. For example, aaaaaaaaaaaaaaaaaaaaaa...
stackexchange_codegolf
This is the followup question to this previous CodeGolf question about Covering Arrays (the details of what Covering Arrays are and how they are formatted at the NIST website are there). In this challenge, we won't just be validating covering arrays - we will try to minimize them. Finding minimal Covering Arrays, in ge...
stackexchange_codegolf
We often see music videos on Youtube. Many Youtube channels that host music videos are "powered by VEVO". Those can be easily identified by both embedding VEVO at their video thumbnails and appending VEVO to their channel name. Now write some code to test whether a string given by user is a VEVO user account or not. Re...
stackexchange_codegolf
What happens when the CapsLock key on your keyboard doesn't have a notch in it? "This hPPENS." The goal of this program is to consistently emulate keyboard misses where each A press is replaced with CapsLock. Uppercase 'A's from the source should yield the same effect. When CapsLock is enabled, capitalization is revers...
stackexchange_codegolf
Introduction One day, you were just relaxing in your office in the CIA, when suddenly you see an alert on your computer. Your programs have just intercepted hundreds of coded messages! A quick examination reveals the rule for encoding, but you need a program in order to decode fast. Challenge You will be given a list...
stackexchange_codegolf
Given a random code written using Brainfuck commands. You program should translate that code into the following ascii art: each Brainfuck command represents as 5x9 array of A and B symbols. All commands are concatenated with 5x3 arrays of A symbols. Symbols A and B you choose yourself. For example, when input is ><+,.[...
stackexchange_codegolf
Your task is to build a natural number using the fewest number of ones and only the operators + or -. For example, the number seven can be written 1+1+1+1+1+1+1=7, but it can also be written as 11-1-1-1-1=7. The first one uses 7 ones, while the latter only uses 6. Your task is to return the minimum number of ones that ...
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
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
If you like this, consider participating in: The Official Dyalog APL 2016 Year Game The monthly Dyalog APL 2017 Code Golf Challenge Make 12 snippets/expressions, in the same language, that result in the numbers 0 through 10, and 42 respectively, but without writing any literal numeric, string, or character data. Bui...
stackexchange_codegolf
For more MtG-goodness: Magic: The Gathering Combat with Abilities Premise: In Magic: the Gathering, you cast spells by paying their mana cost by tapping lands for the required amount. These lands can produce one of the five colors which are: White (W) Blue (U) Black (B) Red (R) Green (G) The cost is made up of two...
stackexchange_codegolf
You are given a square matrix of width \$\ge2\$, containing square numbers \$\ge1\$. Your task is to make all square numbers 'explode' until all of them have disappeared. You must print or return the final matrix. More specifically: Look for the highest square \$x^2\$ in the matrix. Look for its smallest adjacent neig...
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
Background: Take this input as an example: 1 1 2 1 1 2 1 3 1 3 If you look only at the first few digits, between 1 1 2 and 1 1 2 1 1 2 1, this input appears to consist of the pattern 1 1 2 repeating indefinitely. This would make its period 3, as there are 3 numbers in the pattern. Given only the first number, the peri...
stackexchange_codegolf
For this challenge, submissions should be a program or function shaped like a right triangle, which produces a right triangle of the same size. What is a right triangle? For this challenge, a right triangle consists of 1 or more lines, each containing a number of characters (assume all non-newline characters are the sa...
stackexchange_codegolf
For any ragged list its dimensions will be a list of non-negative integers defined as follows: Elements that are not a list will have dimensions \$\textbf{[}\,\,\textbf{]}\$. An empty list has dimensions \$[0]\$. An \$n\$ dimensional list \$L\$ of length \$x\$ has dimensions \$x : k\$ where \$k\$ is the element wise m...
stackexchange_codegolf
Background K functions have a feature called projection, which is essentially partial application of values to a function. The syntax for projections is a natural extension of the regular function call syntax: f[1;2;3] / call a ternary function f with three arguments 1, 2, 3 f[1;2;] / the third argument is missi...
stackexchange_codegolf
What is Permutation Coefficient Permutation refers to the process of arranging all the members of a given set to form a sequence. The number of permutations on a set of n elements is given by n! , where “!” represents factorial. The Permutation Coefficient represented by P(n, k) is used to represent the number of ways ...
stackexchange_codegolf
What general tips do you have for golfing in BQN? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to BQN (e.g. "remove comments" is not an answer). Please post one tip per answer. At the moment of writing, the official BQN site is the most comprehensive res...
stackexchange_codegolf
A radiation-hardened quine can take a hit and stay standing, but nobody ever said that the quine can't be a wuss about it. For this challenge, you should write a quine that: If no characters are removed, prints its source code normally. Iff any one character is removed, prints the original program's source code, follo...
stackexchange_codegolf
Challenge Write \$2 \le n \le 10\$ distinct, valid non-halting full programs in your language of choice. If all of them are concatenated in order, the resulting full program should be a valid halting program, but if any of them are left out, the result should still be a valid non-halting program. More formally, write \...
stackexchange_codegolf
CHALLENGE STATUS: OPEN Comment, open a PR, or otherwise yell at me if I'm missing your bot. Prisoner's dilemma ... with three choices. Crazy, huh? Here's our payoff matrix. Player A on the left, B on the top A,B| C | N | D ---|---|---|--- C |3,3|4,1|0,5 N |1,4|2,2|3,2 D |5,0|2,3|1,1 The payoff matrix is engineered...
stackexchange_codegolf
You are the electoral strategist for a sudden late entrant in the 2020 US presidental election. Your task: print out the names of states* your candidate will win, totalling at least 270 electoral college votes. Background Each state (and Washington DC) in the US system has an arbitrary number of "electoral college vot...
stackexchange_codegolf
ASCII art is fun. Modern text editors are very good at manipulating text. Are modern programming languages up to the task? One common task in ASCII art manipulation is to crop text to a rectangle between two characters. This is the task you must implement in this challenge. Details Your program will take 3 inputs: t...
stackexchange_codegolf
Hearts is a 4-player game that uses the following scoring rules: Everyone starts with score 0. Each round every player gets a non-negative amount of points. The sum of the points is 26, and at least one player gets 13 or more points.1 The points are then added to the players' score except if a player gets 26 points. I...
stackexchange_codegolf
I have this problem where I listen to so much music that I can never remember what songs are called. But even if I remember the lyrics, I won't always know the song's name. But lucky for me, there's a pretty neat formula to determine¹ the title of a song just based on its lyrics. I'll define the way a song title can be...
stackexchange_codegolf
Sandbox Given a boolean matrix representing my grass field, sheep length \$n\$ and wool thickness \$k\$, you will have to count my sheep. A sheep is a single independent unbroken line of sheep length \$n\$ and thickness \$k\$. #|##|# | # #| | #|# are all valid sheep for \$n=2,k=1.\$ ##|###|## | ## ##|###| ## | ## ...
stackexchange_codegolf
A number spiral is an infinite grid whose upper-left square has number 1. Here are the first five layers of the spiral: Your task is to find out the number in row y and column x. Example: Input: 2 3 Out : 8 Input: 1 1 Out : 1 Input: 4 2 Out : 15 Note: Any programming language is allowed. This is a code-golf cha...
stackexchange_codegolf
One of your acquaintances has a hobby of making make-shift electrical gadgets using various types of batteries. However, since they're thrifty, they want to use as few batteries as possible for their projects. This challenge uses several types of batteries; your job is to output the fewest number of batteries that will...
stackexchange_codegolf
As in this challenge, the task is to generate the vertices of a polyhedron. The polyhedron here is the one obtained by dividing a regular icosahedron's triangular faces into smaller triangles so that each edge is divided into \$b\$ segments (denoted \$\{3,5+\}_{b,0}\$ here) and projecting onto the unit sphere. Your pro...
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
Your task is to print the following: I have a pen I have an apple Uh! Apple pen! I have a pen I have pineapple Uh! Pineapple pen! Apple pen... Pineapple pen... Uh! Pen Pineapple Apple Pen! Remember, this is code-golf, so the code with the smallest number of bytes wins. Leaderboards Here is a Stack Snippet to generat...
stackexchange_codegolf
Given two numbers, print a page with an "X" in the specified location (±10%). The numbers must be either percentages or fractions of the page's print area dimensions, e.g. [25,75] or ["15%","0%"] or [0.33,1]. You do not have to consider margins. Just remember to state which number is width, and which is height, and whi...
stackexchange_codegolf
For today's challenge, you must write a program or function that alternates the case of a string. However, you must ignore non-alphabetic characters. This means that every alphabetic character must have a different case than the preceding and following alphabetic character. This is slightly more complex than uppercasin...
stackexchange_codegolf
There is a challenge Let's play tennis by Daniel. He proposes to place a court in the North-South direction. My proposal is to create a court to play tennis in the East-West direction too. You have to print a tennis court, but you have to do it in the fewest bytes possible because of confidential reasons. Tennis court...
stackexchange_codegolf
Given a string of text that contains lowercase letters, encode it as follows: (I will be using abcdef) First, encode the alphabet cipher, but this time, 0-indexed. 000102030405 Reverse it. 504030201000 Loop through the string. If the next two digits together are 25 or smaller, encode those two numbers. 5 04 03 02 01...
stackexchange_codegolf
I am writing a golfing language. Do you suggest variables, stack(s), tapes, registers, etc for storage in a code-golf language? What about implicit input? Rough definitions: A variable is simply a name (usually one character long in golfing languages) that a value can be assigned to, and later retrieved by that name....
stackexchange_codegolf
Given string s of even length as input, randomly capitalize exactly half of the letters. You can assume the input will always be a non-zero, even length You can assume the input will consist of only lowercase letters ([a-z]) Exactly half of the letters should be capitalized in the output Every permutation that has exa...
stackexchange_codegolf
Weirdo Incorporates have a weird way of grading their staffs by the number of days they were present in the office: 0 - 13 : F 14 - 170 : E 171 - 180 : D 181 - 294 : C 295 - 300 : B 301 - 365 : A Note: The range is inclusive (i.e. 0-13 means 0 days and 13 days both will evaluate as grade 'F'). Objective: Write ...
stackexchange_codegolf
This challenge is a riff on Dion's challenge "Is this a rectangle?". The goal of this challenge is to write a program to decide whether or not some collection of tuples of integers represents a hypercube of some dimension. Background A hypercube is a generalization of a square. A \$0\$-cube is a single point. A \$1\$...
stackexchange_codegolf
Inspired by This answer to a Puzzling question Background - exponentiation by squaring If you don't want to read the background, or don't understand it, there's a worked example in Java, linked at the bottom of the post. \$a^{2^{x+1}} = a^{2^{x}} * a^{2^{x}}\$ Therefore to find \$a^b\$ (where \$a\$ and \$b\$ are base-1...
stackexchange_codegolf
Introduction Don't worry - no knowledge in mathematics is needed. It is possible to just skip the motivation part, but I think it is nice if a puzzle has a background story. Since the title contains the number I there will be more puzzles of this kind, if you like them. Feedback is highly appreciated. I hope you have f...
stackexchange_codegolf
Stewie's Game of Life and Fatigue is quite similar to the more famous Conway's Game of Life. The universe of the Stewie's Game of Life and Fatigue (GoLF) is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of three possible states, alive, dead or tired. Every cell interacts with its...
stackexchange_codegolf
Inspired by this game Challenge: Given an ASCII art string representing a number, output that number. Example: Input: &&&& ##### .====.. .&&& $$$$$. %% %% % % . +. . @@@ . @@ . = . = . ???? +++. && &&. % % = = $$$ . @@@@@ # # . ===. .$$$$$ ...
stackexchange_codegolf
You're given a rectangular grid of the characters . and #, like this: .......... ..#....... ....#..#.. ...#...... .......... Your task is to fill the entire axis-aligned bounding box of the # with further #: .......... ..######.. ..######.. ..######.. .......... The axis-aligned bounding box is the smallest rectangle...
stackexchange_codegolf
The program must output the letter that is paired the most. For example, if your program was given the following string: "Sally's friend Bobby searched for seashells." it must output L because "ll" occurs twice, which is more frequent than the other pair "bb". Rules: If more than one letter has 1st place for occurre...
stackexchange_codegolf
You want to find the length shortest path between two points, on an 2d ASCII "map". The roads are made up of + characters, and the two endpoints are represented by #s (not counted in the length). This road can be arranged in any way, and any other characters can be ignored. You can assume the endpoints will always conn...
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
The goal is really simple. Receiving a string as input, parse all the HTML entities that correspond to the following characters (including their uppercase variants): áàãâäéèêëíìîïóòõôöúùûüýÿ Parsing rules: Each entity starts with & and ends with ; The first character after the & will be the modified character (letter...
stackexchange_codegolf
A common year is a year that is not a leap year and where the first and last day of the year are on the same day. A special common year is one that starts on a Monday and so ends on a Monday as well. Your challenge is to create a program/function that when given a year as input finds the nearest special common year, o...
stackexchange_codegolf
Write a program or function that will break ciphers, using as few bytes as possible. Task Given an encrypted message and a dictionary as input, output the decrypted message. The messages will be encrypted using a one-to-one character mapping, i.e. two characters can't both map to one, and vice versa. The message will o...
stackexchange_codegolf
We had a challenge on Multiplicative Persistence here. As a recap, to get a multiplicative persistence of a number, do these steps: Multiply all the digits of a number (in base \$10\$) Repeat Step 1 until you have a single digit left. Then count the number of iterations. More here on Numberphile: Numberphile "What's...
stackexchange_codegolf
While I was traveling in the future, I noticed a funny game among kids circa 2275. When they don't want their great-great-great-great-grand parents to understand what they're saying, they use the BIBABOBU speak. Obviously, I couldn't understand anything either with my pre-cyborg era brain and I felt (or technically: I ...
stackexchange_codegolf
This is my first challenge on ppcg! Input A string consisting of two different ascii characters. For example ABAABBAAAAAABBAAABAABBAABA Challenge The task is to decode this string following these rules: Skip the first two characters Split the rest of the string into groups of 8 characters In each group, replace each ...
stackexchange_codegolf
Question: Print out all the coordinates of a NxN grid. Preferably in C, however other languages also accepted Input: N (integer) Output: for N=3, a 3x3 grid: 0,0 1,0 2,0 0,1 1,1 2,1 0,2 1,2 2,2
stackexchange_codegolf