instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
The spoak laugh For those who don't know, in Brazil some people laugh on chats like this: aposkpaoskaposkaposkpaokspaoskpaoksa. So here is the challenge: To make a program that generate this laugh in a natural way. How to produce this laugh programatticaly? When you laugh like this, you use one hand on the (a, s) part ...
stackexchange_codegolf
Over at our friends at Puzzling.SE, the following puzzle was posted: Is this chromatic puzzle always solvable? by Edgar G. You can play it here. Puzzle explanation Given a m x n grid with tiles of three different colours, you may select any two adjacent tiles, if their colours are different. These two tiles are then co...
stackexchange_codegolf
Given two positive integers a and b, output two positive integers c and d such that: c divides a d divides b c and d are co-prime the least common multiple of c and d equals the least common multiple of a and b. If there are more than one possible answers, you can output only one or all of them. Test cases: a b c ...
stackexchange_codegolf
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...
stackexchange_codegolf
I wrote a code that separates the numbers from 1 to 9999 by comma void p(n){printf("%d,",n);if(n<9999){p(n+1);}}main(){p(1);} Is there a way to make this short code without using a repeat statement?
stackexchange_codegolf
Consider a n x n multiplication table and replace each item with its remainder of division by n. For example, here is a 6x6 table and its "modulo 6" structure: (The last column and row are ignored since both are null) 1 2 3 4 5 6 | 1 2 3 4 5 2 4 6 8 10 12 | 2 4 0 2 4 3 6 9 12 15 18 | 3 0 3 0 3...
stackexchange_codegolf
One thing that is constantly frustrating when golfing ARM Thumb-2 code is generating constants. Since Thumb only has 16-bit and 32-bit instructions, it is impossible to encode every immediate 32-bit value into a single instruction. Additionally, since it is a variable length instruction set, some methods of generating ...
stackexchange_codegolf
Background The sequence in the title is A245788 "n times the number of 1's in the binary expansion of n" ("times" here means multiplication), which starts like this: 1, 2, 6, 4, 10, 12, 21, 8, 18, 20, 33, 24, 39, 42, 60, 16, 34, 36, 57, 40, 63, 66, 92, 48, 75, 78, 108, 84, 116, 120, 155, 3...
stackexchange_codegolf
This is the cops' thread. The robbers' thread goes here. Write a program or function consisting only of printable ASCII characters (that excludes tab and newline) that outputs at least 5 printable ASCII characters in ascending order (from space to tilde / 32 to 126). Characters can be outputted several times, as long a...
stackexchange_codegolf
You have a bunch of cities on a grid which you wish to link up. Roads can be placed on any tile that doesn't contain a city, and connect to all roads or cities adjacent to them, vertically, horizontally or diagonally. Roads can link up via cities, for example C \ C-C is fully linked up. However, there are some moun...
stackexchange_codegolf
To find the digital hardness of an integer, take its binary representation, and count the number of times both a leading and trailing 1 can be removed until it either start or ends with a 0. The total number of bits removed is its digital hardness. That's quite a wordy explanation - so let's break it down with a wor...
stackexchange_codegolf
The knight is a chess piece that, when placed on the o-marked square, can move to any of the x-marked squares (as long as they are inside the board): .x.x. x...x ..o.. x...x .x.x. Eight knights, numbered from 1 to 8, have been placed on a 3×3 board, leaving one single square empty .. They can neither attack each other...
stackexchange_codegolf
Given two strings of digits, determine which string, if any, has the earliest digit which is lower than the other string's digit at the same index. Do note that this differs from alphabetization, as shown in the following examples: Examples Given inputs 12345000 and 1233999999, the second string would have the earliest...
stackexchange_codegolf
Sequence: We start at 1. We first add the current 1-indexed value to the previous number in the sequence. Then we apply the following mathematical operations in order if they apply to this current value: Divisible by 2? => Addition Divisible by 3? => Subtraction Divisible by 4? => (Addition AND) Multiply Not divisib...
stackexchange_codegolf
Write the shortest possible code cause an error due to recursion too deep Example error in python RecursionError: maximum recursion depth exceeded Example error in c Segmentation fault My Python version (15 bytes): def f():f() f()
stackexchange_codegolf
Write a program that translates an arithmetic expression to a Brainfuck program which evaluates the expression and prints the result in decimal numbers. For example, this arithmetic expression, 2 * (3 + 4) can be translated to Brainfuck as, ++ 2 >+++ 3 >++++ 4 [-<+>]< add <[>[->+>+<<]>[-<+>]<<-]>[-]>>[-<<<+>>>]<<< mul...
stackexchange_codegolf
The challenge: output this exact ASCII art of a spiderweb in a window: _______________________________ |\_____________________________/| || \ | / || || \ /|\ / || || /\'.__.' : '.__.'/\ || || __.' \ | / '.__ || ||'. /\'---':'---'/\ .'|| ||\ '. /' \...
stackexchange_codegolf
This is not a challenge. I'm wondering if it's at all possible to get user input into two separate variables in python (2 or 3) with less than 19 bytes. These are all the shortest I can get: a,b=input(),input() a=input();b=input() (newline replaced with semicolon for readability) i=input;a,b=i(),i() Is there any short...
stackexchange_codegolf
Challenge: Create a program or function that takes an integer input, which outputs a new program/function as specified below. Input: Integer n: Time in seconds before the Time Bomb explodes. Output: The original program which had the time in seconds n as input, will output a new program/function that does the following...
stackexchange_codegolf
Task: Input will consist of some text, with nested [] separating some of it into nested groups: abc[d[fgijk]nopq]rst[u[v[[w]]]xy[[[z]]]] Your task is to remove all brackets, and everything wrapped in an odd number of brackets. For example, a[b]c would remove the [], and the b inside of it. a[[b]]c, however, would only...
stackexchange_codegolf
Halley's Comet is the only comet that may appear (i.e. become visible to the naked eye on Earth) twice in a human lifetime. The orbital period of Halley's Comet is not constant: it has varied between 75 to 79 Earth years since the first definite apparition was recorded in 240 BCE. This variability is mainly driven by g...
stackexchange_codegolf
The oldest Polish salt mine, located in Bochnia*, was started in year 1248, which we can consider a magical number. We can see that it's equal to 4 digits from the sequence of exponentiations: . As the date is actually 4 digits from the sequence, we could make it longer. We could repeat the process until we reach infin...
stackexchange_codegolf
If someone facing north at point A in this grid wanted directions to follow the green path (as they can only follow gridlines) to point B you might tell them: Go North, North, West, East, East, South, East, East. or equivalently Go Forward, Forward, Left, Back, Forward, Right, Left, Forward. (Where a command of Right...
stackexchange_codegolf
Given a string as input find the longest contiguous substring that does not have any character twice or more. If there are multiple such substrings you may output either. You may assume that the input is on the printable ASCII range if you wish. Scoring Answers will first be ranked by the length of their own longest ...
stackexchange_codegolf
Given two strings of letters, transfer the capitalization pattern of each string onto the other one. Fewest bytes wins. Input: CodeGolf xxPPCGxx Output: coDEGOlf XxppCgxx Both strings will be equal-length and nonempty, with only letters a..z and A..Z. You may output the two resulting strings in either order rel...
stackexchange_codegolf
I would like to see who can make Python have a fatal crash with the most creative code. This means that when the program runs, Windows for example, will take over and pop up with something like “IDLE has stopped working”, or Linux will do whatever Linux does when a program crashes. Rules: This must be made in Python 2...
stackexchange_codegolf
Task: Given two positive integers, generate a random integer between them (inclusive) and then output all its prime factors. Examples: Input: Random Number: Output: 1,2 2 [2] 12,46 18 [2,9] 142,17 40 [2,2,2,5] Scoring: This is code-golf so the least by...
stackexchange_codegolf
Given a string of brackets tell the user whether or not the brackets are well matched or not. Brackets include []{}(). For example: () <---- Well Matched ([{}][]) <---- Well Matched ({)} <---- Not Well Matched ({]) <----- Not Well Matched This is a code-golf challenge so as always the shortest solution wins.
stackexchange_codegolf
Inspired by this Game of Life question. Wireworld simulates "electrons" flowing through "wires", simple arrangements of which produce typical logic gate behavior. I challenge you to build a digital clock in the Wireworld cellular automaton. Your clock must count upwards from 00:00 to 23:59 in the usual fashion, or to 1...
stackexchange_codegolf
The objective Given a string of Hangul syllables, sort the characters in North Korean dictionary order. Introduction to Hangul syllables Hangul(한글) is the Korean writing system invented by Sejong the Great. Hangul syllables are allocated in Unicode point U+AC00 – U+D7A3. A Hangul syllable consists of an initial consona...
stackexchange_codegolf
This originally came from Give the best Chaitin incompleteness bound, but I realized that there was a fragment of this problem which still potentially gives a good coding challenge. First Order Logic With Equality First, I will need to fix an encoding of first order formulas ('For all x there exists y such that ...'). ...
stackexchange_codegolf
Uilta is a minority tungusic language spoken in the far east of Russia. A neat thing about Uilta is that it has pitch accent which can be predicted by a computer program. In this challenge we are going to take Uilta a word and determine where the accent peak is. Let me explain how this can be done. Phonemes The first ...
stackexchange_codegolf
This is a challenge to write bots to play the 1st and 2nd players in the following simple poker game. Rules of the poker game There are two players, A and B. Each antes $10 into the pot, and is dealt a card, which is a real number in the range [0, 1). Player A goes first, and may pass or bet. If A passes, then there is...
stackexchange_codegolf
Your task will be to write a Haskell function that takes a list of integers and returns a sorted version of the same list. You are to do this without the use of builtins What are builtins? To keep ourselves from having to navigate edge case hell we are going to limit answers to Haskell (sorry if Haskell is not your fa...
stackexchange_codegolf
A Bell number (OEIS A000110) is the number of ways to partition a set of n labeled (distinct) elements. The 0th Bell number is defined as 1. Let's look at some examples (I use brackets to denote the subsets and braces for the partitions): 1: {1} 2: {[1,2]}, {[1],[2]} 3: {[1,2,3]}, {[1,2],[3]}, {[1,3],[2]}, {[2,3],[1]}...
stackexchange_codegolf
Introduction: I think we've all heard of it, but here a very brief summary: Noah gathered two of every species of animal on the planet, male and female, to save in his Ark during a great flood. The actual quote from the Bible is: Genesis 7:2-3 You must take with you seven of every kind of clean animal, the male and it...
stackexchange_codegolf
I keep hearing that thinking outside the box is a goal worth achieving, but how can I tell if I'm successfully doing it? To solve this dilemma I have already wrote a Brainwave-to-ASCII-translator which in theory should produce outputs like # +------------+ # | thinking | # | ...
stackexchange_codegolf
This challenge takes place on the snub square tiling. Start by choosing any triangle, and color it \$c_1\$. Next, find all tiles which touch this triangle at any vertex, and color them \$c_2\$. Next, find all tiles which share a vertex with any \$c_2\$-colored tile, and color these \$c_3\$. Continue this process ad inf...
stackexchange_codegolf
Introduction Imagine you are on a two dimensional cartesian plane and want to determine your position on it. You know 3 points on that plane and your distance to each of them. While it is always possible to calculate your position from that, doing that in your head is pretty hard. So you decide to write a program for t...
stackexchange_codegolf
For a given positive integer, try to find out the smallest possible rotation resulted by rotating it 0 or more bits. For example, when the given number is 177, whose binary representation is \$10110001_{(2)}\$: \$ 10110001_{(2)}=177 \$ \$ 01100011_{(2)}=99 \$ \$ 11000110_{(2)}=198 \$ \$ 10001101_{(2)}=141 \$ \$ 00011...
stackexchange_codegolf
Make a quine but with a twist. Statement The quine prints its code but puts its first character at the end. (You can do it in reverse but include that note in your answer) The output must then be a program which is also an solution. Example: Assume your code was foobar, running it will return oobarf which will be anoth...
stackexchange_codegolf
Inspired by How do you write dates in Latin? Challenge Given a month-and-day date, output that date in abbreviated Latin, as explained below. Input Input is flexible, following conventions from other date and sequence challenges. You may choose to: Take a date in mm/dd or dd/mm format or two separate month,day argumen...
stackexchange_codegolf
Given a nonzero polynomial with integer coefficients and roots that are on the imaginary and on the real line such that if a is a root then so is -a, return another polynomial with the roots rotated by 90 degrees. Details The polynomial can be given in any reasonable format, e.g. as a list of coefficients. The symmetry...
stackexchange_codegolf
We've recently reached the threshold of 10,000 questions on PPCG. Hooray! Let's celebrate this with a simple challenge. Input Two integers \$A\$ and \$B\$, both in \$[1..9999]\$, such that \$A+B<10000\$. Task Your task is to add one single digit to one of these integers or one single digit to both of them such that \$A...
stackexchange_codegolf
I can't believe we don't have this already.. It's one of the most important data-structures in programming, yet still simple enough to implement it in a code-golf: Challenge Your task is to implement a stack that allows pushing and popping numbers, to test your implementation and keep I/O simple we'll use the following...
stackexchange_codegolf
You are playing a famous game called \$1\text{D Array BattleGround}\$. In the game, the player can be stationed in any position from \$0\$ to \$10^5\$. You are a Paratrooper in the game and have the ability to do two types of operation \$-\$ Advance, which would multiply your position by \$2\$ Fall-back, which would d...
stackexchange_codegolf
This challenge is related to some of the MATL language's features, as part of the May 2018 Language of the Month event. Associated challenge: Function clipboard: paste. Introduction MATL has several clipboards, where you can store values (copy) to be retrieved later (paste). Some clipboards are automatic, which means...
stackexchange_codegolf
It's simple, simply output text to STDERR containing the string EOF. Input/Output Your input will be none; however, you should output the message to STDERR. Rules Since this is code-golf, the shortest answer wins. No standard loopholes please. Any method approved by Standard I/O is allowed. Your code may not contain t...
stackexchange_codegolf
In the context of quines, an intron (or payload) is a part of a quine that serves no purpose in producing output, but is still included in the data section. For example: function quine() { const data = "function quine() {\n const data=\"@\";\n // Arr! This be an intron!\n return data.replace(\"@\", JSON.s...
stackexchange_codegolf
The naming conventions for games in the Super Mario series is very strange, and don't match up between regions. | Japanese Name | American Name | |---------------------|------------------------------------| | Super Mario Bros. | Super Mario Bros. | | Super Mario Bros. 2 | S...
stackexchange_codegolf
Challenge Write code that, given an English word, outputs the number of syllables it has. Scoring will be determined by a combination of code length and accuracy. Rules The accuracy of the solution should be measured against this CSV file (which countains syllable counts for all the 52,439 entries in the CMU Pronounc...
stackexchange_codegolf
This is the second in a series, the third is Two roads diverged in a yellow wood (part 3) This is based on Two roads diverged in a yellow wood (part 1), a previous challenge of mine. It was fairly well received, but it was also fairly trivial (a Java answer in 52 bytes!) So I made something more complex... The inspirat...
stackexchange_codegolf
One thing that is constantly frustrating when golfing ARM Thumb-2 code is generating constants. Since Thumb only has 16-bit and 32-bit instructions, it is impossible to encode every immediate 32-bit value into a single instruction. Additionally, since it is a variable length instruction set, some methods of generating ...
stackexchange_codegolf
Rules Given an ISO3166-1-Alpha-2 country code your task is to decide on the traffic direction for that country: Input will be a valid country code (valid as in it's an element of the two lists provided) Input may be a list of two characters instead of a string if it helps You may choose to take input in lowercase You ...
stackexchange_codegolf
The Challenge Given two strings containing only lowercase letters and no spaces, the result should be the shorter string, followed by an underscore, followed by the longer string with the first instance of a character removed for each character it contains that is in the shorter string. You can assume the strings will...
stackexchange_codegolf
Overview In this challenge, your task is to randomly generate a monotonic mathematical function between two sets. Input Your inputs are two positive integers s and n. After getting these inputs, your program shall generate a random mathematical function f from the set {0,1,...,s-1}n to {0,1,...,s-1}. In other words, f ...
stackexchange_codegolf
Your assignment is to write a program of even length, that prints an ASCII-art square (described below), that increases its side length by 1 unit each time the original source code is pasted in the middle of the current code. It is quite hard for me to define this task very well, so I'll give you an example: Let's sa...
stackexchange_codegolf
Given a list of unique strings that are anagrams of each other, output an anagram of those words that is different from each word in the list. The strings will be alphanumeric, and there is guaranteed to be a valid anagram. The program or function can, but doesn't have to be non-deterministic, meaning given the same in...
stackexchange_codegolf
I have a series of binary switches, which I can represent as a bit string. The last person who used my switches left them in some arbitrary state without cleaning up, and it bugs me. I always keep the switches in one of four possible "tidy" configurations: All 1: e.g., 111111111 All 0: e.g., 000000000 Alternating 1 an...
stackexchange_codegolf
You are a Computer Science professor teaching the C programming language. One principle you seek to impart to the students is modularity. Unfortunately, past classes have tended not to get the message, submitting assignments with the entire program inside main(). Therefore, for this semester you have issued strict modu...
stackexchange_codegolf
Your program should find the number of string pairs (pairs of 2) that contain all vowels (a e i o u), when given an integer N and N strings. There are easy ways to do this, but I'm looking for the quickest possible solution. Example: INPUT: 4 password unique orbiting ointmental OUTPUT: 2 EXPLANATION: password has a,o...
stackexchange_codegolf
The Levenshtein distance between two strings is the minimum number of single character insertions, deletions, or substitutions to convert one string into the other one. Given a binary string \$S\$ of length \$n\$, we are a interested in the number of different strings of length \$n\$ which have distance at most \$3\$ ...
stackexchange_codegolf
In speedcubing, an Ao5 (Average of 5) is computed for a set of five times by removing the fastest and slowest times, and then computing the mean of the remaining three times. A "rolling ao5" is computed for a sequence of at least five times by computing the ao5 for every set of consecutive five times (some sets will o...
stackexchange_codegolf
Imagine travelling to a point lying A miles away horizontally and B miles away vertically from your current position. Or in other words, travelling from (0, 0) to point (a, b). How far would you need to end up travelling? This seems like a straightforward question, but the answer depends on who you ask. If you're a cro...
stackexchange_codegolf
In this challenge, you will remove duplicate words from each sentence. Examples Hello Hello, World! Hello, World! Code Code! Golf Code Code! Golf Code Hello hello World Hello World Programming Golf Programming! Programming Golf! Specification Input will be a string of ASCII characters. A sentence is defined a...
stackexchange_codegolf
Heavily inspired by Hello, World! (Every other character) Write a program that outputs 1. When the first, third, fifth, etc. chars are removed, it outputs 2. When all chars where their (1-based) index in the source, mod N, are not 0, are removed, it should output N. This is code-challenge. The winner is the program tha...
stackexchange_codegolf
Given the spiral of size S and the step N, output the "square" S*S spiral having N asterisks, built from the outer to inner radius clockwise. Test cases (examples) below. Input: 4 3 Output: *** Input: 4 6 Output: **** * * Input: 4 11 Output: **** * * * **** Input: 6 18 Output: ****** * * * * ...
stackexchange_codegolf
Your challenge is given an input of a prison layout to work out whether any of the prisoners can escape. Input Input may be in any reasonable format such as a string, array, array of arrays etc. The input will consist of three characters, in this case #, P and space. The input will not necessarily contain all three cha...
stackexchange_codegolf
The sci-fi shooter Destiny 2 contains guns which have the ability to regenerate ammunition directly into the magazine if, and only if x (precision) shots are landed (in a fixed amount of time), returning y bullets to the magazine. For example, the perk (ability) "Triple Tap" will return 1 bullet to the magazine if 3 pr...
stackexchange_codegolf
There are more than 100 elements in the modern periodic table. You challenge is to output the rounded mass of an element with respect to the input given. Input Input will contain an abbreviation of an element. Input can be taken from any one of the following: stdin command-line arguments function arguments Input wil...
stackexchange_codegolf
The game of Chinese checkers is played on a board with spaces in the shape of a six-pointed star: Image from Wikipedia We can create an ASCII-art representation of this board, using . for empty spots and the letters GYORPB for the six colored starting locations: G G G G G G G ...
stackexchange_codegolf
Synopsis: Find characters that are enclosed by MYPOCKET. Example Input MYPHEIF YFOCKVH MBNDEIF TEUFTMY ESNDUWP KBOVUVO CENWFKC OPYMTEB Example Output F BND EUF SNDUW BOVUV ENWF Huh? How did we get that as an output? The "pocket" can sometimes be difficult to see. This will make it clearer: MYPHEIF YFOCK...
stackexchange_codegolf
Homologous series, any of numerous groups of chemical compounds in each of which the difference between successive members is a simple structural unit. As an example, Alkane is a homologous group where the chemical compounds are in \$C_nH_{2n+2}\$ format. \$CH_4\$ (Methane) is part of the Alkane group because \$CH_4 \t...
stackexchange_codegolf
Above is the picture of the flag of the country Nepal. Pretty cool. What's cooler, is the aspect ratio, which is defined under the constitution as: That formula in copyable form: $$ 1 : \frac{6136891429688-306253616715\sqrt{2}-\sqrt{118-48\sqrt{2}}(934861968+20332617192\sqrt{2})}{4506606337686} $$ Your task is to out...
stackexchange_codegolf
The title is an homage of the Natural Number Game, which is a nice interactive tutorial into proving certain properties of natural numbers in Lean. Given that the previous two were slightly too involved (either mathematically or technically) for newcomers to Lean (i.e. the vast majority of CGCC community), I decided to...
stackexchange_codegolf
(with apologies to Jim West for the title, and randomly inspired by Cisco's textual representation of their logo: .:|:.:|:. for the concept) Given an input integer 1 <= n <= 255, output an ASCII art representation of a suspension bridge of distance n following the below construction rules: The start and end of the bri...
stackexchange_codegolf
Warning The answers to this challenge test for a specific version of the patch that helps stop WannaCrypt/WannaCry attacks. Depending on your operating system, you may have a different patch. The best way to protect yourself is to make sure your PC is fully up to date and be careful when opening attachments and web lin...
stackexchange_codegolf
Background Gödel numbers are a way of encoding any string with a unique positive integer, using prime factorisations: First, each symbol in the alphabet is assigned a predetermined integer code. Then, to encode a string \$ x_1 x_2 x_3 \ldots x_n \$, where each \$ x_i \$ represents an symbol's integer code, the resultan...
stackexchange_codegolf
Preamble We've already proven we're good at adding two numbers, but many solutions only operate on tiny numbers like 2³²-1, honestly we can do a lot better. The Challenge Given two unsigned, non-negative integers, add them together and return the output. Input may be taken in any convenient format (String, Array of byt...
stackexchange_codegolf
Task In this challenge, your task is to write a program or function which takes an array of paths with an additional boolean indicating it is a file or directory and outputs a file/directory tree in any reasonable format. Remarks Some directories can end with a forward slash ("/") but this is not always the case A par...
stackexchange_codegolf
Make a snake fill any maze (until it gets stuck). The snake The snake starts at a given starting point, pointing EAST. It moves by always having a wall or a part of its body immediately to the LEFT of its head ("left-hand rule wall follower"), until it gets stuck because all four directions around its head are occupied...
stackexchange_codegolf
Given a list of nested menu items, items = [ '3D/Axis', '3D/CameraTracker', 'Color/Invert', 'Color/Log2Lin', 'Color/Math/Add', 'Color/Math/Multiply', 'Other/Group', 'Other/NoOp', 'Views/JoinViews', 'Views/ShuffleViews', 'Views/Stereo/Anaglyph', 'Views/Stereo/ReConver...
stackexchange_codegolf
Rules Given a list of integer coordinates, l, with a length of at least 4, and an integer n such that n is smaller than the length of l (but at least 3), return the largest area of an n-sided polygon satisfies: is simple (not self-intersecting). has all the coordinates of its n vertices in the list l. has no three con...
stackexchange_codegolf
Background A typist comes home wfter some riugh drinkinh and realizes thag an importsnt letter still needs to be wtitten. To make sure he vets the text correct, he writes the text character bh vjaracter t0 be sure of 6he resuly. However, he dtill manages t0 miss some ofbthe keys. Yout task is to write cose that simulat...
stackexchange_codegolf
Task Given a list of nodes representing a binary tree of positive integers serialized depth-first, return a list of nodes representing the same tree serialized breadth-first. To represent an absent child, you may use null, 0, 'X', Nothing, [], or any other value that is distinct from your representation of a node's val...
stackexchange_codegolf
Given a positive integer n, compute the nth Wilson number W(n) where and e = 1 if n has a primitive root modulo n, otherwise e = -1. In other words, n has a primitive root if there does not exist an integer x where 1 < x < n-1 and x2 = 1 mod n. This is code-golf so create the shortest code for a function or program t...
stackexchange_codegolf
This is Bub. Bub is a soccer player. However, he's not a very good one. He still can't kick the ball to the net! (If you haven't noticed, @ is the ball. _____ | \ O ...
stackexchange_codegolf
What are some tips for golfing in Turing Machine But Way Worse, a language made by MilkyWay90 and ASCII-only? Tips should be Turing Machine But Way Worse-specific and not be trivial (For examples that you shouldn't post, removing unnecessary whitespace or using shorter state names). EDIT: Added documentation to TMBWW
stackexchange_codegolf
Your task is to find how many distinct Blackjack sequences can be found in an ordered list of 12 cards. A Blackjack sequence is defined as a sequence of consecutive cards whose sum of points is exactly 21. Points are counted according to the following table: Symbol | Name | Points Symbol | Name | Points -------+-...
stackexchange_codegolf
Recently, I've seen Hare Krishna people with their mantra on the emblem and I've found it may be quite interesting to code golf. The challenge Write the Hare Krishna mantra, i.e.: Hare Krishna Hare Krishna Krishna Krishna Hare Hare Hare Rama Hare Rama Rama Rama Hare Hare Winning criteria This is code-golf, so shortest...
stackexchange_codegolf
inspired by thejonymyster's idea Rules This challenge is about finding languages that are very suitable for one task but quite the opposite in the other. The two tasks share a theme, but Task 1 is designed to be number-oriented while 2 is string-oriented. You can participate in three categories: Numbers: Choose a lang...
stackexchange_codegolf
My doubles pickleball group often has five people. Four are playing and one is awaiting the next game. We can represent the state of the game with a string of five characters like abCde. This indicates that a and b are playing against c and d with c serving. We want to write a routine that gives the possible positions ...
stackexchange_codegolf
I'd like to introduce a new? programming language I call Shue (Simplified Thue). It has very simple syntax. Here is a program that checks if an input is divisible by three: yes no 3=0 4=1 5=2 6=0 7=1 8=2 9=0 00=0 01=1 02=2 10=1 11=2 12=0 20=2 21=0 22=1 0=yes 1=no 2=no Try it online! At the top we can see two lines. Th...
stackexchange_codegolf
A common visual explanation of the Pythagorean theorem is as such: The squares are meant to represent the side length's squared, and the areas of a + b = c, just like the Pythagorean theorem says. This part is what you have to show. Your task You will get two integers as input, meant to represent sides a and b of a r...
stackexchange_codegolf
The challenge Given a 2d string representing the bottom of a boat as an input, you must determine whether or not the boat will float. This 2D string can be in whatever format is most convenient. (String with newlines, list of string, list of list of chars, etc.) Print a truthy value if it will float, and a falsey value...
stackexchange_codegolf
In this game, you can look inside one box at a time chosen by you. When you do that, you can see how many coins there are in that box. The wizard has one last twist for you. At any point, you can choose to give up on this set of boxes and get him to start the whole process again (with a new random \$x\$). Of course, i...
stackexchange_codegolf
Given a word, your task is to compact it by saving its first character and removing any other vowel (aeiou). Input Your input can be the word in STDIN, a function argument or any other input format that doesn't break the standard loopholes. You can assume the input only consists of lower characters. Output Your output...
stackexchange_codegolf
Introduction This is a little challenge with the goal of identifying repeated pattern "blocks" in a string, and outputting them with their frequency of occurence from left to right. A friend asked me this question and I realized it wasn't as simple as tossing what you've seen into a hash table and popping them off if p...
stackexchange_codegolf
Introduction In this challenge, your task is to implement a collection of simple functions that together form a usable mini-library for simple probability distributions. To accommodate some of the more esoteric languages people like to use here, the following implementations are acceptable: A code snippet defining a c...
stackexchange_codegolf
Given a positive integer n (Example: n=1234444999) Separate into consecutive digit runs: [1, 2, 3, 4444, 999] Take the digital product of each run. [1, 2, 3, 4*4*4*4, 9*9*9] = [1, 2, 3, 256, 729] Sum it... 991 Repeat until this converges to a single number: 1234444999 991 82 10 1 Return last number. Test...
stackexchange_codegolf