instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
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
(Hopefully it's still Thanksgiving for you) You got a turkey for your thanksgiving dinner but you don't know how to evenly distribute it. The problem is, some people eat more than others, so you need to find a solution Input There will be two inputs. The first will be an ascii art of various people. o o \|/ \|/ ...
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 is a little codegolf challenge from codingame.com. I was wondering how much Python3 code is necessary (but of course answers are not limited to Python3). Input The first line contains one positive integer n. The second line contains n positive integers. Each consecutive integers on the second line are separated by...
stackexchange_codegolf
Background We all know about distributivity, i.e. \$a(b+c) = ab + ac\$. This is a property on 2 different operations, namely addition and multiplication. But indeed, nothing can stop us from studying distributivity of 1 operation. In this challenge, you will be studying a kind of left-distributive operation. Task Given...
stackexchange_codegolf
Well I think it is about time we have another proof-golf question. This time we are going to prove the well known logical truth \$(A \rightarrow B) \rightarrow (\neg B \rightarrow \neg A)\$ To do this we will use Łukasiewicz's third Axiom Schema, an incredibly elegant set of three axioms that are complete over proposit...
stackexchange_codegolf
Im talking about this question, take a look at it if you are a bit confused. Main Task Your task is to output concatenated integers, in decreasing order, but increasing the maximum integer everytime you hit 1 (for this question, 1 will be considered a prime number). While this doesn't sound any different from the first...
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
Background The Collatz Conjecture is quite well-known. Take any natural number. Triple and increment if odd; cut in half if even. Repeat, and it will reach 1 eventually. This famous conjecture, however, is only that, for it is yet unproven. Little-known to the world, that was not Lothar Collatz's first attempt at fame....
stackexchange_codegolf
Your task is to fill the bucket with numbers upto a given input. Rules Numbers occupy the leftmost position then rightmost, then leftmost and so on. After overflow, the numbers start to gather around the bucket in a similar manner. They occupy position diagonally. The examples should make it clear what the expected out...
stackexchange_codegolf
Your task here will be to write a very dumb AI capable of fetching all treasures on a map. Map The map is defined as follow: (artist-mode™-powered) Basic case: +-+-+-+-+-+-+-+-+-+-+-+-+-+ |P| | | | | | | | | | | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | | | | | | | | | | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+ | | |T| | | | | | | ...
stackexchange_codegolf
Tichu is a card game in which players take turn playing sets of cards from a deck consisting of a standard 52-card deck, plus 4 additional cards: the dragon, which has a greater value than any other card the phoenix, which can act as a wildcard the dog, which passes the turn to your partner the Mah Jong, which has val...
stackexchange_codegolf
This is a cops-and-robbers challenge the Cops' Thread can be found here Your challenge, as robbers is to take outputs from the cops' thread and find anagrams of the output that when run as a program output the original output provided. The winner will be the person with the most valid cracks on this question. Rules Yo...
stackexchange_codegolf
Multi-level marketing related challenge. A peer wants to get rewarded. So it attracted N investors (N>=1), each i-th investor invested x[i]. When a total sum exceeds threshold x[0]+x[1]+...+x[N-1] >= T a peer could be rewarded. But only if a following conditions are satisfied: Minimum amount of investors should be gre...
stackexchange_codegolf
A Latin square of order n is text which is arranged as a square of n lines by n columns, contains n different characters, and each character appears once in each line and column. For example, here is a Latin square of order 9: Code gOlf ode gOlfC de gOlfCo e gOlfCod gOlfCode gOlfCode OlfCode g lfCode gO fCode gOl M...
stackexchange_codegolf
Although there was a prime factors challenge posted ten years ago, it has tedious I/O and restricted time. In this challenge, your task is to write a program or function which takes an integer \$n \ge 2\$ as input, and returns its prime factors. Task: Input will consist of an integer, \$n \ge 2\$. Your program should t...
stackexchange_codegolf
You know those letterboards outside old-style cinemas which show upcoming films - perhaps you have a miniature one in your home? If you've operated one, you'll know that you can normally add letters from either side of a row. But the slots (in which you slide letters) are thin, so it's impossible to swap the order of ...
stackexchange_codegolf
The barfoos, a hypothetical alien species, go about charity in an interesting way. Every morning, barfoo Specialists come up with an ordered list of causes to donate to, and for each cause they recommend what quantity of resources should be donated. That wasn't the weird part. Here's the weird part: A random civilian b...
stackexchange_codegolf
Two dimensional chiral objects are not chiral in three dimensional space. This is because you can flip them over which is equivalent to taking the mirror image unlike in two dimensions where only rotations in the plane of the object are allowed which cannot reproduce the effect of a mirror operation. In this challenge,...
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
Sandbox A spin-off of a rip-off of a rip-off of a rip-off of a rip-off. Go upvote those! Your task, if you accept it, is to write a program/function that outputs/returns its input/argument. The tricky part is that if I left shift your source code, the output must be left shifted too. Likewise, if I right shift your so...
stackexchange_codegolf
It's that time of year when many of us get our advent calendars! If you are unfamiliar with an advent calendar, these are special calendars used to count down advent in anticipation of Christmas. In my experience the doors are placed randomly, and part of the fun as a child was working out where tomorrow's door was! O...
stackexchange_codegolf
A Tiefling is a character race, from Dungeons and Dragons, that has this list of possible traits: small horns fangs or sharp teeth a forked tongue catlike eyes six fingers on each hand goat-like legs cloven hoofs a forked tail leathery or scaly skin red or dark blue skin cast no shadow or reflection exude a smell of b...
stackexchange_codegolf
I could not think of a better title. This is a tips question. I'm asking for tips on golfing my code. I recently took part in a code golf competition in C. The competition ended and I lost. The problem is: Input a line with a number n. Then input n lines, each line contains only a set of cards in descending order, e. ...
stackexchange_codegolf
...or "snakes but not too long". Inspired by this challenge and this comment. Task Write a program or a function that takes no input and outputs its own source code formatted as a snake according to the rules below: If your code has any whitespace, it will not be output; it will just be skipped. There will be one char...
stackexchange_codegolf
You task here is very simple: Given a positive integer n without leading zeroes as input, split it in all possible ways Examples Input->Output 111 -> {{111}, {1, 11}, {11, 1}, {1, 1, 1}} 123 -> {{123}, {12, 3}, {1, 23}, {1, 2, 3}} 8451 -> {{8451}, {845, 1}, {8, 451}, {84, 51}, {84, 5, 1}, {8, 45, 1}, {8, 4, 51}...
stackexchange_codegolf
During work on some project I needed to draw pixels on screen. I found some put-pixel function in JS, but code was quite big and clumsy - so I wonder, how small put-pixel function can be... Challenge Create the smallest put-pixel function. We count size of whole program: initialization code (if needed), function and co...
stackexchange_codegolf
Context: Gynvael Coldwind, a famous security researcher, published a contest in his blog post (that is now complete). The goal was similar to the one described here, but with certain restrictions depending on which of the three allowed programming languages was chosen. I found the exercise fun and wanted to extend the ...
stackexchange_codegolf
Given one of the following as input: AK,AR,AS,AZ,CA,CT,DC,FL,GA,IL,IN,IA,KS,KY,LA,MD,MI,MN,MS,NV,NH,NJ,NM,NY,NC,ND,MP,OH,OK,OR,PA,PR,RI,SC,TN,TX,UT,VT,VA,WA,WI (with quotes) "AK","AR","AS","AZ","CA","CT","DC","FL","GA","IL","IN","IA","KS","KY","LA","MD","MI","MN","MS","NV","NH","NJ","NM","NY","NC","ND","MP","OH","OK",...
stackexchange_codegolf
There have of course been challenges to render ASCII art fonts here and there. This challenge doesn't add anything to those. In contrary, it subtracts from them for a good reason. If you allow all characters, it's a lot of boring work the task is mainly about clever compression of the font and short extraction This o...
stackexchange_codegolf
Create a bot to choose the smallest unique number. (Based on a psychology experiment I heard about many years ago but haven't been able to track down again.) Rules Each game will consist of 10 randomly selected bots playing 1000 rounds. Each round, all bots select an integer from 1 to 10 (inclusive). Any bots that ch...
stackexchange_codegolf
A barcode of EAN-13 symbology consists of 13 digits (0-9). The last digit of this barcode is its check digit. It is calculated by the following means (the barcode 8923642469559 is used as an example): Starting from the second digit, sum up all alternating digits and multiply the sum by 3: 8 9 2 3 6 4 2 4 6 9 5 5 9 |...
stackexchange_codegolf
Challenge Hi, given a string as input, remove any salutations found at the start of the string. The program which performs the most correct substitutions in under 50 bytes wins. Salutations Hey, a salutation is defined as one of the following words: hi hey hello dear greetings hai guys hii howdy hiya hay heya hola hih...
stackexchange_codegolf
Related to, but not a duplicate of, this challenge. Basics This is a clock: ****** ** | ** ** | ** * | * * | * * | * * | * * | * * ...
stackexchange_codegolf
To be able to challenge the Elite-4 of top programmers, you need to show your badges first, that qualify you as a potential programmer-master. However, there's a twist. Once you show a badge, it is collected, which means you can't re-show it. So better come prepared! There are n badge collectors, each has a known list ...
stackexchange_codegolf
Take three inputs, a string of text, T; a string of characters to replace, F; and a string of characters to replace them with, R. For each substring of T with the same (case insensitive) characters as F, replace them with the characters in R. However, keep the same case as the original text. If there are more character...
stackexchange_codegolf
The task is to calculate the average "funniness" of a given number given the following scoring system: 1 point for each "420" in it 2 points for each "69" in it 3 points if its a palindrome (doesn't count if it's just a single digit) 4 points if it has (not for each) "800813" 5 points for ending in "420" 6 points for ...
stackexchange_codegolf
Challenge: Add two numbers. In O(n^m) time, where n and m are the two numbers given. Sleeping, or your language equivalent, is not allowed. Input: Two integers, separated by a space. Output: The sum of the two integers. Additional notes: The exact timing doesn't matter, as long as the input 1000 2 takes roughly 1/1000t...
stackexchange_codegolf
Challenge: write a single script file foo.cmd which can be invoked from the vanilla Windows cmd.exe prompt (not PowerShell, not in administrator mode), to execute arbitrary Windows-specific code... > .\foo.cmd Hello Windows! ...but also be invoked unaltered from a typical POSIX-compliant (Linux/OSX) shell prompt (ba...
stackexchange_codegolf
Your task is to create a polish notation calculator. For those who don't know what is polish notation, it's a mathematical notation where operators are before the operands. Eg: + 1 2 = 1 + 2 Your calculator should implement integer addition, substraction multiplication and division. Standard loopholes are forbidden but...
stackexchange_codegolf
The proof of the set of characters is that there is a translator which takes any ascii python program as input and produces a limited character set version of the program. The limited character set program can be slower than the original program. It simply has to be possible to produce the same output as the valid pyth...
stackexchange_codegolf
WPA2, the actual encryption standard that secures all modern wifi networks, has been cracked... This challenge has nothing to do with the way that the WPA2 was cracked, however is is about computing the 64-digit hexadecimal key that corresponds to a given WPA-PSK pass-phrase. A wireless network with WPA-PSK encryption ...
stackexchange_codegolf
For the purpose of this challenge, arguments are things you pass to a function at the call site, while parameters are what the function uses in its implementation. Or, more succinctly: arguments = external, parameters = internal. While there are several modern languages that have support for argument labels for func...
stackexchange_codegolf
Shift Tac Toe Shift Tac Toe is a game that combines Tic Tac Toe and Connect 4 together. In this game, you start with a 3 by 3 board, and each row is connected to a slider that you can move left and right. At the start, the sliders all start to the very right(this means that you can't move the slider to the right on the...
stackexchange_codegolf
Task Make code given on the command line that takes an unpacked hex value as input and evals that in Perl. Like this: perl -e 'map{eval}pack q/h*/,q/072796e6470222458656275672370202d6f62756020222b302072796e6470222478616e60202f6e6560202771697020247f6020246f602029647e2c5e622/' But with one additional restriction: Your c...
stackexchange_codegolf
Given an input list of non-empty strings, output an ASCII art representation of a tournament, based on the following drawing rules: The number of strings is guaranteed to be of quantity 2,4,8,16,etc. The first two strings play each other, and the next two play each other, and so on. This is the first round. For each g...
stackexchange_codegolf
Your mission, even if you don't accept it, is to input three numbers from STDIN or file: 5 0.5 6 What you must do is evaluate this: (5a + 0.5b)^6 This basically means that the first two numbers are the coefficients of a and b and the third is the exponent in a binomial expansion. Rules: The first two numbers are e...
stackexchange_codegolf
Given n, k, and p, find the probability that a weighted coin with probability p of heads will flip heads at least k times in a row in n flips, correct to 3 decimal digits after decimal point (changed from 8 because I don't know how to estimate the accuracy of double computation for this (was using arbitrary precision f...
stackexchange_codegolf
Write a program that prints "Hello, World!". But also, if you take only the first, third, fifth, etc. characters of your program, the resulting program should still print "Hello, World!". If your program is: abc def It should output "Hello, World!", but so should acdf No solutions with fewer than 2 characters.
stackexchange_codegolf
Discussion in courtrooms often occurs at a high speed and needs to be accurately transcribed in case the text of the decision is needed in future cases. For this purpose, the stenographers who transcribe court discussions use specially designed keyboards with a small set of buttons, which are pressed in groups to spell...
stackexchange_codegolf
The Challenge Given an integer n>0 output a n+1 X n+1 matrix containing all integers from 1 to 2n as shown in the test cases bellow Test Cases n=1 1 2 2 2 n=2 1 2 4 2 3 4 4 4 4 n=5 1 2 3 4 5 10 2 3 4 5 6 10 3 4 5 6 7 10 4 5 6 7 8 10 5 6 7...
stackexchange_codegolf
Simple challenge: The code must be both valid Lisp and valid Fortran, and must print out "hello world" in both. Note: I've sunk about 5 hours into this at this point, I'm not even sure it's possible at this point... Details: Must be in a single source file. Any version of Fortran and any Lisp are allowed (specify whic...
stackexchange_codegolf
It is Halloween and Jimmy (/o\) has gone into a mysterious neighborhood for trick-or-treating (ask himself why). Now some evil ghosts are chasing him. Can Jimmy escape the ghosts? Challenge: Input: A board showing position of Jimmy, ghosts, solid objects and empty spaces. An example 10x5 board, o is Jimmy (we needed a ...
stackexchange_codegolf
Given a non-empty list L of integers greater than 1, we define d(L) as the smallest positive integer such that n + d(L) is composite for each n in L. We define the sequence an as: a0 = 2 ai+1 is the smallest integer greater than ai such that d(a0, ..., ai, ai+1) > d(a0, ..., ai) Your task You may either: Take an in...
stackexchange_codegolf
The task is simple. You are given a string with alphabetical words (say "Hello world, this are tests"). You have to return the mode of the lengths of words in the string. In this case, output is 5, as it's the most often length of words in the string. Definition of an alphabetical word (for this challenge): a string th...
stackexchange_codegolf
Write a program or function that takes in a positive integer N, and outputs an N×N pixel image of Google's "G" logo according to this* construction: For example, if N is 400, a 400×400 pixel logo should be output, with correct dimensions and colors: It should look accurate regardless of how large or small N is. e.g...
stackexchange_codegolf
Output # # # # # ##### ## # ## #### ####### # # ## #### ## ## # ### ####### # # # # ##### ### # # # # ### ##### ##### # ...
stackexchange_codegolf
Inspired by this challenge Goal: The goal is to draw waves crashing onto a beach. Input: You will be given 3 integers (in whatever format you want) as input. The first integer will be the length of the drawing The second integer will be the index of the sandbar, where the waves start to crest (at least 3 spaces from ...
stackexchange_codegolf
Today's problem is easy. You're given two strings A and B of equal length consisting of only the characters ( and ). Check whether after any number of operations you can make both strings balanced or not. The only operation allowed is swapping A[i] and B[i], where i is an arbitrary index. Here is the definition of a ba...
stackexchange_codegolf
Minimum Scalar Product The inspiration for this code golf problem is from Google's code jam competition. The premise behind the problem is, given the input of two vectors of varying lengths, find the minimum possible scalar. A scalar can be found using the following formula: x1 * y1 + x2 * y2 + ... + xn * yn The probl...
stackexchange_codegolf
Powers We define an important power as a number that can be represented as \$ x^y \$ where \$ x ≥ 2 \$ and \$ y ≥ 2 \$. Palindrome We define an important palindrome as a number that is the same written forwards and backward, and is greater than 10. Thus, the last digit must not be 0. Palindromic Power We define a Palin...
stackexchange_codegolf
In as few bytes as possible, sort the input, a delimited string OR list/vector/array of words, words contain printable ASCII except space (ASCII values 33-126) into a numbered list, table, or something resembling a table, by length. Table rules are as follows: Order is mandatory, direction is optional, either labelled...
stackexchange_codegolf
In this challenge, you need to simulate a frog jumping back and forth on lily pads. The pond is infinitely big, has a line of an infinite number of lily pads, and the frog can jump across as many lily pads as he likes. This frog likes to jump back and forth: after jumping forward, he always jumps backwards, and vice ...
stackexchange_codegolf
I've been doing quite a few code golf recently and I realised that a lot of times, I have to do something involving list. Most of the times lists are space-separated or comma-separated values in the first argument (argv[2]), and the return value should also be a space/comma-separated string. Are there any tips for conv...
stackexchange_codegolf
Inspired by this Youtube Video from Tom Scott. Write a program or function that prints the current amount of views this question has. That's it. Your program may only access the stack exchange api, any other websites are disallowed. Output An integer with the exact amount of views this question has at the moment. Outpu...
stackexchange_codegolf
Introduction Jonny wants to play Frogger. However, he's not very good. In fact, he will only try to move forward, and only after the platforms have moved. Find out if Jonny's frog manages to reach the end of the path or if it dies on its way. Challenge The program will be receiving as input a Frogger grid composed by 0...
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
The Challenge Given a string, output the text in the shape of a square. You can assume that the text will always fit in a square, and that it will never be an empty string. You can also assume it will never have newlines. Example Input: Hi, world Output: Hi, wo rld Test Cases Input: Hi, world! Hello Output: Hi, wo...
stackexchange_codegolf
Background The traveling salesman problem (TSP) asks for the shortest circuit that visits a given collection of cities. For the purposes of this question, the cities will be points in the plane and the distances between them will be the usual Euclidean distances (rounded to the nearest integer). The circuit must be "...
stackexchange_codegolf
Imagine you have a grid where some squares are walls, some are empty, and some are lights that shine for arbitrary distances in the four cardinal directions until they meet walls: ####.#### ##..L.... ####.##.# ####.##L. ##......L In the above grid, the lights cover all the tiles. But in some cases, they may not be: ##...
stackexchange_codegolf
Background Inspired by a now deleted question by John Burger from which I quote: Now obviously no human made this mistake. It's a mis-decode of something - perhaps the ISBN? My question is: does anyone know of an existing algorithm that was so messed up it would invent an entirely new calendar? TFeld ingeniously com...
stackexchange_codegolf
Introduction Of course, we've got a lot of sequence challenges, so here is another one. The Kimberling sequence (A007063) goes as following: 1, 3, 5, 4, 10, 7, 15, 8, 20, 9, 18, 24, 31, 14, 28, 22, ... This is produced by shuffling the normal iteration: [1] 2 3 4 5 6 7 8 The first term of the sequence is 1. Aft...
stackexchange_codegolf
Giuga numbers (A007850) are composite numbers \$n\$ such that, for each prime factor \$p_i\$ of \$n\$, \$p_i \mid \left( \frac n {p_i} -1 \right)\$. That is, that for each prime factor \$p_i\$, you can divide \$n\$ by the factor, decrement it and the result is divisible by \$p_i\$ For example, \$n = 30\$ is a Giuga num...
stackexchange_codegolf
This challenge is based on this Stackoverflow question. With a positive number as input, output it as the sum of each digit multiplied by its power-of-10 representation. Input A number, as an integer, a string or a list of digits/characters. The number will be strictly positive. If you accept the number as a string or...
stackexchange_codegolf
Alternatively: Now you're checking with portals! Inspired this challenge I am somewhat of a self-declared Chess Anarchist. That means that when I play chess, en passant is forced (else the brick gets used), double check is mate (and pasta), and all sorts of new pieces and squares are added to the game. One such piece i...
stackexchange_codegolf
My homework is to write a Martian essay (see below) between 729 and 810 words, inclusive. Your task is to write a program that will generate the essay. History Around the turn of the 20th century, spiritualist Catherine-Elise Müller allegedly communicated with Martians. During somnambulatory trances, she would write ...
stackexchange_codegolf
Summer Klerance turned in her term assignment for this challenge. Her professor was miffed (but also amused) when he overheard a disgruntled classmate of Summer's saying she got her answers by simulation rather than by the probabilistic methods covered in the course. Summer received a note to see the prof during his ne...
stackexchange_codegolf
Introduction In the United States, national elections are normally held on the first Tuesday after the first Monday in November. Challenge Write a program that takes a Year as integer, and a pair of (day of week as character and ordinal as integer) and output the date as "yyyy-mm-dd" Remember, the second pair is after...
stackexchange_codegolf
Challenge I think everyone of us heard of URL encoding mechanism - it's basically everywhere. Given an URLEncoded string on stdin, decode it, and output the decoded form to stdout. The encoding is very simple, + or %20 is representing space. Every percent followed by two hex digits (uppercase or lowercase) has to be re...
stackexchange_codegolf
Introduction Given an undirected graph G, we can construct a graph L(G) (called the line graph or conjugate graph) that represents the connections between edges in G. This is done by creating a new vertex in L(G) for every edge in G and connecting these vertices if the edges they represent have a vertex in common. Here...
stackexchange_codegolf
"I want to go to the Araby bazaar to buy a present for the one I have fallen in love with. However, if I arrive too late all the stores will be closed and I won't be able to buy anything. Can you help me?" Goal: Get the boy to Araby from North Richmond Street before all the stores close. Actual Goal: Make sure the boy ...
stackexchange_codegolf
We will say a string \$x\$ is cyclic maximal if there is no way to cycle its elements to get a lexicographically larger string. In other words there is no \$a\$ and \$b\$ such that \$a \oplus b = x\$ and \$b \oplus a > x\$, where \$\oplus\$ is concatenation. For example [3,2,3,3] is not cyclic maximal because you can c...
stackexchange_codegolf
First, a mathematical interlude, short, and worth your while: If 0 < a < 4, the logistic function f(x) = ax(1-x) maps the interval [0,1] inside itself. This means that one can play the iteration game; for instance, if a=2, the initial value 0.3 becomes 0.42, then 0.4872, etc. As the parameter a increases, the quadratic...
stackexchange_codegolf
Most people are familiar with Pascal's triangle. 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 Pascal's triangle is an automaton where the value of a cell is the sum of the cells to the upper left and upper right. Now we are going to define a similar triangle. Instead of just taking the cells to the upper left and the upp...
stackexchange_codegolf
This question is written because "Thing Explainer" is fun to read, and gave me an idea. Write "stuff that makes computer do things" that reads/takes a set of letters, numbers and things like this "#%|? and returns True / 1 if all words are part of this set. If all words are not part of that set, return the words that w...
stackexchange_codegolf
Find the nearest Date to a TargetDate for a given Day of Week. For example, given a date of 20161219 and a day of week of Friday (6), the answer is 20161216. Another example, given a date of 20161219 and a day of week of Wednesday (4), the answer is 20161221. A final example, given a date of 20161219 and a day of week ...
stackexchange_codegolf
In a smallish class, some lectures are set aside for working in groups. The instructors don't want people to group themselves together with the same people every time; instead, they create the groups beforehand, trying to make sure that all students work with one another as equally as possible. Your job is to write a p...
stackexchange_codegolf
.Net Technology is an incredible framework with marvellous functionalities, and among all of them, the most important one obviously stands out: Yep, your simple task is create a program that when it takes at input: dotnet ef It prints the following ascii art by output: /\__ ---==/ \\ ___ ___ ...
stackexchange_codegolf
Inspired by this and the following chat: Your task is to output the following: _ _ _ /_/_/_/\ /_/_/_/\/\ /_/_/_/\/\/\ \_\_\_\/\/\/ \_\_\_\/\/ \_\_\_\/ Extra leading or trailing whitespace is allowed, as long as it does not change the appearance of the cube. As usual, returning the above or a list of strings ...
stackexchange_codegolf
This challenge is inspired by this app. The test cases are borrowed from that app. This is a fastest-code challenge, where the objective is to solve the largest test cases in the least amount of time. There are provided some smaller test cases, so that people might test their algorithms faster. You'll be given a squa...
stackexchange_codegolf
Consider the Tetris pieces, but made out of some number of (hyper)cubes instead of four squares, where two blocks are considered the same if one is a rotation, reflection, or translation of another. The goal of this challenge is to take two positive integer input values, n and k, and count the number of \$n\$-celled po...
stackexchange_codegolf
While the binomial coefficient are the coefficients of \$(1+x)^n\$, m-nomial coefficients are the coefficients of \$(1+x+x^2+...+x^{m-1})^n\$. For example, \$m(3,5,6)\$ is the coefficient of \$x^6\$ in the expansion of \$(1+x+x^2)^5\$. Write a program/function that takes 3 numbers as input and outputs the corresponding...
stackexchange_codegolf
Given a string s and an array/list l, determine whether or not s can be made with parts from l. For example, if the string is "Hello, world!" and the list is [' world!', 'Hello,'], then the program/function should return a truthy value, because you can arrange the list to form the string. The following list would also ...
stackexchange_codegolf
I use "suffix" loosely here to mean "any sub-string that follows the prefix". "Prefix" here means the START of a word, where a word's start is defined as either after a space or from the first character of the input text (for the first word). A "prefix" in the middle of a word is ignored. E.g. if your input prefix is "...
stackexchange_codegolf
Problem: In chess, there is a somewhat well known rule about draw by repetition. If the same position is repeated 3 times (or more) then the player intending to make the move which will cause the this repetition can claim a draw. Sometimes this is an easy task for an arbiter to spot, if the last few moves are just the ...
stackexchange_codegolf
You will be given a string s. It is guaranteed that the string has equal and at least one [s and ]s. It is also guaranteed that the brackets are balanced. The string can also have other characters. The objective is to output/return a list of tuples or a list of lists containing indices of each [ and ] pair. note: The s...
stackexchange_codegolf
In this challenge you will take two lists as input and you will zip them. The zip can be defined with this recursive expression: \$ \mathrm{zip}(a,b) = \begin{cases} \left[\,\,\right] & a = \left[\,\,\right] \\ [a_0]\mid\mid\mathrm{zip}(b, t) & a = [a_0] \mid\mid t \end{cases} \$ or this Haskell program if you would l...
stackexchange_codegolf
Here is Minkowski's question mark function: It is a strictly increasing and continuous function from the reals to themselves that, among other unusual properties, maps rational numbers to dyadic rationals (those with a power-of-two denominator). Specifically, suppose the continued fraction representation of a rational...
stackexchange_codegolf
Your goal is to write an obfuscated program that displays the current time. Guidelines: The program can print local or global time. You are allowed to draw ASCII numbers, display an analog clock, etc. No input should be needed. Whether you include 12 or 24 hour, including AM/PM, milliseconds and seconds or not, it all ...
stackexchange_codegolf
The coefficients of a perfect square polynomial can be calculated by the formula \$(ax)^2 + 2abx + b^2\$, where both a and b are integers. The objective of this challenge is to create a program that not only can find if an input trinomial is a perfect square, but also find its square root binomial. The input trinomial ...
stackexchange_codegolf