instruction
stringlengths
34
53.1k
Let me explain one by one the above terms... We will call \$\text{Z-Factorial}(n)\$ of a positive integer \$n\$, \$n!\$ (i.e. \$n\$ factorial) without any trailing zeros. So, \$\text{Z-Factorial}(30)\$ is \$26525285981219105863630848\$ because \$30!=265252859812191058636308480000000\$ We will call Modified Z-Factorial ...
You've inherited a server that runs several apps which all output to the same log. Your task is to de-interleave the lines of the log file by source. Fortunately, each line begins with a tag that indicates which app it is from. Logs Each line will look something like this: [app_name] Something horrible happened! App ...
As TIO can show, every letter of the Latin alphabet is represented when it comes to languages. For every letter there is at least 1 programming language whose name begins with that letter. Your task is to create a polyglot in order to demonstrate that. Your program should be runnable in between 2 and 26 different langu...
Background Tetris Grand Master 3 has a hidden grading system based on the shape of the stack at the end of the game, which is called Secret ">" Stacking Challenge. It consists of entirely filling the lowest rows except for the zigzag pattern which starts at the left bottom cell and spans the entire width: # .######### ...
Just like code-golf, restricted-source pushes one to exploit quirks and hidden features of the Python language. We already have a place to collect all these tips for code-golf, those for restricted-source remain transmitted by word of mouth or hidden deep within the python documentation. So today I would like to ask y...
Write three different programs such that when any one program is provided as input to one of the other two, you get the source of the remaining program as output. More explicitly, given programs \$A\$, \$B\$, and \$C\$, where \$f(g)\$ denotes the output obtained from inputting the text of program \$g\$ into program \$f...
Write a quine which attempts to invert the case of as many ascii characters in the source code as possible. For example in javascript: (x=function(y){return ('(x='+y+')(x)').toUpperCase();})(x) Standard quine rules apply. The score is given by number of bytes in the source code - number of case inversions. For examp...
How do I remove all duplicates from list and order it based on count? s = ["foo", "this", "lem", "foo", "lem"] s = ["foo", "ebh", "wosv", "wosv", "ebh", "4whcu"] #should return >>> ["foo", "lem", "this"] >>> ["ebh", "wosv", "foo", "4whcu"] Rules: Must be shorter than the below code in terms of byte size. Order must b...
CODE GOLF & Coding Challenges: In today's challenge, you'll be asked to print the following very special AND tricky AND satisfying Prime Number...! Are you golfers ready? 67796869327179767032383267111100105110103326710497108108101110103101115583273110321161111009712139115329910497108108101110103101443212111111739108108...
The challenge: Assuming you have \$ X \$ collections, each collection \$ C_i \$ has a name \$ N_i \$ and a capacity \$ N_i \$ of elements - Determine which collection will be overflowed first while counting the occurrences of the names in a cyclic list. Also print how many cycles of the list occurred. Example: 4 Collec...
Input A bound m <= 4294967295. Output Consider values sampled uniformly at random from integers in the range 0 to m, inclusive. Your output should be the expected (average) number of trailing zeros in the binary representation of the sampled value. Your answer should be exact, for example given as a fraction. Example ...
In the body of this challenge, \$\begin{pmatrix}n\\k\end{pmatrix}\$ is used to represent the number of combinations of \$k\$ elements of \$n\$, also written as \$\frac{n!}{k!(n-k)!}\$ or \$n\mathrm{C}r\$. Any nonnegative integer \$m\$, for arbitrary natural (positive) \$r\$, can be written as a unique series of \$r\$ c...
Let's just see how this goes If you've ever listened to the radio program "I'm sorry, I haven't a clue", then you've probably heard of the game called "Mornington Crescent". For those who haven't, it's a game where players name random stations on the London Underground network. The first person to name "Mornington Cres...
Write the shortest program that prints the sound my alarm clock makes, and stops after an inputted number of beeps. For reference, here is the sound my alarm makes: beep beep beep beep beep beepbeep beepbeep beepbeep beepbeep beepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeepbeep bee...
Note This is the decryption challenge. The encryption challenge can be found here. Challenge The challenge is to decrypt a given string, using the rules as specified below. The string will only contain lowercase alphabets, digits, and/or blank spaces. If you want to know how the input string has been encrypted, refer t...
Number Splitting Instructions Oh no, my numbers have stuck together! Luckily, we can split them apart with code. Your code should be a function that takes an integer input from stdin or as an argument. You must split the number into single digits, keeping the order and possible duplicates of these digits. The output sh...
The challenge Given point and a path of points, say whether or not the point is in the polygon that is created by the path. Also return true if the point is on an edge of the polygon. Input A list of pairs of integers. The first 2 integers represent the point. The remaining pairs (3rd and 4th, 5th and 6th etc.) represe...
The mean of a population \$(x_1,\dots,x_n)\$ is defined as \$\bar x=\frac1n\sum_{i=1}^n x_i\$. The (uncorrected) standard deviation of the population is defined as \$\sqrt{\frac1n\sum (x_i-\bar x)^2}\$. It measures how dispersed the population is: a large standard deviation indicates that the values are far apart; a lo...
Your task here is to take a LifeOnTheEdge pattern and convert it to LifeOnTheSlope. A LifeOnTheEdge pattern is composed of these four characters: |_L . A pattern corresponds to a certain arrangement of "on" edges in a square grid. The pattern is placed in the grid first with the characters in the cells, and each of the...
In the face of some regrettable rules that turned the original into a glorified sorting task, I am posting a more challenging variant. Shout out to Luis Mendo for the suggestion of how to improve the original challenge. You've inherited a server that runs several apps which all output to the same log. Your task is to ...
Challenge Given an integer radius \$r \geq 0\$, write a program that prints each set of cartesian coordinates in a counter-clockwise spiral originating at \$(0, 0)\$ as shown here (for \$r = 3\$), with indices: Input The program should take \$r\$, a non-negative integer, as an input. The input is assumed to be valid a...
This challenge has officially ended. Further submissions will not be competitive (but are still welcome!). View the scores here In this challenge, submissions ("bots") should be Javascript functions which try to win as many races as possible. In each race, bots will have a limited amount of energy which should be use...
Task Given a non-negative integer \$n\$, evaluate the factorial \$n!\$. The factorial is defined as follows: $$ n!=\begin{cases}1 & n=0\\n\times(n-1)!&n>0\end{cases} $$ Rules All default I/O methods are allowed. Standard loopholes are forbidden. Built-ins are allowed. There is no time or memory limit. Giving imprecise...
Task Given an integer \$n\in[0,10^{12})\$ in any convenient format, return the number of strokes needed to write that character in simplified Chinese. Background Chinese numerals are expressed in base 10 with a system of digits and places, with an important distinction that digits are in groups of four, rather than thr...
Similar in spirit to Number of distinct tilings of an n X n square with free n-polyominoes and Partition a square grid into parts of equal area, this challenge will have you count ways of partitioning a triangle in a triangular grid. The goal of this code-golf challenge is to write a program that outputs \$ a(n,m)\$, t...
Background Two numbers, \$a\$ and \$b\$, are said to be connected by a Brussels choice operation* if \$b\$ can be reached from \$a\$ by doubling or halving (if even) a substring (the substring must not be empty and may not contain any leading 0s but it can be 0) in the base-10 representation of \$a\$ *This operation is...
Sandbox Definition: A positive integer n is almost-prime, if it can be written in the form n=p^k where p is a prime and k is also a positive integers. In other words, the prime factorization of n contains only the same number. Input: A positive integer 2<=n<=2^31-1 Output: a truthy value, if n is almost-prime, and a fa...
Design a language and golf its interpreter so that it solves the following programming challenges in as few bytes as possible: Hello World cat Fizz Buzz List the first \$n\$ primes Fibonacci Sequence Sort a numerical list Balanced parentheses/brackets/braces test Rule 110 (as a proof of Turing completeness) Challenge...
Introduction Recently I was trying out one of the more obscure use-cases of a modern smartphone: Calling someone by number. While typing it in, I noticed that some of my phonebook entries were displayed, even though the number I was trying to call was different! After some experiments, I figured out why. What it does ...
Write the shortest program or function that takes some text as input, and outputs either it or an empty line in a repeating pattern: some text some text some text some text some text some text ... This must continue indefinitely, or until some unpreventable limitation occurs (stack size, memory, etc.). It must be n...
Problem Statement: You will receive a substring of a palindromic string. You must return the index of the substring which marks the point of reflection of the original string. You are only provided the substring, which is not necessarily a palindrome because it is not necessarily centered about the middle of the origin...
I just realized that Python allows more than names as for loop iteration variables: for a[i] in sequence: pass The real fun begins when a and i change during the loop. The following function inverts a list a in place while printing the intermediate steps. All assignments occur implicitly in the iteration variables...
You task here is very simple: Given a positive integer n without leading zeroes as input, split it in all possible ways Examples Input->Output 111 -> {{111}, {1, 11}, {11, 1}, {1, 1, 1}} 123 -> {{123}, {12, 3}, {1, 23}, {1, 2, 3}} 8451 -> {{8451}, {845, 1}, {8, 451}, {84, 51}, {84, 5, 1}, {8, 45, 1}, {8, 4, 51}...
Problem Statement: Consider a number n in base-10. Find the smallest base-10 integer i greater than n, such that both the decimal and binary representations of i are prime (when viewed in decimal). Input: a number in decimal Output: The smallest base-10 number greater than n, which when viewed in both binary and deci...
This challenge is from a game, Keep Talking And Nobody Explodes. It's hard to say how this mechanism works. The engineering is pretty impressive, but there must have been an easier way to manage nine wires. — from the manual Input Exactly 9 "wires", each which is labeled 'A', 'B', or 'C', and is colored red, blue, or b...
Pip is an imperative golfing language with infix operators. It also borrows some features from functional and array programming. What general tips do you have for golfing in Pip? I'm looking for approaches and tricks that are commonly useful for code golf and are specific to Pip (e.g. "remove comments" is not an answer...
The Polygamma function of order \$m\$, \$\psi^{(m)}(z)\$, is the \$(m + 1)\$th derivative of the logarithm of the gamma function, which is also the \$m\$th derivative of the digamma function. Your task is to take an integer \$m\$ and a positive real number \$z\$ and output \$\psi^{(m)}(z)\$ Definitions For those unfami...
Input: A positive integer n=p^q where p and q are prime. Output: Output the result of q^p Test cases (in, out): 4, 4 8, 9 25, 32 27, 27 49, 128 121, 2048 125, 243 343, 2187 1331, 177147 3125, 3125, 16807, 78125, 823543, 823543 161051, 48828125 19487171, 1977326743 Scoring: This is code-golf, so may the shortest code...
Challenge Given a string of any length, write it as a triangle, spiraling out from the center. For example, abcdefghijklmnop becomes: g fah edcbi ponmlkj Or more explicitly: If you like, you can spiral counter-clockwise instead: g haf ibcde jklmnop Or add spaces uniformly: g f a h ...
What general tips do you have for golfing in Scala 3? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Scala 3 (e.g. "remove comments" is not an answer). Please post one tip per answer. Also see Tips for golfing in Scala
Background Hello is a language "written" by Anne Veling, which errors if the program does not contain only h, and will print Hello World for every h Task You are to write an interpreter/compiler for Hello. Example in Python import os i = input("Program: ") for a in i: if a != 'h': print("err") quit(...
Challenge Given a number x and a precision e, find the lowest positive integer q such that x can be approximated as a fraction p / q within precision e. In other words, find the lowest positive integer q such that there exists an integer p such that abs(x - p/q) < e. Input The pair (x, e) where x is a floating-point n...
In this game of cops and robbers, each cop will make a vault: a program that stores a secret, and requires a key to unlock. The robbers should find a way to get the vault to reveal its secret without knowing the key. Cop rules Cops will write two short segments of code: A vault, which takes a key and secret, then allo...
This is the robbers' thread. The cops' thread is located here. Robber rules Should work for all keys and secrets Should require the same number or fewer guesses as the cop's fault, to prevent brute forcing Does not need to be the same as the cop's intended fault Multiple cracks may be made for the same cop, as long as...
Input a String and surround it with a rounded rectangle of alternating "friendliness pellets".(0) Sandbox Idea originally from Lyxal. Challenge Given a single line non-empty String of length \$<100\$, print the string with a rounded rectangle of alternating pellets(0) around it. The rectangle must be 11 lines in heigh...
Banknotes in many countries come in denominations of 1,2,5,10,20,50,100,200,500,1000, etc. That is, one of \$ \{ 1,2,5\} \$ times a power of \$10\$. This is OEIS A051109, except we'll extend the sequence to bigger values. Given a positive integer as the input, the program should output the largest bank note that is les...
A mortality table or life table is an actuarial tool that gives the probability that a person aged \$A\$ years will die in the next year, and is used to help calculate the premiums for life insurance, among other things. One of the first people to compile a life table was Edmond Halley, of cometary fame. These probabi...
Consider a word/string of length \$n\$, only including the letters A-Z, a-z. A word/string is a double prime word if and only if n is prime and the sum of the letters, s, is also prime, using their numeric position in the alphabet (a=1, B=2, c=3, etc.). Input can be any combination of upper or lower case alphabetic cha...
Introduction Arrays are usually used with for-loops or iterators. One different task might be the use as a cheap way to rotate through a set of items, so after reaching the last index, the next item would be the first item of the array. This is useful for cases like menus and physical controls. Challenge Given the size...
Background A staircase polyomino is a polyomino made of unit squares whose shape resembles a staircase. More formally, a staircase polyomino of size \$n\$ is defined as follows: A staircase polyomino of size 1 is a single unit square. A staircase polyomino of size \$n\$ is the same as that of size \$n-1\$ with a horiz...
Summary We already have a challenge for the minimal number of characters for Turing completeness. But what about the minimal maximum byte? Challenge For a language of your choice, find a subset of characters that allows your language to be Turing complete with the minimal maximum byte value. Example If your language is...
Task Given a string s, output a truthy value if the ASCII code of each letter is divisible by the length of s, and a falsey otherwise. Input/Output Input is a nonempty string containing only ASCII [32-126]. Output is a standard truthy/falsey value. Note that you can switch the values, for example returning 0/False if d...
Challenge Given daily arrival and departure times of every train that reaches a railway station, find the minimum number of platforms required for the railway station so that no train waits. In other words, find the maximal number of trains simultaneously present in the station. Input a pair of lists of times: arrival...
A drug comes in 5mg, 2.5mg, and 1mg sized pills. The drug is taken once a day. The total daily dose will be only one of the following (all in mg): 1, 2, 3, ... 20, 22.5, 25, 27.5, 30, 32.5, 35, 37.5, 40, 42.5, 45, 47.5, 50 In words: any whole number less or equal to 20, then at 2.5mg increments up to 50. Your task is t...
Given a rectangle, a start point, and an end point, find any path from start to finish that avoids the rectangle. Example Suppose you were at \$(1.5, -1.5)\$ and you needed to get to \$(2, 4)\$. However, there is a rectangle with upper left corner \$(1, 3)\$ and bottom right corner \$(4, 1)\$ in your way. It would look...
Not to be confused with Is my OS 32-bit or 64-bit. This one is very simple, tell me whether or not my CPU supports 64-bit instructions. If my CPU supports 32-bit instructions, print '32', if my CPU supports 64 bit instructions, print '64', if my processor naitively supports other lengths of instructions, print 'other'....
You are a medieval overlord tasked with designing a road network between three kingdoms placed on a \$9 \times 9\$ grid. A sample placement of kingdoms might look like this: Non-commercial use of tileset by douteigami. Thanks! The kingdoms make the following three demands: The road network must be connected: for any ...
Let us take a break from the brain-wrecking questions and answer some of the simpler ones You have recently read something extremely funny, and want to express your laughter to the world! But how can you? Task You have to display the string: Lololololololololololololololololololololololololololololololololololololololo...
Starting an the origin on an infinite grid, you follow a predetermined path going up (U), down (D), left (L), or right (R). You paint every square you visit, including the square you started at and the square you finish at. Using this method, we can paint the number six using the instructions RRDDLLUUUURR: The origin ...
A positive integer \$x\$ is an \$n\$-perfect number if \$\sigma(x) = nx\$, where \$\sigma(x)\$ is the divisor sum function. For example, \$120\$ is a \$3\$-perfect number because its divisors sum to \$360\$: $$360 = 3\times120 = 1+2+3+4+5+6+8+10+12+15+20+24+30+40+60+120$$ and $$926073336514623897600 = 6\times1543455560...
Background Tetris is a single-player game played on a rectangular grid with tetromino pieces. When you fill one or more lines with tetrominoes, the filled lines are removed, and all blocks above them move down accordingly. In the following diagrams, . is an empty space, # is an existing block, and the tetromino marked ...
Your program is supposed to create a full red screen in MSDOS. The source of the binary (.com file) must be 5 bytes or less. No wild assumptions, the binary must work in MsDos, DosBox, and FreeDos alike. For winning, you have to post x86 assembler code which can be assembled with NASM (FASM) or directly the hex code of...
A little while back, data was frequently stored on punched card. A typical card would have 80 columns of 12 possible 'punch' positions. A plethora of encodings was used, each for their own specific purpose. These days we like to think of a byte as 8 bits. In this challenge, you're tasked to convert an 8-bit byte to a 1...
Backstory You own a tiny jewellery shop in the suburbs of the city. The suburbs are too much overpopulated, so your shop has a thickness of only one character to fit in the busy streets. Recently, there has been lots of cases of robbery on the neighborhood, and you fear that robbers will also come to get your bounty. T...
Check if two blocks of bits dovetail perfectly. Specifications A block of bits is a fixed sequence of 8 bits just like this for example : 11110101. For simplicity we refer to truthy/falsey values as 1/0 bits but they can be everything capable of representing those two states in a clear, well defined and consistent wa...
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 ...
It's one of these again :D Your task, if you wish to accept it, is to write a program/function (without any uppercase letters) that outputs/returns its string input/argument. The tricky part is that if I convert your source code to uppercase, the output must be reversed. For simplicity, you can assume that the input is...
Inspired by this OEIS entry. Background A saturated domino covering is a placement of dominoes over an area such that the dominoes are completely inside the area, the dominoes entirely cover the given area, the dominoes may overlap, and removal of any domino reveals an uncovered cell (thus failing to satisfy condition...
Background We've studied at least five different types of numbers based on the IDs of different users on this site. Why not study another? My user ID is \$91030_{10}\$. Its binary representation is \$10110001110010110_2\$, a representation which has an interesting property of its own: One option for the longest palind...
Who's up for a second attempt? If you've ever listened to the radio program "I'm sorry, I haven't a clue", then you've probably heard of the game called "Mornington Crescent". For those who haven't, it's a game where players name random stations on the London Underground network. The first person to name "Mornington Cr...
The coefficients of a perfect square polynomial can be calculated by the formula \$(ax)^2 + 2abx + b^2\$, where both a and b are integers. The objective of this challenge is to create a program that not only can find if an input trinomial is a perfect square, but also find its square root binomial. The input trinomial ...
I tested the waters on this sort of question with python, but now I get to the real question I want to ask. restricted-source challenges are uniquely rewarding in Haskell because of Haskell's strict rule set. Type coercion which is the bread and butter for other languages in these sort of challenges is arguably non-ex...
The purpose of this challenge is to figure out whether all the dominoes will fall, given an input string representing a top view of the table. Input format The program can take the input as a single string with newlines or a list of strings. Spaces denote, well, empty spaces, and the rest represent dominoes. The start ...
Inspired by Find the largest fragile prime. By removing at least 1 digit from a positive integer, we can get a different non-negative integer. Note that this is different to the Remove function in the linked question. We say a prime number is delicate if all integers generated this way are not prime. For example, \$606...
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...
A port of my other question: Double Prime Words Consider a word/string of n alphanumeric characters with sum of the characters, s, using their numeric position in the alphabet (a=1, B=2, c=3, etc.) or numeric value (0,1, 2, 3 - 9). Numeric characters should be taken at individual value. (66 is two 6 characters for a su...
In this challenge, the goal is to find the values of some variables after a number of assignments are done. An example input: a = 5 b = 4 c = a = b a = 2 b = a This would result in: a = 2 b = 2 c = 4 Each statement will be one of the following: A variable name ([a-z_]+) A numeric value ([0-9]+) An assignment operati...
Intro Given radius \$r\$, draw a circle in the center of the screen. Sandbox. The Challenge Here is a simple challenge. Plot a circle using the formula \$x^2+y^2=r^2\$, or any other formula that will plot a circle according to the given parameters. You may use any units that your language provides, so long as they are ...
Create a function which takes in a input integer and then returns the number of factors it has, like if you pass 25 then it will return 3 since it has 3 factors i.e. 1,5,25. Challenge: Make the fastest and the smallest code!
At time of writing, my reputation is \$16,256\$. As I noted in chat, Oh cool my rep is the concatenation of two powers of 2: 16,256 Or even the concatenation of a power of 2 and its square, which is much more interesting which then spawned a CMC about checking if a number has this property. Given an integer \$n > 0\...
You place a standard die at the origin of a 2D grid that stretches infinitely in every direction. You place the die such that the 1 is facing upwards, the 2 is facing in the negative y direction, and the 3 is facing in the positive x direction, as shown in the figure below: You then proceed to execute a series of move...
Background There is an interesting question on MathSE about some conjectures that are disproven by extremely large counter-examples. This delightful answer tells the story of a sequence of numbers called Gijswijt's sequence, which is now registered as A090822. The sequence is defined as follows Let \$a_1 = 1\$ and for...
The International Phonetic Alphabet is a system of phonetic notation intended to be able to accurately represent every sound used in spoken language. The alphabet contains 29 vowel letters iyɨʉɯuɪʏʊeøɘɵɤoəɛœɜɞʌɔæɐaɶäɑɒ and 81 consonant letters, although I missed three (ɦǀǂ) when I first posted this challenge, so you on...
Rest in peace, John Horton Conway There are a ton of different Game of Life interpreters out there! A ton! Currently for you, getting an interpreter is just a dozen types and a couple of clicks away. But wait, do you notice a common thing in the interpreters? Every interpreter is graphical, i.e there are only images an...
The Xerox Alto, originally released in 1973, was the first computer to feature the now-familiar angled mouse pointer. The Alto's bitmapped pointer looked like this (redrawn from Fig. 2 here): Your task in this code-golf challenge is to write a program/function that generates an ASCII art representation of the mouse po...
I guess you could call this the next challenge in the "Irreducible series". Hello World Challenge Create a cat subject to the constraint that it is irreducible. A cat program C is considered irreducible if there does not exist a cat (in the same programming language as C) that can be constructed by removing character...
Introduction Logic gates! Everyone knows them, everyone loves them (unless you're starting to learn them). Take two booleans, compare them, get a single boolean in return. AND, NAND, OR, NOR, XOR, XNOR. Fun! But, what if you only had the inputs and output, but not the operator? Challenge Given a three digit number, xy...
Challenge Unlike the circumference of a circle (which is as simple as \$2\pi r\$), the circumference (arc length) of an ellipse is hard. Given the semi-major axis \$a\$ and semi-minor axis \$b\$ of an ellipse (see the image below, from Wikipedia), calculate its circumference. By definition, you can assume \$0 < b \le a...
Deserializing binary trees depth-first is pretty easy, but doing it breadth-first is (hopefully) harder. Your mission, should you choose to accept it, is to do the latter. The input will be a 1-D list of positive integers representing node values and some other consistent value representing the absence of a child (I'll...
Introduction Just on Hacker news, John Resig contemplates transforming a query “foo=1&foo=2&foo=3&blah=a&blah=b” into one that looks like this: “foo=1,2,3&blah=a,b", https://johnresig.com/blog/search-and-dont-replace/. He claims "being 10 lines shorter than Mark’s solution". Query strings consist of sequences of name-v...
OG post Task In this challenge, you will be given an string emoticon, and your task will be to output its happiness. How? An emoticon will always have eyes and mouth. It can also include eyebrows and nose. Each part will influence the overall happiness rating, which is the sum of happiness ratings of all parts. Emotic...
As the title says, you are to create a pristine program in as many languages as possible. A pristine program, taken from here, is: Let's define a pristine program as a program that does not have any errors itself but will error if you modify it by removing any contiguous substring of \$N\$ characters, where \$1 \le N ...
Let's start by defining a Two Bit Number™: It is a positive integer When expressed as a binary string it has exactly 2 true bits OR When expressed as a decimal number, it has exactly 2 of the numeral one, and all other numerals are zero. Or as a sentence A Two Bit Number™ is a number which contains exactly 2 of the n...
Introduction: You're a key maker, and want to access something from a safe that has a lock. Unfortunately, the key to that lock is lost, so you'll have to make a new one. You have access to a bunch of blank keys, to which you can add notches to turn it into actual keys. You also have loads of keys with notches already ...
Executive summary: Print NxN matrices \$A\$ and \$B\$ where \$ AB = 10A + B \$. Largest N wins! Details: Entrants in this challenge should choose an N. Submit a program that takes an input integer 'seed', and produces two full rank NxN matrices \$A\$ and \$B\$, where each element of \$A\$ and \$B\$ is an integer from ...
Objective Mimic Haskell's reads :: ReadS (). Or in other words, parse nested parentheses. Since the target type is () (the type with one possible value), "parsing" means discarding a leading nested parentheses. Valid Input "Nested parentheses" means (), (()), ((())), and so on. That is, leading nonzero (s and trailing ...
Find what is the distance for a given string to its closest palindrome of the same length. For this task I decided to give the characters further away from the string's center more weight (think of it as contributing more torque), proportional to their distance to the center. Let's define the palindrome distance for a ...
Introduction Ah, INTERCAL... As much as I'd like encourage everyone to Try it Online, text output is just painful. According to the docs it uses the "Turing Text Model". While an... interesting concept, using it is about as much fun as shooting yourself in the foot. And what do we do with a task like this? Automate it....
Leonhard Euler wants to visit a few friends who live in houses 2, 3, ..., N (he lives in house 1). However, because of how his city is laid out, none of the paths between any houses form a loop (so, the houses exist on a graph which is a tree). He gets bored easily but if he visits his friends in a different order, he ...
Intro Given a whole number \$< 100,\$ extend/shorten the english representation of the number to have as many characters as it's value. Sandbox Rules Take the number \$n\$, and get it in words from this dictionary. You may take this dictionary in any way you prefer. (a list, read from link, command line arg, STDIN, va...