instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Write a function f(n,k) that displays the k-dimensional countdown from n. A 1-dimensional countdown from 5 looks like 54321 A 2-dimensional countdown from 5 looks like 54321 4321 321 21 1 Finally, a 3-dimensional countdown from 5 looks like 54321 4321 321 21 1 4321 321 21 1 321 21 1 21 1 1 Forma...
stackexchange_codegolf
Take a string as an input, and perform addition/subtraction of all the digits in the string and output the sum of those operations as the result. Rules The digits in the string are read from left to right If a digit (n) is odd, perform addition with the next digit (n + n1) If a digit (n) is even, perform subtraction ...
stackexchange_codegolf
You are given an array A of non-negative integers. You can pick any non-empty subset, S from the array A. The score of a subset S is the sum of the elements in S raised to the power of K, i.e. for a subset S={s1,s2,…,sm}, the score of S is (s1+s2+…,sm)K. Output the sum of scores over all possible non-empty subsets of A...
stackexchange_codegolf
Your task is when given a chemical formula as input, output the total number of atoms in the formula. Input A chemical formula in any reasonable format. Each chemical formula has the following: A leading coefficient, which is a number \$N > 1\$. At least 0 groupings of elements surrounded by parentheses. Groupings ca...
stackexchange_codegolf
A palindrome is a word which is spelled the same backwards and forwards. For example, "racecar" is a palindrome as is "redder". A double palindrome is a palindrome whose halves are also palindromes. For example, "abbabba" is a double palindrome, as the half "abba" is also a palindrome. Similarily, "abaababaaba" is a tr...
stackexchange_codegolf
Context After "Computing a specific coefficient in a product of polynomials", asking you to compute a specific coefficient of polynomial multiplication, I wish to create a "mirror" challenge, asking you to compute a specific coefficient from polynomial division. Polynomial division Let us establish an analogy with inte...
stackexchange_codegolf
A Euler Brick is a cuboid where the length of all the edges are integers and all of the diagonals of the faces are integers as well. All sides must also be different. Your program has to find as many different Euler Bricks where the sides are less than L within the time M (L and M will be defined later). All of your c...
stackexchange_codegolf
Input 4 integers w, x, y, z from the range -999 to 999 inclusive where none of the values is 0. Output 4 integers a, b, c, d so that aw + bx + cy + dz == 0 where none of the values is 0. Restrictions Your output should be the solution with the smallest sum of absolute values possible. That is the smallest value of \$|...
stackexchange_codegolf
Given a number as input, determine how many significant figures it has. This number will should be taken as a string because you have to do some special formatting. You'll see what I mean soon (I think). A digit is a sig-fig if at least one of the following apply: Non-zero digits are always significant. Any zeros bet...
stackexchange_codegolf
Challenge Write a program or function that takes a number \$n\$ and returns the smallest \$k\$ such that concatenation \$n'k\$ is a square. This sequence is described by A071176 on the OEIS. I/O Examples input --> output 1 --> 6 (4^2) 10 --> 0 (10^2) 35 --> 344 (188^2) 164 --> 836 (406^2) 284 --> 2596 (168...
stackexchange_codegolf
Every now and again, I'll encounter a large string of alphabetical text encoded as numbers from 1-26. Before I knew that I could just google a translator online, I had to personally, painstakingly copy and paste the entirety of the encoded text into a text document and translate it myself. Thankfully, I did know about ...
stackexchange_codegolf
Inspired by this post over on Puzzling. Spoilers for that puzzle are below. Given three positive integers as input, (x, y, z), construct the inclusive range [x, y], concatenate that range together, then remove z not-necessarily-consecutive digits to produce the largest and smallest positive integers possible. Leading z...
stackexchange_codegolf
In my previous bioinformatics challenge, I asked you to mutate a DNA sequence. This time, I'd like you to evaluate how likely a mutation, or a series of mutations, is. The two types of substitutions are transitions and transversions, and due to the chemical structure of DNA bases, transitions are more likely to occur t...
stackexchange_codegolf
Your task here is to take a LifeOnTheEdge pattern and convert it to LifeOnTheSlope. A LifeOnTheEdge pattern is composed of these four characters: |_L . A pattern corresponds to a certain arrangement of "on" edges in a square grid. The pattern is placed in the grid first with the characters in the cells, and each of the...
stackexchange_codegolf
(or: Output the plural demonym.) When in Rome, do as the Romans do. This is a well-known English phrase meaning that it’s best to follow what others are doing around you — to go with the flow. Today, you're going to rewrite the phrase to fit most (Western) place names. To get the name of a group that lives within a reg...
stackexchange_codegolf
The following data contains the (approximate) population of each UTC timezone in the world (source): UTC;Population (in thousands) -11;57 -10;1853 -9.5;8 -9;639 -8;66121 -7;41542 -6;272974 -5;332101 -4.5;31923 -4;77707 -3.5;499 -3;248013 -2;4855 -1;3285 0;285534 +1;857443 +2;609921 +3;496279 +3.5;81889 +4;129089 +4.5;3...
stackexchange_codegolf
Background Python 3 has many types of string literals. For example, the string this 'is' an exa\\m/ple can be represented as: 'this \'is\' an exa\\\\m/ple' "this 'is' an exa\\\\m/ple" r"this 'is' an exa\\m/ple" '''this 'is' an exa\\\\m/ple''' """this 'is' an exa\\\\m/ple""" r'''this 'is' an exa\\m/ple''' r"""this 'is' ...
stackexchange_codegolf
This is a challenge to write bots to play the 1st and 2nd players in the following simple poker game. Rules of the poker game There are two players, A and B. Each antes $10 into the pot, and is dealt a card, which is a real number in the range [0, 1). Player A goes first, and may pass or bet. If A passes, then there is...
stackexchange_codegolf
I posted this challenge a while ago, which concerns how many elves Santa needs to deliver presents. Due to population increase, Santa is a little more pressed for time this year. Although in the past we operated very asynchronously, we are beginning to experiment with being more and more synchronized. So, Santa needs t...
stackexchange_codegolf
Challenge: You are given a string containing only digits. Your task is to output the minimum number of primes which must be concatenated to form the string. If this is impossible, output 0. Test Cases: Input -> Output: 252 -> 3 235 -> 2 92 -> 0 31149 -> 2
stackexchange_codegolf
The game shapez.io has a lot of shapes. In my previous challenge, the object was to generate a random code for a shape. Now, your challenge is to render a shape. Specs Shapes Each shape has a unique shortcode, for example: is CrWgRuSp - clockwise from top right, red circle, green wedge, uncolored rectangle, purple sta...
stackexchange_codegolf
I recently ordered some new and colorful tiles to replace my boring old white tiling for my kitchen. However, when the tiles arrived, they were all in a weird shape! Therefore, I need a program to figure out how to arrange the tiles so that I need to use as few of my old boring white tiling as possible. Even though t...
stackexchange_codegolf
So, I wrote a simple Javascript game (as yet unnamed) and naturally I wanted to write an API so I could write a bot to play it for me, and naturally I wanted to let the PPCG community have a go for themselves. It's a 'snake' game with the simple goal of collecting as many blue squares as possible while avoiding red squ...
stackexchange_codegolf
Given an input array having minimum length 2 and maximum length 9 having any initial values output an array having length 2 consisting of the 1-based indexes of the array represented as either an integer or string in forward and reverse order. The values of the array or string do not matter and are ignored. For example...
stackexchange_codegolf
Introduction During work with BMP (bitmap) generator I face problem of converting number to little endian hex string. Here is function which I create in JavaScript - but wonder how small code can works similarly let liEnd= num => num.toString(16).padStart(8,'0').match(/../g).reverse().join``; console.log(liEnd(304767...
stackexchange_codegolf
Define the (unnormalised) Willmore energy of a surface as the integral of squared mean curvature over it: $$W=\int_SH^2\,dA$$ For surfaces topologically equivalent to a sphere \$W\ge4\pi\$, and \$W=4\pi\$ iff it is actually a sphere. Thus the energy quantifies how spherical a surface is. In September 2020 I asked on Ma...
stackexchange_codegolf
Background Though this is a bit late for Pi Day, I saw an article about Pilish and thought it would make a great challenge. Pilish is created by using a sequence of words where each word's length corresponds to a digit of pi. Example from Wikipedia: The following Pilish poem (written by Joseph Shipley) matches the fir...
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
It's a funny accident that this world happens to have just 1 time dimension, but it doesn't have to be like that. It's easy to imagine worlds with 2 or more time dimensions, and in those worlds you could build computers and run software on them, just like in this one. The System Here is a system for running Brainf*ck p...
stackexchange_codegolf
The reason for this question is because I made a deadlineless bounty and I need a tips question to link in the bounty Vyxal 3 is the third major version of the Vyxal golfing language. As it is significantly different to Vyxal 2, the tips there don't apply. Therefore, what tips and tricks do you have for golfing in Vyxa...
stackexchange_codegolf
You are given a nonary (base 9) non-negative integer consisting of the digits 0 through 8 as usual. However the number of digits in this number (with no leading zeros) is a prefect square. Because of this, the number can be arranged in a square grid (with the reading order still preserved). Example with 1480 (1125 base...
stackexchange_codegolf
Challenge Assume two vectors \$\mathbf{a} = (a_1,a_2,\cdots,a_n)\$ and \$\mathbf{b} = (b_1,b_2,\cdots,b_n)\$ are given in an \$n\$-dimensional space, where at least one of \$b_1,\cdots,b_n\$ is nonzero. Then \$\mathbf{a}\$ can be uniquely decomposed into two vectors, one being a scalar multiple of \$\mathbf{b}\$ and on...
stackexchange_codegolf
Strobogrammatic Numbers Definition A number which is rotationally symmetrical, i.e., it'll appear the same when rotated by 180 deg in the plane of your screen. The following figure illustrates it better, (source: w3resource.com) Task Given a number as the input, determine if it's strobogrammatic or not. Examples Tr...
stackexchange_codegolf
\$ 1089 \$ is a very special number. To prove why, select any 3-digit number whose first and last digits differ by at least 2. Then, reverse the digits, and take the difference of these two numbers. Reverse the digits once more, and add these two numbers together. You will get \$ 1089 \$. The magic is left as an exerci...
stackexchange_codegolf
Background Joe is working on his new Brainfuck answer on Codegolf. The algorithm he's using to solve the challenge is a bit complicated, so Joe came up with idea of simplifying his Brainfuck notation to make programming easier and faster. The challenge Let's look at snippet written by Joe a moment ago: 0+++++1+++++0[3+...
stackexchange_codegolf
Task: Given an array of numbers as input (you can choose what subset, such as integers or natural numbers), replace all items with the number of times they appear within the array. As an example, [1, 2, 2, 1, 4, 8, 1] would become [3, 2, 2, 3, 1, 1, 3]. You can take input/produce output as arrays, lists, tuples, or any...
stackexchange_codegolf
Challenge Given an image of the Moon as input, output the phase of the Moon. Phases of the Moon Your program will be supplied one of these images in png format and you must output the phase exactly as given: new moon hexdump waxing crescent hexdump first quarter hexdump waxing gibbous hexdump full moon hexdump...
stackexchange_codegolf
Your program must accept as input six numbers, which describe a triangle - for example, the inputs 80, 23, 45, 1, 76, -2 describe a triangle with vertices (80, 23), (45, 1), and (76, -2). The input must be given as six plain real numbers or as a list of six real numbers, in the order given in the example. Your task is ...
stackexchange_codegolf
Input: The input will be a string of any characters. Output: the output will be an emojified (discord emojis) version of the input string. The way it will work is as so: Letters: a-z (case insensitive) will become ':regional_indicator_lowercase letter here:' e.g 'A' will become ':regional_indicator_a:' Digits: any digi...
stackexchange_codegolf
Every so often I have a function of type a -> b and a function of type b -> b -> c and I would like a function of type a -> a -> c. For example if I wanted to check the second element of each two tuples were equal snd :: (a , b) -> b (==) :: Eq a => a -> a -> Bool And I want something of type Eq b => (a, b) -> (c, b)...
stackexchange_codegolf
A long period prime is a prime number \$p\$ such that decimal expansion of \$1/p\$ has period of length \$(p-1)\$. Your task is to output this number sequence. For purposes of this challenge we will consider only odd primes. Period of a decimal expansion of a rational number is the smallest period \$k\$ that makes the ...
stackexchange_codegolf
Given an integer n, your task is to determine whether it is a perfect square that when reversed, is still a perfect square. You may assume n is always positive. When numbers such as 100 (10x10) are reversed the result may have leading zeros (001) In this case, ignore the leading zeros and treat it as 1 (1x1). Test case...
stackexchange_codegolf
This is the cop's thread of a cops-and-robbers challenge. You can view the robber's thread here A pretty common beginner style question is to print some string, but there's a catch! You need to do it without using any of the characters in the string itself! For this challenge, we will find out who is the best at printi...
stackexchange_codegolf
Design a function or program that, when run normally, outputs the triangular numbers. However, when any single character is deleted, the program/function should not function in the original programming language, but instead produce the triangular numbers in one other programming language. Scoring Your score will be the...
stackexchange_codegolf
Background Skip to "Task" if you are familiar with Tic-Tac-Toe (I think most are!) Tic-Tac-Toe is a famous two-player game. It consists of a 3x3 board that is filled gradually by two players (clarifications below); The first player uses the character X and the other one uses O. The winner is the first to get 3 consecut...
stackexchange_codegolf
A sestina is a format of poem that follows an interesting pattern that we can generate. It has six stanzas of six lines each, where the last words of each line in the first stanza make up the line endings in each successive stanza, rotated in a set pattern. (There's also a three-line stanza at the end, but we won't wor...
stackexchange_codegolf
Task Given an input n, calculate the n-th decimal digit of pi Rules Answer can be a full program or a function. Input must be taken from stdin or from function arguments. Output must be either sent to stdout, the return value of a function, or written to a file. all n values between 0 and 20000 must be supported (can ...
stackexchange_codegolf
Sandbox What is Hexagonification™? Hexagonification™ is a transformation that creates a hexagon with 3 copies of a rectangle block, each skewed to the right by 30 degrees and then rotated by 0, 120 and 240 degrees respectively, as shown in the following image. A triangle hole may appear in the middle, but that isn't a ...
stackexchange_codegolf
Problem: Given a string representing a mathematical expression with constants (pi, e, psi, i), basic arithmetic operations (+, -, *, /), parentheses, fractions, and exponentiation, write a program or function to convert a string to its equivalent LaTeX code. The input string will only contain digits, arithmetic operato...
stackexchange_codegolf
Task Given \$n\$, output position of the last odd digit in the decimal representation of \$2^n\$ (counting from the end). Rules There are no odd digits for \$n=1,2,3,6,11\$ \$(2, 4, 8, 64, 2048)\$ - you may output anything that is not a positive integer for them (no need to be consistent). You choose whether to handle...
stackexchange_codegolf
Write a program that takes an undirected graph and finds the minimum cut, i.e., the set of edges that, if removed, would disconnect the graph into two or more connected components. The program should have a time complexity of \$O(n^2m)\$, where n is the number of vertices and m is the number of edges in the graph. One ...
stackexchange_codegolf
Spirals are cool , so are numbers, and number spirals are even cooler. But what if I want a specific number, in a specific place using xy coordinates... Challenge Using an infinite spiral moving down first, curling in a counterclockwise manner ex: 6 5 4 7 0 3 8 1 2 9 10 11 Take negative and positive inputs(...
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
Introduction Eisenstein integers are complex numbers of the form a+bω Where a,b are integers, and ω = e^(2πi/3) The Eisenstein integers form a triangular lattice in the complex plane: We say that an Eisenstein integer z=a+bω is prime if it cannot be written as the product of two non-unit (not 1,-1,ω,-ω,ω^2, or -ω^2) ...
stackexchange_codegolf
A prime gap is the difference between two consecutive primes. More specifically, if p and q are primes with p <q and p+1, p+2, ..., _q_−1 are not primes, the primes p and q define a gap of n = q_−_p. The gap is said to be started by p, and to have length n. It is known that arbitrarily large prime gaps exist. That is, ...
stackexchange_codegolf
For those of you who have seen the popular daytime TV show Countdown, you will know that the contestants are given 9 randomly selected letters and must then find the longest word they can in 30 seconds. Your challenge is, given a string of 9 letters, to find the longest word that is an anagram of the largest subset of ...
stackexchange_codegolf
The game shapez.io has a huge variety of shapes you can produce, such as: Each shape has a unique short code, for example the above is CrWbScRu. This means, going clockwise from top right, red circle (Cr), blue wedge (Wb), cyan star (Sc), uncolored rectangle (Ru). There are four different shapes: Rectangle - R Wedge ...
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
Given string S representing a dollar amount, make change for that amount of money use the least number of coins to make the change and record the amount of each coin in a list. Here are the coins available to use and their value. Coin : Value Dollar Coins : $1.00 Quarters: $0.25 Dimes: $0.10 Nickels: $0.05 Pennies: $0....
stackexchange_codegolf
Your task is, given a family tree, to calculate the Coefficient of Inbreeding for a given person in it. Definition The Coefficient of Inbreeding is equal to the Coefficient of Relationship of the parents. The Coefficient of Relationship between two people is defined as weighed sum over all common ancestry as follows: E...
stackexchange_codegolf
Poker has etiquette in how you arrange your chips, often enforced in tournaments - your chips may not be "hidden" from your opponents by being behind others, mostly to not hide some large denomination chip(s). The Challenge We are going to be playing poker in ASCII, so we need to write a function or program that will ...
stackexchange_codegolf
* and don't have a word processor with top-left align support :D Take several lines of input, with at least four unique characters of your choice including newline and space. The input can also be taken as a space-padded matrix of characters. Squash it upwards, then squash it left. Output this, with any amount of trail...
stackexchange_codegolf
Challenge Design a compression algorithm specialized for compressing ASCII mazes. You will need to create both a compression algorithm and a decompression algorithm. Your score will be based on the size of your compressed mazes. Mazes These mazes are made primarily of the characters (floors), +, -, |, and # (walls), a...
stackexchange_codegolf
Today, my girlfriend and I started with this year's Advent of Code to improve our Python. So far we only did Day 1 and the first part of Day 2. The latter, I found to be very fun, so, to spice it up a little, and with a tip o' the head to Eric Wastl, here's my attempt at turning it into a Code Golf challenge. Task Your...
stackexchange_codegolf
Github You have probably played, and may even have written a program to play, a simple number guessing game. If so, this probably looks familiar: Try to guess my number (1 to 100)! Please enter a guess: 50 Too small, guess again! Please enter a guess: 75 Too big, guess again! Please enter a guess: 63 Correct! (Obvious...
stackexchange_codegolf
Write a program that takes in two non-negative integers S and N in that order. S represents the side length of a square grid of . characters. N represents the number of those .'s that need to be changed to x's. You may assume N is no greater than S squared. Your program needs to output this S×S square of .'s and N x's ...
stackexchange_codegolf
Given a string, reverse it interleavingly. Here's how to do it for abcdefghi and abcdefghij, 0-indexed: Separate the chars at even indices from the chars at odd indices:a c e g i b d f h a c e g i b d f h j Reverse the chars at odd indices:a c e g i h f d b a c e g i j h f d b Interleave into one string again:ahcf...
stackexchange_codegolf
Related Goal: Given two creatures with optional combat abilities, return unique but consistent values that represent which creatures died, if any. Input: #Longest form: [[P,T, "<abilities>"], [P,T, "<abilities>"]] #Shortest form: [[P,T], [P,T]] Each creature will be given in the form of [P,T,"<abilities>"]. It will be...
stackexchange_codegolf
Several Mathematica functions have system-defined short forms, e.g., /@ for Map. Many of them are listed here: https://reference.wolfram.com/language/tutorial/OperatorInputForms.html However, there also exist some system-defined short forms for function-option combinations. E.g., Log2@ninstead of Log[2, n] and Log10@...
stackexchange_codegolf
Terminology An increasing number is one where each digit is greater than or equal to all the digits to the left of it (ex. 12239) A decreasing number is one where each digit is less than or equal to all the digits to the left of it (ex. 95531) A bouncy number is any number that is not increasing or decreasing. Since th...
stackexchange_codegolf
Given a matrix of size at least 3×3 formed by positive integers, determine if it contains at least one "U" pattern, defined as + + + - - - + + + + - N - N - + + + - N - N - + + + - N N N - + + + + - - - + + where N is the same number, repeated in those seven positions - (optional) represents any number different than...
stackexchange_codegolf
Background Boolean Algebra concerns representing values with letters and simplifying expressions. The following is a chart for the standard notation used: Above is what actual boolean algebra looks like. For the purposes of this code golf, this is not the syntax that will be used. Your Task Given a string with three c...
stackexchange_codegolf
...will you help me immortalize it? I've had this pillow a few years now, and apparently it's time to get rid of it. Can you please write a function or program, that I can bring with me and use to recreate this pillow whenever I want to reminisce a bit. It must work with no input arguments. The output should look exa...
stackexchange_codegolf
Task The task is to write a program that outputs a consistent but otherwise arbitrary positive integer \$x\$ (so strictly greater than 0). Here's the catch: when the source is repeated \$N\$ times (the code is appended/concatenated \$N-1\$ to itself), the program should have a \$\dfrac{1}{N}\$ probability of outputting...
stackexchange_codegolf
Given a string, shuffle it so that it becomes a palindrome. For example, adadbcc can be arranged into dacbcad, or dcabacd, acdbdca and more. Any of these (or all) is acceptable, and duplicates are allowed if outputting all. Something like abc cannot be shuffled into a palindrome, and you can assume it won't be inputted...
stackexchange_codegolf
User inputs an integer. Print out proper fractions using all positive integers up to the user's input, in ascending order. Rule 1: Eliminate equal fractions. Rule 2: Fractions should be in their simplest form. Rule 3: Use "/" as a fraction symbol and next line (\n or \r as convenient) as a separator between fractions. ...
stackexchange_codegolf
The difficulty with sharing pizza with friends is that it is hard to make sure that everyone gets the same amount of pepperoni on their slice. So, your task is to decide how to fairly slice a pizza so that everyone is happy. Directions Write a program that, given a list of the positions of pepperonis on a circular pizz...
stackexchange_codegolf
I noticed that in Microsoft Word, single quotations are either ‘ or ’, but not in Notepad. Your task today is: given a string q, convert all the ' characters (only) to ‘ or ’, according to these rules, and then output it: If the character before the quote is a space, and after it comes a character, it becomes ‘ If the...
stackexchange_codegolf
Introduction I don't particularly know where the fizz buzz trend came from. It might just be a meme or something, but it is somewhat popular. Challenge Your job today is to convert Fizz Buzz into binary (0, 1) respectively, and convert that binary to text. Pretty standard stuff. How does that work? FizzBuzzBuzzFizzBuzz...
stackexchange_codegolf
In information theory, a "prefix code" is a dictionary where none of the keys are a prefix of another. In other words, this means that none of the strings starts with any of the other. For example, {"9", "55"} is a prefix code, but {"5", "9", "55"} is not. The biggest advantage of this, is that the encoded text can be...
stackexchange_codegolf
Introduction Bob likes to have different passwords for each website he uses. He wants passwords in a special format so that he can remember. Help him by building a password generator which is as short as possible in code length, because he likes keeping stuff short just like his name. Challenge Build Bob a password gen...
stackexchange_codegolf
In this challenge, you are going to create a Fellowship with the goal of defeating all other fellowships in battle. A fellowship (team) consists of 3 characters. Each character moves independently of the rest of their team, but they will need to work together when fighting your enemy. Teams will face each other head t...
stackexchange_codegolf
Output one random character for each character of source code (as illustrated below). The probability of each character is its frequency in the original source code. Thus the output will be fake source code resembling a quine. Specification Restrictions Standard quine constrains apply. No empty programs or functions....
stackexchange_codegolf
In this challenge, you will play the noisy iterated prisoner's dilemma. The Prisoner's dilemma is a scenario in game theory where there are two players, each with two options: cooperate, or defect. Each player does better for themself if they defect than if they cooperate, but both players would prefer the outcome wher...
stackexchange_codegolf
April 5th is National Deep DIsh Pizza Day, the theme of this challenge. Given a positive integer n (n is greater than 0), create an ASCII deep dish pizza. Actual deep dish pizza shown: As you can see, there is a layer of crust on the bottom and surrounding the rest of the pizza. How to make the pizza The crust is mad...
stackexchange_codegolf
It's simple, simply output text to STDERR containing the string EOF. Input/Output Your input will be none; however, you should output the message to STDERR. Rules Since this is code-golf, the shortest answer wins. No standard loopholes please. Any method approved by Standard I/O is allowed. Your code may not contain t...
stackexchange_codegolf
Given string S representing a dollar amount, make change for that amount of money use the least number of coins to make the change and record the amount of each coin in a list. Here are the coins available to use and their value. Coin : Value Dollar Coins : $1.00 Quarters: $0.25 Dimes: $0.10 Nickels: $0.05 Pennies: $0....
stackexchange_codegolf
I came up with a series of numbers the other day and decided to check what the OEIS number for it was. Much to my surprise, the sequence did not appear to be in the OEIS database, so I decided to name the sequence after myself (note that someone else who's a lot smarter than me has probably already come up with this, ...
stackexchange_codegolf
Introduction Let's observe the following string: AABBCCDDEFFGG You can see that every letter has been duplicated, except for the letter E. That means that the letter E has been de-duplicated. So, the only thing we need to do here is to reverse that process, which gives us the following un-de-duplicated string: AABBCCD...
stackexchange_codegolf
Having a function f that takes arguments x1, x2, …, xn                                                – ie.  f : X1 × X2 × … × Xn → Y – currying redefines f as a function taking a single argument a1 which maps to yet another function. This technique is useful for partial application, for example with a curried pow func...
stackexchange_codegolf
Disclaimer: This is heavily inspired by "Polyglot the OEIS!" but fixes the problem that lead to closure (see the output section) and was re-posted as to not invalidate answers. Introduction We all know and love the on-line encyclopedia of integer sequences (OEIS). So what if we made an off-line version of the interesti...
stackexchange_codegolf
Yeah... it's confusing. Let me explain it a little better: With a string, get the unicode code points of each letter Let's use "Hello World!". The code points would be [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33] Of each digit of the code points, get their binary format Get the binary of 7, then 2, the...
stackexchange_codegolf
Suppose we have a matrix like this: 11111 12221 12321 12221 11111 This matrix represents a terrain, and each cell represents a portion of terrain. The number in each cell represents the time the portion of terrain needs to be completely burnt (in minutes, if a measurement unit is needed), according to its combustibili...
stackexchange_codegolf
I'm currently converting a Float32Array to an Int32Array for input to a real-time audio raw PCM to MP3 recording application. new Int32Array([...new Float32Array(b)].map(f=>f<0?f*32768:f*32767) The examples in the wild I've seen convert each float individually to avoid static, gaps, glitches when the audio recording i...
stackexchange_codegolf
Task Write a program/function that, given three integers n,a,b prints a regular expression which matches all of the base-n integers from a to b (and no integers outside of that range). Your algorithm should, in theory, work for arbitrarily large integers. In practice, you may assume that the input can be stored in your...
stackexchange_codegolf
A three-fruit pie is made of three different fruits. What is the most three-fruit pies you can make from the quantities of 5 fruits you have? For example, with 1 apple 1 banana 4 mangoes 2 nectarines 0 peaches you can make 2 pies: apple, mango, nectarine banana, mango, nectarine Input: Five non-negative integers, ...
stackexchange_codegolf
I've been working on this iOS app recently and I encountered a (rather easily solved) problem: How do I determine if my string is comprised only of emojis? Well, that's your job today! Input A string. If the presence of unicode characters is problematic for you then you may use a different reasonable format. Please st...
stackexchange_codegolf
The idea of this is mainly from BIO 2017 q1. I got the idea for posting this challenge from my Binary Sequences challenge, since lots of people seemed to like it. Also, this is the first challenge I've posted without posting on the sandbox. I'll delete it if no one likes it. Rules Take in a sequence of digits in ternar...
stackexchange_codegolf
As you may very well know python has lists. As you might not know these lists can contain themselves. a = [] a.append(a) Python 2 Python 3 These are cool and there are lots of interesting things you can do with them, however you cannot compare them. a = [] a.append(a) b = [] b.append(b) a == b Python 2 Python 3 Task...
stackexchange_codegolf
This small challenge derives from my annoyance at discovering that numpy doesn't have a built in function for it. Input An n by m matrix of integers. Output The maximum value in the matrix and the 2d coordinates of one of its occurrences. The coordinates should be in the order (row_idx, col_idx) if your code is no sho...
stackexchange_codegolf