instruction
stringlengths
34
53.1k
Following last year's event, we're doing Code Golf Advent Calendar 2022! On each day from today (Dec 1) until Christmas (Dec 25), a Christmas-themed challenge will be posted, just like an Advent calendar. It is a free-for-all and just-have-fun-by-participation event, no leaderboards and no prizes for solving them fast ...
Description Inspired by this question, write a program/function to encode a number and a program (possibly the same as the first) to decode a bitstream in variable-length encoding as follows (taken from that question's answer, slightly modified): Represent the string x using the following encoding: $$0, x_k, \dots, 0,...
“Cut” a matrix of integers on the line where the sum of the absolute differences of “severed” neighbors is the least. Example Consider this matrix: 1 2 -4 5 -1 3 2 -2 0 It can be cut in 4 places, here shown by lines lettered A–D: A B ╷ ╷ 1 ╎ 2 ╎ -4 C ---╎----╎---- 5 ╎ -1 ╎ 3 D ---╎----╎--...
Write the shortest possible program or function that will join a list of columnar strings. For this challenge, columnar strings are defined as one-character-wide strings spanning across multiple lines. Each character, except for the last one, is separated by a newline character. Some examples, separated by ---: a b c d...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. An Elf is hopping on a chessboard which extends infinitely in all four directions. They move like a generalized chess Knight: on each step, they move X units horizontally and Y units vertically, or Y units horizontally and X units vert...
Given a matrix of integers \$M\$ and a list of four integers \$L\$, find the sub-matrix \$N\$ whose corners are given by \$L\$ and return the sum of its elements. Suppose you're given the list \$L = [-8, -3, 2, 9]\$ and the following matrix \$M\$. The numbers in the list are highlighted in blue to illustrate: $$ \begi...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. I've got an infinite supply of \$n\$-dimensional chocolate for some positive integer \$n\$. The shape of the chocolate is not important. You may assume that they are just \$n\$-dimensional hypercubes with side length \$1\$. To celebrat...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Christmas is coming up, and Santa hasn't kept to his diet very well this year. Due to his size, he is getting the elves to collect a list of all the chimneys he will be able to fit down. Unfortunately, chimneys these days are a bit of ...
The task is simple. You're given an arbitrary string message. Return that message prefixed with a number, such that the length of that number plus the message equals the number. In other words, the length in your output must be the total length of your output. If multiple candidates exist, you can output any of them. F...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. It's time to prepare an advent calendar, but I've only got a large sheet of rectangular paper, randomly colored red and green like this: GRRRGRRGRG GGRGGGRRGR GRRGRGRGRG GGRRGRGRGG GRGGRGRGGG RRGRGRGRRG RRRGRGRGGG RGGRGGRRRG RGGGRRRRRG...
In 2009, Hannah Alpert described the "far-difference" representation, a novel way of representing integers as sums and differences of Fibonacci numbers according to the following rules: every two terms of the same sign differ in index by at least 4, and every two terms with different signs differ in index by at least ...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. On the flight to Hawaii for vacation, I'm playing with a deck of cards numbered from 1 to \$n\$. Out of curiosity, I come up with a definition of "magic number" for a shuffled deck: The magic number of a shuffle is the minimum number ...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Fen is a magician Elf. He can cast spells on an array of numbers to produce another number or array of numbers. One of his inventions is the Wick spell. He loves to use this spell because "once this spell is applied, a combination of p...
I struggle to easily encode big numbers in ><>. If only there was a program that could find the best way for me? What is ><> ><>, pronounced "fish", is a esoteric 2dimentional programing language. We will consider a subset here, consisting of the following commands: 0123456789 push one number to the stack, equal to th...
Your task is to make a program in L that takes n as an input number, output a program p in L that prints its own first n characters. Rules The program p has to be irreducible, See an example below. PAY ATTENTION TO THIS RULE: If a program takes an input as n, the first n characters of the output would be the same as...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Fen is a magician Elf. He can cast spells on an array of numbers to produce another number or array of numbers. One of his inventions is the Wick spell. He likes this magic so much that he's cast it on every single array in sight. Now ...
Santa's Shortest Path Problem Trying to be as time-efficient as possible Santa needs to plan his trips carefully. Given a 5X5 grid representing a map of villages it is your task to be Santa's flight controller. Show santa the shortest and therefor fastest route to fly his sleigh and give him a list of coördinates (or d...
Note: This is a more limited version of a challenge from 2014 that only received one answer. That challenge required participants write two programs; this challenge is essentially one half of that. The text here is original, but credit for the idea goes to Matthew Butterick, who is no longer active on the site. Given...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. The Elves like playing number games. One day, Bin (a friend of Fen) suggests a new game: given a positive integer n, each Elf says a number which has exactly n runs of ones in binary. The first Elf must say the smallest number, and the...
Rolling a 1x1x2 block This challenge is inspired by the game Bloxorz. Like that game, there is a 1x1x2 block, which may be moved on a square grid in any of the four cardinal directions. It moves by rotating 90 degrees about one of its edges which is touching the ground. Initially, the block is standing upright on a sin...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Santa likes to sort his presents in a special way. He keeps "uninterleaving" the pile of presents into smaller sub-piles until each sub-pile is either full of toys or full of coal. Your job is to, given a pile of presents, determine th...
Traditionally presents are kept secret in boxes wrapped in paper. Since the ice caps are melting Santa Claus has begun to investigate some ways they might make the whole gift wrapping operation a little more eco-friendly. The first thing they've decided to do is to put all presents in perfectly cubic boxes. This makes...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. There's a good news and a bad news. Good news: you got a Christmas present from Santa. (Already?! Christmas is two weeks away!) Bad news: the present is locked with a laser lock. And a note next to it says: Only the ones who can prope...
Given a positive integer n. Generate a JSON array (can be a string, or your language's built-in JSON representation as long as we can get valid JSON, (your code does not need to include outputting the string, you can just use the built-in JSON representation)) containing two empty JSON arrays, then, add a set of 2 empt...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. You successfully route the laser into the sensor, but nothing happens. "What?" Frustrated, you flip the note from Santa. There's some more text: Calculate the number of ways to complete the laser puzzle, and enter it into the number p...
A neat trick is if you ever need a nine-sided die, it is possible to make one using two six-sided dice using the numbers below. This is assuming you either have a way to rewrite the faces on the dice, or use some algorithm to map the numbers on a normal die onto these new numbers. 0 0 3 3 6 6 ----------- 1|1 1 4 4 ...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. As we all know, Santa comes down the chimney to deliver presents to good kids. But chimneys are normally full of smoke, and the Elves are worried about Santa's health. So they decide to blow the smoke out using an electronic air blower...
Sometimes when you're playing Wordle, you get to your fifth guess and you can't figure out the word any more, so you start mentally running through the list of remaining iterations, both sensical and nonsensical trying to figure out what those last few letters are. The task here is to create all permutations of a final...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. While other Elves are busy carrying air blowers, Fen comes and shouts, "I've got a spell for this job!" To recap, a chimney is modeled as a rectangular grid. The number in each cell represents the amount of smoke in the region. The lef...
Input a list of strings a and a string s for search keyword. Find out all strings in a which contains s as subsequence. And sort them in the following order: Exactly equals to s Starts with s Contains s as substring (continuous subsequence) Contains s as subsequence Detail When two strings belongs to the same sortin...
Each element on the periodic table of the elements has an atomic weight. For example, boron (element 5) has an atomic weight of 10.81. Your challenge is to write a program which takes as input the atomic number of an element and outputs its atomic weight. Your program only needs to support elements up to and including ...
Introduction In the binary representation of a \$k-\$bit \$(k>1)\$ square number \$n^2, \$ not all bits can be \$1\$. The maximum number of \$1\$-bits (Hamming weight, \$B\$ for short) is given in A357658, but only up to \$k=95\$ bits. An example of a \$99\$-bit square is \$B(796095014224053^2)=87\$. The records in A35...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. As soon as the Elves get bored with the last week's game, Bin comes up with a new game. The rules are similar, except the Elves are supposed to say the numbers that have its "left side" equal to its "right side" when written in binary....
Given a rectangle input with only \, / and space, decide if it's a valid output of Drawing in Slashes Empty lines and columns at edge get cleaned up, so the 3rd true case is true. True cases: /\/\ / /\ \ \/ / \ /\/ /\ \ \ / \/ \ \ \ \ \/ /\/\ / /\ \ / \ \/ / /\ \/\ \/ \ / / / ...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Inspired by https://xkcd.com/835 In the midst of his mid-life crisis, Santa has impulsively purchased a Sports Sleigh™ for present delivery this year. The only problem is that this sleigh has a specially designed Infinite Present Trunk...
I have a string like this: s = "helloworldandhellocodegolf" I want to make every consonant after a vowel uppercase. Desired output: heLloWoRldaNdheLloCoDeGoLf As you can see, l gets uppercased because it's right after the vowel e etc.. If there are repeated vowels, like: s = "aabeekad" Desired output: s = "aaBeeKaD"...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. It's Hanukkah! Unfortunately, it appears some of the candles in your menorah have been blown out. You've got a lighter on hand, but it doesn't work quite right. Whenever you use your lighter at position k, the candles at positions k-1,...
I have a number like this: n = 548915381 The output should be the sum of every second digit of that number. In this case 26: 4+9+5+8 = 26 Rules: This is a code-golf, so the shortest code in bytes wins. The input consists only of numbers bigger than 10 (at least 2 digits) but smaller than a 32-bit integer. The input ...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Happy Hanukkah! A beloved Hanukkah tradition for many, the game of Dreidel (s'vivon in Hebrew) is a betting game (for money or for chocolate gelt (coins)) centered on the titular spinning tops called dreidels. Dreidels have four sides:...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Oh no, Santa spilled wine all over his great book. Now most of the letters are illegible. How will Santa now know who is groovy and who is unspeakable? Challenge There was once a sequence of words, like this: groovy groovy groovy unspe...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Santa and the Elves are secretly preparing for a new tourist train service, called "North Pole Railroads". The train will travel through various sightseeing spots near the North Pole. As a part of this project, they want to know how ma...
Let's say I have this string: s = "Code Golf! I love Code Golf. It is the best." I want to replace all the vowels with repeated "aeiou". Notes: Uppercase vowels should be replaced by an uppercase letter, and lowercase vowels should be replaced by a lowercase letter. Consonants (all alphabet characters except for "ae...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. challenge idea by emanresu A Santa has a bunch of presents wrapped in cuboid boxes of various sizes. As his sled flies above a chimney, a stack of presents will be automatically dropped through it. Santa wants to carefully choose the p...
Strassen's algorithm was the first method of matrix multiplication in subcubic time complexity, namely O(n**log2(7)) for a pair of n*n matrices (assuming the numbers therein are large enough that their O(n*log2(n)) exact multiplication has become the constraint on your performance, and any nested structures and functio...
Challenge: Given the input number n. It should give me nested sublists of n layers with the power of two numbers for each level. Each power of two value will be in separate sublists. Notes: n will always be greater than 0 I am using the example output with Python Lists. You can use any type of sequence in your own la...
Challenge Given a string of any length which contains only digits from 0 to 9, replace each consecutive run of the digit 0 with its length. Test Cases 1234500362000440 → 1234523623441 123450036200044 → 123452362344 000000000000 → 12 0123456789 → 1123456789 1234567890 → 1234567891 123456789 → 123456789 010203004050 → 1...
Given an 8086 segmented ("logical") memory address, output its actual linear physical address. A segmented memory address has format xxxx:xxxx, where each of x is one of 0-9A-F, and the two parts are parsed as hexadecimal integers. Both parts are exactly 4 digits. To get its actual linear address, multiply the first pa...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Santa has a bunch of presents wrapped in cuboid boxes of various sizes. As his sled flies above a chimney, a stack of presents will be automatically dropped through it. Santa wants to carefully choose the presents so that all of them f...
Challenge: Given the input array l with a list of strings, only keep the elements in the sequence that have a letter that's repeated at least 3 times. Like 'lessons' has 3 s letters, so it should be kept in the sequence. But, 'lesson' has only two s letters, so it should be removed. Notes: l will always be a sequence,...
Task A pure mirror checkmate is a checkmate position, where the mated king is surrounded by 8 empty squares which are attacked or guarded by the winning side exactly once. You will be given a valid chess position where Black is in mate. Your task is to find if that mate is a pure mirror checkmate. Examples (click for l...
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Santa and the Elves are secretly preparing for a new tourist train service, called "North Pole Railroads". The train will travel through various sightseeing spots near the North Pole. As a part of this project, they want to know how ma...
Scientists have made contact with a parallel universe. Just one problem: They write math differently. Help the scientists make a program that can convert normal math expressions to their equivalent in alternate universe math. The connection through the portal is bad so your code needs to be as short as possible Given a...
Given two non-zero 16-bit integers a and b, decide the smallest number of shift operations needed to turn a into b. A shift is one of the following (big-endian) operations: shl (shift left): move all bits to the left, adding a 0x0 bit to the right. shr (shift right): move all bytes to the right, adding a 0x0 bit to th...
Background Here in the UK1, these are the income tax rules: You get a personal allowance (untaxed) of up to £12,570: If you earn less than £100,000, you get the full £12,570 as personal allowance For every £2 over £100,000, your personal allowance goes down by £1 After the personal allowance, the next £37,700 is ta...
Presumably everybody here knows that for the legacy BIOS, the tiniest bootable disk image is 512 bytes (the lower bound is due to the 2-byte magic at offset 510), and there is a bootsector demoscene where people try to fit the entire demo into the 510 bytes of usable space. Now that the BIOS is being superseded by UEFI...
Part of the Code Golf Advent Calendar 2022 event. See the linked meta post for details. As a Christmas gift, you were given a toy solar system. In this toy, all the orbits are circular and happen in the same plane. Each planet starts at a fixed location, has a fixed circumference orbit, and moves at a fixed speed (all...
According to MDN, every WebSocket message is sent as one or more frames. Your job is to extract the payload given a (masked) client-to-server text frame. The steps to extract the payload is as follows: ignore byte 1; read byte 2 if it is 254, skip the next 2 bytes if it is 255, skip the next 8 bytes, otherwise, conti...
Objective Given a permutation of 4 distinct items, classify the permutation by the normal subgroup(s) it belongs. Input/Output Format You gotta choose the followings as the hyperparameters for your submission: The 4 distinct items. The permutation serving as the identity permutation. The input format is to accept a...
Task Provide two programs/functions A and B (not necessarily in the same language) with the following properties: Either program, when given its own source code as input, produces an accepting output. Either program, when given the other program's source code as input, produces a rejecting output. It doesn't matter w...
The Riemann R function is as follows: $$R (x)=\sum _{n=1}^{\infty } \frac{\mu (n) \text{li}\left(x^{1/n}\right)}{n}.$$ This uses the Möbius function as well as the logarithmic integral. From Wikipedia, the Möbius function is defined so that for any positive integer \$n\$, \$μ(n)\$ is the sum of the primitive nth roots...
The Prime Signature of a number is the list of the exponents of the prime factors of a number, sorted in descending order (exponents of 0 are ignored). Inspired by Combo Class's "The Magnificent Patterns of Prime Signatures" video. For example, the prime factorization of 6860 is 2 * 2 * 5 * 7 * 7 * 7, or 2^2 + 5^1 + 7^...
Title is an homage to this classic challenge In Pip, the Scalar data type encompasses strings and numbers. A Scalar value is truthy in most cases. It is falsey only if: It is the empty string ""; or It is some representation of the number zero. A Scalar is considered to be a representation of zero if: It consists of...
Last time you were required to write program that output a file, such that no byte is same as original file. The request meant to let everyone carry part of information, but it ends up that everyone carry same info to reduce their storage... This challenge is similar. Write at most 1024 programs that output at least 85...
Introduction The \$RADD(n)\$ operation is defined as the sum of \$n + [\$ the number whose decimal representation are the decimal digits of \$n\$ in reverse order \$]\$, see A004086. After reversal, trailing zeros are lost. See Reverse-Then-Add Sequence and A056964. Not all numbers can be represented as the result of a...
We're going to turn ascii art versions of polygons into their equivalent GeoJSON. The ASCII shape language The input ASCII language only has 3 possible characters: * signifies a vertex - signifies a horizontal line | signifies a vertical line A * will never be directly adjacent to another * (but may be diagonal to on...
Fastest code is a scoring method on this site where the goal is to write code that is as fast as possible. From the tag wiki: The winner of a fastest-code challenge is determined by the runtime performance of the submissions. For fairness, all submissions should be benchmarked on the same machine, which usually means ...
Introduction Our goal is to efficiently find the maximum of a large amount of (redundant) data. We define the outer product of vectors \$A\$ and \$B\$ as a matrix containing the products of all entries of \$A\$ with each entry of \$B\$. (see outer Product) $$ A\otimes B := A\cdot B^T = \left(\begin{array}{rrr} A(1)\cdo...
The standard way to round numbers is to choose the nearest whole value, if the initial value is exactly halfway between two values, i.e. there is a tie, then you choose the larger one. However where I work we round in a different way. Everything is measured in powers of two. So wholes, halves, quarters, eights, sixte...
Given a word list, find all sets of five words of five letters each, such that the words of each set have 25 distinct letters in total. This challenge was inspired by this video by Matt Parker. Testcases Use this file if you want to test your code against the English vocabulary. Sample output sets: ["fjord", "vibex", ...
Given two rectangles, which are possibly not in the orthogonal direction, find the area of their intersection. Input You may take the rectangles as input in one of the following ways: The coordinates of the four vertices of the rectangle. These coordinates are guaranteed to represent a rectangle. The coordinates of t...
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...
I just discovered this site and this is my first question, I hope I'm doing it correctly. The challenge is the following, you must write a code that prints all the prime numbers of \$n\$ digits. Since this problem is computationally complicated, I think that one way to simplify it is to give a number \$m\$ that will be...
Consider a list of subject, grade pairs. E.g. [("Latin", "A"), ("French", "A*"), ("Math", "B"), ("Latin", "A*")] The task is to return the same list but with each subject given at most once. Where a subject occurred more than once originally, the returned list should have the highest grade for that subject. Using th...
I have this problem where I listen to so much music that I can never remember what songs are called. But even if I remember the lyrics, I won't always know the song's name. But lucky for me, there's a pretty neat formula to determine¹ the title of a song just based on its lyrics. I'll define the way a song title can be...
Wren is a small, fast, class-based concurrent scripting language. Does anyone have any tips for this language? Please make sure to post 1 tip per answer, and don't post answers like "remove whitespace".
Given as input a positive nonzero integer n >= 10 and a sequence of digits 0-9 (which may be taken as a string or a list), find the first contiguous subsequence of digits in the sequence that sums to n and output the start and end indexes. You may use zero- or one-based indexing. If no such subsequence exists, your pro...
Given a list of lists of positive integers, output a subset of them so their union forms a continuous non-empty range with no numbers missing. For example, consider this input: [ [1, 2, 3, 5], [2, 4, 6], [7, 9, 11] ] The union of the first 2 forms a continuous sequence: [1, 2, 3, 4, 5, 6] with no numbers miss...
Related Now you have some dice which you may roll several times. You need a uniform random integer between 1 and \$n\$, inclusive. Show a method that rolls the fewest times and behaves as an \$n\$-sided dice. Alternative question: Given a set \$S\$ and \$n\$, pick the fewest elements from \$S\$(each element can be pick...
Consider: c=(a,b)=>(+a||0)+(+b||0) Yes, it is not good to solve it like that. But I want to shorten it even more. If a is a string and b is a string, then return 0. If one is a number, return it (floats and intergers). And if both inputs are numbers, then return the sum (if either string can be cast to a number, treat...
Intro The Tetris Guidelines specify what RNG is needed for the piece selection to be called a Tetris game, called the Random Generator. Yes, that's the actual name ("Random Generator"). In essence, it acts like a bag without replacement: You can draw pieces out of the bag, but you cannot draw the same piece from the ba...
Write a function that takes an ASCII-printable-only (all charcodes ∈ [32..126]) string input x and provides an ASCII-printable-only output string f(x), such that for every x f(f(x))=x f(x) is all-numeric (all charcodes ∈ [48..57]) iff x is not all-numeric You can assume input is not empty and never provide empty outp...
Inspired by the title of the Toggle some bits and get a square challenge. In that challenge you output how many bits should be toggled, in order for the base-10 representation of the binary to become a square number. Challenge: In this challenge, you'll be given a bit-matrix \$M\$ and an integer \$n\$ as inputs. Output...
In chess, fork means to target two pieces with just one piece, and one of the best pieces for forking is the knight. In this challenge, you will be given three coordinates in a to h and 1 to 8 (like a8 or e7) format. The first and second coordinates are for two other random pieces, and the third is the knight's coordin...
A Shift matrix is a binary matrix with one superdiagonal or subdiagonal formed by only ones, everything else is a zero. A superdiagonal/subdiagonal is a diagonal parallel to the main diagonal, which is not the main diagonal, i.e. all entries \$a_{ij}\$ where \$i=j+k\$ and \$k \neq 0\$. The main diagonal is defined to b...
Sometimes I feel like the conversation is going down the wrong path and take it upon myself to steer it in another direction. And this conversation is going wrong real fast, so I need to change the subject in as few characters as possible.1 Task Given a list of sentences, return the sentences ordered such that each sen...
Let's solve the same task as in this challenge but faster! Input: a non-empty string containing letters a-z Output: the length of a longest (contiguous) substring in which all letters are different Time and space complexity: O(n). The number of letters in the alphabet is 26, or O(1). Make sure you understand how your l...
Context So the Dutch "Ministerie van Binnenlandse Zaken en Koninkrijksrelaties" (NL) - "Ministry of the Interior and Kingdom Relations" (EN) recently released the source code of their digid-app. They have some goofy code in there, which led to mockery and memes on reddit Source code of the offending method can be found...
Alternatively: That one challenge I forgot I had in the sandbox and is about stuff from Discrete Mathematics I learned like 5-6 months ago and kinda don't remember Given a path of vertices that form a cycle on a graph, output a simple version of the cycle. That is, if a vertex appears twice, snip out the part in betwee...
Challenge To quote Wikipedia: An octave-repeating scale can be represented as a circular arrangement of pitch classes, ordered by increasing (or decreasing) pitch class. For instance, the increasing C major scale is C–D–E–F–G–A–B–[C], with the bracket indicating that the last note is an octave higher than the first no...
Inspired by a challenge from the OUCC 2022 Seniors competition. Background Two teams are playing "capture the flag". They take turns invading each other's base and capturing their opposing team's flag in the shortest amount of time. The attacking players each have one soft ball they can throw at the defenders. Teams ge...
Given a matrix of positive integers, output whether it's possible to generate it by starting with an empty1 matrix of the same dimensions and repeatedly filling a whole row or a whole column with the same value, overwriting any values already written. Example The following matrix: $$\begin{pmatrix}1&1&1\\2&3&4\\2&3&4\e...
Introduction An abstract syntax tree (AST) is a tree of tokens that shows their connection to each other and syntactical meaning. They are commonly used in compilers and static analysis tools, as parsing a language into an AST helps remove any ambiguity and can be helpful for optimizations. Many ASTs are large and comp...
2fuck is a simple 2D variation on brainfuck. Like traditional brainfuck, there is an 1D memory tape that extends 30000 bytes to the right from its beginning, consisting of values between 0 and 255. Arithmetic should wrap around, adding 1 to 255 sets the cell to 0, and moving right from memory cell 29999 should move the...
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 ...
Introduction In the prisoner's dilemma, two partners in crime are being interrogated, and have the choice to either betray their partner or stay silent. If both prisoners betray each other, they both get 2 years in prison. If neither betrays (both stay silent), they both get 1 year in prison. If only one betrays and t...
In a certain chatroom, we like making acronym jokes about the build tool we use called sbt. While it usually stands for "Scala Build Tool", we aim to come up with all sorts of meanings, such as: Stupid Brick Teeth Sussy Baka Training Shady Blue Tourists Seriously Big Toes Silly Bear Topics Salacious Bacon Tripod Syrin...
Alternatively: Now you're checking with portals! Inspired this challenge I am somewhat of a self-declared Chess Anarchist. That means that when I play chess, en passant is forced (else the brick gets used), double check is mate (and pasta), and all sorts of new pieces and squares are added to the game. One such piece i...
Bingo Bingo is a numbers game where players match randomly drawn numbers to the numbers on their cards. Each bingo card is a square grid with 25 spaces, and the columns of the grid are labeled with letters such as "B", "I", "N", "G", "O". The letters help to identify the number range in each column, for example, the "B...
Output the numbers 1-16 (or any other set of 16 distinct items). Then, repeatedly, output a random value chosen uniformly from the last 16 items outputted. After the same item is printed 16 times in a row, halt. If a number appears multiple times in the last 16 values, it should have proportionally more chance to be ch...
Introduction In the United States, national elections are normally held on the first Tuesday after the first Monday in November. Challenge Write a program that takes a Year as integer, and a pair of (day of week as character and ordinal as integer) and output the date as "yyyy-mm-dd" Remember, the second pair is after...