instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
You are on a plane filled with boxes, and you get a sequence of movements, say "up right right down left": You move up, pushing all boxes in front of you away: You move right, right and down, getting and finally left. This time you only push one box rather than infinite boxes: At the end, there are 4 spaces. Given ...
stackexchange_codegolf
I was doing the bandit wargame from overthewire.org and because I am a script kiddie, I googled the answer for level 24. password="UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ" for i in {0000..9999} //looping to try any possible pin code do echo $password' '$i >> wordlist.txt //save password and possible pin code into wordlist ...
stackexchange_codegolf
Produce this square snowflake. XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XX X X X X X X X X X X X X X X XX X XXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXX X XX X X X X X X X X X X X X XX X X XXX XXXX XXXX XXXX ...
stackexchange_codegolf
UTF-9 was an April Fool's Day RFC joke specifications for encoding Unicode suitable for 9-bit nonet platforms. Challenge Your task is to implement a program or a function or a subroutine that takes one integer, who represents the codepoint of a character, to return a sequence of integers that represents its correspondi...
stackexchange_codegolf
Choose a challenge from the Cops thread, determine the third hidden message, and describe how the system works. Keep in mind limitations and possibilities available to Cops: You are not expected to guess any cryptographic secrets or additional information required to extract the hidden messages, as they should have al...
stackexchange_codegolf
A slightly more challenging one compared to my previous challenge. Given a list of positive integers (>0) and the positive integer m, output a list of positive integers that are capped values of the input values so that the sum of the capped values equals m. Cap the highest values first. And keep the same order. Cases ...
stackexchange_codegolf
Inspired by @AviFS. Given a string containing brackets, e.g. [xyz]]abc[[def]hij[ You can parse through it with a stack of brackets. When you find an open bracket, push a value to the stack, when you find a close bracket, pop from the stack. If you make these values indices, you know where you need to remove brackets. ...
stackexchange_codegolf
Robbers thread In this thread, your task is to find a non-recursive solution which produces the same integer series of a submission not marked as 'safe' in the Cops' thread. Challenge synopsis In many languages, recursive functions can significantly simplify a programming task. However, the syntax overhead for a prope...
stackexchange_codegolf
Clarification: Basically, you need to make this Euler's totient function has the name phi. Let's try to calculate phi(8) First, list all numbers 8 and under backwards, not including 0 or under 8 7 6 5 4 3 2 1 Now find which numbers don't share a factor with 8 (1 doesn't count), and place a # in their place. 8 # 6 # 4 ...
stackexchange_codegolf
The SKI calculus is a variant of the Lambda calculus that doesn't use lambda expressions. Instead, only application and the combinators S, K, and I are used. In this challenge, your task is to translate SKI terms into Lambda terms in β normal form. Input Specification The input is an SKI term in the following textual ...
stackexchange_codegolf
The city defines a dog as any living entity with four legs and a tail. So raccoons, bears, mountain lions, mice, these are all just different sizes of dog. Given an ASCII-art image of an animal, determine if that animal is a dog. Rules An animal is a dog if it has four legs and a tail. The foot of a leg starts with one...
stackexchange_codegolf
I'm a developer, and I don't feel like doing my work. I know from XKCD that the best excuse for slacking off is that your code's compiling. Because of this, I think I need some code that will compile forever! And because I'm lazy and don't want to have to type much, this has to be done with the shortest code possible. ...
stackexchange_codegolf
Dina loves most numbers. In fact, she loves every number that is not a multiple of n (she really hates the number n). For her friends’ birthdays this year, Dina has decided to draw each of them a sequence of n−1 flowers. Each of the flowers will contain between 1 and n−1 flower petals (inclusive). Because of her hatred...
stackexchange_codegolf
Input An integer n and a pair of distinct integer valued (x, y) coordinates on the boundary of the grid. The coordinates are indexed from 1. For example, n=10 and (1,2), (10, 7). The points will always be on different sides of the grid and neither of them will be \$(1, 1)\$. Output The number of integer points in an n...
stackexchange_codegolf
Unsolved puzzle: Solved Puzzle: Rules Each circle with number must have as many lines from it as the number in the circle. It is not allowed to have more than two lines between two circles. The lines can not cross each other. All the lines must either be horizontal or vertical. It is not allowed to draw lines diagon...
stackexchange_codegolf
Employers love to see their employees working hard, while the employees would love to work less, especially those with a monthly rather than hourly payment. The laziest of employees are thinking about the world where every month starts with the same weekday and it makes them wonder if they would work more or less. T...
stackexchange_codegolf
Within the recesses of Unicode characters, there exists a Unicode block of (currently) 63 characters named "Number Forms", which consists of characters that have numerical values such as the roman numeral Ⅻ, vulgar fractions like ⅑ or ↉, or weird ones like ↊ (10) or ↈ (100000). Your task is to write a program or functi...
stackexchange_codegolf
Disclaimer While I know there is this particular related question, my question uses two garage doors, a randomizing component, and I'm also basing this on real life events, seeing my son accidentally lowered one of said garage doors whilst I was walking out of the garage last week... Nothing like a blow to the head to ...
stackexchange_codegolf
I define the method of combining a sequence to mean that every number in the sequence is concatenated as a string, then that result is made an integer. [1, 2, 3] -> 123 For every finite sequence of at least 3 consecutive integers, missing exactly one element in the sequence, and this missing element may not be the fir...
stackexchange_codegolf
A Geiger counter is a device that is used to detect radiation. We will be making a Geiger counter program. As we all know, when radiation hits a computer program it removes exactly 1 byte at random. So a Geiger counter program is a program that itself does nothing, but when any byte is removed the modified program pri...
stackexchange_codegolf
You are going to be given a string containing some alphabetic characters along with [ and ]. Your task is to split into sections that are enclosed in a "group" created by [...] and those that are not. e.g. "absbn[mesl]meslo[eyyis]me" -> "absbn" "mesl" "meslo" "eyyis" "me" Super simple right? Well hold your horses. ...
stackexchange_codegolf
If a positive integer \$N > 2\$ has (strictly) less prime factors (without counting multiplicities) than its successor and its predecessor, we will call it a factor-poor number. In other words, \$\omega(N) < \omega(N - 1)\$ and \$\omega(N) < \omega(N + 1)\$, where \$\omega(N)\$ is the number of unique prime factors of...
stackexchange_codegolf
What general tips do you have for golfing in Haxe? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Haxe (e.g. "remove comments" is not an answer). Please post one tip per answer. Haxe can be run online here!
stackexchange_codegolf
Edit 2020-11-06: This challenge has been edited with new provisions to encourage participation. The edits have been bolded for emphasis. Welcome to a cops and robbers version of Find an Illegal String. An illegal string is "a string of characters that cannot appear in any legal program in your programming language of...
stackexchange_codegolf
We can model a rail network as a directed graph, where each node is a train station and each edge is a train connecting two train stations. We'll assume that each train travels between its corresponding stations at a regular schedule and takes a fixed amount of time Your code should take a list of trains, where each tr...
stackexchange_codegolf
Briefing Aliens have settled on earth and strangely enough, their alphabet is the exact same as ours. Their language is also very similar to ours with some very distinct and easy to compute differences. Challenge Take a string and output the alien's language equivalent. The translation works as such: Swap all the vowel...
stackexchange_codegolf
A binary string is a string which contains only characters drawn from 01. A balanced binary string is a binary string which contains exactly as many 0​s as 1​s. You are given a positive integer n and an arbitrary number of masks, each of which is 2n characters long, and contains only characters drawn from 012. A binary...
stackexchange_codegolf
Introduction Bob likes to have different passwords for each website he uses. He wants passwords in a special format so that he can remember. Help him by building a password generator which is as short as possible in code length, because he likes keeping stuff short just like his name. Challenge Build Bob a password gen...
stackexchange_codegolf
(Note: this is an easier spin-off of my previous challenge Find the Infinity Words!, which is a spin-off of my other previous challenge Find the Swirling Words! :) ) Definition of a Wavy Word: If you connect with curves all the characters of a Wavy Word on the alphabet (A-Z) you obtain the path of a wave continuously ...
stackexchange_codegolf
In any programming language, create a program that takes input and animates the text being typed on a keyboard. The delay between each character should be varying to simulate true typing on a keyboard. The delay shall be 0.1, 0.1, 0.5, 0.1, 0.1, 0.5 ... seconds, until the last character is printed. The final output sha...
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
Challenge Taken from here and also here An n parentheses sequence consists of n (s and n )s. A valid parentheses sequence is defined as the following: You can find a way to repeat erasing adjacent pair of parentheses "()" until it becomes empty. For example, (()) is a valid parentheses, you can erase the pair on the 2...
stackexchange_codegolf
Given a string s composed of lowercase letters, such as aabaaababbbbaaba and a positive integer n, such as 4, output a length-n string t such that when t is repeated to the length of s, they have as many chars in common as possible. For the given example, the optimal output would be aaba, because it has thirteen chars...
stackexchange_codegolf
Your task is to decipher a non-empty string consisting of printable ASCII characters in the range [32..126]. Reading the string character per character: each time you encounter a letter in lowercase, associate it with the next letter in uppercase, starting with 'A' each time you encounter a letter in uppercase, replac...
stackexchange_codegolf
You are given an encrypted string, encrypted using a very simple substitution cipher. Problem You do not know what the cipher is but you do know the ciphertext is English and that the most frequent letters in English are etaoinshrdlucmfwypvbgkqjxz in that order. The only allowed characters are uppercase letters and sp...
stackexchange_codegolf
Lets define a class of functions. These functions will map from the positive integers to the positive integers and must satisfy the following requirements: The function must be Bijective, meaning that every value maps to and is mapped to by exactly one value. You must be able to get from any positive integer to any o...
stackexchange_codegolf
Problem statement Pólya is playing about with his urn again and he wants you to help him calculate some probabilities. In this urn experiment Pólya has an urn which initially contains 1 red and 1 blue bead. For every iteration, he reaches in and retrieves a bead, then inspects the colour and places the bead back in the...
stackexchange_codegolf
Challenge Given some input string, return a truthy value if it represents a correct roman numeral between 1 (=I) and 3999 (=MMMCMXCIX), and a falsey value otherwise. Details The input is a non-empty string that only comprises the characters IVXLCDM. The roman numerals (that we use here in this challenge) are defined a...
stackexchange_codegolf
Most people are familiar with the trope about counting sheep to fall asleep. There's a herd of sheep, some of them jumping over a fence, and you count the sheep as they jump. Supposedly, this helps quiet your mind and gets you into a sleep-like state so that you'll fall asleep. Here's an ASCII sheep facing to the right...
stackexchange_codegolf
Above is the picture of the flag of the country Nepal. Pretty cool. What's cooler, is the aspect ratio, which is defined under the constitution as: That formula in copyable form: $$ 1 : \frac{6136891429688-306253616715\sqrt{2}-\sqrt{118-48\sqrt{2}}(934861968+20332617192\sqrt{2})}{4506606337686} $$ Your task is to out...
stackexchange_codegolf
Challenge Sandbox post Given a positive integer (K) Output a uniformly-random integer (Y) between [0, K). If Y > 0 Assume K = Y and repeat the process until Y = 0. Rules Input must be printed at first Output format as you wish Your program must finish. 0 must be the final output, Optionally an empty line instead 0
stackexchange_codegolf
Input A single integer in your language's preferred format, e.g int or an array of digits are all acceptable. Output A truthy or falsely value, depending on whether the given number is palindromic (same forwards and backwards) Rules Numbers will always be positive, at least two digits long. This is fastest-algorithm, ...
stackexchange_codegolf
You’re given two \$r×c\$ grids. Each cell contains either 0 or 1. What are the minimum number of swaps (between horizontally and vertically adjacent cell elements, no wrapping i.e no swapping between last and first element of a row) are required in the first grid for it to match the second. If the matched arrangement c...
stackexchange_codegolf
Challenge Given a string, make it into a triangle as shown below: Input Hello, world! Output H He Hel Hell Hello Hello, Hello, Hello, w Hello, wo Hello, wor Hello, worl Hello, world Hello, world! The first line contains the first character of the string. The following lines contain one more character on each line, u...
stackexchange_codegolf
I have noticed that there are a disproportionate number of computer languages based on English. I propose to fix this by translating existing computer languages into foreign languages! Pick a computer language that uses English keywords/functions Pick any natural* language other than English Write a program that trans...
stackexchange_codegolf
Alternating Arrays An alternating array is a list of any length in which two (not necessarily different) values are alternating. That is to say, all even-indexed items are equal, and all odd-indexed items are equal. Your task is to write a program or function which, when given a list of positive integers, outputs/retur...
stackexchange_codegolf
The game shapez.io has a lot of shapes. In my previous challenge, the object was to generate a random code for a shape. Now, your challenge is to render a shape. Specs Shapes Each shape has a unique shortcode, for example: is CrWgRuSp - clockwise from top right, red circle, green wedge, uncolored rectangle, purple sta...
stackexchange_codegolf
+-= is a language created by Esolangs user Anonymous in 2017.The language consists of only three commands: + increases the accumulator by one. - decreases the accumulator by one. = outputs the accumulator and a newline. Rules This is code-golf, all usual golfing rules apply. Standard rules apply. You may assume inpu...
stackexchange_codegolf
Let \$S \subset \mathbb N_{\geq0}\$ be a subset of the nonnegative integers, and let $$ S^{(k)} = \underbrace{S + S + \dots + S}_{k\ \textrm{times}} = \{ a_1 + a_2 + \dots + a_k : a_i \in S\}. $$ For example, $$\begin{align} \{1,2,3\}^{(2)} &= \{1+1, 1+2, 1+3, 2+1, 2+2, 2+3, 3+1, 3+2, 3+3\}\\ &=\{2,3,4,5,6\} \end{align...
stackexchange_codegolf
These are the hosts of the "Weekend Update" news segment on Saturday Night Live, with the years they hosted and their initials: Chevy Chase 1975-1976 CC Jane Curtain 1976-1980 JC Dan Aykroyd 1977-1978 DA Bill Murray 1978-1980 BM Charles Rocket 1980-1981 CR Gail Matthius 19...
stackexchange_codegolf
Wise is a simple bitwise language I designed a while back. It is based around Python's bitwise operations. It has several operations most of these are the same or very similar to the equivalent symbol in Python. : Duplicate the top of the stack ? Rotate the top of the stack to the bottom ! Rotate the bottom of the s...
stackexchange_codegolf
(based on this deleted question) Take the English alphabet a b c d e f g h i j k l m n o p q r s t u v w x y z (spaces added for clarity), and split it into chunks of X width, padding any leftover lines with spaces if necessary for your language. For example, splitting it into width 4 results in a b c d e f g h i j k l...
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
Researchers recently discovered an interesting bee colony that lives in an infinite field of honeycomb: Each cell can house a bee or not. In fact, the lives of those creatures appear to be a bit ... chaotic. It could be calculated that a colony always starts with the following pattern: (Bee drawn by Emmanuel Bou...
stackexchange_codegolf
A digit addition generator of an integer n is any integer x that satisfy the equation x + s(x) = n, with s(x) being the sum of the digits of x. (We will work under base 10 for convenience.) For example, a digit addition generator for 29 would be 19, because 19 + (1 + 9) = 29. Some numbers have more than one generator. ...
stackexchange_codegolf
Given 2 random circle sections, return how many times they intersect. Rules/clarifications are as below. You are provided 10 total values, The center (x,y) of the circle section Angles of the circle (i.e. (0,90) would be a quarter circle "facing" the top-right corner. The radius of the circle section The circle s...
stackexchange_codegolf
Write a program or function that takes input and outputs/returns a full program (in the same language) that outputs said input. Note that the input may contain any printable ASCII character or newline (AKA 0x20-0x7f and 0x0a). However, the input will not have trailing whitespace nor preceding whitespace, nor will it be...
stackexchange_codegolf
A palindrome is a word which is spelled the same backwards and forwards. For example, "racecar" is a palindrome as is "redder". A double palindrome is a palindrome whose halves are also palindromes. For example, "abbabba" is a double palindrome, as the half "abba" is also a palindrome. Similarily, "abaababaaba" is a tr...
stackexchange_codegolf
Your task is to write a program that performs case conversion from plain text, and other case formats, into one of the specified formats below. Inputs will be either plain lowercase text, or one of the detailed cases below. You must remove non-alphabetic characters except (space), _ (underscore) and - (hyphen), then ...
stackexchange_codegolf
Introduction Every letter in the English alphabet can be represented as an ASCII code. For example, a is 97, and S is 83. As we all know, the formula for averaging two numbers \$x\$ and \$y\$ is \$\frac{x+y}{2}\$. I'm pretty sure you can see where this is going. Your challenge is to average two letters. Challenge Yo...
stackexchange_codegolf
Your submission must take a list of numbers (in whatever list format your language supports, or using multiple function / command-line parameters) or a string of numbers separated by any character that is not 0123456789. In one language, it must add all of them and output the sum. In another language, it must output th...
stackexchange_codegolf
One reason why ISO8601 is the best date string format, is that you can simply append as much precision as you like. Given 2 integers representing seconds and nanoseconds that have passed since 1970-01-01T00:00:00, return an ISO8601 string as described below. Output: The standard output format without timezone looks lik...
stackexchange_codegolf
Generate the contents of an SVG file containing 6 bingo cards. Winner is the one that uses the shortest code. A qualifying answer has an output that can be directly pasted in a blank to get the required image. Rules are as follows. The generated SVG code should comply with SVG version 1.1 described here. The size of t...
stackexchange_codegolf
Challenge Given two lists of strings where each string is of length 50 and each list is also of length 50 generate the shortest regex you can that fully matches all the strings in the first list and does not match any of the strings in the second list. Scoring Your score will be the average length of the regexes your p...
stackexchange_codegolf
In honor of how much rep I had several hours ago, when I first thought of this challenge: Numbers like this that are made up of a single digit repeating are called repdigits. Repdigits are fun! Every body would be more happy if the amount of rep they had was a repdigit¹, but I am impatient, so you need to help me find...
stackexchange_codegolf
Sandbox Have y'all ever written an answer with unprintable ASCII characters in it and wished that there was an easy way to represent those characters in a printable way? Well, that's why the Control Pictures Unicode block was invented. However, manually substituting these characters into one's answer is time-consumin...
stackexchange_codegolf
Introduction We have 22 Collatz conjecture-related challenges as of October 2020, but none of which cares about the restrictions on counter-examples, if any exists, to the conjecture. Considering a variant of the operation defined in the conjecture: $$f(x)= \cases{ \frac{x}{2}&for even x \cr \frac{3x+1}{2}&for odd x }...
stackexchange_codegolf
Inverse function of this challenge To (properly) multiply an string by an integer, you split the string into characters, repeat each character a number of times equal to the integer, and then stick the characters back together. If the integer is negative, we use its absolute value in the first step, and then reverse t...
stackexchange_codegolf
Your task is to create a program that is to mimic Big Ben (Twitter). Task Whenever a new hour has begun (according to your computer's local time or UTC), you have to output BONG repeated hour times (with a space between the words). For example, when it's 3 o' clock, you have to output BONG BONG BONG. The time format fo...
stackexchange_codegolf
Using ASCII print a section of a hexagon ring tiling. Here's a small section: /\__/\ /_/ \_\ /\__/\ \__/ /\__/\ /_/ \_\/__\/_/ \_\ \ \__/ /\__/\ \__/ / \/__\/_/ \_\/__\/ /\__/\ \__/ /\__/\ /_/ \_\/__\/_/ \_\ \ \__/ /\__/\ \__/ / \/__\/_/ \_\/__\/ \ \__/ / \/__\/ Here's a larger...
stackexchange_codegolf
Background A checkered tiling of a rectangular grid is a tiling using some polyominoes, where each region can be colored either black or white so that no two polyominoes sharing an edge has the same color. In graph-theoretic terms, the chromatic number of the adjacency graph is 2. Terminology adapted from a Fillomino v...
stackexchange_codegolf
For example, if n is 5 and r is 2, it would mean the number of lists below: [1,1,1,1,1] [1,1,1,2,2] [1,1,2,2,2] [2,2,1,1,1] [2,2,2,1,1] [2,2,2,2,2] which is 6. If n is 4 and r is 3: [1,1,1,1] [1,1,2,2] [1,1,3,3] [2,2,1,1] ... [3,3,3,3] which is 9. where each item has a neighbour whose value is the same. For example, ...
stackexchange_codegolf
Suppose we define a simple program that takes an array L of natural numbers with some length N and does the following: i=0 #start at the first element in the source array P=[] #make an empty array while L[i]!=0: #and while the value at the current position is not 0 P.append(L[i])...
stackexchange_codegolf
The random Fibonacci sequence is defined as follows: $$ f_n = \begin{cases} f_{n-1}+f_{n-2} \text{ with probability } 1/2 \\ f_{n-1}-f_{n-2} \text{ with probability } 1/2 \\ \end{cases} $$ $$ f_1 = f_2 = 1 $$ i.e. whether the next term is the sum or difference of the previous two is chosen at random, independently of ...
stackexchange_codegolf
This is a cops-and-robbers challenge. The Cops' thread to this challenge is here An interesting question to think about is the following: If I have a sequence of numbers how many of them do I have to provide before it is clear what sequence I am talking about? For example if I want to talk about the positive integers...
stackexchange_codegolf
(Literally: "Does this follow/realize the gismu-form?") Premise The language Lojban is a constructed language, meaning in part that all of its words have been created rather than allowed to develop naturally. The semantic base of Lojban are its gismu, or root words, which were synthesized by combining roots from widely...
stackexchange_codegolf
Given an unsorted list of unique strictly positive integers, minimally sort it into a 2D matrix. The input list is guaranteed to be of composite length, which means the output matrix is not necessarily square, but is of size n x m with n,m > 1. "Minimally sort" here means the following: Sort the list in ascending orde...
stackexchange_codegolf
There are 18 primes with distinct prime digits (A124674). Namely, they are: \$2, 3, 5, 7, 23, 37, 53, 73, 257, 523, 2357, 2753, 3257, 3527, 5237, 5273, 7253, 7523\$ Your task is to output this sequence. Rules sequence rules apply. This means valid solutions may use any of the following formats: Given some index \$n\$...
stackexchange_codegolf
Plot: Jimmy is missing; we have to find him. We should split up. Plot twist: Jimmy is already dead. But, our cast doesn't know that, so they need to search the whole area anyway. There is an N columns x M rows (1<=M,N<=256) grid of cells, either marked as "S" for the starting point, "." for open space, or "#" for an o...
stackexchange_codegolf
Above is the picture of the flag of the country Nepal. Pretty cool. What's cooler, is the aspect ratio, which is defined under the constitution as: That formula in copyable form: $$ 1 : \frac{6136891429688-306253616715\sqrt{2}-\sqrt{118-48\sqrt{2}}(934861968+20332617192\sqrt{2})}{4506606337686} $$ Your task is to out...
stackexchange_codegolf
I got the spontaneous idea of making a series of challenges of users that have helped and continue to help the PPCG community be an enjoyable place for everyone, or maybe just specifically for me. :P If you convert Dennis's name to an array of 1s and 0s where each consonant is 1 and each vowel is 0, the array is [1, 0,...
stackexchange_codegolf
Write a function or program that accepts one character (or a string of length 1) as input, and outputs the number of times that character occurs inside the code. This program must be a Proper Quine, only in the sense that it cannot, for example, read itself as a file, etc. Input can be any character, printable or not...
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
Your task, if you choose to accept it, is simple. Objective You must make a program that, when run, prints some (as many as you want) terms in a sequence that you choose. The sequence must be a valid OEIS sequence. The twist is that when you take the characters from your code that make up your sequence, string them tog...
stackexchange_codegolf
This question is inspired by this awesome answer. The challenge is to write a program or function which takes in a positive integer, and outputs "Happy new year to you" or a slight variation thereof, such that the character codes of that string add up to the inputted number. The space counts towards the sum of characte...
stackexchange_codegolf
In most programming languages, arithmetic is written with infix notation -- i.e. the operator is put in between the operands -- e.g. 1+2. In contrast, with Polish notation (a.k.a prefix notation), the operator comes before the operands -- e.g. +1 2. As long as the number of operands for each operator is fixed, this mea...
stackexchange_codegolf
Given a positive integer \$N >= 4\$, output an RSA key pair (both the private and the public key) whose key length is \$N\$ bits. The RSA key generation algorithm is as follows: Choose an \$N\$-bit semiprime \$n\$. Let the prime factors of \$n\$ be \$p\$ and \$q\$. Compute \$\lambda(n) = LCM(p-1, q-1)\$. Choose an int...
stackexchange_codegolf
Introduction This challenge appeared in the 2020 Estonian Open Informatics Olympiad and was created Sandra Schumann. I thought it was interesting because it involves symmetry and is quite hard even to brute force by hand. The problem author said that it's ok for me to post it here: Challenge You may use a modified vers...
stackexchange_codegolf
Inspired by this blog post. Write a program that outputs 99 distinct programs (in the same language) that output the string I love you. How the programs are separated from one another in the output will be defined by you. However, Each byte of output can only belong to at most 1 of the 99 programs. Constraints for Out...
stackexchange_codegolf
The task in this challenge is to put elements of an array into time bins. The input will be a non-decreasing array of positive integers representing the time of events, and an integer which represents the size of each bin. Let us start with an example. We call the input array A and the output array O. `A = [1,1,1,2,7,...
stackexchange_codegolf
Substitute a string with itself Your goal is to substitute a string with itself by replacing each character in the original string with the one before it, starting with the first character and wrapping around. Here are some examples to show what I mean: 1st example: Input: program Output: apgopra How: Program -> mrogr...
stackexchange_codegolf
The goal is to simplify sentences containing multiple negatives. Like with multiplying negative numbers, two negative words annihilate each other until at most one is left (doesn't matter which one). While some words disappear without a trace, other leave behind a positive part The affected words are: no not couldn't ...
stackexchange_codegolf
"nimi ale lon toki pona" is a song by YouTuber jan Misali which lists 137 common words in the constructed language Toki Pona. This challenge is not a duplicate of "How high can you count?" or "Alphabet printing challenge" because instead of numbers or single characters, it outputs random (to many programming languages)...
stackexchange_codegolf
In the context of quines, an intron (or payload) is a part of a quine that serves no purpose in producing output, but is still included in the data section. For example: function quine() { const data = "function quine() {\n const data=\"@\";\n // Arr! This be an intron!\n return data.replace(\"@\", JSON.s...
stackexchange_codegolf
Define the (unnormalised) Willmore energy of a surface as the integral of squared mean curvature over it: $$W=\int_SH^2\,dA$$ For surfaces topologically equivalent to a sphere \$W\ge4\pi\$, and \$W=4\pi\$ iff it is actually a sphere. Thus the energy quantifies how spherical a surface is. In September 2020 I asked on Ma...
stackexchange_codegolf
ISO Paper Sizes Defined: The A series paper sizes are defined by the following requirements: The length divided by the width is the square root of 2. The A0 size has an area of 1 unit. Each subsequent size A(n) is defined as A(n-1) cut in half parallel to its shorter sides. Task: given an input f[n] output A0 divided...
stackexchange_codegolf
We're back! And this time with an objective scoring criteria! This is a challenge I thought of recently which I think is not hard but allows for a wide range of possible solutions. Seems like a perfect fit for the creativity of PPCG users :) Your Task Define two functions combine and separate with respective types Str...
stackexchange_codegolf
Let's begin with a thought experiment. You have a clock and a timer, in which you start the timer when the clock shows exactly hh:mm.00. Clock: The clock employs 24-hour time. So the range of hh is 0<=h<23. (Because 23 inputs are unsolvable, you aren't required to handle that) Timer: It starts exactly on 00.00. The nu...
stackexchange_codegolf
Related to: Make a ;# interpreter and Generate ;# code ;# - A Whirlwind Guide This is a simple language with two commands. Its only data structure is an accumulator, which is initialized to 0. ; Increment the accumulator # Calculate the value of the accumulator modulo 127, and print the corresponding ASCII character....
stackexchange_codegolf
As we all know, negative press covfefe has been conspiring to bring down the American president for some months now. There's also, definitely, an algorithm in play in that word. Covfe is a refreshing caffeinated beverage, and following the president's remarks it's clear the word can now be appended with successive f's ...
stackexchange_codegolf