instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Write a program or function that takes a character as input and outputs a character. Also, choose a list of 13 distinct ASCII printable characters (32-126). When a character from this list is passed into the program or function, it should output the character at the corresponding position in Hello, world!. This way, ru...
stackexchange_codegolf
Note: this is heavily inspired by this question. Task: Your task is to generate the nth prime, when each character of your program is repeated n times in place. Let's say your program is: Derp Every character in there is repeated once, so it should output 2. When every character is duplicated in place, like so: DDeerr...
stackexchange_codegolf
The task Write a program or function that given three strings A, B, C produces an output string where each instance of B in A has been recursively substituted with C. Recursively substituting means repeating a substitution where at each step all non-overlapping instances of B in A (chosen greedily from left to right) a...
stackexchange_codegolf
You sit at home, rubbing your hands in a most evil fashion. This time, I'll be able to set the community A-SPIN! I'll merely claim that I have proven this problem (which is of no doubt improvable) inside this book here… You open to the first relevant page. You scrawl those words… You are, of course, the evil Fermat! Ha...
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 Lisp style languages, a list is usually defined like this: (list 1 2 3) For the purposes of this challenge, all lists will only contain positive integers or other lists. We will also leave out the list keyword at the start, so the list will now look like this: (1 2 3) We can get the first element of a list by usin...
stackexchange_codegolf
Robbers Thread Cops, your task is to chose a program that prints a string (you can choose). Although, if you change 1 character in your code, it should print another string. But there's a twist: You should make your code hard to read, so that the robbers can't find your "changeable" character. The winner cop is the use...
stackexchange_codegolf
Main objective The main objective is to output a text, it doesn't mind which text or where the text gets its output (it can be on a browser window, the default console etc). It just requires the condition that what is output must be indeed "real chars" (the ones in UNICODE for example), it's not considered valid to dis...
stackexchange_codegolf
Given an integer k and either a block of text, or a 2d array that the inner arrays may have unequal lengths (that resembles a block of text), rotate every character or element in the k-th column up or down to the next position that exists. Example Rotate the 20th column of the following text (1-based): A line with more...
stackexchange_codegolf
Background We define the two types of chain to be a string that contains only dashes, "-", or only underscores, "_". We link two chains using one equals sign, "=". Criteria: The type of chain must change following an equals sign. You must link the chains, you can do so multiple times, and it does not matter what lengt...
stackexchange_codegolf
Validating a CPR number A Danish CPR number (Person Identification Number) is date of birth followed by 4 digits (the last one being a control digit): DDMMYY-XXXX The final digit validates the CPR number using Modulo 11 by satisfying the following equation: where the are the ten digits of the complete ID number, and ...
stackexchange_codegolf
Challenge Given a number width, number height, hours and minutes print the time using the following format style: ------ - ------ ------ - - ------ ------ ------ ------ ------ | | | | | | | | | | | | | | | | | ------ ------ ------ ------ ------ | ...
stackexchange_codegolf
Inspired by this challenge (or, more specifically, by misreading it), I've come up with the following challenge: Given an input string S, reverse the order of all uppercase characters, and all lowercase characters. Leave all non-letter characters in place. For instance: Note that the uppercase W (the first uppercase l...
stackexchange_codegolf
Given a positive integer N ("virality"), your program should create an ASCII-art drawing of a tree with two branches of length N extending downwards and/or rightwards from the top-left corner. The direction taken by each branch after the first asterisk can be either rightwards or downwards, and this choice should be ma...
stackexchange_codegolf
The Venetian election system was... complicated. The Great Council came together and put in an urn the ballots of all the councilors who were older than 30. The youngest councilor went to St Mark's Square and chose the first boy he met who drew from the urn a ballot for each councillor and only those 30 who got the wo...
stackexchange_codegolf
Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2020 Day 11, Part 2. You enter the waiting area for a ferry, and you see a bunch of people sitting at a bunch of seats. The seats form a grid like this (. is a floor, L is an empty seat and # is an occupied seat): LL.#L #.L.L L...
stackexchange_codegolf
Cops' Challenge Robbers' challenge here. It has now been four days since the challenge was posted so all new answers should be marked as non-competing in the title. These answers can still be cracked by robbers but will not go towards their total, and cannot win this challenge. In this cops-and-robbers challenge, you...
stackexchange_codegolf
Migrated from chat Given two non-empty non-negative integer matrices A and B, answer the number of times A occurs as a contiguous, possibly overlapping, submatrix in B. Examples/Rules 0. There may not be any submatrices A: [[3,1], [1,4]] B: [[1,4], [3,1]] Answer: 0 1. Submatrices must be contiguous A: [[1,4], [3,1]]...
stackexchange_codegolf
Objective Given a nonnegative integer, calculate its NDos-size as defined below, and output it. NDos' numeral system The concept of NDos-size comes from the numeral system I made. It represents every nonnegative integer by a nested list, as follows: With the binary expansion of given nonnegative integer, each entry of...
stackexchange_codegolf
You want to draw a regular polygon but you have limited space! In this challenge, you should draw a polygon with n sides which is as big as possible for a given square container image. I found surprisingly little information on the Internet about inscribing a polygon into a square. To save you the hassle, I verified th...
stackexchange_codegolf
Challenge Given input in the form <n1>, <n2> where number can be -1, 0, or 1, return the corresponding cardinal direction. Positive numbers move East in the x-axis and South in the y-axis, Negative numbers move West in the x-axis and North in the y-axis. Output must be in the form South East, North East, North. It is c...
stackexchange_codegolf
We'll call the consecutive distance rating of an integer sequence the sum of the distances between consecutive integers. Consider 2 9 3 6 8 1. 2 9 3 6 8 1 <----5----> <-2-> <--3--> \$2\$ and \$1\$ are consecutive integers, and their distance apart in the sequence is \$5\$. \$2\$ and \$3\$ are consecutive integers, a...
stackexchange_codegolf
This ascii-art challenge is about walking around a string like a snake. s-n-a-k .---. e d <-' a n-u-o-r You will be given a string \$ S \$ of length \$ l \$ and a positive integer \$ n \$ where \$ n ^ 2 \ge l + 1 \$. The string rotates 90° after writing \$ n \$ characters of \$ S \$, or when it hits itself. When \$ S ...
stackexchange_codegolf
Background Math SE's HNQ How to straighten a parabola? has 4,000+ views, ~60 up votes, 16 bookmarks and six answers so far and has a related companion HNQ in Mathematica SE How to straighten a curve? which includes a second part asking to move a point cloud along with the curve that we can ignore here. From the Math SE...
stackexchange_codegolf
Many programming languages are written using solely printable ASCII, tabs and newlines. These 97 characters are then stored in 8-bit bytes (which are actually capable of holding 256 different characters!), which is just terribly inefficient - especially in code-golfing, where every byte counts! In this challenge, you w...
stackexchange_codegolf
Despite having 17 questions tagged anagrams, we still don't have this question, so here it is. Your Task You must write a program or function that, when receiving a string, prints out all possible anagrams of it. For the purposes of this question, an anagram is a string that contains the same character as the original...
stackexchange_codegolf
Given an integer n, output the following ASCII art to n rows: 1+1=2 1+2=3 2+3=5 3+5=8 5+8=13 Essentially, the first row is 1+1=2 and the nth row (1-indexed) is \$f_n + f_{n+1} = f_{n+2}\$ where \$f\$ is the Fibonacci sequence, padded so the numbers line up with the previous row. You may instead out...
stackexchange_codegolf
Task: Given an integer number in decimal number system, reduce it to a single decimal digit as follows: Convert the number to a list of decimal digits. Find the largest digit, D Remove D from the list. If there is more than one occurrence of D, choose the first from the left (at the most significant position), all oth...
stackexchange_codegolf
Given a list of positive integers determine if there is an element that is either greater than its two neighbors or less than its two neighbors (a "bump"). To be clear a bump can never be the first or last item of the list because they only have one neighbor. Your program should output one of two consistent values eac...
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
To check whether a decimal number is divisible by 7: Erase the last digit. Multiply it by 2 and subtract from what is left. If the result is divisible by 7, the original number is divisible by 7. (also described e.g. here) This rule is good for manual divisibility check. For example: Is 2016 divisible by 7? Subtract...
stackexchange_codegolf
The 80's TV series Knight Rider featured an intelligent, self-aware car called KITT. One distinctive aspect of the car was a front-mounted scanner bar that allowed KITT to "see" (and that looked suspiciously familiar to fans of another, earlier TV series). The scanner had eight lights as seen in this picture: The ligh...
stackexchange_codegolf
Your task Given two positive integers \$x\$ and \$d\$ (such that \$d<x\$), output the 5th term of the \$d\$th difference of the sequence \$n^x\$ Example Let's say we are given the inputs \$x=4\$ and \$d=2\$. First, we get the series \$n^4\$: \$0^4 = 0\$ \$1^4 = 1\$ \$2^4 = 16\$ \$3^4 = 81\$ ... These are the first 10...
stackexchange_codegolf
Introduction: I have loads of different ciphers stored in a document I once compiled as a kid, I picked a few of the ones I thought were best suitable for challenges (not too trivial, and not too hard) and transformed them into challenges. Most of them are still in the sandbox, and I'm not sure yet whether I'll post al...
stackexchange_codegolf
In the most common contemporary graphical desktop interfaces, when you perform double-click in a text, the word around your cursor in the text will be selected.† For example, let | be your cursor in abc de|f ghi. Then, when you double click, the substring def will be selected. Input/Output You receive two inputs: a st...
stackexchange_codegolf
Your job is to write a program that takes a number N as input and outputs all 2-by-N mazes that are solvable. Output format can be in the form of any two distinct values representing wall and empty - I use x and . here but you can use anything. You can have a matrix, array, string, ascii art, whatever is convenient, an...
stackexchange_codegolf
The Challenge Everybody loves genetics, right? In this challenge, you will be given the genotypes of two parents. You must find each possible genotype of a child produced by the parents. You must account for dominant and recessive alleles as well as incomplete dominance and codominance. An example input for the parents...
stackexchange_codegolf
The official release of the Nintendo 64 in North America was on September 29, 1996.[1] I figured that this anniversary deserved an ASCII art challenge. There's one small twist though, you have to output a different ASCII art for each of three different inputs. If the input is 1, output this ASCII art of an N64 Controll...
stackexchange_codegolf
A very simple golf this time, but should be fun to do. Challenge Output your code, but rotated 45 (or -45) degrees. E.g: lorem ipsum dolor sit amet becomes t e m a t i ...
stackexchange_codegolf
Arturo is a bytecode-compiled/interpreted, garbage-collected general-purpose language filling a role similar to JavaScript, Python and Ruby. It is centered around the concept of blocks, which hold code just as easily as data. It uses fixed-arity prefix syntax and emphasizes the procedural and functional paradigms. What...
stackexchange_codegolf
With roughly one second (plus or minus 10 ms) between outputs, output anything. The first output must be at most one second after the start of the program, but can be as soon as right when the program starts. So, the first output can be up to a second after the program starts, the second exactly one second after that, ...
stackexchange_codegolf
Consider a binary tree built the following way: The root node is \$1\$ For a given node \$n\$: If \$n\$ is odd, its only child is \$2n\$ If \$n\$ is even, one of its children is \$2n\$. If \$\frac {n-1} 3\$ is an integer and not already part of the tree, its right child is \$\frac {n-1} 3\$ Recursively and infinite...
stackexchange_codegolf
The On-Line Encyclopedia of Integer Sequences (OEIS) is an online database of integer sequences. It contains nearly 280000 sequences of mathematical interest. Examples of sequences: positive integers (A000027) prime numbers (A000040) Fibonacci numbers (A000045) Your task is to write a program or function that displ...
stackexchange_codegolf
What general tips do you have for golfing in Keg? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Keg (e.g. "remove comments" is not an answer). Please post one tip per answer.
stackexchange_codegolf
Given the input of the first number and the second number (both positive integers, zero exluded), determine in how many ways could you make the second out of the first, using following actions: +1,+2 and *3. Operations are simply applied from left to right. Examples: Input: 1 2. Output: 1. I.e, you could only get 2 b...
stackexchange_codegolf
We all know that \$(-a) \times (-a) = a \times a\$ (hopefully), but can you prove it? Your task is to prove this fact using the ring axioms. What are the ring axioms? The ring axioms are a list of rules that two binary operations on a set have to follow. The two operation are addition, \$+\$, and multiplication, \$\...
stackexchange_codegolf
Given two numbers, the first is greater than the second, check whether the first number is divisible by the second without a remainder. If divisible, answer "yes"(or any other string), otherwise "no"(or any other string you like). Conditions: You cannot use conditional operators, loops, arrays, bitwise operations, func...
stackexchange_codegolf
Inspired by a tweet by Nathan W. Pyle There is, now, a standard method of converting your boring, normal human name into a mysterious, ethereal Ghost Name™️. Ably described by Mr Pyle... Use your first name: a - add “t” after it e - add “boo” after it h - becomes “s” n - add “oo” after it r - add “eee” after it...
stackexchange_codegolf
I am working on a code to print all semimagic squares [1] of a given size. I am working with the following definition: An \$n\times n\$ consists of numbers \$1,2,\cdots, n^2\$. All numbers must be distinct. Sum of each row and each column is equal. According to Ripatti A. (2018) [1]: \$n\$ number of semimagic squ...
stackexchange_codegolf
Challenge Write code that outputs TeX (LaTeX) math-equation code (given below) that will typeset Sierpinski Triangle Fractal of 5 levels. Shortest code wins. Details TeX (and friends like LaTeX, etc.) is a sophisticated typesetting system. It can render arbitrary nested complex expressions for mathematical formulas. Co...
stackexchange_codegolf
In this question I asked you to guess an anagram quine based on its output. However it looks like we don't have a question asking to golf an anagram quine yet. So your task will be to make the shortest anagram quine that you can. What is an anagram quine? An anagram quine is a non empty program that prints an anagram...
stackexchange_codegolf
In CSS, colours can be specified by a "hex triplet" - a three byte (six digit) hexadecimal number where each byte represents the red, green, or blue components of the colour. For instance, #FF0000 is completely red, and is equivalent to rgb(255, 0, 0). Colours can also be represented by the shorthand notation which use...
stackexchange_codegolf
Challenge: make a program that outputs a MD5 hash of its source code. You should not use tricks that would be considered cheating in a quine sense (discussed here). Using built-in functions and external libraries is allowed. The program should be a full program (not a function/subroutine). Code-golf: shortest solution ...
stackexchange_codegolf
You are given a square \$n \times n\$ matrix \$A\$, and a list (or vector) \$u\$ of length \$n\$ containing the numbers \$1\$ through \$n\$ (or \$0\$ through \$n-1\$). Your task is to reorder the columns and rows of the matrix \$A\$ according to the order specified in \$u\$. That is, you will construct a matrix \$B\$...
stackexchange_codegolf
This question is a sequel to this one, working in the opposite direction. For a reminder of terminology, the letters L, R, U, and D represent one-unit movement of a robot on the coordinate plane in the directions left, right, up, and down respectively. Given a positive even integer n, generate and print all sequences ...
stackexchange_codegolf
Preface There are many "draw x flag" challenges, and upon searching it turns out there are no challenges to draw the union Jack! I feel like this would be a harder flag to draw but it should still be possible. Challenge Draw the Union Jack. It can be outputted to a file in any freely available graphics file format or d...
stackexchange_codegolf
This challenge is inspired by a talk about Schläfli symbols, etc that I gave in a Geometry seminar. While I was putting together this challenge, I saw that Donald Knuth himself was interested in (some subset of) this problem. In October 2016, he commented on a related OEIS sequence: If [the OEIS author] is wrong about...
stackexchange_codegolf
Problem 4 in the 2019 BMO, Round 1 describes the following setup: There are \$2019\$ penguins waddling towards their favourite restaurant. As the penguins arrive, they are handed tickets numbered in ascending order from \$1\$ to \$2019\$, and told to join the queue. The first penguin starts the queue. For each \...
stackexchange_codegolf
Let \$A\$ be a positive integer consisting of \$n\$ decimal digits \$d_1,d_2,...,d_n\$. Let \$B\$ be another positive integer. For the purpose of this challenge, we call \$A\$ a copycat of \$B\$ if there exists at least one list of positive integers \$p_1,p_2,...,p_n\$ such that: $$\sum_{i=1}^{n}{{d_i}^{p_i}}=B$$ \$A\$...
stackexchange_codegolf
This proposal had few attention for 8 months (though an answer was posted in the sandbox at that time), so I decided to post it anyway. Introduction Napier's bones is a calculation tool, which helps speeding up the calculation of multiplication, division and digit-by-digit square root extraction by turning n-digit-by...
stackexchange_codegolf
I don't know about you all but I'm not preparing for Halloween––never did never will––but, my neighbor is, so we'll help her out. She needs help figuring out which brand of candy she has, but she has so much candy she would not be able to finish before Halloween. She has: Snickers KitKat Starburst GummyBears Twix Inp...
stackexchange_codegolf
Given a positive integer n > 1 determine how many numbers can be made by adding integers greater than 1 whose product is n. For example if n = 24 we can express n as a product in the following ways 24 = 24 -> 24 = 24 24 = 12 * 2 -> 12 + 2 = 14 24 = 6 * 2 * 2 -> 6 + 2 + 2 ...
stackexchange_codegolf
You have a bunch of cities on a grid which you wish to link up. Roads can be placed on any tile that doesn't contain a city, and connect to all roads or cities adjacent to them, vertically, horizontally or diagonally. Roads can link up via cities, for example C \ C-C is fully linked up. However, there are some moun...
stackexchange_codegolf
Input: An NxM grid or multi-line string (or other reasonable input-format), containing only printable ASCII (unicode range [32,126]). Output: The amount of closed polygons of the same character that can be found, with two special rules: Spaces are wildcards and can be used (multiple times) for any character o, O, and ...
stackexchange_codegolf
Randomness is fun. Challenges with no point are fun. Write a function that, given integer input n, will output a set (unordered, unique) of exactly n random integers between 1 and n^2 (inclusive) such that the sum of all integers is equal to n^2. Randomness does not have to be uniform, provided each valid set has a non...
stackexchange_codegolf
Write the shortest code that will take any real number greater than 1 as input and will output its positive inverse factorial. In other words, it answers the question "what number factorial is equal to this number?". Use the Gamma function to extend the definition for factorial to any real number as described here. For...
stackexchange_codegolf
Every integer can be expressed in powers of 2. You know this as the binary system Assume you are given a set of k numbers (0 < k < 2^n). You want to decide for this set whether every integer power of 2 up to 2^(n-1) occurs at least m times One example: n = 7 (2^n = 128, ) k = 5 set = {100, 91, 88, 63, 44} m = 3 Solut...
stackexchange_codegolf
Here's a relatively simple challenge for you: Given a list of positive integers: Line them up in a grid, and sum each column. For example, if the input was [123, 7, 49, 681], the grid would look like this: 1 2 3 7 4 9 6 8 1 And the sum of each column would be [18, 19, 4]: 1 2 3 7 4 9 6 8 1 --...
stackexchange_codegolf
Background Most of you know what a Fibonacci number is. Some of you may know that all positive integers can be represented as a sum of one or more distinct Fibonacci numbers, according to Zeckendorf's Theorem. If the number of terms in the optimal Zeckendorf Representation of an integer n is itself a Fibonacci number, ...
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
Write a program that outputs the lyrics to 99 Bottles of Beer, in as few bytes as possible. Lyrics: 99 bottles of beer on the wall, 99 bottles of beer. Take one down and pass it around, 98 bottles of beer on the wall. 98 bottles of beer on the wall, 98 bottles of beer. Take one down and pass it around, 97 bottles of b...
stackexchange_codegolf
Challenge Given a grid size, obstacles' positions, player position and target position your task is to find a path for the player to get to the target and avoid the obstacles at the same time (if necessary). Input N: Grid size N x N P: Player's position [playerposx, playerposy] T: Target's position [targetposx, targ...
stackexchange_codegolf
You must write a program that takes an encrypted string and decrypt it according to specific rules and then print it out. Decryption will occur by performing two operations. Sample Input Argument 1 (the encrypted string) HGJILKBADCFE Operation 1: Swap the first half of the string with the second half, which should lea...
stackexchange_codegolf
Goal Using the programming language of your choice, write the shortest program to eliminate comments from a string representing a C program. Input The string can be taken as any form of input, but it may also be taken as a variable. Instructions Two different kinds of comments are to be removed: multiline comments, ...
stackexchange_codegolf
The Challenge: Draw a rectangle of ASCII boxes: [] The Rules: Takes a width and a height input You can assume both of these are numbers Must produce a string with newline characters, \n Examples: 2, 2: [][] [][] 2, 3: [][] [][] [][] Fewest Bytes wins.
stackexchange_codegolf
Inspired by one of many bugs I ran into while implementing selection sort in trilangle. Given a non-empty list of non-negative integers, "sort" the list using the following procedure: Find and output the smallest value in the list. If the list only has one element, stop. Recurse on a sublist: If the last element in t...
stackexchange_codegolf
Given an input value \$n\$, construct an array of \$n\$ random 128 bit (unsigned) integers. The integers should be uniformly random. Your code can use any in built random number generation function it has or you can implement your own. Clearly this challenge is harder (and more fun) in lower level languages.
stackexchange_codegolf
Task Read the contents of a table given a set of coordinates. Table formatting Tables will be in this basic format: |[name]|[name]| --------------------- [name]| [val]|[val] | [name]| [val]|[val] | Column names are always unique within columns. Row names are also unique within rows. This includes names that are ...
stackexchange_codegolf
Word equations, but not as you know it! Given a sentence which will include two numbers, numerically, and a spelt operator, in the order seen in the examples, your goal is to give the numerical answer The operators will be spelt as: "add", "minus", "times" and "divide" Any real number integer may be used, as suggested ...
stackexchange_codegolf
A twin of this. FizzBuzz is where a range of positive integers is taken, and numbers divisible by 3 are replaced with "Fizz", divisible by 5 with "Buzz" and divisible by 15 with "FizzBuzz". For example, FizzBuzz from 1 to 10 is 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz. Your challenge is to, given a list of Fizzes, B...
stackexchange_codegolf
Inspired by my geography class, Sandboxed Simulate weathering / erosion. Input Input will be given as a string of any 2 characters (or see below) you like in the shape of the rock (here i use spaces and hashes): ### #### ##### ####### ####### ######## Or if your language doesn't support strings, a square matrix ...
stackexchange_codegolf
Your task is to write a non-empty computer program comprised of some sequence of bytes. If we choose a particular byte in the program and remove all instances of it from the program, the modified program should output the removed byte. For example if our program were aabacba Then bcb would output a, aaaca would need ...
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
Your task is to write a piece of code that zeros the current cell in the Brainfuck variant that, each cell can contain a signed integer of arbitrarily large magnitude, instead of the normal 0 to 255. You may assume there are l cells to the left and r cells to the right of the current cell that are initially zero. You p...
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
It's the end of the year, you and your friends have just received your grades and ranks for the GOLF101 class. On a chat group, everyone sends their grade and rank to see who's got the best one. Problem: someone is lying. Here is an excerpt from the chat: <A> I'm ranked 1 with a grade of 85. <B> Ranked 3, got 50. <C> R...
stackexchange_codegolf
Challenge Given a string with any characters a-z or A-Z, return an 'encrypted' string, where all characters are replaced by the character next to it (assuming a QWERTY keyboard). Case (uppercase, lowercase) does not matter. The input will only have characters a-z and A-Z. Shortest code in bytes wins. Example Input a...
stackexchange_codegolf
Challenge I've checked that there is a question Compute the Discrete Cosine Transform which is a competition for implementing a shortest solution to compute the one dimensional discrete cosine transform. The goal of this challenge is to implement a program to calculate three dimensional discrete cosine transform which ...
stackexchange_codegolf
In this challenge we considered a frog hopping around a lily pond. To recap the lily pond was represented as a finite list of positive integers. The frog can only jump forward or backwards by a distance equal to the number at its current location. So for example: [2, 3, 1, 4, 1] Here the frog is on a 1 so i...
stackexchange_codegolf
In the old DOS operating system, a number of characters were provided to draw boxes. Here is a selection of these characters and their code points: B3 B4 BF C0 C1 C2 C3 C4 C5 D9 DA │ ┤ ┐ └ ┴ ┬ ├ ─ ┼ ┘ ┌ You can use these characters to draw boxes like this: ┌─────────┐ │ │ └─────────┘ Boxes can be at...
stackexchange_codegolf
Introduction Your goal is to find the least number of ones you need to add or multiply together to get the input value, this is A005245. Input One positive integer N. Output The smallest number of ones that must be added/multiplied to get N. Sample Input 7 Sample Output 6 Explanation (1 + 1 + 1) * (1 + 1) + 1 = 7 ...
stackexchange_codegolf
Simple question! Given a string that contains a date in ISO8601 format, print the first of the next month in ISO8601 format. Example inputs: 2018-05-06 2019-12-20 Their respective outputs: 2018-06-01 2020-01-01 The rules: Imports are free and don't count towards your score. The date will be stored in a string called s...
stackexchange_codegolf
Sociable numbers are a generalisation of both perfect and amicable numbers. They are numbers whose proper divisor sums form cycles beginning and ending at the same number. A number is \$n\$-sociable if the cycle it forms has \$n\$ unique elements. For example, perfect numbers are \$1\$-sociable (\$6\to6\to\cdots\$) and...
stackexchange_codegolf
From here. Every new game is the first day of the month, 12:00 PM UTC. The goal is to create the Stack Overflow logo using ASCII characters. It looks like this. The exact output should look like this: \\ \\ \= \\ \= \\ \= \\ \== \\ ¯¯¯ \== ¯¯¯...
stackexchange_codegolf
The question score on Stack Exchange is the total number of upvotes minus the total number of downvotes a question receives. However, the reputation gained/lost for every upvote/downvote is different (eg. 10/-2 on Code Golf). Given the total reputation earned, the reputation gained by an upvote and the reputation lost ...
stackexchange_codegolf
Write a program that takes in a string where every line consists of the character 0 indented by some number of spaces. The top line is not indented and every other line will be indented by at most one more space than the line just before it. No lines will have trailing spaces but you may optionally assume there is a si...
stackexchange_codegolf
In this challenge we are going to consider lists of integers such that for every member \$x\$ at index \$i\$ then the indexes \$i+x\$ and \$i-x\$ have the value \$x+1\$ or are out of bounds for the list. We will call these trampoline lists. If we play around with these for a while we can notice that if we start a list...
stackexchange_codegolf
This is a cops-and-robbers challenge, the robbers thread can be found here. Your task is to write some code that outputs an OEIS sequence, and contains the name of the sequence in the code (A______) and outputs a second separate sequence when the name of the sequence in the code is changed to the name of the second s...
stackexchange_codegolf
Basing on this SO question. Challenge is rather simple: given a date period in the format YYYYMM output it in the format MMMYY. Rules: The input will be a number or a string exactly 6 characters long, consisting only of digits. Last two digits will be between 01 and 12. Output must be in the form MMMYY, where MMM repr...
stackexchange_codegolf
This challenge is based on the game Layerz. Given, on stdin or as a function argument, a 2D rectangular array of cells where each cell contains either a blank (you may choose to use 0s instead of blanks at no penalty), a 1, a 2, a 3, or a 4; find a way to divide it into valid regions (as defined below) such that each n...
stackexchange_codegolf