instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
I'd like to get a list of words that are strongly connected with a particular time epoch, for example, 19th century, 20th century and 21st century. I suspect that nobody used a word like "smartphone" in 19th and 20th century, and, vice versa, nobody still uses a word like "grubble" anymore in 21th century. Input data I...
stackexchange_codegolf
The generalised harmonic number of order \$m\$ of \$n\$ is $$H_{n,m} = \sum_{k=1}^n \frac 1 {k^m}$$ For example, the harmonic numbers are \$H_{n,1}\$, and \$H_{\infty,2} = \frac {\pi^2} 6\$. These are related to the Riemann zeta function as $$\zeta(m) = \lim_{n \to \infty} H_{n,m}$$ Given two positive integers \$n > 0\...
stackexchange_codegolf
Given 2 integer inputs representing the size of the field, x and y, output a path through the field. Example output for 5, 4: # # # ### ### # The whole field is 5 by 4, and there is a path made of hashmarks crossing the field. The path should always start in the top left corner, and go to the bottom right. T...
stackexchange_codegolf
Write a program or function that draws an ASCII star, given the size of the arms as input. Here's a star of size 1 _/\_ \ / |/\| Here's a star of size 2 /\ __/ \__ \ / \ / | /\ | |/ \| Here's a star of size 3 /\ / \ ___/ \___ \ / \ / \ / | /\ | | / \ | |/...
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
This question is a sequel to this one, working in the opposite direction. For a reminder of terminology, the letters L, R, U, and D represent one-unit movement of a robot on the coordinate plane in the directions left, right, up, and down respectively. Given a positive even integer n, generate and print all sequences ...
stackexchange_codegolf
For today's challenge, you must write a program or function that alternates the case of a string. However, you must ignore non-alphabetic characters. This means that every alphabetic character must have a different case than the preceding and following alphabetic character. This is slightly more complex than uppercasin...
stackexchange_codegolf
This challenge is a sequel to Letter Boxed Validator. The New York Times has a daily online game called Letter Boxed (the link is behind a paywall; the game is also described here), presented on a square as follows: You are given 4 groups of 3 letters (each group corresponds to one side on the picture); no letter appe...
stackexchange_codegolf
Introduction I've always liked the idea of finding the most possible bang-for-your-buck squeezed out of a tiny chip, like the 6502. Of course, I'll need to start small. Filling the screen on 6502asm.com should be easy enough. Challenge Fill the entire program output screen on 6502asm.com with the color white using the ...
stackexchange_codegolf
Who doesn't absolutely love permutations, right? I know, they are amazing––so much fun! Well, why not take this fun and make it funner? Here's the challenge: Given an input in the exact form: nPr, where n is the pool taken from and r is the number of selections from that pool (and n and r are integers), output/return t...
stackexchange_codegolf
Having spend some time on this site I have come to enjoy things being as short as possible. That may be the reason why I'm recently kind of offended by strings containing the same characters more than once. Your job is to write a function or program which condenses a given string according to the following rules: Star...
stackexchange_codegolf
Implement a FUSE filesystem in minimum bytes. Your program must do three things: Mounting the virtual filesystem to a directory Handling requests to enumerate files in that directory (showing one file) Handling requests to read the file in that directory Rules: ls (a system program, you don't need to implement it) m...
stackexchange_codegolf
Objective Given a string with single Unicode vulgar fraction, parse it to a rational number. Valid inputs A valid input is one of: ¼ U+00BC; one quarter ½ U+00BD; one half ¾ U+00BE; three quarters ⅐ U+2150; one seventh ⅑ U+2151; one ninth ⅒ U+2152; one tenth ⅓ U+2153; one third ⅔ U+2154; two thirds ⅕ U+2155; one fifth...
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
You work in a kitchen which has a peculiar rule. When you mix something into a pot you must always add at least one new ingredient. So you can add pasta, oil, salt then pesto, but not pasta, pesto, salt and oil since pesto already contains salt and oil. You only have one pot per dish, so you can't mix ingredients in on...
stackexchange_codegolf
Background You awake on the ground. Above you is a giant stepped pyramid-like structure. Based on your ancient history lessons, you recognize it as a ziggurat. You have been transported by Dr. Sargostein back into ancient Mesopotamia to play a game. In this King of the Hill Ziggurat challenge, you will write a bot that...
stackexchange_codegolf
My stovetop has 10 (0 through 9) different settings of heat and a very odd way of cycling through them. It always starts at 0 When I hit plus it increments the number, unless the number is 9 in which case it becomes 0, or the number is 0 in which case it becomes 9. When I hit minus it decrements the number, unless t...
stackexchange_codegolf
There are two forms of nouns, singular and plural. The conversion between these two is quite easy. Normally, you end it with s. ex. car => cars. If it ends with s,x,z,ch or sh, end it with es. ex. bus=>buses. If it ends with y with a consonant just before it, change the y to ies. ex. penny => pennies. If it ends wi...
stackexchange_codegolf
You know how many and which kinds of chess pieces were murdered. Can you come up with any possibility for who killed whom and how? Background During the course of a game of chess, there are between 2 and 32 pieces on the board. Call the collection of all pieces on the board (both white and black), without regard to p...
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
Write a program or a function in your favorite programming language that will take as input a number n (integer or non-integer) between 0 and 100 inclusive, and output the corresponding grade as outlined below: If 0 < n <= 40, then output E. If 40 < n <= 55, then output D. If 55 < n <= 65, then output C. If 65 < n <= ...
stackexchange_codegolf
We all know scoring by characters is ripe for abuse. Let's prove this. The Challenge Output the following: "m8V}G=D@7G1lAI,v08` #(hNb0A8T!g;==SVaG5~ g"jUF!bmRY(3I@na?2S{ fJVzo/GQYU%ybpfUq3aG Yza[jc,WJ$bP^7r};Da} V-!Z+Nk:`/poc}d/X:G\ sWX{dbAUv6,i]%RG$hRp ),bd+?/{U1tU[;<;u.Nk ZFPIOzJ/HimL!nexc,ls HM%k3D$n2|R,8L?'eI_n qs....
stackexchange_codegolf
A square-free word is a word consisting of arbitrary symbols where the pattern \$XX\$ (for an arbitrary non-empty word \$X\$) does not appear. This pattern is termed a "square". For example, squarefree is not square-free (using the lowercase letters as the alphabet), as the square ee appears; but word is square-free. A...
stackexchange_codegolf
This is an answer-chaining challenge relating to the OEIS. Oh, the justification for this is because a company needs one program to print out their OEIS sequences real bad and they have every language. The answer-chaining format works in the following way: Someone posts the first answer, from which all further solution...
stackexchange_codegolf
Introduction I would like to drawn a nice spinner by using eight braille patterns on two lines, drawing a square of 8x8 pixel, for showing a kind of snake growing and reducing: declare -a shapes=([0]=$'\E[A⠁⠀⠀⠀\E[B\E[4D⠀⠀⠀⠀' [1]=$'\E[A⠈⠀⠀⠀\E[B\E[4D⠀⠀⠀⠀' [2]=$'\E[A⠀⠁⠀⠀\E[B\E[4D⠀⠀⠀⠀' [3]=$'\E[A⠀⠈⠀⠀\E[B\E[4D⠀⠀⠀⠀' [4]=$'\E...
stackexchange_codegolf
Usually each cell in brainfuck has 256 states, which is not enough to tell whether input is EOF or a character (usually \xFF). To fix it we can add one more state to it, and EOF (256) isn't mistake from a byte. Since outputting EOF is also not defined, . on 256 works as reading, and therefore , is removed from the mod...
stackexchange_codegolf
Your challenge is to write a program that takes input from stdin, creates a set of 1 to ncolors and outputs them on stdout, formatted as a 6-digit-hex value with a prefixed #. The starting color should have following values (in a hsv colorspace) (pesudocode) h=rand(), s=0.5, v=0.95. Every subsequent color should ha...
stackexchange_codegolf
What is the shortest selector (by character count) to select ALL html elements on a web page, without using asterisk (*)? Some examples are the following: a,:not(a) /*9 chars*/ :nth-child(n) /*12 chars*/ :link,:not(:link) /*17 chars*/
stackexchange_codegolf
This challenge will have give you a positive integer \$n\$ and ask you to output \$t(n)\$, the number of triangles (up to congruence) satisfying the three conditions: The triangles have perimeter of 1, the triangles have side lengths \$\displaystyle\frac{a_1}{b_1}, \frac{a_2}{b_2}\$, and \$\displaystyle\frac{a_3}{b_3}...
stackexchange_codegolf
Ascii Pong The challenge is to recreate the classic game "pong" in ASCII characters in the shortest code possible. Requirements/specifications The "screen" should be 45x25 characters. White space should actually be white space. The paddles should be 9 equals signs: ========= and should be on the top-most and bottom-mo...
stackexchange_codegolf
Take a line of input (function arguments or stdin, etc.). Remove comments in it, where a comment starts and ends with ". Do not remove comments in string literals, which start and end with '. String literals do not contain escapes, because smalltalk has nice, easily lexable syntax ;). Output this string. The number of...
stackexchange_codegolf
Write a program that takes in a true-color RGB image I, the maximum number of lines to draw L, and the minimum m and maximum M length of each line. Output an image O that looks as much as possible like I and is drawn using L or fewer straight lines, all of which have Euclidean length between m and M. Each line must be ...
stackexchange_codegolf
A magic square is an \$ n \times n \$ square grid, such that the sum of the integers on each row and column are equal. Note that the definition which will be used in this challenge is different than the one used by Wikipedia, since diagonal sums are not accounted for the numbers are not required to be distinct or in t...
stackexchange_codegolf
A composition of an integer \$n\$ is a representation of \$n\$ as a sum of positive integers. For example the eight compositions of 4 are as follows: 4, 3 + 1, 1 + 3, 2 + 2, 2 + 1 + 1, 1 + 2 + 1, 1 + 1 + 2, 1 + 1 + 1 + 1. The challenge is to output the number of compositions of \$n\$ in which the greatest part is odd....
stackexchange_codegolf
Let \$p(x)\$ be a polynomial. We say \$a\$ is a root of multiplicity \$k\$ of \$p(x)\$, if there is another polynomial \$s(x)\$ such that \$p(x)=s(x)(x-a)^k\$ and \$s(a)\ne0\$. For example, the polynomial \$p(x)=x^3+2x^2-7x+4=(x+4)(x-1)^2\$ has \$1\$ and \$-4\$ as roots. \$1\$ is a root of multiplicity \$2\$. \$-4\$ is...
stackexchange_codegolf
We all often hear the idiom "walk through the array" to mean "map the function over the following array". However, I need it done (now!), so I want you to run through the array. How do I run? Imagine there's a wild pack of wolves behind you Running through an array is like walking through one, except you can skip over...
stackexchange_codegolf
Write a program that translates ASCII text to braille output. Requirements: Input may come from stdin, command line, or some other external input source. Output should be recognisable as braille, the form of output is up to you. An example would be o for a raised dot and . for a non-raised dot. Textual pattern represe...
stackexchange_codegolf
Background A backronym is an acronym that was formed from an existing word. For example, spam is actually named after the canned meat product as used in the Monty Python sketch, but can be interpreted as "stupid pointless annoying mail". Challenge Given a string a, and a word t, capitalise the correct letters of the w...
stackexchange_codegolf
Entries are now closed. Any new entries or edits will not be counted in the final run. Join the chat! Challenge Try to fill the canvas with as much paint as possible. Be careful of other bots that may paint over your hard work though! Note: In this challenge description, paint means to change the colour of the squar...
stackexchange_codegolf
Explanation In this task you'll be given a set of N points (x1,y1),…,(xN,yN) with distinct xi values and your task is to interpolate a polynomial through these points. If you know what Lagrange interpolation is you can skip this section. The goal of a polynomial interpolation is to construct the (unique) polynomial p(x...
stackexchange_codegolf
Objective You're on a nonempty list of integers that wraps around. You start at the leftmost entry of the list, and keep jumping to the right to the amount of the integer entry you're at. Eventually, you'll end up in a cycle. The objective is to output the length of this cycle. I/O format Provided that the inputted lis...
stackexchange_codegolf
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...
stackexchange_codegolf
We all have knowledge of the periodic table, since our days in school. Something most of us have often tried to do is to spell out your name using elements of the table. Your challenge is to do exactly this. You will be given a string to STDIN or equivalent, and you will need to output the formula corresponding to the ...
stackexchange_codegolf
Problem Let's say that a word is almost a palindrome if it is possible to remove one of its letters so that the word becomes a palindrome. Your task is to write a program that for a given word determines which letter to remove to get a palindrome. The shortest code to do this in any programming language wins. Input Inp...
stackexchange_codegolf
You're at integer coordinates \$(x,y)\$ facing one of North, South, East, or West. Your goal is to walk home to \$(0,0)\$. At each step, you may do one of: Walk one step in the current facing direction, that is to whichever of \$(x+1,y)\$, \$(x-1,y)\$, \$(x,y-1)\$, or \$(x,y+1)\$ you're facing. Rotate 90 degrees left,...
stackexchange_codegolf
There's a payment machine for laundry in my building which does a few frustrating things. The ones relevant to this challenge are: It doesn't make change. So if you pay over the amount then you are not getting that over-payment back. It doesn't accept coins smaller than 20c. Meaning the only coins it accepts are 20c...
stackexchange_codegolf
I recently got a new Sudoku app that produces really hard Sudoku's, which can't be solved using the standard strategies. So I had to learn a few new ones. One of these strategies is the Y-Wing Strategy. It is ranked under "Tough Strategies", but it is actually not that hard. Example For this strategy only 4 cells are ...
stackexchange_codegolf
Introduction My gnome friends are writing a programming language and have asked for my help. Due to their size, the gnomes can only handle small superscript numbers instead of big numbers. However, the language they're writing the interpreter in only accepts big numbers! Your Challenge Given an input of a superscript n...
stackexchange_codegolf
Given an input of any valid Glypho program, output its "human-readable" counterpart. Glypho is an interesting esolang idea: The instruction reference is given here. For each instruction, the characters abcd represent the symbols composing each instruction. a refers to the first unique symbol, b refers to the secon...
stackexchange_codegolf
In chess, the Fool's Mate is the fastest possible way to reach checkmate. It is reached with Black's second move. In chess notation, one possible sequence of moves that achieves Fool's Mate is 1.f3 e6 2.g4 Qh4#. This is not the only possible way to achieve this checkmate (in the same number of moves). There are three ...
stackexchange_codegolf
In this challenge, you are passed two things: A string length, N A list of strings, L, each with an assigned point value. Any string that is not passed in has a point value of 0 You need to construct a string of length N such that the sum of all substring points is as large as possible. For example: 5 [("ABC", 3), (...
stackexchange_codegolf
Introduction A popular word puzzle is to convert one word into another via a series of steps which replace only one letter and which always result in a valid word. For example, BAG can be converted to DOG via a path of five steps: BAG -> BAT -> CAT -> COT -> COG -> DOG Shorter paths also exist in this case; for example...
stackexchange_codegolf
Given an integer n, return the number of ways that n can be written as a list of prime numbers. For example, 2323 can be written as (2,3,23), (23,23) or (2,3,2,3) or (23,2,3), so you would output 4. If it can not be written in this way, you should output 0. A prime number such as 019 or 00000037 is a valid prime for th...
stackexchange_codegolf
Challenge In this challenge, the input will be an ordered set of numbers and the program should be able to tell if the set of numbers is an Arithmetic Sequence. Input The input will be a list separated by ,(comma) or , (comma+space). The minimum length of the list should be 3 elements. Output The Output can be a Boo...
stackexchange_codegolf
Related Task Your task is to calculate the new Elo rating (FIDE rating system) for a player after winning, losing or drawing a game of chess. To calculate the Elo rating two formulas are needed: R' = R0 + K*(S - E) E = 1 / (1 + 10 ^ ((R1 - R0) / 400)) where: R' is the new rating for player0, R0 is the current rating ...
stackexchange_codegolf
Robber's challenge This cops-and-robbers challenge challenges the Cop to write a non-empty program that, when run, produces some non-empty output in language A, and, when reversed, produces some non-empty output in language B. The program may produce any output to STDERR when run in either language, but may not take in...
stackexchange_codegolf
A narcissistic number is a natural number which is equal to the sum of its digits when each digit is taken to the power of the number digits. For example \$8208 = 8^4 + 2^4 + 0^4 + 8^4\$, so is narcissistic. We'll define a function \$f(x)\$ as the following, for a natural number \$x = d_1d_2\dots d_n\$, where \$d_i\$ i...
stackexchange_codegolf
I was looking for this page to help me enhance my first answer with SQLite, but I couldnt find one. So here we are! What general tips do you have for golfing in SQLite? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to SQLite. Please post one tip per answe...
stackexchange_codegolf
You are piloting a spaceship, outfitted with an engine that can accelerate you at 1km/s^2 in the direction the ship is facing (you have very good inertial dampers). You also have thrusters which can rotate you 180 degrees in 1s (rotating 45 degrees takes 0.25s, etc.). You see on your scanner another ship, and decide t...
stackexchange_codegolf
Coordinates in the flat-Earth world consist of latitude (x) and longitude (y), which are integers in the range 0...9999. Much like Gaussian integers, but they are always written using this notation: 411S 370E That is, with S or N appended to the latitude, and E or W appended to the longitude, with space(s) between the...
stackexchange_codegolf
What general tips do you have for golfing in Smalltalk? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Smalltalk (e.g. "remove comments" is not an answer). Smalltalk is a purely object-oriented language created by Alan Kay. The two links are GNU Small...
stackexchange_codegolf
Write two functions/programs which take an ASCII code of character (8-bit unsigned integer) and one of them converts char to uppercase and other to lowercase. That is, they must be equivalent to following functions: unsigned char toUpper(unsigned char c){ if (c >= 97 && c <= 122) return c - 32; return c; } unsi...
stackexchange_codegolf
Background With the success of Simple Boolean Algebra Calculator, I present a more difficult problem. Boolean Algebra concerns representing values with letters and simplifying expressions. The following is a chart for the standard notation used: Above is what actual boolean algebra looks like. For the purposes of this...
stackexchange_codegolf
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...
stackexchange_codegolf
There are quite a few accumulator-based programming languages featured in challenges across the site, but it's a little tiring to have to write almost identical code for each one. So in this challenge you will write a program which can generate interpreters from an input. How does this work? Let us take this example: [...
stackexchange_codegolf
Introduction Logic gates! Everyone knows them, everyone loves them (unless you're starting to learn them). Take two booleans, compare them, get a single boolean in return. AND, NAND, OR, NOR, XOR, XNOR. Fun! But, what if you only had the inputs and output, but not the operator? Challenge Given a three digit number, xy...
stackexchange_codegolf
The purpose of this challenge is to figure out whether all the dominoes will fall, given an input string representing a top view of the table. Input format The program can take the input as a single string with newlines or a list of strings. Spaces denote, well, empty spaces, and the rest represent dominoes. The start ...
stackexchange_codegolf
This is an extension of Fibonacci Domino Tiling. Your goal is to print all 281 ways to tile a 4x6 rectangle with 1x2 and 2x1 dominoes. Fewest bytes wins. Use the vertical bar | to indicate a space covered by the vertical domino, and an em-dash — (count it as if it were ASCII) or hyphen - for horizontal ones. Example ou...
stackexchange_codegolf
A magic square is an n-by-n square grid, filled with distinct positive integers in the range 1,2,...n^2, such that each cell contains a different integer and the sum of the integers in each row, column and diagonal is equal. Your task is to take an n-by-n matrix consisting of positive numbers, and a placeholder charact...
stackexchange_codegolf
Make a quine. Simple enough, except it has to be a palindrome and accept input. Now, any side of a palindromic quine is one half of it. For example, one side of the hypothetical quine AAAA is AA. One side of AAAAA is AA (the center symbol is ignored). Your job is to make a quine like this that accepts input. If the inp...
stackexchange_codegolf
From the wikipedia: Net neutrality is the principle that Internet service providers and governments regulating the Internet should treat all data on the Internet the same, not discriminating or charging differentially by user, content, website, platform, application, type of attached equipment, or mode of communicatio...
stackexchange_codegolf
This is a cops-and-robbers challenge. The robbers' thread is here. An interesting question to think about is the following: If I have a sequence of numbers how many of them do I have to provide before it is clear what sequence I am talking about? For example if I want to talk about the positive integers in order star...
stackexchange_codegolf
Your task is to make a bidirectional compressor. It takes a list of bytes as input and returns a list of bytes as output. It has the property than whenever it is iterated twice it returns the original input. In other words, if f is your program as a function, then f(f(x))=x for all x. Now, since this is a "compressor",...
stackexchange_codegolf
Inspired by and drawns from Is this number Loeschian? A positive integer \$k\$ is a Loeschian number if \$k\$ can be expressed as \$i^2 + j^2 + i\times j\$ for \$i\$, \$j\$ integers. For example, the first positive Loeschian numbers are: \$1\$ (\$i=1, j=0\$); \$3\$ (\$i=j=1\$); \$4\$ (\$i=2, j=0\$); \$7\$ (\$i=2, j=...
stackexchange_codegolf
Suppose you are stringing a strand of Froot Loops for a necklace, bracelet, shoelace, or whatever. There are 6 loop colors: red, orange, yellow, green, blue, and purple. You want your strand to start with red at the very left and cycle in rainbow order going right, ending with purple. That is, you want to make it so yo...
stackexchange_codegolf
Given an input sentence consisting of one or more words [a-z]+ and zero or more spaces , output an ASCII-art histogram (bar graph) of the letter distribution of the input sentence. The histogram must be laid out horizontally, i.e. with the letter key along the bottom in alphabetical order from left to right, with a Y-a...
stackexchange_codegolf
For a given number n, output an strictly decreasing array whose sum is n and its lexicographical order is the smallest for any possible outputs Smallest lexicographical order means that for or sum n=9 the following strictly decreasing arrays are possible: [[9],[8,1],[7,2],[6,3],[5,4],[6,2,1],[5,3,1],[4,3,2]]. Putting t...
stackexchange_codegolf
This is the logo for LAPACK, a widely used software library for numerical linear algebra. Your task is to print the logo (color and matrix brackets not required) as this exact string. Trailing newline is allowed. L A P A C K L -A P -A C -K L A P A -C -K L -A P -A -C K L A -P -A C K L -A -P A C -K
stackexchange_codegolf
The world is full of Turing-complete programming languages. Just about every useful language (and most useless ones) are Turing-complete. Some even became Turing-complete by accident. Often this is great, since every Turing-complete language supports the same power of universal computation. But the power of Turing ...
stackexchange_codegolf
The Wilson score interval is a confidence interval of the probability of success, based on the proportion of successes in a set of Bernoulli trials (a Bernoulli trial is a trial in which exactly two outcomes are possible: success or failure). The interval is given by the following formula: The two values given by the ...
stackexchange_codegolf
The permanent of an \$n\$-by-\$n\$ matrix \$A = (a_{i,j})\$ is defined as: $$\operatorname{perm}(A)=\sum_{\sigma\in S_n}\prod_{i=1}^n a_{i,\sigma(i)}$$ For a fixed \$n\$, consider the \$n\$-by-\$n\$ matrices whose entries are taken from \$\{-1, 0, +1\}\$ . Task For each \$n\$ from 1 upwards, output the number of \$n\$-...
stackexchange_codegolf
This is a different type of compression challenge. In a normal kolmogorov-complexity challenge, you are required to recreate a list exactly. Here, you are allowed to round the values in any way you wish. What's the catch? Your score is penalized based on how wrong your output is. At the bottom of this question is a...
stackexchange_codegolf
Results are now out here! Congratulations offset prediction for winning the challenge! Don't worry if you missed out, the controller code as well as all the bots that competed are all in the Github repo, so you can always test your bot against those that competed in the challenge yourself. (Hover for more info) This c...
stackexchange_codegolf
I'm working from home and the heat of my laptop on my lap is the only thing keeping me warm. I have a Dell G3 Laptop with an NVidia GEForce GTX CPU. I have tried writing a rust program with 5 threads that calculates and prints the Fibonacci sequence in an infinite unthrottled loop, but that only gave a bit of warmth, a...
stackexchange_codegolf
Now that we know how to Square a Number my Way, we need an inverse operation, a way to Square Root a Number my Way. To square a number my way, you simply stack it on top of itself a number of times equal to the number of digits it contains, and then take read off every number that is formed both vertically and horizon...
stackexchange_codegolf
Your task is to take as input a single string (or list of characters, list of code points, etc.) and return the length of the longest substring with no character appearing more than once. Aside: This challenge is similar to Longest Non-Repeating Substring, but without the source restriction ranking submissions by their...
stackexchange_codegolf
Takuzu is a logic game in which you have to complete a grid with cells containing 0s and 1s. The grid must follow 3 rules: No three horizontal or vertical consecutive cells can be the same. There must be an equal number of 0s and 1s in each row and column. No two rows can be the same, and no two columns can be the sam...
stackexchange_codegolf
Given two inputs q n determine if q is a quadratic residue of n. That is, is there an x where x**2 == q (mod n) or is q a square mod n? Input Two integers q and n, where q and n are any integers 0 <= q < n. Output A truthy or a falsey. Optionally, print any (or all) x that is x**2 == q (mod n) Examples >>> quadratic_re...
stackexchange_codegolf
In this question I defined a "chain" function as a function that: is a permutation, meaning that every value maps to and is mapped to by exactly one value. and allows any value can be obtained from any other value by repeated applications of the function or its inverse. There are a lot of functions that do this and s...
stackexchange_codegolf
A spoonerism is what you get when swap the beginnings of two adjacent words in a sentence. In this challenge, we'll try to find a plausible spoonerism based on one incorrect word. So, given a list of words** and an input word that is NOT in the dictionary, return a string (not necessarily a dictionary word) for which t...
stackexchange_codegolf
The task is simple, divide, get the quotient and the remainder, and if the remainder isn't 1 or 0, do the same thing (quotient divmod remainder) until the remainder is 1 or 0, then get the remainder. If the last input number is 1 or 0, output it. If the input is [15, 4], then the output would be 0, because the divmod o...
stackexchange_codegolf
Given a string l, find all palindromic substrings p of l (including duplicates and single character strings). Next, rearrange all sub-strings in p into a valid palindrome (there may be multiple correct answers). If it is not possible to rearrange p into a single palindrome, your program may have undefined behavior (err...
stackexchange_codegolf
Challenge Write the shortest program that converts a human readable time interval to date components of the form: {±YEARS|±MONTHS|±DAYS|±HOURS|±MINUTES|±SECONDS} Sample cases Each test case is two lines, input followed by output: 1 year 2 months 3 seconds {1|2|0|0|0|3} -2 day 5 year 8months {5|8|-2|0|0|0} 3day 9 ...
stackexchange_codegolf
Write two programs A and B. Program A (the encoder) takes 1024 pairs of integers \$(k,v)\$, where \$0≤k<2^{32}\$ and \$0≤v<1024\$, and all \$k\$ will be different. It will output a single positive integer (likely a few thousand digits long). Program B (the decoder) takes two inputs: the output-integer of program A, a...
stackexchange_codegolf
Let me know if this task has already been posed. I haven't found it when I looked. Input master sequence \$\ X = x_1\dots x_n\$: sequence of characters, eg. \$\rm international\$ subsequence \$\ Y = y_1\dots y_m\$: sequence of characters, eg. \$\rm intl\$ Output Number of possible mappings \$\mu: [1\dots m] \righta...
stackexchange_codegolf
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", ...
stackexchange_codegolf
Your task is to output a Magical 8 Trapezium: 1 × 8 + 1 = 9 12 × 8 + 2 = 98 123 × 8 + 3 = 987 1234 × 8 + 4 = 9876 12345 × 8 + 5 = 98765 123456 × 8 + 6 = 987654 1234567 × 8 + 7 = 9876543 12345678 × 8 + 8 = 98765432 123456789 × 8 + 9 = 987654321 Output in your chosen language in the ...
stackexchange_codegolf
The Challenge Write a program that takes an integer N as input, and outputs the stage of life or death that a tree is currently in. N will always be between 0 and 10. The Stages of Life and Death Life: To draw a stage of life, simply draw a base of size N, consisting of ^ characters, then move up and substract 2 from ...
stackexchange_codegolf
This is an answer-chaining challenge relating to the OEIS. Oh, the justification for this is because a company needs one program to print out their OEIS sequences real bad and they have every language. The answer-chaining format works in the following way: Someone posts the first answer, from which all further solution...
stackexchange_codegolf
This is the cops' thread to a cops-and-robbers challenge. Click the link to find the robbers' thread. The challenge here is very simple. Create two programs of the same size, in the same language, which output (using 1 standard output method) two different natural numbers, \$x\$ and \$y\$. Submit both programs, bot...
stackexchange_codegolf