instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
"Hey Bob, I need a new acronym. Something better than 'Automated Support System'. I need you to fabricate me an acronym!" "Sure thing Joe! I'd love to fabricate an elaborate way to renovate, and not replicate something that you can tolerate." "Alright Bob, make sure it can separate itself from the old acronym we need t...
stackexchange_codegolf
Fast and Golfiest Cops Thread Welcome to the first season of Fast and Golfiest, a cops-and-robbers challenge! I designed this challenge to encourage competitive coding for efficiency (fastest algorithm) to become more popular on the site. The rules are simple. The cops must choose a problem from LeetCode, the prestigio...
stackexchange_codegolf
What general tips do you have for golfing in LiveScript? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to LiveScript (e.g. "remove comments" is not an answer). Please post one tip per answer.
stackexchange_codegolf
Your task is to sort an array containing the strings "quarter", "dime", "nickel", and "penny" any number of times in no specific order and sort them so that they are in this order: quarter dime nickel penny (in other words, greatest to least monetary value). Rules Your program must take an array as input containing...
stackexchange_codegolf
Challenge: Create a program that takes input of a positive non-zero integer and outputs the 4 next numbers in the sequence described below. Note: Checking if the input is actually a positive non-zero integer is not necessary Sequence: Every number in this sequence (apart from the first, which is the input) shall be com...
stackexchange_codegolf
Task Your task is to generate a password that is both secure and short in the fewest bytes possible given an integer seed as input. Input No seed Or An integer seed Output A password Scoring Your score is how many seconds the password takes to crack on How secure is my password divided by (bytes * password length) Scor...
stackexchange_codegolf
I have a counter. It's a small device that looks like this: The display goes from 0000 to 9999. It has a little push-button at the top that increases the count by 1, and a little knob at the right whose purpose is to reset the counter back to 0. Now, the thing about the little knob is that if you turn it backwards, y...
stackexchange_codegolf
Rules: Your program must print "hello world" when executed Your program must be interpretable or compilable into 2 or more languages Your program must require no input or arguments Languages with identical syntax are too easy, and will be shunned. We all know you can write echo hello world in Bash and Batch, so let's ...
stackexchange_codegolf
Challenge: Your task is to write as many programs / functions / snippets as you can, where each one outputs / prints / returns an integer. The first program must output the integer 1, the second one 2 and so on. You can not reuse any characters between the programs. So, if the first program is: x==x, then you may not u...
stackexchange_codegolf
A room can be made up of connected rectangles, for instance an L-shaped room. Such a room can be described by a list of dimensions describing the size of each rectangle. Assume you have two input lists. The first contains the width of rectangles stacked vertically over each other. The second contains the height of the...
stackexchange_codegolf
Related puzzle: Pathfinder (available on Puzzle Picnic) Background A robot is standing on a cell of a rectangular grid, where each cell has one or more gems except for the one with the robot. The robot can move to a horizontally or vertically adjacent cell in one step, and it picks up one gem from the cell it steps on....
stackexchange_codegolf
Given an integer n > 9, for each possible insertion between digits in that integer, insert an addition + and evaluate. Then, take the original number modulo those results. Output the sum total of these operations. An example with n = 47852: 47852 % (4785+2) = 4769 47852 % (478+52) = 152 47852 % (47+852) = 205 47852 %...
stackexchange_codegolf
I have encountered this type of puzzle, that usually involves apples, several times. It goes as follows: There is a certain number of apples in a basket. Ava takes a third of the apples. Bob takes a quarter of the apples that are left. Finally, Dennis takes one-sixth of the apples left. In the end, there are 10 leftov...
stackexchange_codegolf
Introduction My car speedometer was hacked! Instead of showing me how fast i'm driving, it just shows: "Vroooom!" Please help me know how fast i'm going. Challenge Take a string as input, and check if it matches the regex /^[Vv]ro*m!$/m. In English that means any line of the string must start with a capital or lowercas...
stackexchange_codegolf
Part 1 of the challenge revolved around converting the letters into specific unicode characters. Lore In this part we receive the output from the function made in Part 1, which now has to be arranged in an artistic manner. Aim Take 1 word as input which has already undergone transformation in the function made in Part ...
stackexchange_codegolf
This time I will give you an easy challenge: Print the Om sign with \$\pi\$!(Sorry for many challenges with \$\pi\$) Here is the om sign drawn using pi numbers: 59 0 64 230781 3.14159 26 502884 535 83279 1971 89 433 6939 79 44 937 ...
stackexchange_codegolf
Golf Me a Text Editor (similar challenges: Create a simple line editor and Line editor (more text here)) I seem to have forgotten which program to use to open, read, and write text files. Something like Noteleaf or VSBro or ... You see my conundrum. But never fear! I know some people who can write one. But I'm a bit li...
stackexchange_codegolf
Yesterday, as part of a IQ-style test, I got this interesting question: The time on a 24-hour clock is 11:43. What is the least number of minutes I should wait before the same digits are on the screen again (in any valid 24-hour time order)? The answer's 91 minutes, if you were wondering! This stuck in my mind, and ...
stackexchange_codegolf
Leonardo of Pisa (ca. 1175 - ca. 1245) is better known as Fibonacci. But this is actually a short for the Latin "filius Bonacci" (the son of Bonacci) which was made up during the 18th century (according to Wikipedia). In this challenge, you'll be given an ordinal number (in the literal sense) between 1st and 20th and y...
stackexchange_codegolf
In this challenge we learned a way to encode every positive integer using factor trees. Here is how it works: The empty string has value of 1. (S) where S is any expression with a value of S evaluates to the Sth prime. AB where A and B are arbirary expressions with values of A and B respectively has value A*B. For ex...
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
Challenge You are given the following function:- which is the same as:- with the base cases q(r, b, L) = 1 whenever r ≤ L, q(r, 0, L) = 0, if r > L and q(r, 0, L) = 1, if r ≤ L. Your task is to code a program that takes r as input, and outputs the value of q(r, r - L, L) for all L taking integer values from 1 to (r-...
stackexchange_codegolf
The set of all polynomials with integer coefficients is countable. This means that there is a sequence that contains each polynomial with integer coefficients exactly once. Your goal is it to write a function or program that outputs such a sequence. Example (you may use another sequence): // list of integers [i -> Z(i)...
stackexchange_codegolf
You should code a piece of code that looks like it outputs the language name but actually outputs the name reversed. E.g. a Python program should look like it outputs Python but should actually output nohtyP. The winner is the answer with the most upvotes in a week!
stackexchange_codegolf
map is a very basic yet important function in functional programming. All FP programming languages have it built-in but it is always fun to see how shortly you can define it yourself. This will be scored in AST nodes, not bytes. A token is the second-smallest building block of a program, over characters. A token is: a...
stackexchange_codegolf
A magic word is a word whose Braille spelling contains precisely 26 dots (because the Morse code alphabet can be circularly encoded within). For example: ⠎ ⠝ ⠥ ⠛ ⠛ ⠇ ⠽ snuggly ⠏ ⠕ ⠇ ⠽ ⠛ ⠕ ⠝ polygon ⠝ ⠥ ⠛ ⠛ ⠑ ⠞ ⠽ nuggety ⠽ ⠕ ⠛ ⠓ ⠥ ⠗ ⠞ yoghurt are all magic words. Objective: Craft a program to identify 77 such mag...
stackexchange_codegolf
Let's say I have this string: s = "Code Golf! I love Code Golf. It is the best." I want to replace all the vowels with repeated "aeiou". Notes: Uppercase vowels should be replaced by an uppercase letter, and lowercase vowels should be replaced by a lowercase letter. Consonants (all alphabet characters except for "ae...
stackexchange_codegolf
Challenge Implement the 1-indexed sequence A054049, which starts like this: 1, 2, 3, 6, 13, 5, 9, 377, 21, 11, 89, 14, 8, 233, 16, 987, 18, 2584, 20, 6765, 55, 23, 28657, 25, 75025, 27, 196418, 29, 514229, 31, 1346269, 33, 3524578, ... This sequence is the lexicographically smallest sequence of positive integers, so t...
stackexchange_codegolf
The tetration operation consists of repeated exponentiation, and it is written ↑↑. For instance, 3↑↑3 =3 ^(3^3) = 3^27 = 7,625,597,484,987 A tetrate of two is an integer that is equal to 2↑↑n for some nonnegative integer n. As an edge case, we say that 2↑↑0=1. In this challenge, you will be given a positive integer as...
stackexchange_codegolf
Overview Given a 3 line string, figure out if the structure falls to the left, balances, or falls to the right. Input structure You can imagine the structure as metal rod with stuff on top, all being balanced on top of a vertical rod. 1 7 4 a =============== | The first line is the items. Each item's w...
stackexchange_codegolf
We've had lots of questions about quines, programs where the source code and output are identical. For compiled languages, there are other combinations: we've already had a question about writing a program where the executable and output are identical. But there's one combination left. The task Using a compiled languag...
stackexchange_codegolf
Inspired in part by this Mathologer video on gorgeous visual "shrink" proofs, and my general interest in the topic, this challenge will have you count regular polygons with integer coordinates in 3D. You'll be provided an input n, which is a non-negative integer. Your program should find the number of subsets of \$\{0,...
stackexchange_codegolf
Challenge : Given a word, check whether or not it is an isogram. What : An isogram is a word consisting only of letters with no duplicates (case insensitive). The empty string is an isogram. Examples : "Dermatoglyphics" ---> true "ab" ---> true "aba" ---> false "moOse" ...
stackexchange_codegolf
The Background Future In the year 2017, you and your opponent will face off in a futuristic gun battle where only one may survive. Are you experienced enough to defeat your opponent? Now is the time to polish your guns skills in your favorite programming language and fight against all odds! Tournament Results This tour...
stackexchange_codegolf
Background When I was younger, I was taught a method of drawing a weird "S" shape, that I (along with my classmates) found fascinating. Today, I rediscovered it, and due to its formulaic approach to drawing it, thought it could lead to an interesting challenge :P Drawing the "S" The S can be drawn by following these si...
stackexchange_codegolf
In the hovertext of this xkcd: There's an "encoding" based on replacing runs of roman numerals with their sums. To do this: Find all runs of at least 1 roman numeral (IVXLCDM) Replace them with their sums, as numbers The Roman Numerals are IVXLCDM, corresponding respectively to 1, 5, 10, 50, 100, 500, 1000. You shou...
stackexchange_codegolf
Inspired by this challenge and related to this one. Background Badugi [bæduːɡiː] is a low-ball draw-poker variant. The Pokerstars World Cup Of Online Poker $1K event starts within 3 hours and I'll need to know how good my hands are! The game uses a standard deck of 52 cards of four suits and thirteen ranks. The suits...
stackexchange_codegolf
I just discovered this site and this is my first question, I hope I'm doing it correctly. The challenge is the following, you must write a code that prints all the prime numbers of \$n\$ digits. Since this problem is computationally complicated, I think that one way to simplify it is to give a number \$m\$ that will be...
stackexchange_codegolf
Given an integer n, return the number of ways that n can be written as a list of prime numbers. For example, 2323 can be written as (2,3,23), (23,23) or (2,3,2,3) or (23,2,3), so you would output 4. If it can not be written in this way, you should output 0. A prime number such as 019 or 00000037 is a valid prime for th...
stackexchange_codegolf
Introduction This challenge appeared in the 2020 Estonian Open Informatics Olympiad and was created Sandra Schumann. I thought it was interesting because it involves symmetry and is quite hard even to brute force by hand. The problem author said that it's ok for me to post it here: Challenge You may use a modified vers...
stackexchange_codegolf
Background theme Introduction Obi-Wan Kenobi, Qui-Gon Jinn and Darth Maul are about to fight! However, they've all forgotten to bring their respective lightsabers. Write a program or function which, given the string Jedi as input, generates an image similar to this*: and given the string Sith, generates an image sim...
stackexchange_codegolf
Your task is to determine the palindromic degree of a given non-empty string. To do this, loop until one of the following conditions are met: The string is not a palindrome. You encounter a string that has already been encountered. And do the following: If it is a palindrome, add one to the degree. Depalindromize. ...
stackexchange_codegolf
Objective: Write one program that outputs sourcecode for another program that outputs words. General information: Any programming language. Rules: Your programs should not take any input. (from user, filename, network or anything). The generated program sourcecode must not be in the same programming language as th...
stackexchange_codegolf
Challenge The challenge is simple: print a snake. You will get the length of the snake as input. A snake of length 2 looks like this: ==(:)- A snake of length 7 looks like this: =======(:)- In other words, the length of a snake is how many equal signs are before the head. Usage Let's say I made a C++ implementation a...
stackexchange_codegolf
Given a string, like potatocarrot, break it into the smallest number of substrings possible. These substrings can consist either be a single character, or one of a list of words passed as input. For example, if [carrot, potato] was the input, the optimal way to break the string up would be [potato][carrot]. If the list...
stackexchange_codegolf
Your task is to modify the original Plan 9 cat tool for UNIX, in order to make it a fully turing complete language interpreter. You may make use of ANSI escape codes and the backspace character (\x08) to aid in this. You must submit: A modified version of the Plan 9 cat tool A hexdump of the turing machine that can be...
stackexchange_codegolf
The Myriad System is an alternative system for naming large numbers proposed by Donald Knuth in 1981. In this system, numbers up to 999 are named as they are normally, but 1000 is not given a special name and is instead named as "ten hundred"; the next benchmark number being 10000, or "one myriad" (which, of course, co...
stackexchange_codegolf
Given an integral polynomial \$p\$, determine if \$p\$ is a square of another integral polynomial. An integral polynomial is a polynomial with only integers as coefficients. For example, \$x^2+2x+1\$ should gives truthy, because \$x^2+2x+1 = (x+1)^2\$. On the other hand, \$2x^2+4x+2\$ should gives falsy: \$2x^2+4x+2 = ...
stackexchange_codegolf
Figuring out whether a given number is prime, while not very complicated, is kind of hard. But making a guess doesn't need to be. Seeing whether a number is a multiple of 2 or 5 is easy - you can just look at the last digit. Multiples of 3 isn't much harder, just add up the digits and see if you end up with a multiple ...
stackexchange_codegolf
Sometimes I feel like the conversation is going down the wrong path and take it upon myself to steer it in another direction. And this conversation is going wrong real fast, so I need to change the subject in as few characters as possible.1 Task Given a list of sentences, return the sentences ordered such that each sen...
stackexchange_codegolf
I wanted to ask this question: Convert to and from the factorial number system but I'm a couple of years too late! So, instead you must convert to and from the lairotcaf backwards-factorial number base! The way it works is that the first digit is always 0, the maximum value of the next digit is 1, then 2 and so on. If ...
stackexchange_codegolf
This should be easy: given an arbitrary string, your program will give it a name. Requirements Your program will accept an input of a UTF8 string, and output a string representing the input's "name", how you define this name is arbitrary, but it must comply with some conditions. I/O Ranges The input will at most be 382...
stackexchange_codegolf
A program is "conveniently palindromic" if it is equal to the string derived when its reverse has all its parentheses (()), brackets ([]), and braces ({}) flipped. No other characters are special and require flipping. (<> are sometimes paired but often not so they are left out.) copied from this challenge. Write a co...
stackexchange_codegolf
Much harder than Can this pattern be made with dominoes? Challenge A grid of width \$w\$ and height \$h\$ is given, filled with 1s and 0s. You can place a domino somewhere on the grid only if both cells are 1. You cannot overlap dominoes. What is the maximum number of dominoes you can fit in the given grid? The worst-c...
stackexchange_codegolf
Inspiration. Inverse. Evaluate a given omnifix expression. Omnifix is like normal mathematics' infix notation, but with additional copies of each symbol surrounding the arguments. The outer symbols take the place of parentheses, and there is therefore no need for additional parentheses. You must support addition, subtr...
stackexchange_codegolf
This sentence employs two a’s, two c’s, two d’s, twenty-eight e’s, five f’s, three g’s, eight h’s, eleven i’s, three l’s, two m’s, thirteen n’s, nine o’s, two p’s, five r’s, twenty-five s’s, twenty-three t’s, six v’s, ten w’s, two x’s, five y’s, and one z. Such sentences are called autograms. Your task is to write a p...
stackexchange_codegolf
Knight is the Language of the Month for August 2022, and I noticed that it didn't have a tips page, so here it is! I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Knight (e.g. "remove comments" is not an answer). Please post only one tip per answer.
stackexchange_codegolf
Dart is an object oriented programming language borrowing from both Java and Javascript. What general tips do you have for golfing in Dart? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Dart (e.g. "remove comments" is not an answer). Please post one ti...
stackexchange_codegolf
Given a string that represents a bunch of tables stacked on top of each other and/or arranged side-by-side, disassemble all the tables. Tables A table looks like this: ------- | | | | More formally, a table has a tabletop, composed of n dashes, and two visible legs. (Obviously, there are two hidden behind, but...
stackexchange_codegolf
Challenge Given a positive integer, determine whether it is a triangular number, and accordingly output one of any two constant, distinct values. Definition A triangular number is a number that can be expressed as the sum of consecutive positive integers, starting at 1. They can also be expressed with the formula \$\fr...
stackexchange_codegolf
This challenge, I hope, is simple to understand. Given a date-string (given in any format you prefer, so long as it has 4 digits of year and 2 digits of day and month), calculate the weekday for the particular date-string. You must output 7 different values, corresponding to the weekday you have calculated. It's okay i...
stackexchange_codegolf
A Bayer matrix is a threshold map used for ordered dithering that gives the illusion of having more shades of color than actually present by using a crosshatch-like pattern. Bayer matrices are square with a side length that is a power of 2. Here are some examples: \$ \displaystyle\frac{1}{4} \times \begin{bmatrix} 0 & ...
stackexchange_codegolf
Play the Fruit Box Game Intro Fruit Box is a game consisting of a 10x17 grid of numbers, each between 1 and 9, where the goal is to clear as many numbers as possible in a two-minute time window. In order to clear numbers, one selects a rectangle aligned with the grid, and if the numbers inside of it sum to 10, they are...
stackexchange_codegolf
Print the following text and nothing else: <html> <body> <p>HTML is kinda annoying</p> </body> </html> I'm happy I'm not a web developer. The catch? Your code must fit the template: print(<?>), where ? can be any group of characters. You can paste your completed code (with the print(<>) part) into this Scast...
stackexchange_codegolf
(Based on this closed challenge, related) Given an integer n > 1, draw a grid composed of the characters: "-" "+" and "|". However, since I want the grid to look nice, the horizontal component should be 2 wide. Trailing spaces for each line are not required. Examples: n = 2 | --+-- | n = 3 | | --+--+-- | ...
stackexchange_codegolf
The Challenge Write a complete program that writes twice as many bytes to standard output as the length of the program. Rules The program must write ASCII characters to the standard output. The contents of the output doesn't matter. The output, measured in bytes, must be exactly twice the length of the program, also ...
stackexchange_codegolf
Backstory I was fiddling around with the Evolution of Trust and thought of this.Warning: I recommend you go check it out first before attempting this challenge. Summary for people who haven’t played A quick summary of what it says on the site: there is a machine. If you put in one coin, your opponent gets three coins (...
stackexchange_codegolf
A while ago I purchased a new wallet which is able to hold 8 cards (4 on both side). However, I seem to have way more cards than that and I need to make choices on which ones I want to carry with me. Some cards I use more often than others, but the cards I prefer to carry with me are not necessarily the ones I use most...
stackexchange_codegolf
Many important topics in abstract algebra involve a binary function acting on a set. A number of properties of such functions have been defined in the investigation of such topics. Your challenge will be to determine whether a given binary function on a given domain possesses five of these properties. Properties Closur...
stackexchange_codegolf
Task description In number theory, the Carmichael function λ takes a positive integer n and returns the least positive integer k so that the k-th power of each integer coprime to n equals 1 modulo n. Given a positive integer n, your solution must compute λ(n). The shortest code in bytes wins. Your program should theore...
stackexchange_codegolf
In this challenge, you'll print out the SBCS of Jelly, a popular golfing language. Its code page looks like this: _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F 0_ ¡ ¢ £ ¤ ¥ ¦ © ¬ ® µ ½ ¿ € Æ Ç Ð 1_ Ñ × Ø Œ Þ ß æ ç ð ı ȷ ñ ÷ ø œ þ 2_   ! " # $ % & ' ( ) * + , - . / 3_ 0 1 2 3 4 5 6 7 8 9 : ; < = > ? 4...
stackexchange_codegolf
(Essentially the inverse of Find the needle in the haystack) Given two tuples, (w, h) and (x, y), generate a haystack composed of a single random printable ASCII character of w width and h height with a needle made of a different random printable ASCII character at (x, y) when measured from the upper-left. For example,...
stackexchange_codegolf
You are writing a screen scraper application monitoring a text-only chat window. Text is added at the bottom of the window. The application takes screenshot of the chat window. If a change has occurred since last screenshot (new_screenshot != old_screenshot), the screenshot is saved. After X time, all images are merg...
stackexchange_codegolf
Let's build an advent Calendar for this Christmas! Many Advent calendars for children take the form of a large rectangular card with numbered windows for each day of December starting from 1 ( although advent time begins on Advent Sunday, which is the fourth Sunday before Christmas day and often happens to be on Novemb...
stackexchange_codegolf
Generate the following list of lists consisting of the unique last digits of the powers from 1 to 9 for the numbers [0..9] [[0], [1], [2, 4, 8, 6], [3, 9, 7, 1], [4, 6], [5], [6], [7, 9, 3, 1], [8, 4, 2, 6], [9, 1]] e.g. For the number 2 we have: \$2^1,2^2,2^3,2^4,2^5,... \to 2,4,8,16,32,64,128,... \to 2,4,8,6,4,8,.....
stackexchange_codegolf
Input a list of strings a and a string s for search keyword. Find out all strings in a which contains s as subsequence. And sort them in the following order: Exactly equals to s Starts with s Contains s as substring (continuous subsequence) Contains s as subsequence Detail When two strings belongs to the same sortin...
stackexchange_codegolf
Based on a comment by Jo King on my previous question (called 'Inverse-quotes-quine'), I present this new question. The rules are similar, but just, the opposite: If your program is run normally, all of the code not in the speech marks (" - double quotes) should be printed. If your program is wrapped in double quotes ...
stackexchange_codegolf
Your input will consist of an 18×18 image in any reasonable format, containing a horizontally and vertically centered 14px Roboto Mono character. This can be any of 94 printable ASCII characters (not including the space). But: you only need to be able to recognize some 80 character subset of your choice. Output should ...
stackexchange_codegolf
Given integers k and n, generate a sequence of n unique k-tuples of pairwise coprime integers. Every such tuple must occur once eventually, that is, for any existing k-tuple of pairwise coprime integers, some n will eventually generate it. The output may be printed or evaluated in any list/tuple-like form. Definitions ...
stackexchange_codegolf
Imagine a simple SKI calculus expression - for example, (((S α) β) γ). As you can see, each node of the rooted tree has exactly two children. Sometimes though, the parentheses are omitted and the tree is unrooted (just to make the notation clear, I believe). The challenge is to put the parentheses back, so that the tre...
stackexchange_codegolf
Introduction Humans are a remarkable species, but we can be very awkward to understand sometimes—especially for computers. In particular, we seem to like writing polynomials in a very convoluted fashion with seemingly arbitrary rules. What is the shortest program you can write to format a polynomial correctly using t...
stackexchange_codegolf
Objective Write a full program that works exactly like the flow chart below. Each output, which is an integer, shall be through stdout, followed by a line feed. Each input shall be a line of string fed through stdin, and shall be judged to a predicate you choose for branching. The same predicate must be used for all br...
stackexchange_codegolf
The challenge How well can you gerrymander North Carolina into 13 voting districts? In this challenge, you use the following files to draw different maps for Republicans and Democrats. File 1: NC_2016_presidential_election.csv File 2: NC_county_adjacency.csv File 1 gives county-level voting data from the 2016 president...
stackexchange_codegolf
Challenge Given a positive integer N, output the sum of the first N reciprocals as an exact fraction, which is represented as a pair of integers in a consistent order representing numerator and denominator. Rules Output must be exact. Output should be as a pair of integers in a consistent order representing numerator ...
stackexchange_codegolf
What is a home prime? For an example, take HP(4). First, find the prime factors. The prime factors of 4 (in numerical order from least to greatest, always) are 2, 2. Take those factors as a literal number. 2, 2 becomes 22. This process of factoring continues until you reach a prime number. number prime factors 4 ...
stackexchange_codegolf
Write a program that outputs the exact string: jan ale o, toki! ("Hello, world" but in toki pona to prevent builtins.) with an optional trailing newline. Additionally when all copies of any one byte present in your program are removed the program must fail to produce a correct output no matter what byte is selected. T...
stackexchange_codegolf
Wikipedia: Zeno's Dichotomy Paradox An infinite number of mathematicians walk into a bar. The first one orders a beer. The second one orders half a beer. The third one orders a fourth of a beer. The bartender stops them, pours two beers and says, "You're all a bunch of idiots." Reddit Print the following series for a...
stackexchange_codegolf
Write the shortest program which, when run with no arguments, stdin, or user input, triggers a core dump. Your code must behave this way when run on some common out-of-the-box Linux distribution. Other than installing support for your target language, you may not reconfigure the system to make it more fragile than it i...
stackexchange_codegolf
Introduction Wardialing was a very interesting way to try to hack people back in the '80s and '90s. When everyone used dial-up, people would dial huge amounts of numbers to search for BBS's, computers, or fax machines. If it was answered by a human or answering machine, it hung up and forgot the number. If it was answe...
stackexchange_codegolf
An office (let's call it "The Office") is going to cut down on wasted time in 2019 by consolidating office birthday parties. Any two people with a birthday between Monday and Friday (inclusive) of the same week will be celebrated with a Shared Birthday Party some time that week. People whose birthdays fall on a Saturda...
stackexchange_codegolf
Task For a given base \$n \ge 3\$, find the smallest positive integer \$m\$, when written in base \$n\$ and rotated right once, equals \$2m\$. The base-\$n\$ representation of \$m\$ cannot have leading zeroes. The corresponding OEIS sequence is A087502, and its base-\$n\$ representation is A158877 (this one stops at \$...
stackexchange_codegolf
Given two strings \$A\$ and \$B\$ with edit (Levenshtein) distance \$x\$, find a third string with edit distance \$a\$ to \$A\$ and edit distance \$b\$ to \$B\$ so that \$a+b=x\$ and \$a=int(x/2)\$ (that is half of \$x\$ rounded down to the nearest integer). The input is the two strings \$A\$ and \$B\$ and their edit d...
stackexchange_codegolf
Your task is to write a program or function which, given two nonzero integers x and y, returns a truthy value if the image at coordinates x east and y north of xkcd's click and drag comic is mostly white and a falsey value otherwise. Specifications The image should be retrieved from imgs.xkcd.com/clickdrag/[y]n[x]e.pn...
stackexchange_codegolf
The Recursively Prime Primes is are sequence of primes such that p(1) = 2 p(n) = the p(n-1)th prime Here is an example of how one might calculate the 4th Recursively Prime Prime. p(4) = the p(3)th prime p(3) = the p(2)th prime p(2) = the p(1)th prime p(1) = 2 p(2) = the 2nd prime p(2) = 3 p(3) = the 3rd prime p(3) = 5...
stackexchange_codegolf
Suppose you have two six-sided dice. Roll the pair 100 times, calculating the sum of each pair. Print out the number of times each sum occurred. If a sum was never rolled, you must include a zero or some way to identify that that particular sum was never rolled. Example Output: [3, 3, 9, 11, 15, 15, 11, 15, 7, 8, 3] ...
stackexchange_codegolf
Input variables: (Names are just examples, they don't need to be named like this) GrandTotal - integer to divide SplitCount - number of output integers required UpperLimit - highest valid value for any one output integer LowerLimit - lowest valid value for any one output integer Valid Output: Outout must be a random ...
stackexchange_codegolf
This problem is about separating a string representing a product identifier into three components. The first part consists of upper and lower letters of arbitrary length which represents the warehouse. The second part is digits which represents the product number. This part is also of arbitrary length. The last par...
stackexchange_codegolf
Inspired by my geography class, Sandboxed Simulate weathering / erosion. Input Input will be given as a string of any 2 characters (or see below) you like in the shape of the rock (here i use spaces and hashes): ### #### ##### ####### ####### ######## Or if your language doesn't support strings, a square matrix ...
stackexchange_codegolf
In this challenge about prefix code, we learnt that prefix codes are uniquely concatenable. That means, they can be joined together without separator, and without ambiguity. For example, since [1,2,45] is a prefix code, I can join them together without separator as such: 1245245112145, and there will be no ambiguity. H...
stackexchange_codegolf
Is it possible to make this C code smaller? It prints out all primes from 0 to 1000. C, 89 chars int i,p,c;for(i=2;i<1e3;i++){c=0;for(p=2;p<i;p++)if(i%p==0)c++;if(c==0)printf("%u\n",i);}
stackexchange_codegolf