instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Background Visualizing λ-calculus terms Famous lambda-juggler (and code golfer) John Tromp devised an interesting visualization of terms in the λ-calculus. In his words: abstractions (lambdas) are represented by horizontal lines, variables by vertical lines emanating down from their binding lambda, and applications by...
stackexchange_codegolf
Othello/Reversi is a board game in which players take turn placing pieces of a color (dark or light) on the 8x8 board. The possible moves are positions where there are one or more pieces of the opponent's color in a straight (horizontal, vertical, or diagonal) line between that position and a piece of the player's colo...
stackexchange_codegolf
I don't know about you all but I'm not preparing for Halloween––never did never will––but, my neighbor is, so we'll help her out. She needs help figuring out which brand of candy she has, but she has so much candy she would not be able to finish before Halloween. She has: Snickers KitKat Starburst GummyBears Twix Inp...
stackexchange_codegolf
Cleaning the dishes In this task, you will be given a bar of soap with a width of 1 or more units. You will also be given a plate, which you will have to clean, using the soap as few times as you can. The plate will be at least 1 character. You will have to output a plate with the 'clean' character representing the pla...
stackexchange_codegolf
I often have to take character data and categorize it numerically at work. A common thing I do is to take character type variables and convert them to numeric type characters, keeping same categories according to the level of work I'm doing. (The longer the substring, the more in depth and specific, shorter substrings ...
stackexchange_codegolf
Write a program that groups a string into parentheses cluster. Each cluster should be balanced. Examples : split("((())d)") ➞ ["((()))"] split("(h(e(l)l)o)(w(o)r)l(d)(w)h(a(t)(s)u)p") ➞ ["((()))", "(())", "()", "()", "(()())"] split("((())())(()(()()))") ➞ ["((())())", "(()(()()))"] Input may contain letters other t...
stackexchange_codegolf
Can you recover a sequence of letters from a sequence of dots and dashes? In Morse code, x is represented by -..-, but without the help of spaces, -..---.-... could represent xmas, or dole, or teettteteee, etc. I took the lyrics from "Rudolph, the Red-Nosed Reindeer" to make the following sequence of letters: youknowda...
stackexchange_codegolf
Given two positive integers, 'a' and 'b', output an ascii-art "box" that is a characters wide and b characters tall. For example, with '4' and '6': **** * * * * * * * * **** Simple right? Here's the twist: The border of the box must be the characters of "a" and "b" alternating. This starts at the top left corner, ...
stackexchange_codegolf
I came across SVGCaptcha, and immediately knew it was a bad idea. I would like you to show just how bad an idea this is by extracting the validation code from the SVG images that code produces. An example image looks like this: Here is the source of the example image: <?xml version="1.0" encoding="utf-8"?><!DOCTYPE s...
stackexchange_codegolf
Let's imagine we have a finite set of positive integers. This set can be represented as a line of dots where each integer present in the set is filled in like a scantron or punch card. For example the set {1,3,4,6} could be represented as: *.**.* * represents a member of our set and . represents an integer that is n...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Santa has a bunch of presents wrapped in cuboid boxes of various sizes. As his sled flies above a chimney, a stack of presents will be automatically dropped through it. Santa wants to carefully choose the presents so that all of them f...
stackexchange_codegolf
Related | Related Given an ASCII art with |, _, and , check if you can draw the art in one stroke. Description Your task is, if the ASCII art is representing lines, then check if you can draw the whole art in one stroke, which means: without drawing an already drawn line again without lifting and continuing the stro...
stackexchange_codegolf
Given a grid which contains these signs: 0..9, x, =, write the fastest code that outputs the longest string of connected (horizontally, vertically, and diagonally adjacent), distinct cells which is a mathematically valid expression formed on this grammar: E := T '=' T T := F 'x' T | F F -> {0..9}+ More formally, a so...
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
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
Given a PPCG user's user ID, calculate how much times is their Each SE site reputation is from average reputation in the Stack exchange sites they have made accounts. Let me explain, If someone's total network reputation (Total reputation in the stack exchange sites he has participated) is 10k, and if he has participat...
stackexchange_codegolf
Your challenge is to create a regex that matches every string permutation of itself, and nothing else. The match must also be case-sensitive. So, for example, if your regex is: ABC It should match (and only match) these strings: ABC ACB BAC BCA CAB CBA It shouldn't match things like: AABC (contains an extra A) ABCD (...
stackexchange_codegolf
Definition For any \$a\equiv1\ (\text{mod }8)\$ and \$n\ge3\$, there are exactly 4 roots to the equation \$x^2\equiv a\ (\text{mod }2^n)\$. Now, let \$x_k(a)\$ be the smallest root to the equation \$x^2\equiv a\ (\text{mod }2^k)\$, then $$\{x_3(a),x_4(a),x_5(a),x_6(a),\cdots\}$$ is a smallest square root sequence (SSRS...
stackexchange_codegolf
Given the name of an HTTP status code, such as OK or Continue, output or return the corresponding number. Your code is limited to 200 bytes, and the winner is the answer that correctly finds the number for the most status codes. For this challenge, the status codes your program should handle are: 100 Continue 101 Switc...
stackexchange_codegolf
The quaint hamlet of Кодгольф in the Russian far east has a problem: their population is low (below 66), and no new people have arrived for years. Moreover, after centuries of near-isolation, just about everybody is related to each other. Mayor Стекобмен has a solution that should keep the morale high: organise a weddi...
stackexchange_codegolf
You will receive an integer less than 2000000000 and bigger than -2000000000 and you have to test what type(s) of number this is out of: Factorial Square Cube Prime Composite Triangular Positive Negative Here is a definition of all the different types of numbers: Factorial - A number That is equal to the product of a...
stackexchange_codegolf
Given a permutation of the alphabet and an intended "word", determine if the word was guessed in a game of Hangman, where the permutation is the list of guesses. For example, given ASTNORDYUVKFMCLWIHEBQGPJXZ as the permutation, and ASTRONAUT as the word, we know that the word was guessed. Only 2 letters (DY) were wrong...
stackexchange_codegolf
This is a tips question for golfing in Python concerning the Evil Numbers question on Anarchy Golf. An number is evil if its binary expansion has an even number of 1's. The challenge is to print the first 400 evil numbers 0,3,5,...,795,797,798, one per line. The Python 2 submissions are led by llhuii with a 42-byte so...
stackexchange_codegolf
Cops thread Your task as robbers is to find cops solutions and write a program in the language provided that computes the nth term of the sequence using only the bytes in the provided set. The goal will be to crack as many cops answers as possible. With each crack awarding you a single point. Cracks need not be th...
stackexchange_codegolf
Alternate Title: Tally Your Prison Sentence on the Wall Given a number n, output tallies grouped into the traditional 5-per-group and 50 per row. Examples 1 | | | | 4 |||| |||| |||| |||| 5 |||/ ||/| |/|| /||| 6 |||/ | ||/| | |/|| | /||| | 50 |||/ |||/ |||/ |||/ |||/ |||/ |||/ |||/ |||/ |||/ ||/| ||/| ||/| ||/| ||/...
stackexchange_codegolf
Challenge : Count the number of ones 1 in the binary representation of all number between a range. Input : Two non-decimal positive integers Output : The sum of all the 1s in the range between the two numbers. Example : 4 , 7 ---> 8 4 = 100 (adds one) = 1 5 = 101 (adds two) = 3 6 = 110 (adds two) = 5...
stackexchange_codegolf
A positive integer can be diluted by inserting a 0 between two bits in its binary expansion. This means that an n-bit number has n-1 dilutions, which are not necessarily all distinct. For example, for 12 (or 1100 in binary), the dilutions are 11000 = 24 ^ 11000 = 24 ^ 10100 = 20 ^ In this challenge, we're goin...
stackexchange_codegolf
Definition For any \$a\equiv1\ (\text{mod }8)\$ and \$n\ge3\$, there are exactly 4 roots to the equation \$x^2\equiv a\ (\text{mod }2^n)\$. Now, let \$x_k(a)\$ be the smallest root to the equation \$x^2\equiv a\ (\text{mod }2^k)\$, then $$\{x_3(a),x_4(a),x_5(a),x_6(a),\cdots\}$$ is a smallest square root sequence (SSRS...
stackexchange_codegolf
I love functional programming in Octave, but it's rather unwieldy in practice. I'm wondering about the shortest way to define an anonymous recursive function. I have some ideas, but I'm wondering if there is a way to combine these ideas to make them even shorter (or equally short but more versatile). For the sake of th...
stackexchange_codegolf
Consider an arbitrary set of letters \$L\$. It may either be \$\{A, B, C\}\$, \$\{M, N, O, P\}\$, \$\{N, F, K, D\}\$, or even contain all the 26 letters. Given an instance of \$L\$ and a positive integer \$n\$, how many \$n\$-letter words can we build from \$L\$ such that no adjacent letters are the same (so for exampl...
stackexchange_codegolf
Definitions: A triangle is considered a right triangle if one of the inner angles is exactly 90 degrees. A number is considered rational if it can be represented by a ratio of integers, i.e., p/q, where both p and q are integers. A number n is a congruent number if there exists a right triangle of area n where all thr...
stackexchange_codegolf
Consider this spiral ########### # # ####### # # # # # ### # # # # # # # # # # # # # # # # ##### # # # ######### Starting in the centre: The first line (upwards) has 3 characters. The second line has the same number of characters (3) Next, we add two chars (5) for the next two sides. This pattern continue...
stackexchange_codegolf
Your task is to create a program that determines whether a given string is a valid regular expression or not using code snippets sourced from sites on the StackExchange network. For the purposes of this challenge, the regular expression dialect will be a stripped down and mostly minimal set of meta-characters: ()*?|\. ...
stackexchange_codegolf
After all assignments are submitted, a dictionary is created that maps student number to the hash of their file. This dictionary, or hashmap, or mapping (whatever your language calls it) will look as follows: {100: "aabb", 104: "43a", 52: "00ab", 430: "aabb", 332: "43a"} The key is the student number, and the value is ...
stackexchange_codegolf
Write a square root function taking a single input – positive, negative or sign‑less (zero is sign‑less) – that outputs its approximate principal square root, correct up to six decimal places past the decimal point (truncate after the sixth decimal place). Employing scientific notation (1E3 = 1 × 10³ = 100) or similar ...
stackexchange_codegolf
Task Given two positive integers a, b and a Unicode mathematical inequality symbol c, determine if a c b is true. You many take the character or its Unicode codepoint for the input c. You may output your language's truthy/falsy values, or two distinct values for true and false respectively. Standard code-golf rules app...
stackexchange_codegolf
I was watching the world snooker championship and it got me wondering.. Snooker scoring In the game of snooker there are certain rules that you must adhere too: When there are red balls on the table, during your turn you must first pot a red ball After potting each red ball, you must pot a colored (not red) ball (the ...
stackexchange_codegolf
How to Given an integer n start with n ones (i.e. 4 -> 1 1 1 1). Then sum up the last n numbers, and repeat. For n = 4 this looks like this: Start with 1 1 1 1, sum up the last 4 numbers resulting in 1 1 1 1 4, then sum up the last 4 numbers resulting in 1 1 1 1 4 7, then sum up the last 4 numbers resulting in 1 1 1 ...
stackexchange_codegolf
The challenge today is very simple. The task is to determine the TI calculator for which the submitted datafile was made. The datafiles always start with a string **TI, the version (described below), and other data you can ignore. Now, the versions you need to recognize are: 95* => TI-95 92P => TI-92+ 92* => TI-92 89* ...
stackexchange_codegolf
Program the shortest code that will calculate the average BPM (Beats per Minute) using 8 data points of time passed. This is my first post, and I haven't seen a question similar to this. Since I am a fan of rhythm games, it would be nice to have a small handy tool to calculate BPM using your own keyboard and your own s...
stackexchange_codegolf
Background Here in the UK1, these are the income tax rules: You get a personal allowance (untaxed) of up to £12,570: If you earn less than £100,000, you get the full £12,570 as personal allowance For every £2 over £100,000, your personal allowance goes down by £1 After the personal allowance, the next £37,700 is ta...
stackexchange_codegolf
If you like this, consider participating in: The Official Dyalog APL 2016 Year Game The monthly Dyalog APL 2017 Code Golf Challenge Make 12 snippets/expressions, in the same language, that result in the numbers 0 through 10, and 42 respectively, but without writing any literal numeric, string, or character data. Bui...
stackexchange_codegolf
Input Two non-negative floating point numbers \$x < y\$. You can assume they are close enough to each other that there is no integer between \$x\$ and \$y\$. Output A fraction with the smallest possible denomination that lies strictly between \$x\$ and \$y\$. Examples Input: 1 and 2 Output: 3/2 Input: 0 and 0.33 Output...
stackexchange_codegolf
Challenge Given the high resolution molecular mass of an organic molecule, output the molecule's molecular formula. Explanation The input will be a single number to three decimal places of precision, the relative molecular mass of the molecule. Here, the molecular mass is defined as the sum of the masses of the atoms i...
stackexchange_codegolf
Context So the Dutch "Ministerie van Binnenlandse Zaken en Koninkrijksrelaties" (NL) - "Ministry of the Interior and Kingdom Relations" (EN) recently released the source code of their digid-app. They have some goofy code in there, which led to mockery and memes on reddit Source code of the offending method can be found...
stackexchange_codegolf
Challenge Your task is to write a piece of code that outputs another piece of code. That code must in turn output yet another code until the final code outputs the integer 1. The chain ends the first time 1 is outputted. None of your programs may share any characters (there's one exception in the Rules-section). The w...
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
I like to think of a 10-adic number as a number that goes infinitely to the left, or an integer modulo a very very large power of 10. Things carry infinitely to the left and vanish. To see what I mean, note that ...6667 * 3 = 1 in the 10-adic land, since the "2" that carries to the left goes to infinity. Addition and m...
stackexchange_codegolf
You are given an array A of length N and an array B of length N-1. You need to output array where items alternates: A[0], B[0], A[1], B[1], ..., B[N-2], A[N-1] Restrictions: N>0 Type of items is not specified, but code should work at least for unsigned integers. Sample input: A = [1,2,3,4] B = [7,8,9] Sample output:...
stackexchange_codegolf
Given a distance in meters as an integer \$60\le d \le 260\$, return the number of clubs that may be used according to the following arbitrary chart, where both \$min\$ and \$max\$ are inclusive: club | min | max ----------------+-----+----- Driver | 200 | 260 3-wood | 180 | 235 5-wood ...
stackexchange_codegolf
Let's say we have some arbitrary number: For example 25. We also have some "tokens" (poker chips, money, something similar) with different values. Values of tokens are 2; 3; 4; 5. "Tokens" are limitless You need to achieve number 25 using exactly n tokens (for example, 8) and to output all possible ways of doing so. F...
stackexchange_codegolf
The way points are assigned on a dice follows a regular pattern, the center dot is present if and only if the number is odd. To represent the even numbers, pairs of dots on opposite sides of the center are added, which will stay present for all successive numbers. 1: O 2: 3: 4: 5: 6: O O O O O O ...
stackexchange_codegolf
Using your language of choice, write a function that takes a variable number of arguments and returns the number of arguments it was called with. Specifics: Your language needs to support variadic argument functions: something callable that takes an arbitrary number of arguments and returns a value. Parameters must be...
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
Given a rectangle input with only \, / and space, decide if it's a valid output of Drawing in Slashes Empty lines and columns at edge get cleaned up, so the 3rd true case is true. True cases: /\/\ / /\ \ \/ / \ /\/ /\ \ \ / \/ \ \ \ \ \/ /\/\ / /\ \ / \ \/ / /\ \/\ \/ \ / / / ...
stackexchange_codegolf
Create a program to display some approximation of a bell curve. You are free to use whatever method you wish for generating the data, but the data must be displayed vertically, as in oriented like so: Other restrictions: Your code must create the approximation, that is, don't hardcode or take data from the internet. ...
stackexchange_codegolf
According to this page, the best strategy to guess English hangman words is to calculate the odds of each letter in a word list that meet our conditions. But, as I'm really lazy, I don't really want to compute every word in the dictionary by myself. But, as I know that you are always here to help me, I'm sure you will ...
stackexchange_codegolf
Chomp is a two-player game with a setup of a rectangle of pieces. Each player takes a turn removing any piece, along with all pieces above it and to its right. Whoever takes the bottom-left piece loses. It can be proven fairly easily that the first player always has a winning move (except with a 1-by-1 rectangle); find...
stackexchange_codegolf
Coming from this sandbox post This is inspired from an 8th graders math test Intro We have a cube with following corners A(0, 0, 0) B(1, 0, 0) C(1, 1, 0) D(0, 1, 0) E(0, 0, 1) F(1, 0, 1) G(1, 1, 1) H(0, 1, 1) This cube clearly has 8 corners, 12 edges and 6 faces. If we now cut off corner G, such that our cut plane goe...
stackexchange_codegolf
What general tips do you have for golfing in S.I.L.O.S? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to S.I.L.O.S (e.g. "remove comments" is not an answer). Please post one tip per answer. S.I.L.O.S can be run here.
stackexchange_codegolf
Once I wrote a JavaScript program that would take as input a string and a character and would remove all characters except for the first one and the character given as input, one by one. For example, computing this with inputs codegolf.stackexchange.com and e for the character yields: codegolf.stackexchange.com cdegolf...
stackexchange_codegolf
Make a code that gets list of badges that nobody received yet (for example, by using this website API for badges), and output the sorted list of such badges, with new line after each. Example output (may be smaller, depending on when you do this challenge): Archaeologist Caucus Constituent Copy Editor Deputy Electorate...
stackexchange_codegolf
Inspired by this question by @CᴏɴᴏʀO'Bʀɪᴇɴ. Taken from the question: Your task is simple: given two integers a and b, output ∏[a,b]; that is, the product of the range between a and b. You may take a and b in any reasonable format, whether that be arguments to a function, a list input, STDIN, et cetera. You may ...
stackexchange_codegolf
\$723 = 3 \times 241\$ is a semi-prime (the product of two primes) whose prime factors include all digits from \$1\$ to \$n\$, where \$n\$ is the total number of digits between them. Another way to look at this is that the (sorted) digits in the factorisation of \$723\$ are all consecutive. The first 10 such semi-prime...
stackexchange_codegolf
Sometimes I see a claim like "80% of respondents agreed" and I think "what was your sample size? 5?" because, of course, with a sample size of 5 it's possible to get 80% to agree on something. If the claim is "47% of respondents agreed" then I know it must be a larger sample size.[1] challenge Given a positive integer ...
stackexchange_codegolf
Story: The π was recently computed with accuracy to 100 trillions digits, but it is useless to us. We can't do accurate enough math, because rational numbers are too boring and so we don't know that much digits of them! Challenge: Your task will be to write program or function which takes string of digits including dec...
stackexchange_codegolf
(This challenge exists to extend sequence A276272 in the On-Line Encyclopedia of Integer Sequences, and perhaps create a new OEIS sequence1.) This is a code-challenge, which will have you write code to compute as many terms of this sequence as possible. Background A polytet is a kind of polyform which is construct...
stackexchange_codegolf
Your Task Write a program using ASCII characters. Five alphanumeric (0-9, A-Z, a-z) characters will be inserted at random into your program's source code. Your task is to detect and output these characters inserted into your program. Conditions Your code cannot use any form of backup file. Your code may produce any un...
stackexchange_codegolf
For the purposes of this question, the prime factorial of a number n is the result of multiplying all prime numbers smaller than n, and then multiplying the result by n. Your Task: Write a program or function to find the prime factorial of a number, as outlined above. Input: An integer n where n is greater than one...
stackexchange_codegolf
Given a list of positive integers, give the longest contiguous sublist which contains at most 1 pair of identical items. In the case of a tie return any of the solutions. This is code-golf so the goal is to minimize your source code with answers being scored in bytes. Test cases [] -> [] [1,2,3] -> [1,2,3] [1,2,2,3] -...
stackexchange_codegolf
The task Given an image as input, your task is to do the following: Resize the image so it is At least 2 times smaller, but still has the same width/height ratio by taking every second (if resized to 2x) pixel in both horizontal and vertical directions and using those in the pixel art image. Example: a 4x4 image [a...
stackexchange_codegolf
Create a progress bar indicating year progress Your code has to output the percentage of the year already passed form 1st of January of the current year. You have to display a progress bar and the figure. Input You may use builtins to get the current date, if your language doesen't have it you can get date as input but...
stackexchange_codegolf
The string tut-tutut-tut-tuttut-tut can be constructed with overlapping or concatenated instances of the word tut-tut: tut-tutut-tut-tuttut-tut tut-tut tut-tut tut-tut tut-tut The string tut-tututut-tutut-tut cannot: tut-tututut-tutut-tut tut-tut^ |tut-tut | tut-tut ...
stackexchange_codegolf
Write a program or function that takes two inputs: A text message The dictionary of English language, as it appears in this Github file (containing about 60000 words) and outputs the number of spelling errors in the message (see below for definition and test cases). You can receive the dictionary as a parameter to yo...
stackexchange_codegolf
I recently saw this language in a challenge and it's awesome. Does anyone have some tips for code-golfing in it? Your tips should be at least somewhat specific to MarioLANG. Please post one tip per answer.
stackexchange_codegolf
I recently learned from a comment by MathOverflow user pregunton that it is possible to enumerate all rational numbers using iterated maps of the form \$f(x) = x+1\$ or \$\displaystyle g(x) = -\frac 1x\$, starting from \$0\$. For example, $$0 \overset{f}{\mapsto} 1 \overset{f}{\mapsto} 2 \overset{g}{\mapsto} -\frac12 \...
stackexchange_codegolf
After all assignments are submitted, a dictionary is created that maps student number to the hash of their file. This dictionary, or hashmap, or mapping (whatever your language calls it) will look as follows: {100: "aabb", 104: "43a", 52: "00ab", 430: "aabb", 332: "43a"} The key is the student number, and the value is ...
stackexchange_codegolf
There are two types of people in this world: users and admins. Let's find out who the real admins are. The task is simple: If the script is run with elevation, print 'True' and only 'True' (only trailing newlines permitted as extra). If the script is run as an unelevated user, print 'False' and only 'False', exceptions...
stackexchange_codegolf
Write a program or function that takes in three integers, a width w, a height h, and a step count s. You will be drawing a non-self-intersecting random walk s steps long on a 5*w by 5*h pixel image where every 5 by 5 pixel cell is either empty (pure beige) or one of these twelve simple "pipes": The image above is enla...
stackexchange_codegolf
Carry sort is an \$O(n)\$ "sorting" algorithm. Here's how it works. The algorithm moves left to right along a list. As it traverses a list it "carries" a single item, the largest item it has encountered so far. Once it encounters a larger item it picks up that item and drops the item it is already carrying in place. W...
stackexchange_codegolf
Task Write a program or a function that calculates a week-day name of a date which a user inputs. Input & Output Input is a string, YYYYMMDD. Example of input values: 20110617 : June 17, 2011 19040229 : February 29, 1904 06661225 : December 25, 666 00000101 : January 1, 0 99991231 : December 31, 9999 You may assume t...
stackexchange_codegolf
This challenge is inspired by one of my other challenges: Pointlessly make your way down the alphabet That challenge asked you to take a string of text, and for each letter produce a sequence of letters moving down the alphabet to 'a'. For this challenge I'd like to decode the output of that challenge (minus the line b...
stackexchange_codegolf
Your goal is to calculate the exponential of a float (e**x) up to 2 decimal places for any float within 1 to 10. The accepted error range is 0.01. However, you must not use the built-in exponential function or the logarithm function. In fact, attempts to circumvent this by (2**x)**(1/ln(2)) are prohibited, even if you ...
stackexchange_codegolf
In this challenge, you implement an interpreter for a simple stack-based programming language. Your language must provide the following instructions: push a positive number pop two numbers and push their sum pop two numbers and push their difference (second number - first number) pop a number and push it twice (dup) p...
stackexchange_codegolf
Challenge Given a polynomial \$p\$ with real coefficients of order \$1\$ and degree \$n\$, find another polynomial \$q\$ of degree at most \$n\$ such that \$(p∘q)(X) = p(q(X)) \equiv X \mod X^{n+1}\$, or in other words such that \$p(q(X)) = X + h(X)\$ where \$h\$ is an arbitrary polynomial with \$ord(h) \geqslant n+1\...
stackexchange_codegolf
This is the sequel to one of my previous challenges, Three-Three-Three! Write a program (or function, or snippet) that takes no input and produces an output according to the following four Conditions. Both the program and the output must be written such that: At least 16 distinct characters appear (since 16 = 4 × 4)...
stackexchange_codegolf
Your bird has been itching for some exercise and is sick of being stuck in static positions all the time. Write a program that will show a randomly dancing ascii bird, updating every 100ms*n or 200ms*n depending on the dance move. The bird always begins with the dance move <(")>. The program should accept one input whi...
stackexchange_codegolf
Challenge Given a positive integer N, output the sum of the first N reciprocals as an exact fraction, which is represented as a pair of integers in a consistent order representing numerator and denominator. Rules Output must be exact. Output should be as a pair of integers in a consistent order representing numerator ...
stackexchange_codegolf
Background The Schläfli Symbol is a notation of the form {p,q,r,...} that defines regular polytopes and tessellations. The Schläfli symbol is a recursive description, starting with a p-sided regular polygon as {p}. For example, {3} is an equilateral triangle, {4} is a square and so on. A regular polyhedron that has q r...
stackexchange_codegolf
A connected graph is a graph that contains a path between any two vertices. Challenge Build a [2-input NAND-gate] circuit that determines whether a 4-vertex graph is connected. (A gate's 2 inputs can be the same input bit or other gate.) Output True if the graph is connected, and False otherwise. Input The six possib...
stackexchange_codegolf
Cheat is a card game where you're trying to get rid of your hand. A turn looks something roughly like this: Determine what card rank you have to play that turn. In most variants this is one rank higher than the previous turn. Play 1-4 cards, face down. These don't have to match the valid rank. If they don't, it's cons...
stackexchange_codegolf
Here's an array representing a standard deck of cards, including two Jokers. [ "AS", "2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "10S", "JS", "QS", "KS", "AD", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "10D", "JD", "QD", "KD", "AH", "2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "10H", "JH", "QH", "K...
stackexchange_codegolf
Given a black-and-white image in any reasonable lossless format as input, output ASCII art that is as close to the input image as possible. Rules Only linefeeds and ASCII bytes 32-127 may be used. The input image will be cropped so that there is no extraneous whitespace surrounding the image. Submissions must be able ...
stackexchange_codegolf
You are given a multi-dimensional array of integers. Each dimension has a fixed size (so that it would be always rectangular if it is 2D). Your program should calculate the sums in each dimension and append the sums as the new last items in that dimension. Assume the input and output arrays are A and B, and the size of...
stackexchange_codegolf
Happy birthday to Me! Write a program that prints Happy birthday to me! on its birthday. The program's birthday is the creation, last modification or compilation time of the program (you choose), and must not be hard-coded. The date you use as the birthday must not be affected by the program's invocation or execution ...
stackexchange_codegolf
Given a string containing only 0's 1's, 2's and brackets, output the grammar tree of the string. A 2 requires 2 arguments - one to the left and one to the right A 1 requires a single argument - to either the left or right A 0 doesn't require any arguments and is the base case A pair of brackets counts as one argument a...
stackexchange_codegolf
Print or return the following text: Hello world! The quick brown fox jumps over a lazy dog. However, your submission will not be scored in bytes. Instead, primarily it will be scored by the width in pixels of the program when written in Arial in a 12pt font. In particular, the score is: $$ (\text{visual width in px}) ...
stackexchange_codegolf
Introduction A quine is a program that outputs its own source code. For example, a well-known Python quine is _='_=%r;print(end=_%%_)';print(end=_%_). Running it outputs _='_=%r;print(end=_%%_)';print(end=_%_), therefore it is a valid quine. An error quine is similar to a regular quine, however it must output to STDERR...
stackexchange_codegolf
Given two rectangles, which are possibly not in the orthogonal direction, find the area of their intersection. Input You may take the rectangles as input in one of the following ways: The coordinates of the four vertices of the rectangle. These coordinates are guaranteed to represent a rectangle. The coordinates of t...
stackexchange_codegolf
We can write mathematical expressions using the standard math operators (,),+,*,/,- available pretty much universally. We allow the symbols a, b, c, d and integers (e.g. 1, 45, etc.) but will restrict to just these four symbols. (Bonus points if you can handle more.) The goal is to take an expression as input and outpu...
stackexchange_codegolf