instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
This question is a part of the lean LotM. A ring is a type of structure that takes the rules of addition and multiplication we are familiar with and abstracts them, so we can reason about them. To do this we state a number of expected properties as axioms and see what we can say about systems that follow these axioms....
stackexchange_codegolf
I am trying to write a solution to the following problem using as few characters as possible (to meme my friend and introduce him to golfing). Can any improvements be done to my code? So the problem requires us to write a function called navigate in Python 3.6 (language of the judge, sorry, no walruses) that takes two ...
stackexchange_codegolf
Definition Two integers are coprime if they share no positive common divisors other than 1. a(1) = 1 a(2) = 2 a(n) is the smallest positive integer which is coprime to the a(n-1) and a(n-2) and has not yet appeared, for integer n >= 3. Task Given positive integer n, output/print a(n). Example a(11) = 6 because 6 i...
stackexchange_codegolf
In this challenge, you'll take an answer as input, and print the answer before it. If the answer passed as input is the first answer, print your own submission's source. You'll be passed any answer in the chain up to and including your own answer, but none after it in the chain. For example, if the first submission is ...
stackexchange_codegolf
Because ARM is the July 2021 LoTM, I figured I'd create the tips thread. ARM is probably the most successful architecture for the digital world. From mobile phones to supercomputers, ARM is everywhere! Consequently, let's have a thread where we can help each other shorten our ARM code. One tip per answer, and no stupid...
stackexchange_codegolf
The objective Given a Russian text, encrypt it with Caesar cipher with key 16. The basic Cyrillic alphabets The basic Cyrillic alphabets are: (U+0410 – U+042F) АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ By the Caesar cipher, they are mapped to: РСТУФХЦЧШЩЪЫЬЭЮЯАБВГДЕЖЗИЙКЛМНОП The small letters (U+0430 – U+044F) are also mappe...
stackexchange_codegolf
The edit distance between two strings is the minimum number of single character insertions, deletions and substitutions needed to transform one string into the other. This task is simply to write code that determines if two strings have edit distance exactly 2 from each other. The twist is that your code must run in l...
stackexchange_codegolf
Write a program or a function to print the following cube (if you allow me to call it so) in different sizes: ^L^L^L^L^L^L^L^L^L^L^L //^L^L^L^L^L^L^L^L^L^L^L ////^L^L^L^L^L^L^L^L^L^L^L //////^L^L^L^L^L^L^L^L^L^L^L ////////^L^L^L^L^L^L^L^L^L^L^L //////////^L^L^L^L^L^L^L^L^L^L...
stackexchange_codegolf
Introduction I have a lot of ASCII rocks. They are built with dashes, pipes, Vs, carets, angle brackets, slashes and spaces. Example: /--\ | | | | \--/ I want to erode them, like this: /\ / \ \ / \/ All of the corners have become rounder. A more complicated example: /----\ | \------\ | | | ...
stackexchange_codegolf
The Task Given a natural number as input, your task is to output a truthy or falsey value based on whether the input is a factorial of any natural number. You can assume that the input number will always be in the range of numbers supported by your language, but you must not abuse native number types to trivialize the ...
stackexchange_codegolf
You want to find the length shortest path between two points, on an 2d ASCII "map". The roads are made up of + characters, and the two endpoints are represented by #s (not counted in the length). This road can be arranged in any way, and any other characters can be ignored. You can assume the endpoints will always conn...
stackexchange_codegolf
Write a function to produce, for a non-negative integer, a string containing a sum of terms according to the following: 3 -> "3" 805 -> "800 + 5" 700390 -> "700000 + 300 + 90" 0 -> "0" 13 -> "10 + 3" 200 -> "200" Any input other than a non-negative integer can be ignored. Zero terms must be skipped unless the inp...
stackexchange_codegolf
Adapted from this StackOverflow question In this challenge you will take a list of lists of integers, e.g. A = [[1,2],[3,4],[5],[]] And an additional single integer (e.g. n = 7). If you were to add n to the front of one of the lists in A there would be as many ways to do that as there are lists in A. In this example ...
stackexchange_codegolf
Most Unicode characters have full names, for example ” is "RIGHT DOUBLE QUOTATION MARK". You can find a useful reference here, just type in the character you want to find the full name of and look in the DESCRIPTION column. Your challenge is to write a program or function that outputs itself as a string of these. You c...
stackexchange_codegolf
Surprised that we don't have a symmetric difference challenge yet. Given two lists only containing positive integers, return all items among these two lists that aren't contained in both of the lists. Rules From the set definition: A set is a collection of definite distinct items. So you can assume the items in the ...
stackexchange_codegolf
I was browsing Stackoverflow and saw this question about tiling an MxN rectangle, and I thought it would be great for golfing. Here is the task. Given the dimension M and N, write a program that outputs how many unique ways a MxN rectangle (N is the number of rows, not columns. Not that it really matters) can be tiled ...
stackexchange_codegolf
Challenge For any two non-empty strings A and B, we define the following sequence : F(0) = A F(1) = B F(n) = F(n-1) + F(n-2) Where + denotates the standard string concatenation. The sequence for strings "A" and "B" starts with the following terms: A, B, BA, BAB, BABBA, ... Create a function or program that, when given...
stackexchange_codegolf
Given two numbers, the first is greater than the second, check whether the first number is divisible by the second without a remainder. If divisible, answer "yes"(or any other string), otherwise "no"(or any other string you like). Conditions: You cannot use conditional operators, loops, arrays, bitwise operations, func...
stackexchange_codegolf
I am quite proficient in C++ and Java and want to learn competitive programming to participate in contests like Google codejam and other online contests held on sites like CodeChef and Codeforces. I would like to get information about any free resources including websites and courses to learn the "sport". Book suggesti...
stackexchange_codegolf
Introduction OEIS sequence A127421 is the sequence of numbers whose decimal expansion is a concatenation of 2 consecutive increasing non-negative numbers. Put simply, every number in the sequence is formed by putting together n with n+1 for some non-negative, integer value of n. The first several terms are: 1, 12, 23,...
stackexchange_codegolf
There is a 3x3 square block made of 1x1 square blocks, with coins in each 1x1 block, starting from top left block you want to collect all the coins and return to top left block again, if possible provide instructions to achieve this. Rules From block \$(x,y)\$ in one step you can move right(R) to \$(x,y+1)\$ ,left(L) ...
stackexchange_codegolf
In my time on PPCG, I've noticed that quine problems and polyglot problems are quite popular. Also, meta-solutions to problems, that is, scripts which generate a program which is the solution to a problem, tend to get a lot of positive feedback from the community. Therefore, I have created this challenge, which impleme...
stackexchange_codegolf
Inspired by this glove-themed 538 Riddler Express Puzzle. Task You are given a positive integer n, and a list A = [a_1, a_2, ..., a_k] of k distinct positive integers. Then a restricted composition is an ordered list P = [p_1, p_2, ..., p_m] where each p_i is a (not necessarily distinct) member of A, and p_1 + p_2 + .....
stackexchange_codegolf
Background (F#) Let there be trees: type Tree<'T> = Node of 'T * Tree<'T> list Now lets fold them nicely with a function called... foldTree f:('a -> 'b -> 'c) -> g:('c -> 'b -> 'b) -> a:'b -> t:Tree<'a> -> 'c ...taking two functions f and g, an initial state a and of course a tree structure t. Similar to the well kno...
stackexchange_codegolf
A superabundant number is an integer n that sets a new upper bound for its ratio with the divisor sum function σ. In other words, n is superabundant if and only if, for all positive integers x that are less than n: $$\frac{\sigma(n)}n>\frac{\sigma(x)}x$$ For a few of the values: n σ(n) σ(n)/n superabundant 1 1 ...
stackexchange_codegolf
For a 2 dimensional array we will call the elements in either the first row or the last column the "J-Bracket" of the array. For example in the following array elements in the J-bracket are highlighted: \$ \begin{bmatrix} \color{red}{\underline 1} & \color{red}{\underline 2} & \color{red}{\underline 4} & \color{red}{\...
stackexchange_codegolf
This is a cops-and-robbers challenge. The Cops' thread to this challenge is here An interesting question to think about is the following: If I have a sequence of numbers how many of them do I have to provide before it is clear what sequence I am talking about? For example if I want to talk about the positive integers...
stackexchange_codegolf
Introduction This is a web scraping Code Golf challenge that attempts to take stock Name and price columns from the 'Most Active' list on this New York Times URL. Why is this challenge interesting? Challenge: Scrape these figures from this NYT page and turn it into a data frame using the smallest number of bytes possib...
stackexchange_codegolf
Given a positive integer number \$n\$ output its perfect radical. Definition A perfect radical \$r\$ of a positive integer \$n\$ is the lowest integer root of \$n\$ of any index \$i\$: $$r = \sqrt[i]{n}$$ where \$r\$ is an integer. In other words \$i\$ is the maximum exponent such that \$r\$ raised to \$i\$ is \$n\$: $...
stackexchange_codegolf
The goal of this codegolf is evaluating the cumulative distribution function of the student-t probability distribution. This is not trivial since there is no closed form and the function is dependent of two variables v and x. The distribution function is For getting the CDF you could integrate this function from -inf...
stackexchange_codegolf
Randomly inspired by Numbers Increase While Letters Decrease Given a list of mixed letters and integers (e.g., ['a', 2, 3, 'b']) increase the letters by one position in the alphabet (wrapping at z to a) and decrease the numbers by 1. For the above example, the output should be ['b', 1, 2, 'c']. The input can be a mixe...
stackexchange_codegolf
Introduction For the ones who never heard of this game before. You are playing a ball which needs to survive as long as possible. This is done by moving to the left or right, going to the holes. Since the map moves upwards, you need to go downwards to survive longer. If you search for images, you probably know which ga...
stackexchange_codegolf
The Cabbage, Wolf, Goat riddle with a twist! Backstory: There’s an intergalactic river than needs to be crossed! Being a space-ferryman you’ve offered some aliens on your small space ferry that can only carry two entities: you and a passenger. However, you know that because politics, some of these aliens will instantly...
stackexchange_codegolf
We can write mathematical expressions using the standard math operators (,),+,*,/,- available pretty much universally. We allow the symbols a, b, c, d and integers (e.g. 1, 45, etc.) but will restrict to just these four symbols. (Bonus points if you can handle more.) The goal is to take an expression as input and outpu...
stackexchange_codegolf
Your task is to implement a program similar to the nl command-line tool from the GNU core utilities. Standard loopholes are banned. You may not use any built-in or external function, program or utility for numbering the lines of a file or string, such as nl itself or the = command in GNU sed. Specification Input The pr...
stackexchange_codegolf
Given two positive reals \$a\$ and \$b\$, output some positive reals \$r_i\$, such that \$\sum r_i=a\$ and \$\prod\left(r_i+1\right)=b\$. You can assume that it's possible. You can also assume that your float type have infinite precision. Test cases: 2,3 => 2 2,4 => 1,1 or 1/2,(sqrt(57)+9)/12,(9-sqrt(57))/12 or etc. 2,...
stackexchange_codegolf
RollerCoaster Tycoon 2's maze is the inspiration for this question. Credit to Marcel Vos for thoroughly breaking the classic RCT2 AI. The pathfinding AI in this question is the AI in the latest version of OpenRCT2 at the time of writing, which was updated in response to that video. Suppose a guest enters a \$w \times...
stackexchange_codegolf
The sequence discussed in this challenge is a variant of the Descending Dungeons sequence family. Specifically, the sequence generation rules: (A_b = A's base 10 representation read as a base b number, A = A_10) A(0) = 10 A(n) = 10_(11_(12_(...(n+9)_(n+10)))) Your goal is to make a program which accepts a nonnegative ...
stackexchange_codegolf
Write two programs, each taking a string s and a number n ≥ 0, such that: The first program prints s n times, separated by newlines. The second program prints each character of s n times, with repeated characters separated by newlines. Every character at column x, line y in one program equals the character at column y...
stackexchange_codegolf
Consider a n x n multiplication table and replace each item with its remainder of division by n. For example, here is a 6x6 table and its "modulo 6" structure: (The last column and row are ignored since both are null) 1 2 3 4 5 6 | 1 2 3 4 5 2 4 6 8 10 12 | 2 4 0 2 4 3 6 9 12 15 18 | 3 0 3 0 3...
stackexchange_codegolf
This task is about compressing and processing a sequence of conditionals. In the game Keep Talking and Nobody Explodes, a bomb defuser must disarm a bomb with the help of instructions relayed by experts consulting a convoluted Bomb Defusal Manual. This challenge deals with the module "On the Subject of Wires", explain...
stackexchange_codegolf
The goal of this challenge is to check and extend the OEIS sequence A334248: Number of distinct acyclic orientations of the edges of an n-dimensional cube. Take an n-dimensional cube (if n=1, this is a line; if n=2, a square; if n=3, a cube; if n=4, a hypercube/tesseract; etc), and give a direction to all of its edges ...
stackexchange_codegolf
There is a great story to tell about regular hexagons found for example in honeycombs. But this busy bee needs your help in telling him which point is inside or outside his honeypot. So, given a regular hexagon as pictured below, centered at the origin and with edge size l, determine if a set of coordinates (x,y) are i...
stackexchange_codegolf
Given a matrix like this: 1 1 3 -2 3 -4 1 -1 1 1 1 0 0 -1 0 0 By taking a 2×2 "sliding sum", where the sum of every 2×2 region of the matrix is one element of the resulting matrix, we get: 1 1 1 1 -1 1 1 1 1 We can do this for sliding windows of any size. For example, a 1×3 sliding sum of the same input ...
stackexchange_codegolf
Hex triplets such as #ffffff (white) or #3764ef (blueish) are often used to denote RGB colors. They consist of # followed by six hexadecimal digits (0-f), or sometimes three digits where the real color is obtained by doubling each digit. For example, #fff is #ffffff and #1a8 is #11aa88. Sadly, that three digit shorthan...
stackexchange_codegolf
Background An ex-increasing set sequence of order \$N\$ is defined as a sequence of integer sets \$S_1,S_2,\cdots,S_n\$ which satisfies the following: Each \$S_i\$ is a non-empty subset of \$\{1,2,\cdots,N\}\$. For \$1\le i<n\$, \$S_i \cap S_{i+1} = \varnothing\$, i.e. any two consecutive sets have no elements in comm...
stackexchange_codegolf
Task: Given an integer input, figure out whether or not it is a Cyclops Number. What is a Cyclops number, you may ask? Well, it's a number whose binary representation only has one 0 in the center! Test Cases: Input | Output | Binary | Explanation -------------------------------------- 0 | truthy | 0 | only ...
stackexchange_codegolf
Credits for the challenge idea go to @AndrewPiliser. His original proposal in the sandbox was abandoned and since he has not been active here for several months, I have taken over the challenge. Balanced ternary is a non-standard numeral system. It is like ternary in that the digits increase in value by a factor of 3 a...
stackexchange_codegolf
Due to technical limitations of Stack Exchange, the title is rendered incorrectly. The correct title for this challenge is Make a Word Icicle! Word Icicle Word cicle ord cicle ord icle ord i le or i le or i l or l or r Today's challenge is to make icicles out of t...
stackexchange_codegolf
A number is a Chen prime if it satisfies two conditions: It is prime itself Itself plus two is either a prime or a semi-prime. A prime is a number where it has exactly two divisors and those divisors consist of itself and one. A semi-prime is a number which is the product of two primes. (Note that 12 = 2*2*3 is not s...
stackexchange_codegolf
The largest forum on the web, called postcount++ decided to make a new forum game. In this game, the goal is to post the word, but the word has to have one letter added, removed, or changed. Your boss wanted you to write a program which gets the word, and the UNIX dictionary, as you work for company who has more intell...
stackexchange_codegolf
Carry sort is an \$O(n)\$ "sorting" algorithm. Here's how it works. The algorithm moves left to right along a list. As it traverses a list it "carries" a single item, the largest item it has encountered so far. Once it encounters a larger item it picks up that item and drops the item it is already carrying in place. W...
stackexchange_codegolf
Background You're an attractive code golfer and quite a few people are asking you out. You don't have time to think about which days exactly you're available, so you decide to create a function the accepts a date and returns the days of that week. You then take those days of the week, insert it into your calendar progr...
stackexchange_codegolf
You are fish in a pond that needs to survive by eating other fish. You can only eat fish that are the same size or smaller than yourself. You must create a program that takes a shoal of fish as sorted input. From this you must work out how many fish you can eat and ultimately the size you will grow to. Size chart +----...
stackexchange_codegolf
Introduction In the strange world of integer numbers, divisors are like assets and they use to call "rich" the numbers having more divisors than their reversal, while they call "poor" the ones having less divisors than their reversal. For example, the number \$2401\$ has five divisors : \$1,7,49,343,2401\$, while its r...
stackexchange_codegolf
This is the cops thread of this cops and robbers challenge. The robbers thread is here. Related, but hashes numbers instead of strings and uses a different scoring system. Definitions A hash collision is when two different strings produce the same hash. Summary In this challenge, the cops will make a hash function, wit...
stackexchange_codegolf
Below on the left is a picture of a sorting network that can sort 4 inputs. On the right you can see it sorting the input 3,2,4,1. A sorting network of size n consists of a set of n horizontal wires where two wires can be connected by a vertical wire. The inputs to a sorting network move from the left to the right on ...
stackexchange_codegolf
A loaded question is something like 'Have you stopped swearing?' in which both yes and no answers mean that I have swore, meaning it is impossible to answer the question if I haven't swore. However, the constructed language Lojban has a word na'i, which means there is something wrong with what you just said. Your input...
stackexchange_codegolf
This is the logo for LAPACK, a widely used software library for numerical linear algebra. Your task is to print the logo (color and matrix brackets not required) as this exact string. Trailing newline is allowed. L A P A C K L -A P -A C -K L A P A -C -K L -A P -A -C K L A -P -A C K L -A -P A C -K
stackexchange_codegolf
Inspired by this 3Blue1Brown video Given a square matrix \$ M \$, compute its matrix exponential \$ \exp(M) \$, which is defined, using an extension of the Maclaurin series for \$ e^x \$, as $$ \exp(M) = \sum_{r=0}^\infty \frac {M^r} {r!} = M^0 + M^1 + \frac 1 2 M^2 + \frac 1 6 M^3 + \cdots + \frac 1 {n!} M^n + \cdots ...
stackexchange_codegolf
Your friend has been caught sleeping in class again! As punishment, his computer science teacher has assigned him homework, knowing that he will not be able to solve it due to not having paid any attention. The assignment seems deceiving simple at first; all that is required is to output the string: John Doe Unfortunat...
stackexchange_codegolf
emanresu A posted a challenge to reconstruct an ordered list of integers from its unordered set of unordered prefixes. Many users (beginning with xnor's answer) noticed that summing each unordered prefix led to a very short solution. Well, let's cruelly take that possibility away by using data that isn't integers! A fe...
stackexchange_codegolf
Output a full formal poof of such statements such as 1+2=3, 2+2=2*(1+1) etc. Introuction If you know Peano Arithmetic you can probably skip this section. Here's how we define the Natural Numbers: (Axiom 1) 0 is a number (Axiom 2) If `x` is a number, the `S(x)`, the successor of `x`, is a number. Hence, for example S(S...
stackexchange_codegolf
There's a payment machine for laundry in my building which does a few frustrating things. The ones relevant to this challenge are: It doesn't make change. So if you pay over the amount then you are not getting that over-payment back. It doesn't accept coins smaller than 20c. Meaning the only coins it accepts are 20c...
stackexchange_codegolf
Wow, time really flies! It's already been one year since the debut of the Code Golf Stack Exchange site design. Let's celebrate this milestone with a code golf challenge... to imitate the site logo! Golf a program that outputs a graphic of a medal enclosed in curly braces {}, along with two lines of text containing COD...
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
In the game of chess, there is piece called the queen that may attack any other piece that is on the same row, column or diagonal. In chess there are typically two sides, black and white, with each piece belonging to one of the teams. Pieces may not attack pieces belong to the same team. Your goal is to find out the ...
stackexchange_codegolf
Challenge To quote Wikipedia: An octave-repeating scale can be represented as a circular arrangement of pitch classes, ordered by increasing (or decreasing) pitch class. For instance, the increasing C major scale is C–D–E–F–G–A–B–[C], with the bracket indicating that the last note is an octave higher than the first no...
stackexchange_codegolf
Given a PPCG user's user ID, calculate how much times is their Each SE site reputation is from average reputation in the Stack exchange sites they have made accounts. Let me explain, If someone's total network reputation (Total reputation in the stack exchange sites he has participated) is 10k, and if he has participat...
stackexchange_codegolf
This is a follow-up question to my Puzzling.SE question: I asked if there’s a function f mapping Boolean strings to Boolean strings, so that f(f(b)) = reverse(b) for all input strings b. (By reverse, I mean the function that reverses the order of bits.) The above link contains a positive answer, with proof, by the grea...
stackexchange_codegolf
Take an arbitrarily sized string as input. This string represents a baseball plate appearance, in which each character represents a pitch as follows: Strike: S Ball: B Foul ball: F Hit by pitch: H Ball in play: X (For those wondering, this is a very very simplified version of Retrosheet's notation) Your program must...
stackexchange_codegolf
Introduction So the Challenge is to give out all combinations with two Inputs. The length of the string is also optional and you should be able to edit this. I've selected this channel because I thought it would be very easy to do it "normally" but the challenge itself could be very interesting. I had to create that fo...
stackexchange_codegolf
Given a positive integer \$n\$, output \$n\$ 2D bool images with the same width and height such that: Each image should be 4-connected, i.e. for each two pixels that are true, you can start from one and go up, down, left and right for some times to the other pixel, only passing through true pixels. Each image should h...
stackexchange_codegolf
Imagine that there are \$n\$ different types of objects \$O_1,O_2,O_3,\ldots,O_n\$ and they each have a conversion factor \$k_1,k_2,k_3,\ldots,k_n\$. You can, for any \$1\le i\le n\$, convert \$k_i\$ amount of \$O_i\$ into \$1\$ of any other type of object. Task Your objective is to output all the possible ending confi...
stackexchange_codegolf
Background MQTT (Message Queuing Telemetry Transport) is an ISO standard publish-subscribe-based messaging protocol (Wikipedia). Each message has a topic, such as the following examples: myhome/groundfloor/livingroom/temperature USA/California/San Francisco/Silicon Valley 5ff4a2ce-e485-40f4-826c-b1a5d81be9b6/status Ge...
stackexchange_codegolf
Weather forecasting: Wrong too often to rely on, right too often to ignore. Given a high and low temperature and one of four weather conditions per day, output an ASCII-art graphical five day weather forecast. The structure of the four graphical indicators are shown below. \ / -O- Sunny / \ \ / -O(==) ...
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
Though challenges involving magic squares abound on this site, none I can find so far ask the golfer to print / output all normal magic squares of a certain size. To be clear, a normal magic square of order \$n\$ is: An \$n\times n\$ array of numbers. Each positive integer up to and including \$n^2\$ appears in exactl...
stackexchange_codegolf
Introduction Consider two strings A and B of the same length L, and an integer K ≥ 0. For the purposes of this challenge, we say that the strings are K-compatible, if there exists a string C of length K such that A is a contiguous substring of the concatenation BCB. Note that A is a substring of BAB, so A and B are alw...
stackexchange_codegolf
Your challenge is to write a program or function to output this sequence of numbers. Output requirements: Must contain numbers specified above Must be in order as specified Numbers must be delimited by whitespace Shortest code in bytes wins.
stackexchange_codegolf
This is the robbers' challenge. To post a cop, go here. In this challenge, cops will invent a (likely simple) programming language, and write an interpreter, transpiler, or compiler that allows you to run it. Robbers will write a program in this language that manages to inject arbitrary code into the interpreter, trans...
stackexchange_codegolf
Symbolic Differentiation 2: Back on the Chain Gang Task Write a program that takes in a certain sort of function from stdin and differentiates it with respect to x, using the chain rule.* The input function will be a string of the following form: "trig_1 trig_2 trig_3 ... x" where trig_n is a trigonometric function si...
stackexchange_codegolf
A Fermi-Dirac Prime is a prime power of the form \$p^{2^k}\$, where \$p\$ is prime and \$k \geq 0\$, or in other words, a prime to the power of an integer power of two. They are listed as integer sequence A050376. While a normal prime factorization generally does not contain a set of distinct primes (for example \$24=2...
stackexchange_codegolf
This task is about compressing and processing a sequence of conditionals. In the game Keep Talking and Nobody Explodes, a bomb defuser must disarm a bomb with the help of instructions relayed by experts consulting a convoluted Bomb Defusal Manual. This challenge deals with the module "On the Subject of Wires", explain...
stackexchange_codegolf
Consider: c=(a,b)=>(+a||0)+(+b||0) Yes, it is not good to solve it like that. But I want to shorten it even more. If a is a string and b is a string, then return 0. If one is a number, return it (floats and intergers). And if both inputs are numbers, then return the sum (if either string can be cast to a number, treat...
stackexchange_codegolf
Because it's Saturday (UTC) and I'm hungry, I would like a slice of pizza. I will give you an order and I would like a nice hot ascii-art pizza. Up to the challenge? The Drive-Thru I'll place my order wherever your drive-thru is, whether it is STDIN, a function parameter, a command-line argument, but I'm not going to p...
stackexchange_codegolf
From http://en.wikipedia.org/wiki/Triangle: Write a program that takes three 2d coordinate tuples (Cartesian), and classifies what shape these three points describe. In almost all cases these points will describe a triangle of varying types. In some degenerate cases, the points will either describe a singular point ...
stackexchange_codegolf
Challenge Make the shortest program to determine if the figures in the input will fit into the space in the input. Requirements The input will be in the format of this example: Input: +----+ -- +--+ | +----+ | | | | +--+ | | +---------+ Output: +----+ |+--++----+ || |-- | |+--+ | ...
stackexchange_codegolf
Introduction You're probably familiar with zip bombs, XML bombs, etc. Put simply, they are (relatively) small files which produce enormous output when interpreted by naïve software. The challenge here is to abuse a compiler in the same way. Challenge Write some source code which occupies 512 bytes or less and which com...
stackexchange_codegolf
Your program has to have an year like 1957 to be the input and then output the century of that year. For example: In: 1946 Out: 20 In: 1705 Out: 18 In: 1900 Out: 19 In: 100 Out: 1 In: 2001 Out 21 because 1946 is in the 20th century. Keep in mind that 2000 should be 20th century or 1900 should be in 19th century. There...
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
In crossword terminology, the grid is the region into which the crossword answers are inserted, consisting of white and black squares. The crossword answers, called entries, are inserted into contiguous sequences of white squares in a row or column, separated by black squares. For straight (American) crosswords, the g...
stackexchange_codegolf
While implementing polynomial multiplication in Itr I found the following interesting operation on strings To compute the convolution of two strings (for instance Hello and World) first combine all pairs of letters with indices that add up to the same number (ordered by the index of the first element) 0 -> "HW" 1 -> "...
stackexchange_codegolf
Background The number of values for a given type is called the cardinality of that type, and that of type T is written as |T|. Haskell and a few other languages have a certain set of enum types, each of which has a small finite number of values (the exact names vary, so this challenge uses some arbitrarily chosen names...
stackexchange_codegolf
I'm letting this one out of the sandbox. Hopefully it is well-written and make sense, feel free to improve. So in order to make 1+ more popular (and ease the creation of golfed 1+ text-printing programs) here comes the metagolf challenge: The 1+ Language 1+ is a fun deque-based esolang where 1 is the only literal, and ...
stackexchange_codegolf
Inspired by this challenge, and similar to this and this. After seeing these, I figured I would continue the trend as there was no inclusive/exclusive sum. The goal here is to sum an interval of integers, either inclusive and exclusive, and output the total to stdout. Input format: either a ( or [ followed by 2 comma s...
stackexchange_codegolf
I'm making a page selector for my super cool terminal-based blog program. In order for it to fit correctly into the design, it has to have some constraints. The page selector can only display a certain number of numbers at a time due to the constraints of the UI system. If there are more characters then can fit, they m...
stackexchange_codegolf
The On-Line Encyclopedia of Integer Sequences (OEIS) is an online database of integer sequences. It contains nearly 280000 sequences of mathematical interest. Examples of sequences: positive integers (A000027) prime numbers (A000040) Fibonacci numbers (A000045) Your task is to write a program or function that displ...
stackexchange_codegolf
Background A ray of light is fired from the top left vertex of an MxN Chamber, where M a denotes the width and N denotes the height of the chamber. The ray of light advances one grid space per second. Given that T is the number of seconds to be simulated, calculate the number of reflections in this time frame. For exam...
stackexchange_codegolf
Let's assume we've got an imaginary assembler. The assembler supports numerical labels. An infinite loop example: :1 jmp 1 Your task is, to write a preprocessor for this assembler supporting named labels (instead of numerical ones; with up to 8 characters in length), so the label name is replaced to it's numerical...
stackexchange_codegolf