instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
This is the robbers' thread. See the cops' thread here. In this cops and robbers challenge, the cops will be tasked with writing an algorithm that computes some function of their choice, while the robbers will try to come up with their algorithm. The catch is, the 'algorithm' must be a single closed-form mathematical e...
stackexchange_codegolf
Sometimes, when writing a program, you need to use a prime number for some reason or other (e.g. cryptography). I assume that sometimes, you need to use a composite number, too. Sometimes, at least here on PPCG, your program has to be able to deal with arbitrary changes. And in circumstances conveniently contrived to m...
stackexchange_codegolf
You're with your best bud, Jim, at the amusement park and as your favorite ride comes into view, you and Jim exchange glances. Naturally you race to get in line. Unfortunately he wins because you're a golfer and he plays a real sport (sorry friends). In fact, you're so far behind that you and Jim are separated by x peo...
stackexchange_codegolf
Contest Finished! Read comments on blobs to view their score. This KoTH is loosely inspired by Primer's Natural Selection Simulation. Your bot is a blob. In order to survive, you must eat pellets to regain energy, which is used to move. With extra energy, blobs can split into two. Energy and Movement Your blob starts o...
stackexchange_codegolf
In crossword terminology, the grid is the region into which the crossword answers are inserted, consisting of white and black squares. The crossword answers, called entries, are inserted into contiguous sequences of white squares in a row or column, separated by black squares. For straight (American) crosswords, the g...
stackexchange_codegolf
Given an array of letters in the range 'a' to 'o', compute how to construct the array by successively inserting the letters in alphabetical order. You will always start the insertion with a base array of all the 'o's that are in the array to be reconstructed. Examples Let the input array be: ['o', 'b', 'o', 'b', 'a'] ...
stackexchange_codegolf
I recently moved to an apartment overlooking the inner ring-road of town, and every day, a beautiful scene unfolds. The traffic lights are apparently so confusing (mostly because the Dutch are used to complex intersections, and this one is too simple for them to wrap their heads around), that the intersection invariabl...
stackexchange_codegolf
Your challenge is to query the SE API and find out whose rep on PPCG is tied, and output it. If these were all the users on PPCG: Martin Ender: 10000 rep Dennis: 10000 rep xnor: 5000 rep sp3000: 3000 rep You should output Martin Ender, Dennis. If these were the only users: Jon Skeet: 1000000 rep Martin Ender: 10000 re...
stackexchange_codegolf
Given a description of the base state of a recursive ASCII pattern, output an expanded state somewhere along the recursion steps. More specifically: Let the following be an example: ##.. ##.. ..__ ..__ Where # is filled, . is empty, and _ is recursive. This describes a pattern wherein the top left quarter is filled, t...
stackexchange_codegolf
Gaussian integer is a complex number in the form \$x+yi\$, where \$x,y\$ are integer and \$i^2=-1\$. The task is to perform such operation for Gaussian integers \$a,b\$, that \$a=q \cdot b+r\$ and \$|r|<|b|\$ (\$q,r\$ are Gaussian integers, \$|z|\$ is defined as \$\sqrt{a^2+b^2}\$ for \$a+bi=z\$). Need to output only ...
stackexchange_codegolf
Yahtzee is a game played with five six-sided dice and a score sheet with thirteen different boxes to fill a score in. Each box has its own scoring rules: 1s, 2s, 3s, 4s, 5s, 6s all score points equal to the sum of the respective dice (that is, a roll of [3, 2, 3, 1, 5] scored as 3s would be awarded 6 points: 3 for eac...
stackexchange_codegolf
Your task is to take an ASCII art image and output it rotated clockwise by 45 degrees and scaled by a factor of \$\sqrt 2\$. The scaling comes from using a lattice pattern which introduces space between the characters. To explain it visually, a \$3 \times 3\$ block would be processed like so: 123 456 789 becomes 1 ...
stackexchange_codegolf
Goal: Write a function that takes a number as input and returns a short-hand roman numeral for that number as output. Roman Numeral Symbols: Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1,000 For an example of what I mean when I say "short-hand roman numerals", let's conside...
stackexchange_codegolf
Skat I'm a fan of anagrams, so given two strings s1 and s2 write a program or function that outputs a truthy value if s2 is an anagram of s1, and a falsey value otherwise (not accounting for spaces and capital letters). For example: Input: s1 = "Anagram"; s2 = "Nag a ram" true Input: s1 = "stack overflow"; s2 = "fewe...
stackexchange_codegolf
Lets say your job is to paint poles, and a client asks you to paint a pole with 4 red sections and 3 yellow sections. You can do that pretty easily as follows: r y r y r y r With just yellow and red stripes. Now lets say your client asks you to paint a pole with 2 red sections, 2 yellow sections, and 1 green section...
stackexchange_codegolf
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...
stackexchange_codegolf
Given a string representing a series of aircraft marshalling hand signals, write a function or program to calculate the final position of an aircraft following these signals. N.B.: Co-ordinates in this challenge are represented as a pair of Cartesian co-ordinates, plus a compass direction heading: (x, y, h) where x is ...
stackexchange_codegolf
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 ...
stackexchange_codegolf
This might be a very basic question in terms of math, x % constant = x_modulus (x + some_number) % constant = y_modulus Given the value of x_modulus, y_modulus, (x + some_number) and constant(common in both), output the value of x itself based on these values.
stackexchange_codegolf
In this challenge, you will create the shortest graphical program that displays exactly "Hello, world!" You will need no input. You might be asking yourself, "what does he mean by graphical?" Well, by graphical, I mean not writing to stdout. For example, look at my ES6 answer, which makes an alert box pop up rather tha...
stackexchange_codegolf
Given a ragged array, find the length of the largest subarray that contains the depth of that subarray. The base array layer has a depth of 0. Here is an example: [1, 2, [3, 4, [2, 5]], 0] Here, the subarray [2, 5] contains its own depth 2 and has a length of 2 as well. But in the outermost subarray is a 0, its depth....
stackexchange_codegolf
Introduction When solving a rubiks cube, one often write down the times like this 11.91, (11.28), (12.32) This is called a average of 3, while a average of 5 looks like this 13.36, (11.89), 12.31, (16.44), 12.26 Note how the worst and best times have parenthesis around them. When calculating the average of 5 these ti...
stackexchange_codegolf
In this challenge, you will write a bot that play's the prisoner's dilemma. Here's the catch: you will not have access to the history of previous games. Instead, you will have access to the opponent itself. In this version, both players get +2 points if they both cooperate, +1 points if they both defect, and if one coo...
stackexchange_codegolf
Rule 110 is a cellular automaton with some interesting properties. Your goal is to simulate a rule 110 in as few characters as possible. For those who don't know, rule 110 is simulated line by line in a grid. Each square in a line of the grid looks at the squares above, above-left and above-right to determine what cel...
stackexchange_codegolf
Inspired by this question. Challenge Let L be a list of n distinct elements. Let P be the set of all (unordered) pairs of positions in P. Let R be a result of applying a pair-swap operation on L by every pair in P in any order. Example: L = [1, 7, 8] P = {(1, 2), (0, 1), (0, 2)} L = [1, 7, 8] -> [1, 8, 7] -> [8, 1, 7] ...
stackexchange_codegolf
Given two strings \$A\$ and \$B\$ with edit (Levenshtein) distance \$x\$, find a third string with edit distance \$a\$ to \$A\$ and edit distance \$b\$ to \$B\$ so that \$a+b=x\$ and \$a=int(x/2)\$ (that is half of \$x\$ rounded down to the nearest integer). The input is the two strings \$A\$ and \$B\$ and their edit d...
stackexchange_codegolf
This was originally a pure mathematics question, but I think I've got the best chance for an answer here. The Challenge For concreteness, consider Peano Arithmetic (PA). For some language L of your choosing, construct a computer program of length at most N bits in L such that: If it terminates, it outputs a number th...
stackexchange_codegolf
Introduction In a list of strings, there is a certain length you can shorten strings to before they become indistinguishable. This is a pretty bad explanation, so here is an example. ['hello', 'help', 'helmet'] ['hell', 'help', 'helme'] ['hell', 'help', 'helm'] ['hel', 'hel', 'hel'] <- At this point the strings are i...
stackexchange_codegolf
Given a number n, find x such that x! = n, where both x and n are positive integers. Assume the input n will always be the factorial of a positive integer, so something like n=23 will not be given as input. Examples: n=1 -> x=1 (0 is not a positive integer), n=24 -> x=4 Shortest code wins.
stackexchange_codegolf
Make a function that increments a number using only bitwise, loops, and conditions. Rules: All entries must be as per the language spec defined below. Scoring is not of code length, but of the points for each operation given below. The entry point is inc(a), for "increment and return a". Lowest score wins. See the e...
stackexchange_codegolf
i've been dabbling with a hypothetical language... now, i want to add a feature/mechanism that can easily format data in as few codes as possible. now, i need to compare my hypothetical language feature with how it's going to be written in other languages. in particular, would it have lesser code? so i just decided i w...
stackexchange_codegolf
In Skyrim, the player character can use powerful magic shouts (Thu'ums) to achieve their goals. Every shout consists of three words, however, the player can use the first one or two words to achieve the same effect with less power but at a shorter cooldown. Given a lowercase ASCII Thu'um phrase without punctuation or s...
stackexchange_codegolf
Inspired by This answer to a Puzzling question Background - exponentiation by squaring If you don't want to read the background, or don't understand it, there's a worked example in Java, linked at the bottom of the post. \$a^{2^{x+1}} = a^{2^{x}} * a^{2^{x}}\$ Therefore to find \$a^b\$ (where \$a\$ and \$b\$ are base-1...
stackexchange_codegolf
In the game of Flood Paint, the goal of the game is to get the entire board to be the same colour in as few turns as possible. The game starts with a board that looks something like this: 3 3 5 4 1 3 4 1 5 5 1 3 4 1 1 5 2 1 6 5 2 3 4 3 3 4 3 4 4 4 5 5 5 4 1 4 6 2 5 3[3]1 1 6 6 5 5 1 2 5 2 6 6 3 6 1 1 5 3 6 2 3 6 1 2 2 ...
stackexchange_codegolf
Challenge Description: An anagram is a word or phrase formed by rearranging the letters of another word or phrase. For example, "listen" and "silent" are anagrams. In this challenge, your task is to write a program or function that takes a list of strings as input and returns the unique anagrams. Write a program or fun...
stackexchange_codegolf
Intro/Background I was looking at a Flybuys card at Coles recently and noticed that if I took something like this: Source, randomly found on the Internet And swapped some words around, I'd get this: After I finished laughing (don't judge my sense of humour please), I said to myself: "I need a program that can gener...
stackexchange_codegolf
Your task is to make a quine, that is a non-empty computer program that prints it's own source without reading it. In addition if you remove any one byte from your original program the new program should print the source of your original program. This is code-golf so answers are scored in bytes with fewer bytes being ...
stackexchange_codegolf
Consider two sorted arrays of integers \$X\$ and \$Y\$ of size \$m\$ and \$n\$ respectively with \$m < n\$. For example \$ X = (1,4)\$, \$Y = (2,10,11)\$. We say that a matching is some way of pairing each element of \$X\$ with an element of \$Y\$ in such a way that no two elements of \$X\$ are paired with the same el...
stackexchange_codegolf
There are several ways to create headers on posts on the Stack Exchange network. The format that's most commonly1 used on PPCG seems to be: # Level one header ## Level two header ### Level three header Note the space after the hash marks. Also, note that trailing hash marks are not included. Challenge: Take a (possib...
stackexchange_codegolf
Interpret loose ranges ListSharp is an interpreted programming language that has many features, one of those features is a 1 index based range creator that works like this: You define a range as (INT) TO (INT) or just (INT) where both or the single int can go from min to max int32 value Then you can use those ranges to...
stackexchange_codegolf
I've tried this question on two forums and have been told this is the best place for this type of question. I'm trying to print from 0 to 1000 then back to 0 again (and all numbers in-between), printing 1000 only once. Also, each number must be on a separate line using vanilla PHP. My current code is 60 characters long...
stackexchange_codegolf
Introduction You are a biologist studying the movement patterns of bacteria. Your research team has a bunch of them in a petri dish, and you are recording their activity. Unfortunately, you are seriously underfunded, and can't afford a video camera, so you just take a picture of the dish at regular intervals. Your task...
stackexchange_codegolf
We seem to never get tired of alphabet-related challenges... The recipe Given a string of letters S, and two positive integers M, N, produce an alphabet soup with the letters of S occupying random positions in a rectangular bowl of size M×N, framed by a non-alphabetic, non-space character to represent the rim of the...
stackexchange_codegolf
Your input will be an English sentence, phrase, or word. It will only contain a-zA-Z' -,.!?. Your task is to take the input, remove spaces, and then redistribute capitalization such that letters at indexes that were capitalized before (and only letters at indexes that were capitalized before) are capitalized. For examp...
stackexchange_codegolf
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 ...
stackexchange_codegolf
I am trying to write a solution to the following problem using as few characters as possible (to meme my friend and introduce him to golfing). Can any improvements be done to my code? So the problem requires us to write a function called navigate in Python 3.6 (language of the judge, sorry, no walruses) that takes two ...
stackexchange_codegolf
In Dungeons & Dragons 5th edition (as well as most other editions), there exists a magic item called the Deck of Many Things. It is an incredibly powerful item, as the cards all have very strong positive or negative effects. To use the deck, a character declares a number, and then draws up to that number of cards, with...
stackexchange_codegolf
I am exploring a unique approach to the classic problem of Reverse Polish Notation on code.golf. Unlike the conventional solutions, my focus lies on leveraging the eval function in GolfScript. This twist was inspired by a comment in a related thread, where the absence of eval was deemed a limitation. "It's a shame no ...
stackexchange_codegolf
Find the most important character The challenge is to write a program that outputs the most occurrent character in the input string, excluding these bracketing characters ()[]{}. Each submission should consist only of non-trivial* characters. Each solution is scored using the formula in the scoring section. Bracketi...
stackexchange_codegolf
Introduction Some time ago, I need to write function which split string in some specific way. At the first look, task looks trivial, but it was not so easy - especially when I want to decrease code size. Challenge As example we have following input string (it can be arbitrary) Lorem ipsum dolor sit amet consectetur ad...
stackexchange_codegolf
While I was writing numbers I noticed after a while that my keyboard had the Shift key pressed and blocked and all I wrote was $%&-like characters. And even worse, I had been switching between the English and Spanish keyboard layouts so I don't know which one I used for each number. Challenge Given a string containing ...
stackexchange_codegolf
The continued fraction of a number n is a fraction of the following form: which converges to n. The sequence a in a continued fraction is typically written as: [a0; a1, a2, a3, ..., an]. Your goal is to return the continued fraction of the given rational number (positive or negative), whether it is an: integer x frac...
stackexchange_codegolf
So, I wrote myself a one-liner which printed out a snake on the console. It's a bit of fun, and I wondered how I might condense my code... Here's a (short) example output: + + + + + + + ...
stackexchange_codegolf
Preamble In Stack Exchange markdown, we use ** to bold out text. For example, this markdown: The **quick brown fox jumps over the lazy** dog. Renders as: The quick brown fox jumps over the lazy dog. Of course, we use ** to close boldness as well. So less of the answer will be bold. For example: The **quick** brown f...
stackexchange_codegolf
Let a counting tree be a rooted tree in which every node is labeled with the number of descendants it has. We can represent such trees as ragged lists with each node being represented by a list containing its label followed by its children. For example the following is a counting tree: [5,[2,[0],[0]],[0],[0]] However ...
stackexchange_codegolf
In this challenge, submissions will be programs or function which, when given an emoticon such as :-), :(, or :D, will rate their happiness from 0 to 3. An emoticon will be one of the following: :(: 0 :|: 1 :): 2 :D: 3 Emoticons may also have noses (a - after the :). Test cases: :( -> 0 :-| -> 1 :D -> 3 :-) -> 2 :|...
stackexchange_codegolf
You're sick of other players smugly announcing "BINGO" and walking triumphantly past you to claim their prize. This time it will be different. You bribed the caller to give you the BINGO calls ahead of time, in the order they will be called. Now you just need to create a BINGO board that will win as early as possible f...
stackexchange_codegolf
The Goal The goal of this question is to put a twist on this question. Your answer should be able to convert an array of words associated with integers into those integers. As an extra challenge, allow support for , +, -, and _ in between numbers such as sixty seven, sixty+seven, sixty-seven, or sixty_seven. Examples ...
stackexchange_codegolf
The Golden Ratio Bureau is obsessed with this new thing they call base-phi. You see it and decide to code-golf, as is your natural instinct. To be specific, base-phi is a number system like base 10, except it uses the number phi, or the golden ratio, as its base. A ones digit would be x*10^y, but in base phi 10 is repl...
stackexchange_codegolf
The Challenge Given a string indicating the symbolic notation of UNIX permission of a file and its ownership (user ID and group ID), decide whether a given user A has permission to read / write / execute it. Related. Permissions in UNIX system In UNIX, every file has three classes of permissions (user, group and others...
stackexchange_codegolf
Write a program that prints the name of its source file. REPL environments are not allowed for this challenge. Your code must work in any file that your language's interpreter will accept. Your answer must also be a full program, not just a function. The source code's file extension must be printed. Leading or trailing...
stackexchange_codegolf
In this challenge, you'll create some programs which behave similarly to genes. When you run one, it will return one of its two "alleles" (a half of its source code), and concatenating any two alleles from your programs will result in a new, functioning program (which returns its own alleles). As an example, say you wr...
stackexchange_codegolf
How well do you know the site? Let's find out. This is a cops-and-robbers challenge. Robber's thread. As a cop, you need to: Find a non-deleted, non-closed challenge on this site to answer. The challenge cannot have the following tags: cops-and-robbers, popularity-contest, code-trolling, underhanded, busy-beaver, k...
stackexchange_codegolf
This is an additional challenge to the generate Loopy puzzles challenge. You might want to solve this challenge before attempting the harder challenge in the previous link. The goal of this challenge is to validate the solution to a loopy puzzle. Please take all documentation on what a loopy puzzle is from the previous...
stackexchange_codegolf
Vim is a great text editor for unix systems, but it's notorious for being difficult to exit. Write a full program that will output :q to exit Vim. It should then read a single line of input, as it will then either be given a bash prompt, in which case the exit was successful, or an error, in which case there are unsave...
stackexchange_codegolf
A simple way to scramble a 2x2x2 Rubik's cube is to make a sequence random moves. This is not how official scrambles are done, but can get pretty close to a uniform distribution of all possible scramble states. Due to the way a 2x2 only has two layers, doing one turn on one face is equivalent (without considering the p...
stackexchange_codegolf
In the misty years of yore, when fanfold terminals walked the earth, there lived a strange creature. Oddly crippled and yet oddly powerful, the line editor teemed across the programming landscape in untold numbers; covering the earth as far as the eye could see. Now it is fallen on hard times. That vast population hunt...
stackexchange_codegolf
Assume you're writing in one method, (or whatever you call them) with 3 inputs: the first string, a character that contains a +, - or * symbol, and the second string. Example in Java: public String strCalc(String str1, char sym, String str2) { //code... } What it should return: str1 sym str2 ans A + A = B ...
stackexchange_codegolf
EDIT It is not clear how answers to the question of compressing a long text, without cumulative properties are relevant to golfing a short cumulative strong, any more than general Lempel Ziv techniques are relevant to code-golfing. Take note that the complexity of 99 bottles of beer is not O(Sqrt(n)) Knuth suggested t...
stackexchange_codegolf
Here is a relatively simple challenge for you. Given a string of length N, output the string forwards, then backwards, then forwards, then backwards... etc. N times. For example, if your input was Hello! You should output: Hello!!olleHHello!!olleHHello!!olleH You may also optionally output one trailing newline. Your...
stackexchange_codegolf
The title says it all; Given a number in the binary (base-2) number system, output the same number expressed in unary (base-1). You should take the binary number as a string (optionally with a separator), list, or equivalent structure of digits, using any number or digit you like for the digits. The unary output can us...
stackexchange_codegolf
Your task – should you choose to accept it – is to build a program that parses and evaluates a string (from left to right and of arbitrary length) of tokens that give directions – either left or right. Here are the four possible tokens and their meanings: > go right one single step < go left one single step -> go rig...
stackexchange_codegolf
Your task is to, as the title discreetly suggests, make a bad fade animation of one word turning into a second word for yours truly. What exactly is this "fade animation" you may ask? To make a spectacular(ly bad) fade animation, you take two strings which will contain only printable ASCII characters. You start by prin...
stackexchange_codegolf
You are in a one-floor dungeon. There is a treasure which is protected by locked doors. Doors can be opened by finding the corresponding keys. Your goal is to find the shortest path to the treasure. Input Input will be a two-dimensional grid representing the initial layout of the dungeon. ########### #$ # g# # #...
stackexchange_codegolf
Your task is to print this exact text: az za abyz zyba abcxyz zyxcba abcdwxyz zyxwdcba abcdevwxyz zyxwvedcba abcdefuvwxyz ...
stackexchange_codegolf
Code Golf Challenge Given a string of 10 characters: 'abcdefghij' I want to format it in this pattern and print it in the console in a minimum number of characters: (abc) def-ghij My solution: print(f"({s[0:3]}) {s[3:6]}-{s[6::]}")
stackexchange_codegolf
The challenge involves printing the difference between ICMP originate and receive timestamps. The idea is being able to determine which asymmetric internet path is responsible for packet delay. One can use hping with --icmp-ts option to gain the raw data on ICMP_TSTAMP. The task is complicated by the fact that hping d...
stackexchange_codegolf
Write some code that causes a BSOD or kernel panic! Rules: On Windows, you must cause a BugCheck (Blue Screen of Death), on Linux (or other *nix systems) you must cause a kernel panic. Must not damage the system (i.e. it should work on reboot) Kernel-mode drivers are allowed. State your OS and version information. Exp...
stackexchange_codegolf
TailwindCSS is a utility that lets one write CSS code using only HTML classes, which are then converted to CSS code with the Tailwind compiler. Ordinarily, one would write CSS in a separate file from the HTML, and reference named classes: <!-- without Tailwind --> <p class="crazy-monologue">Crazy? I was crazy once. The...
stackexchange_codegolf
Yes, this is very similar to this question. However, that concerns infinite linked lists, and you do not need to handle out of bounds indexes in that question. You are in a strange city, looking for the fabled Nineteenth Bakery, where it is said they sell the most delicious deleted posts. The order of shops here is s...
stackexchange_codegolf
The Task In this challenge, your task is to write a program or function which takes in a String and outputs a truthy or falsey value based on whether the first character and the last character of the input String are equal. Input You may take input in any way reasonable way. However, assuming that the input is present...
stackexchange_codegolf
The handshake problem is the classic problem that for n people in a room, if they all shake hands, what's the total number of handshakes that occur. You code should take an input of any number and output the number of handshakes, both in base ten. Also the code should not let non-integers through. You should output a ...
stackexchange_codegolf
In this challenge you must write a computer program that creates a stack of a thousand identical \$1 \times 1\$ frictionless homogeneous blocks such that each block is supported and the stack is stable under gravity when placed on the edge of a table which spans from \$x = -\infty\$ to \$0\$ horizontally, with the surf...
stackexchange_codegolf
Background An interval graph (Wikipedia, MathWorld, GraphClasses) is an undirected graph derived from a set of intervals on a line. Each vertex represents an interval, and an edge is present between two vertices if the corresponding intervals overlap. The following is an example interval graph with corresponding interv...
stackexchange_codegolf
Given an integer N from 1-9, you must print an NxN grid of NxN boxes that print alternating 1s and Ns, with each box having an alternating starting integer. Examples Input: 1 Output: 1 Input: 2 Output: 12 21 21 12 21 12 12 21 Input: 3 Output: 131 313 131 313 131 313 131 313 131 313 131 313 131 313...
stackexchange_codegolf
We have 3 dice in a square dish. The dish is 8 units wide and tall and each die is 3 units wide and tall. The dice are facing up each with a different number on their top face. 111..222 111..222 111..222 ........ ........ 333..... 333..... 333..... Then we play a game. At each step we can slide any 1 die in any card...
stackexchange_codegolf
United States senators are sorted into three classes, based on what year their six-year term starts. Since each state has two senators, each state has a senator in two of the three classes. Given a full state name and a class number (1, 2, or 3), output truthy if that state has a senator of that class, and falsey if th...
stackexchange_codegolf
In information theory, a "prefix code" is a dictionary where none of the keys are a prefix of another. In other words, this means that none of the strings starts with any of the other. For example, {"9", "55"} is a prefix code, but {"5", "9", "55"} is not. The biggest advantage of this, is that the encoded text can be...
stackexchange_codegolf
Língua do Pê, or P Language, is a language game spoken in Brazil and Portugal with Portuguese. It is also known in other languages, such as Dutch and Afrikaans. (Wikipedia) There are some dialects in this language game. The different languages the game is played with even have their own unique dialects. Some people are...
stackexchange_codegolf
Background Malbolge is truly intriguing language. But programs written in it are also extraordinairly huge (and in some cases, unpostable on PPCG). Your challenge (shall you accept it) is, to compress and decompress given normalized Malbolge program. Devise your own lossless algorithm. You may compress your data furthe...
stackexchange_codegolf
Terminals are so boring these days. They used to look like this: Now they're just bland and dull and black-and-white. I want you to write me a program that will make my terminal all colorful again! Description Take this example Ruby code: Most Linux terminals support these escape sequences (\e stands for the escape ...
stackexchange_codegolf
Write a program or function which, given a positive integer as input, outputs the representation of that integer in Maya numerals. Maya numerals Maya numerals is a vigesimal system (base 20) using only 3 symbols : < > for Zero (The correct symbol is some sort of shell that can't easily be represented using ASCII). . ...
stackexchange_codegolf
Introduction "Muhuhuhahahah!" The mad scientist laughs. "You're trapped in my own little game!" In front of you is a deadly pit of snakes, while behind you is a bottomless chasm. There's no way out, you're stuck! "Two steps in front of you is the snake pit, and two steps behind you is the chasm. But! Before you move, y...
stackexchange_codegolf
A ragged list is a (finite depth) list where each element is either a positive integer or a ragged list. A ragged list is properly tiered if it contains either all positive integers or all properly tiered ragged lists. For example [1,2,3,6] is properly tiered because it is a list of only positive integers. [[1,2],[[1]...
stackexchange_codegolf
This expression actually has an omitted pair of parentheses. 1 + 2 * 3 To make things clear, it should be, 1 + (2 * 3) Even this has its parentheses missing. 1 + 2 + 3 It actually means, (1 + 2) + 3 People often assume left-to-right evaluation to such an arithmetic expression, but I want to make everything very cle...
stackexchange_codegolf
Follow the Path I got directions to my friend's house, but it looks like his map might have some mistakes. He's expecting me soon, so I need some short code to figure out if I can get there. The Challenge The code should, when given an ASCII representation of a path as input, traverse from the start to the end, and out...
stackexchange_codegolf
Introduction Congratulations! You've been selected to do research a a newly discovered animal called a fuzzy, a docile, simple creature that strongly resembles a cotton ball. Fuzzies love to be near other fuzzies, but not all fuzzies want to be near each other. There are 6 types of fuzzies, 1a, 1b, 2a, 2b, 3a, and 3b. ...
stackexchange_codegolf
Let \$A\$ be a square matrix that is at least \$2 \times 2\$ where each element is an integer. \$A^2 = A \times A\$ will then have the same dimensions as \$A\$, and will have integer elements. For example, let $$A = \left[ \begin{matrix} -3 & 2 \\ 0 & -1 \end{matrix} \right]$$ Therefore, $$\begin{align} A^2 & = \left...
stackexchange_codegolf
After seeing some impossibly short solutions in this SE, I began to wonder what code someone could come up with to build a pseudo-random number generator. Now given that I am new to programming, I have absolutely no idea what such generator should look like, or what language to write them in. But that did not stop me f...
stackexchange_codegolf
Description The Caesar cipher is a cipher, where every letter in the alphabet will be rotated by a secret number. If the rotation is \$7\$, then a -> h, g -> n, v -> c and z -> g. Today, we're playing Caesar's Cipher with ASCII chars, (0-127 inclusive). So, with rotation \$7\$, b -> i, Z -> a, x -> DEL (127), But, even...
stackexchange_codegolf