instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Related: Name the poker hand A straight flush is a poker hand containing five cards of sequential rank, all of the same suit. As part of a straight flush, an ace can rank either above a king or below a two. An ace can rank either high (e.g. A♥ K♥ Q♥ J♥ 10♥ is an ace-high straight flush) or low (e.g. 5♦ 4♦ 3♦ 2♦ A♦ is ...
stackexchange_codegolf
Sandbox Inspired by a Codingame challenge I tried (and failed at) about a month ago. Given a binary tree of words, say: HELLO / \ WORLD EATING / / \ ARCH IDAHO GUARD / DOOZY / ...
stackexchange_codegolf
In this challenge we are going to consider lists of integers such that for every member \$x\$ at index \$i\$ then the indexes \$i+x\$ and \$i-x\$ have the value \$x+1\$ or are out of bounds for the list. We will call these trampoline lists. If we play around with these for a while we can notice that if we start a list...
stackexchange_codegolf
Write a program that takes a single line string that you can assume will only contain the characters /\_‾. (That's forward and backward slash, underline and overline. You can use ~ in place of overline if you need since overline is not convenient ASCII.) For example, one possible input is: __/‾‾\/\_/‾ Your program nee...
stackexchange_codegolf
The divisors of a natural number form a poset under the relation of "a divides b?", \$a | b\$. This challenge is to produce the number, \$C\$, of non-empty chains of such posets for natural numbers, \$N\$. This is A253249 in the Online Encyclopedia of Integer Sequences. That may sound complicated, but it's not really, ...
stackexchange_codegolf
Input: An NxM grid or multi-line string (or other reasonable input-format), containing only printable ASCII (unicode range [32,126]). Output: The amount of closed polygons of the same character that can be found, with two special rules: Spaces are wildcards and can be used (multiple times) for any character o, O, and ...
stackexchange_codegolf
Given a sequence of three integers, determine if the sequence is arithmetic (of the form [a, a+d, a+2*d]) or geometric (of the form [a, a*r, a*r^2]) by outputting a fourth term that completes it (a+3*d for arithmetic, a*r^3 for geometric). Examples: [1, 2, 3] -> 4 (This is an arithmetic sequence with a difference of 1)...
stackexchange_codegolf
This is a KOTH challenge for the dollar bill auction game in game theory. In it, a dollar is being sold to the highest bidder. Bids go up in increments of 5¢, and the loser also pays their bid. The idea is that both players escalate the bidding war far beyond the value of a dollar in order to cut their losses. Let's ho...
stackexchange_codegolf
Your task is to write a non-empty computer program comprised of some sequence of bytes. If we choose a particular byte in the program and remove all instances of it from the program, the modified program should output the removed byte. For example if our program were aabacba Then bcb would output a, aaaca would need ...
stackexchange_codegolf
A collection of positive integers d_1 d_2 ... d_k is a factorisation of a positive integer n if d_1 * d_2 * ... * d_k = n Each positive integer has a unique prime factorisation, but in general they also have factorisations in which some of the terms are composite. E.g. 12 = 6 * 2 = 4 * 3 = 3 * 2 * 2 Write a program, ...
stackexchange_codegolf
The Fabius function is an example of a function that is infinitely differentiable everywhere, yet nowhere analytic. One way to define the function is in terms of an infinite number of random variables. Specifically, given a sequence of independent random variables \$\{U_n\}\$, where each \$U_n\$ is uniform on the inter...
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
At http://shakespeare.mit.edu/ you can find the full text of each of Shakespeare's plays on one page (e.g. Hamlet). Write a script that takes in the url of a play from stdin, such as http://shakespeare.mit.edu/hamlet/full.html, and outputs the number of text characters each play character spoke to stdout, sorted accord...
stackexchange_codegolf
Your task Randomly pick and print "Joe Mama" or "Joe Biden" in as little bytes as possible. Rules No trailing lines, spaces, or anything else weird like that No election fraud! Both "Joe Mama" and "Joe Biden" must have equal chaces of winning Prize The winner will get a spot in https://github.com/Sid220/joe-mama-or-j...
stackexchange_codegolf
The Challenge It's quite simple really, sort a list of numbers. Details You must sort a list of numbers in ascending order, without using any built-in sorting functions/libraries/etc (i.e. list.sort() in Python). Input/output can be done in any method you choose, as long as it is human readable. Standard loopholes ar...
stackexchange_codegolf
Print this text: _________ | | | | | | |_________| Shortest code wins. Notice the space at the start of the first line.
stackexchange_codegolf
This little piggy went to market, this little piggy wrote some code... Ah wait, we're not talking about that bacon, we're talking about Sir Francis Bacon! Specifically, the cipher Bacon devised in the late 1500s, as a method of hiding a message within another message, a method of steganography. The cipher works by conc...
stackexchange_codegolf
Your network scanning tool is annoyingly picky about input, and immediately crashes if you feed it an IPv4 address that contains improper characters or isn't properly formatted. An IPv4 address is a 32-bit numeric address written as four numbers separated by periods. Each number can be zero to 255. We need to write a...
stackexchange_codegolf
Introduction You may know and love your normal unit circle. But mathematicans are crazy and thus they have abstracted the concept to any point that satisfies x*x+y*y=1. Because Cryptographers1 are also weird, they love finite fields and sometimes finite rings (it is not like they have much choice though), so let's comb...
stackexchange_codegolf
Your job is to output the html of the current version (at the time of this writing) of the Wikipedia page for Kolmogorov complexity: https://en.wikipedia.org/w/index.php?title=Kolmogorov_complexity&oldid=781950121&action=raw (backup) This is code-golf, so the shortest code wins.
stackexchange_codegolf
Input: You will be passed a string containing a single english word. All letters will be lowercase, and there will be no non-alphabetic characters in the string. Output: You will return an integer from 1 to 7 representing how many syllables you think are in the word. Scoring: Your program will be run against all of th...
stackexchange_codegolf
A program ordinal is a (possibly transfinite) ordinal which can be assigned to programs in some language depending on their output. To be more specific: Strings that give no output have ordinal 0 Programs that output a program of ordinal n have ordinal n+1 Programs P0 outputting multiple programs P1, P2... Pn have ord...
stackexchange_codegolf
Your challenge is to write a program that constantly prompts for input, and when input is given, output that five seconds* later. However, your program must continue prompting for input during that time. Since this is a bit confusing, here's a demo. <pre id=x></pre><input id=h onchange='var k=this;(()=>{let a=k.value...
stackexchange_codegolf
The Task Build a function that takes a string of coins ending with an item index, and generates change as a string of coins using the least amount of coins possible. The following are the items that can be bought (0-indexed): [0.45, 0.60, 0.75, 0.95, 1.10, 1.25, 1.40, 1.50, 1.75, 2.00] The following are the coins that ...
stackexchange_codegolf
(This challenge is very similar, but this current challenge has additional complications.) Imagine a 2-dimensional room, where the walls are plated with flat mirrors. Suddenly, a beam of light strikes into the room, where a piece of wall is missing! The lightbeam dances around the room, getting reflected by the wall...
stackexchange_codegolf
A simple graph is toroidal if it can be drawn on the surface of a torus without any edges intersecting. Your task is to take a simple undirected graph via any reasonable method (adjacency matrix, edge vertex sets, etc.) and decide whether or not it is a toroidal graph. You should output one of two distinct values for...
stackexchange_codegolf
Challenge Given an ASCII operator from the list below and a number n, draw an ASCII representation of the operator using that operator as the character with the line segments of the operator having length n. Input An ASCII character from the list = + - x / and an integer n where n >= 1. (I'm using x instead of * and /...
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
The Hilbert curve is a space filling fractal that can be represented as a Lindenmayer system with successive generations that look like this: Thanks to http://www.texample.net/tikz/examples/hilbert-curve/ for the image. Goal Write the shortest program possible (in bytes) that takes a positive integer n from stdin and ...
stackexchange_codegolf
Room Number Locator I have come across an interesting problem solving technique at my job when given the wrong room number from a colleague for a meeting. Every now and then, while on the way to a meeting, a member on my team will send me the wrong room number, typically because they are in a rush at their desk and fat...
stackexchange_codegolf
Lets define a non-empty, unsorted and finite matrix with unique numbers as follow: $$N = \begin{Bmatrix} 4&5&7\\1&3&6 \end{Bmatrix}$$ Lets define 4 matrix moves as: ↑* (up): Moves a column up ↓* (down): Moves a column down →* (right): Moves a row to the right ←* (left): Moves a row to the left The asterisk(*) repre...
stackexchange_codegolf
Given two strings: a string s and an alphabet a, implement string projection in the shortest code possible. String projection returns a string o that contains the characters in s that are in a. The order of the characters in o must match the order of characters in s. So if s = "abcd" and a = "12da34", o = "ad", since o...
stackexchange_codegolf
A strictly non-palindromic number N is a number that isn't a palindrome in any base (in bases 2 to N-2). These numbers are listed on OEIS For example, the number 19 in base 2,3,4,5,6,...17 is: 10011,201,103,34,31,...12. None of these representations is palindromic, so the number is strictly non-palindromic. For this ...
stackexchange_codegolf
My teacher gave me a simple problem which I should solve with a code tiny as possible. I should print all odd numbers from 0 to 100000 into a HTML document using javascript. for(var y = 0; y < 100000; y++){ if(!(y % 2 == 0)){ document.write(y + " "); } }; Is it possible to do that shorter?
stackexchange_codegolf
Input Your program will take in the integer coefficients of the equation \$ax^3+bx^2+cx+d=0\$ as inputs (a, b, c, and d). Output All real solutions of the input equation, with an accuracy of at least the thousandths place, sorted from smallest to largest. Rules Built-in equation solver are not allowed Native math ...
stackexchange_codegolf
In that Coding Golf, you should convert one coding convention with TitleCase to lower_case_with_underscores. And... vice versa! Specification Change the casing in a following way: If underscore character is a delimiter, change the casing to Title Case without any of delimiter. If there are multiple words with no delim...
stackexchange_codegolf
I always used a Mandelbrot image as the 'graphical' version of Hello World in any graphical application I got my hands on. Now it's your guys' turn. Language must be capable of graphical output or drawing charts (saving files disallowed) Render a square image or graph. The size at least 128 and at most 640 across* The...
stackexchange_codegolf
Suppose there are 5 positive integers in an array or list as 14, 12, 23, 45, 39. 14 and 12 cannot be taken in the subset as 1 is common in both. Similarly {12, 23}, {23, 39}, {14, 45} cannot be included in the same subset. So the subset which forms the maximum sum is {12, 45, 39}. The maximum sum such formed is 96. the...
stackexchange_codegolf
Task The task is to golf a real-time exact string matching algorithm of your choice. Input Two lines of text supplied on standard input, separated by a new line. The first line contains the "pattern" and will simply be an ASCII string drawn from the letters a-z. The second line contains the longer "text" and will also ...
stackexchange_codegolf
This question is part of a series Brain-flak Birthday challenges designed to celebrate Brain-Flak's first Birthday. You can find more information about Brain-Flak's Birthday here. Today is Brain-Flak's first Birthday! So I thought we would throw it a surprise birthday party. So in your favorite language print Surp...
stackexchange_codegolf
The task Write a program or function whose input is a list/array X of integers, and whose output is a list of sets of integers Y, such that for each element e in each set Y[i], X[e] = i, and such that the total number of elements in the sets in Y equals the number of elements in X. (This is basically the same operation...
stackexchange_codegolf
Introduction This challenge is about producing a code to count the frequency of bigrams in a text. A bigram is two consecutive letters in a text. For instance 'aabbcd' contains the bigrams aa, ab, bb, bc, cd once each. Counting bigram frequencies is super useful in cryptography. In a brute force algorithm, this code ma...
stackexchange_codegolf
The Quine-McCluskey algorithm merges disjunctors in a disjunction like $$ \lnot x_0 \land \lnot x_1 \land \lnot x_2 \land \lnot x_3 \lor\\ x_0 \land \lnot x_1 \land x_2 \land \lnot x_3 \lor\\ \lnot x_0 \land x_1 \land x_2 \land \lnot x_3 \lor\\ \lnot x_0 \land \lnot x_1 \land \lnot x_2 \land ...
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
One of the interesting aspects of gravity is that, as far as I'm aware, you can't just have stuff floating in midair. However, it seems not everyone at the Association of Random Castle Builders is aware of this fact, leading to castles such as this one: # # # # # #...
stackexchange_codegolf
Thanks to this question for some inspiration In this challenge we will represent a line of dominoes as a string of |, / and \. You will be given a string of dominoes as input and you must determine what they look like when they have settled. Here are the rules for how dominoes fall over A standing domino, |, left ...
stackexchange_codegolf
Task Create a program or a function that is valid in multiple programming languages, and when compiled/interpreted as a different language outputs "Hello, World!" in a different natural language. For example, a valid solution might output Hello World! (English) when compiled and run as C, Hallo Welt! (German) when comp...
stackexchange_codegolf
Create A "Hello, World!" program but without any vowels. Winner is the program with the least bytes. Rules: No vowels are allowed in the code. Must print to STDOUT Must be a full program. Submissions are measured in Bytes Any language goes as long as there aren't any vowels Edit: Y is only a vowel if there aren't any...
stackexchange_codegolf
Quote notation is a way of expressing rational numbers based on the concept of \$p\$-adic numbers, written in the form \$x'y\$. The quote indicates that the number to it's left (\$x\$) is "repeated" infinitely to the left, then prefixed to the number on the right (\$y\$). For example \$3' = \: ...3333\$ and \$764'31 = ...
stackexchange_codegolf
In this cops-and-robbers challenge, robbers must crack cop answers by finding out which languages the cops used. This is the Cops thread. For the Robbers' challenge, see here Cops, you are to write a program, which, when executed in a specific language, does one of the following: Outputs one of the 5 phrases below Out...
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. The challenge is to compute the average Levenshtein distance between two independent and uniformly random chosen binary strings of length n each. Your...
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
Introduction You are stranded on a deserted island with some servants and are hunting for treasure. The longer one searches, the more treasure one finds. The fewer people searching, the more each person finds. Due to limited supplies, the leader has decided that a few people, up to a quarter of the group, shall be left...
stackexchange_codegolf
Pangrams The quick brown fox jumped over the lazy dog. This is an example of a pangram - a sentence that contains every letter of the alphabet at least once. A self-enumerating pangram is a sentence that fulfills the criteria to be a pangram by producing an analysis of its own letter count. An example of achieving th...
stackexchange_codegolf
What is the shortest regular expression (REGEX) you can create for file extensions for all of the following image file formats (photographs, paintings, sketches, and drawings)? .ACAD .AFD .AFP .AOM .AOMA .APNG .ASCII .AVIF .AVIFAV .BMP .BPG .CABAC .CDEC .CDR .CDRAW .CGM .CHEVC .CIEC .CIPA .CMYK .COLLADA .CRT .CWC .DEEP...
stackexchange_codegolf
This golf requires a factorial calculation be split up among multiple threads or processes. Some languages make this easier to coordinate than others, so it is lang agnostic. Ungolfed example code is provided, but you should develop your own algorithm. The goal of the contest is to see who can come up with the shorte...
stackexchange_codegolf
A knight's tour is a sequence of moves of a knight on a chessboard such that the knight visits every square only once. For those who are not aware of how knights in chess work, knights are capable of moving in an L shape (see fig. 1). (Or a ߆ shape, or even a \ shape depending on who you ask.) Essentially, in one move,...
stackexchange_codegolf
I need to stop thinking of punny names Your task is to create as many snippets (programs that have input and output built-in), functions or full programs as possible that sorts whatever your language's version of integer arrays is in ascending order, but for each program, you're only allowed to use the characters in AS...
stackexchange_codegolf
I was messing around on my 'ol TI-84 CE and made a program that produced this output (it was actually bigger but that is not the point): * * * * * * * * * * * * * * * * * ... I evolved it to take input text and make the triangle waves out of that. The final step was to also take a number to specify th...
stackexchange_codegolf
Your task is to write a program or function that takes a string as input, and prints Hello (input), I'm (language name). Examples Python: Input: Oliver Output: Hello Oliver, I'm Python C++: Input: Jacob Output: Hello Jacob, I'm C++ etc. Remember, this is code-golf, so the code with the lowest number of bytes wins. Lead...
stackexchange_codegolf
A manufacturing company wants to print a design on mats of varying dimensions, and they hired you to program a robot to make these mats. The design consists of alternating rings of any 2 symbols on a mat. Below are some sample looks: Column 9 by Row 7 Symbol 1: @ Symbol 2: - Input: 9 7 @ - @@@@@@@@@ @-------@ @-@@@@@-@...
stackexchange_codegolf
This is the second of two challenges about "pulling functions taut". Here is the slightly simpler Part I. Let's drive m nails into a board at positions (x1, y1) to (xm, ym). Tie a rubber band to the first and last of those and stretch around the other nails, such that the band traverses all nails in order. Note that th...
stackexchange_codegolf
About Functional-Basic Functional-Basic (FB for short) is a language that only allows numbers and lists. Basic features, such as the if statement are missing in an attempt to simplify the language. Everything in this language is immutable. input is always assigned to the script input, which can be either a number or a ...
stackexchange_codegolf
Inspired by George Gibson's Print a Tabula Recta. You are to print/output this exact text: ABCDEFGHIJKLMNOPQRSTUVWXYZ BBCDEFGHIJKLMNOPQRSTUVWXYZ CCCDEFGHIJKLMNOPQRSTUVWXYZ DDDDEFGHIJKLMNOPQRSTUVWXYZ EEEEEFGHIJKLMNOPQRSTUVWXYZ FFFFFFGHIJKLMNOPQRSTUVWXYZ GGGGGGGHIJKLMNOPQRSTUVWXYZ HHHHHHHHIJKLMNOPQRSTUVWXYZ IIIIIIIIIJKLM...
stackexchange_codegolf
Challenge For this challenge, a mountainous string is one that conforms to the grammar rule M: x(Mx)* where at each production, the all x's are the same character. When indented, a mountainous string might look something like this: A B C D C E F E C B A As you can see, it looks a bit like a mounta...
stackexchange_codegolf
I have 2 inputs: 1 single number and some numbers separated by whitespace: 1 1 2 3 4 5 I want to loop over the second input, and I don't need the first input. I did this, which works: input() for x in input().split():somecode() But can I go directly to the second input without doing the input() at the beginning or wi...
stackexchange_codegolf
The task In this challenge, your task is to determine whether some string occurs as a substring of a given string both surrounded by another string and reversed. Your input is a non-empty string S of lowercase ASCII letters. If there exist non-empty strings A and B such that the concatenation ABA and the reversal rev(B...
stackexchange_codegolf
Given a message, append checksum digits using prime numbers as weights. A checksum digit is used as an error-detection method. Take, for instance, the error-detection method of the EAN-13 code: The checksum digit is generated by: Multiplying each digit in the message alternating by 1 and 3 (the weights) Summing it up...
stackexchange_codegolf
Satan-Primes who are they? they are Primes containing 666 these are Satan-Primes:[46663,266677,666599,666683,616669] these are NOT :[462667,665669,36363631,555] Plot Every number bigger than 6661 has Satan-Primes behind him The Challenge Given an integer n>6661 find the Satan-Prime behind (or equal) and closest to itse...
stackexchange_codegolf
The challenge is simple: generate a word. Specifications: Word must be pronounceable. This is defined as "alternating between a consonant and a vowel." A consonant is one of the following letters: bcdfghjklmnpqrstvwxz A vowel is one of the following letters: aeiouy Word must be randomly generated. Words must be abl...
stackexchange_codegolf
Everyone loves The Big Bang Theory, right? And everyone loves polyglots, right? So let's combine them! Task Your task in each language is quite basic. You must output the name of the one of the 5 main characters of The Big Bang Theory: Sheldon Lee Cooper, Leonard Leakey Hofstadter, Howard Joel Wolowitz, Rajesh Ramayan ...
stackexchange_codegolf
Gringotts isn't just a vault, but a reputable financial institution and wizards need loans too. Since you don't want to be screwed over by the Gringotts goblins, you decided it would be a good idea to write a program to calculate interest. Interest is compounded only yearly. Your task is to calculate total owed amount ...
stackexchange_codegolf
Today you need to solve a very practical problem: How many loops do you need to have a certain number of sheets on your toilet paper roll? Let's look at some facts: The diameter of a bare toilet paper cylinder is 3.8cm The length of one sheet of toilet paper is 10cm. The thickness of one sheet of toilet paper is 1mm. ...
stackexchange_codegolf
Background We define the prime-counting function, \$\pi(x)\$, as the number of prime numbers less than or equal to \$x\$. You can read about it here. For example, \$\pi(2) = 1\$ and \$\pi(6) = 3\$. It can be shown, using dark magic, that \$ \lim_{x \to \infty} \frac{\pi(x)}{x/\log x} = 1 \$ which means we can approxima...
stackexchange_codegolf
In 256 bytes or fewer write a function, \$f\$, from the positive integers to the positive integers that is: Monotonic: larger inputs always map to larger outputs. (\$a < b \implies f(a) < f(b)\$) Non-linear: does not have asymptotic order notation \$O(n)\$. (\$\displaystyle\forall c: \exists n:c\cdot n < f(n)\$) Your...
stackexchange_codegolf
Given two points \$(x_1, y_1)\$ and \$(x_2, y_2)\$ with integer coordinates, calculate the number of integer points (excluding the given points) that lie on the straight line segment joining these two points. Use any maths formula you like, such as $$gcd(|x_2 - x_1|, |y_2 - y_1|) - 1$$ Input Four integer coordinates of...
stackexchange_codegolf
Disclaimer: This challenge inspired by me spending the morning debugging recursive functions, which have been frying my brain a little. Here's an example of recursion, from a letter, we keep going to the previous letter of the alphabet, printing out each one as we go, until we hit the letter a, then we print that and s...
stackexchange_codegolf
In this challenge, you are going to take a number and turn it into a string, but not in the common way. You will use the aaaaa way! The aaaaa way is simply replacing each digit of the input number with the letter at that position in the alphabet. For example, 11111 would become aaaaa and 21223 would become babbc. If th...
stackexchange_codegolf
Where am I now? Given a string d, containing only the letters NSWE, determine the coordinates I've traveled (from left to right, consuming greedily) and the final coordinate where I reside. The rules for reading coordinates from left-to-right: If the next character is N or S: If the character after the N or S is anot...
stackexchange_codegolf
Input verb, a string that matches the regular expression ([a-pr-vyzıöüçğş]*[aeıioöuü][bcçdfgğhj-nprsştvyz]+|([a-pr-vyzıöüçğş]*[aeıioöuü]){2})(mak|mek) plural, a truthy or falsy value person, an integer having value either 1, 2, or 3 tense, an integer having value either 1, 2, or 3 Output The conjugated form of the Tu...
stackexchange_codegolf
Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2015 Day 3, Part 2. This challenge was kindly contributed by Wheat Wizard (Grain Ghost). Santa is delivering presents to an infinite two-dimensional grid of houses. The delivery begins delivering a present to the ...
stackexchange_codegolf
Given three integers >= 2, create an ASCII cube in an orthogonal (cabinet) projection. The three integers represent height, width and depth (measured in visible characters) including the corners. The corners should be 'o's or '+', free choice. w: 10, h: 5, d: 4 Thus gives: o--------o / /| / / | o...
stackexchange_codegolf
Given two nonnegative integers n,k such that 0 <= k <= n, return the binomial coefficient c(n,k) := (n!) / (k! * (n-k)!) Test cases Most languages will probably have a built in function. c(n,0) = c(n,n) = 1 for all n c(n,1) = c(n,n-1) = n for all n c(5,3) = 10 c(13,5) = 1287 Related challenges Catalan Numbers Compu...
stackexchange_codegolf
Given a text and a number N, output, in a human readable format, the set of the character N-grams with their respective percentages. The smallprint The text can be read from a file, stdin, passed as string parameter to a function or any other common way i forgot to mention The number N can be hardcoded, but only if i...
stackexchange_codegolf
The Levenshtein edit distance between two strings is the minimum possible number of insertions, deletions, or substitutions to convert one word into another word. In this case, each insertion, deletion and substitution has a cost of 1. For example, the distance between roll and rolling is 3, because deletions cost 1, ...
stackexchange_codegolf
Task Provide two programs/functions A and B (not necessarily in the same language) with the following properties: Either program, when given its own source code as input, produces an accepting output. Either program, when given the other program's source code as input, produces a rejecting output. It doesn't matter w...
stackexchange_codegolf
Many of you already know JSF**k. For those who don't, it's a script that basically turns any JavaScript code into something written using only []()!+. Your task is to build, using any language of your choice, a program which converts JSF**k into unobfuscated JavaScript. Input: A string with valid JSF**k code. Output: ...
stackexchange_codegolf
You want to write your English essay. However, all characters on your keyboard broke other than the arrow keys and the enter key. You want to find out how to place the characters so you can write your essay with the least movement. Formally, you have to assign to each character of !"$%&'()+,-./0123456789:;<=?[]`abcdef...
stackexchange_codegolf
Infix notation is a method of printing mathematical expressions where each operator sits between its two arguments, such as \$ \left(5 \cdot 4\right) + 3 \$. Prefix notation is a method of printing expressions where operators sit before their arguments. The equivalent of the above is +*543. It's a bit harder to underst...
stackexchange_codegolf
Given a list of activities and their start time/date, output an ASCII-art calendar showing the activities on the appropriate days. All activities are guaranteed to be in the same month, no two activities will be on the same day, and all activities are guaranteed to fit within the calendar box. The calendar has the date...
stackexchange_codegolf
Objective Given an expression involving ternary values, evaluate it into a ternary value. Ternary Values The three truth values in question are the values of Haskell's Ordering, namely LT, EQ, and GT. They stand for "less-than", "equal-to", and "greater-than", respectively. Furthermore, they themselves have an order; L...
stackexchange_codegolf
Computers are everywhere nowadays - in cars, trains, skateboards, even nuclear reactors. The possibility that your software will run in a time travelling device is just a matter of time. Can you deal with it? Can you at least detect it? Your task: Write a program that loops and keeps querying the system time, in order...
stackexchange_codegolf
I have made a short script that will pull dns txt records down from a server and combine them into a single string. DNS txt records are: 1.website.com 2.website.com 3.website.com Each of these are iterated through using the single digit number. The double quotes at the beginning and the end of the strings are trimmed T...
stackexchange_codegolf
Challenge Train a single perceptron with 2 inputs and 1 output. Step 1: Initialize the weights Step 2: Calculate the output For inputs: [i1, i2, ..., in] and weights: [w1, w2, ..., wn] the output is: i1 * w1 + i2 * w2 + ... + in * wn Step 3: Apply activation function on the output (i.e sigmoid) Step 4: Update the we...
stackexchange_codegolf
Challenge Suppose you have a list of numbers, and a target value. Find the set of all combinations of your numbers which add up to the target value, returning them as list indices. Input and Output The input will take a list of numbers (not necessarily unique) and a target summation number. The output will be a set of ...
stackexchange_codegolf
Introduction Last year was my birthday (really!) and sadly I had to organise my own party. Well, now you know, couldn't you at least make the cake? Challenge Given an integer n as input, write a full program to output a birthday cake with n candles on. Output A piece of cake with one candle on is: $ | --- ~~~ --- An...
stackexchange_codegolf
Given a positive number \$n\$, find the number of alkanes with \$n\$ carbon atoms, ignoring stereoisomers; or equivalently, the number of unlabeled trees with \$n\$ nodes, such that every node has degree \$\le 4\$. This is OEIS sequence A000602. See also: Paraffins - Rosetta Code Example For \$n = 7\$, the answer is \...
stackexchange_codegolf
Wholly surprised this hasn't been posted already, given the large number of chess puzzles on the site. While I thought of this myself, credit to Anush for posting it to the sandbox back in March. But I figured it's been long enough that I could go ahead and do so myself. A checkmate in chess is a position in which the ...
stackexchange_codegolf
Given a matrix of integers \$M\$ and a list of four integers \$L\$, find the sub-matrix \$N\$ whose corners are given by \$L\$ and return the sum of its elements. Suppose you're given the list \$L = [-8, -3, 2, 9]\$ and the following matrix \$M\$. The numbers in the list are highlighted in blue to illustrate: $$ \begi...
stackexchange_codegolf
Introduction: Pete likes doing word search puzzles. Despite that, he has trouble searching for words vertically, (anti-)diagonally, or reversed. Because of that, he'll always search for the words left-to-right, and rotates the entire puzzle in increments of 45 degrees clockwise. In addition to that, he'll also always s...
stackexchange_codegolf