instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Given an ASCII art hexagon as input, output one whose sides are all one unit longer. _____ ____ / \ / \ / \ / \ / \ \ \ => \ \ \ / \ / \____/ \ / \_____/ ...
stackexchange_codegolf
tl;dr: Output the values where the reduced prime factorization leader changes. Every positive integer has a unique prime factorization. Let's call the reduced prime factorization just the list of multiplicity of the prime factors, ordered by the size of the factors. For instance, the reduced prime factorization of 1980...
stackexchange_codegolf
Challenge Create 2 programs A and B The output of program A is exactly program B The output of program B is exactly program A Neither program should depend on inputs to yield the correct output A and B are not identical programs A and B are of different programming languages Neither program may be equivalent to i...
stackexchange_codegolf
Given the battery level L in the range 0-5, your code should draw the following ASCII art. When L=0: ############ # ### # ### # ### ############ When L=1: ############ ### ### ### ### ### ### ############ When L=2: ############ ##### ### ##### ### ##### #...
stackexchange_codegolf
The McGill Billboard Project annotates various audio features of songs from a random sample of the Billboard charts. I scraped this data to produce the following file of chord progressions: chords.txt Write the shortest code that outputs the above file (or its contents). Edit: Here's a quick description of the notation...
stackexchange_codegolf
This contest is over. There are no remaining crackable answer in the cops challenge. Companion thread of Cryptographic hash golf As a reminder, here are the rules for robbers from the main challenge: Task Crack any of the cops' submissions by posting the following in the robbers' thread: two messages M and N in I ...
stackexchange_codegolf
Your challenge is simple: write as long of a pristine program as possible in the language of your choice using only unique bytes. (The full definition of a pristine program, copied from that link, is at the bottom of this question.) That's right, no strings attached. Your code doesn't have to do anything at all, just r...
stackexchange_codegolf
Inspired by Braille graphics and Build an analog clock. The goal there is to create a tool that use terminal console to draw and animate a clock by using UTF-8 fonts \U2800: ⠀ to \U28FF: ⣿. 00:[⠀] 01:[⠁] 02:[⠂] 03:[⠃] 04:[⠄] 05:[⠅] 06:[⠆] 07:[⠇] 08:[⠈] 09:[⠉] 0A:[⠊] 0B:[⠋] 0C:[⠌] 0D:[⠍] 0E:[⠎] 0F:[⠏] 10:[⠐] 11:[⠑] 12:...
stackexchange_codegolf
Given \$ i = \sqrt{-1} \$, a base-\$ (i - 1) \$ binary number \$ N \$ with \$ n \$ binary digits from \$ d_{0} \$ to \$ d_{n - 1} \$ satisfies the following equation. $$ N = d_{n - 1} (i - 1) ^ {n - 1} + d_{n - 2} (i - 1) ^ {n - 2} + \cdots + d_{1} (i - 1) + d_{0} $$ For example, a decimal number \$ 15 \$ is \$ 1000111...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. While other Elves are busy carrying air blowers, Fen comes and shouts, "I've got a spell for this job!" To recap, a chimney is modeled as a rectangular grid. The number in each cell represents the amount of smoke in the region. The lef...
stackexchange_codegolf
My robot has short circuited somehow and randomly run off somewhere from my lab! Luckily, whenever he does this, his shut-down sequence initiates, giving him enough time to randomly turn and run in the direction its facing for five rounds before he switches off. His gyro and accelerometer functions are still relaying t...
stackexchange_codegolf
From the wikipedia: Net neutrality is the principle that Internet service providers and governments regulating the Internet should treat all data on the Internet the same, not discriminating or charging differentially by user, content, website, platform, application, type of attached equipment, or mode of communicatio...
stackexchange_codegolf
Your task is to display the letter "A" alone, without anything else, except any form of trailing newlines if you cannot avoid them, doing so in a program and/or snippet. Code that returns (instead of printing) is allowed. Both the lowercase and uppercase versions of the letter "A" are acceptable (that is, unicode U+006...
stackexchange_codegolf
Left and right Riemann sums are approximations to definite integrals. Of course, in mathematics we need to be very accurate, so we aim to calculate them with a number of subdivisions that approaches infinity, but that's not needed for the purposes of this challenge. You should instead try to write the shortest program,...
stackexchange_codegolf
Goal: This goal to take a string and output how many contributions should be made on which days in order to display a message. Specification Input Support letters plus space (i.e. [A-Za-z ] ) Space is a blank 3X7 The letters are defined in this 5x7 DOT Matrix font provided below The size of each letter is the minim...
stackexchange_codegolf
Write an algorithm to interpret a sequence of letters as a Roman numeral. (see roman numeral rules below) Each distinct letter has a matching Arabic decimal value, no maximum. But you don't have the key beforehand, so {A=10, I=1, X=5, ... Z=1000000} is decided by your interpretation. Challenge Read input via STDI...
stackexchange_codegolf
Rules Given an ISO3166-1-Alpha-2 country code your task is to decide on the traffic direction for that country: Input will be a valid country code (valid as in it's an element of the two lists provided) Input may be a list of two characters instead of a string if it helps You may choose to take input in lowercase You ...
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
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
Find a bijective function which maps integers to arbitrarily large tuples of integers. Given the input \$n\$, output the tuple it matches to. Edit: The empty tuple is included in the mapping.
stackexchange_codegolf
This is the follow up question to standard Sudoku solver. You are given a Sudoku grid where . represents an empty cell and the other cells are filled with numbers 0-8 (inclusive). Rules: All the numbers in Sudoku must appear exactly once in all left-top to right-bottom diagonals. All the numbers in Sudoku must appear ...
stackexchange_codegolf
Challenge Your challenge is simple, calculate the depth of each matching brackets in the given input e.g. (()()(()))->[[1,1,[1]]], and output it in the form of a list/array/string representation Explanation: For every bracket in the input, you have to count how many nested brackets there are for that part of the input ...
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
Background The language BrainF*** (or simply BF), is an extremely minimal programming language. We're going to strip it back even further by eliminating IO operations; only the sub-langage defined by the operations +-<>[], henceforth referred to as BF-subset, shall be used. The BF variant considered has a tape extendin...
stackexchange_codegolf
Background There's a terrible problem in my console - the quotes never get included inside the arguments! So, when given this argument: ["abc","def","ghi","jkl"] it says that the argument is like this: [abc,def,ghi,jkl] It would be very nice if you can fix this problem! Challenge Add double-quotes (") in order to sur...
stackexchange_codegolf
The Challenge You are the owner of an amazing service called Coyote Beta, which magically answers math questions its users send to it over the internet. But it turns out, bandwidth is expensive. You have two choices, either create a "Coyote Beta Pro" or find some way to solve this. Just recently, someone queried (x +...
stackexchange_codegolf
I'm trying to solve a CSS challenge. It contains a rotated leaf shape (looks like an eye). Score for the challenge depends on amount of characters of the code. Here's my way to make a leaf shape: div { width: 200px; height: 200px; border-radius: 99% 0; rotate: 45deg; background: #d9d9d9; } <div></div> He...
stackexchange_codegolf
Computers like binary. Humans like base 10. Assuming users are humans, why not find the best of both worlds? Your task is to find the first n terms in the sequence A008559 where each term is the binary representation of the previous number interpreted as a base 10 number. Input An integer greater than 0. Note that the ...
stackexchange_codegolf
Given an input, output that input followed by a newline endlessly. Input will be a string consisting only of printable ASCII characters (0x20-0x7E) and newlines (0x0A). If input is length 0, endlessly output newlines. This is code-golf so fewest bytes in each language wins!
stackexchange_codegolf
Your task is to calculate the amount you have to pay for prescribed medication at a pharmacy in Germany. The amount is simply based on the full price of the item, which will be your input. It is a decimal number with exactly two fractional digits (ex. 5.43). You can assume it's strictly positive. Your task is to calcul...
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
Your pyramid The pyramid I want you to build is made entirely of cubes. It has 24 layers, and the Nth layer from the top contains N2 cubes arranged in an N by N square. The pyramid looks like this: To build the pyramid, you will need a supply of cubes. You are given 4900 cubes arranged in a 70 by 70 square that looks ...
stackexchange_codegolf
Yesterday I asked this question about riffle shuffles. It seems that yesterdays question was a bit too hard so this question is a related but much easier task. Today you are asked to determine if a permutation is in fact a riffle shuffle. Our definition of riffle shuffle is adapted from our last question: The first ...
stackexchange_codegolf
The challenge Find the smallest feedforward neural network such that, given any 3-dimensional input vector \$(a,b,c)\$ with integer entries in \$[-10,10]\$, the network outputs the largest (i.e., "most positive") root of the polynomial \$x^3+ax^2+bx+c\$ with error strictly smaller than \$0.1\$. Admissibility The notion...
stackexchange_codegolf
I am trying to find the shortest code in python 3, to solve this problem: You are driving a little too fast, and a police officer stops you. Write code to take two integer inputs, first one corresponds to speed, seconds one is either 1 or 0, corresponding to True and False respectively to indicate whether it is birthd...
stackexchange_codegolf
Task: Return an array with all possible pairs between the elements of an array. Example From a=["a", "b", "c", "d"]; return b=[["a","b"],["a","c"],["a","d"],["b","c"],["b","d"],["c","d"]]. Pairs can be in any order as long as all possible combinations are included and obviously ["b","d"] is the same to ["d","b"]. Inpu...
stackexchange_codegolf
Generate the following soccer team ASCII art with the least number of bytes possible. |.| |.| |.| |.| |.| |.| |.| |.| ]^[ ]^[ ]^[ ]^[ ]^[ ]^[ ]^[ ]^[ /~`-'~\ /~`-'~\ /~`-'~\ /~`-'~\ /~`-'~\ /~`-'~\ /~`-'~\ /~`-'~\ {<| 8 |>}{<| 6...
stackexchange_codegolf
Background Roman numeral is a simple number system with the following properties: Each symbol in the system maps to a specific value. (e.g. I = 1, V = 5, X = 10, C = 100) The value of a Roman numeral can be evaluated as follows: First, find all occurrences of adjacent pairs of symbols where a strictly smaller-valued ...
stackexchange_codegolf
The new xkcd feed bot room gave me an idea for a simple challenge. Your code will have to monitor the xkcd website and output all the new comics to the user. Specs When first run it should just sit around waiting. Then, when randall posts a new comic, within a minute, it should display the new comic in any of our usua...
stackexchange_codegolf
The Library of Babel is defined as a universe in the form of a vast library containing all possible 410-page books of a certain format and character set. For the purposes of this question, each page of the book contains 40 lines of 40 characters each. The formatting rules are as follows: Legal characters are the...
stackexchange_codegolf
Create your smallest web server in your preferred language! Requirements Must respond to atleast 1 type of request (get,post,patch,delete), with a specified string. Smallest implementation wins! *String can be empty You may use any library you want My personal record for this was 56B in node require('express')().use((r...
stackexchange_codegolf
A fairly simple challenge: You will receive two inputs, a string and a number (the number may be taken as a string, ie "123" instead of 123) If the string does not end in a number (ie, it does not match the regex \d$), just append the number to the end of the string. If the string does end in a number (ie, it matches t...
stackexchange_codegolf
Note: this is my first post here. The Challenge The challenge is to count the number of chocolate chips in a cookie. A cookie in this case is a circle with dots (the chips) in it. Given any square cartoon image of this cookie, you are to write a bot that counts and outputs the number of chocolate chips. Rules Has to t...
stackexchange_codegolf
The Utah teapot, originally created by Martin Newell, is a convenient object for testing 3D graphics programs. The task is to create a wireframe image of the teapot in perspective projection. To encourage the idea of a source-code application, the viewing and camera control may be isolated and excluded from the count. ...
stackexchange_codegolf
Assume the result of an exam has been published. After 5 minutes, First person knows the result. In next 5 minutes, new 8 persons know the result, and in total 9 know it. Again after 5 minutes, new 27 people know, and total 36 know. In similar fashion, total 100, 225..... people keep knowing it on 5 minute interval. Ch...
stackexchange_codegolf
Your challenge is to read a "password" from the keyboard / standard input. Challenge: Read a string s invisibly. For each of the characters in s, print a character c. In realtime. Rules: You must print c in realtime. As soon as the user enters a character you must display c. c must be constant, i.e. it must be the s...
stackexchange_codegolf
Input The code should take an integer \$n\$ between 1 and 1000. Output The code should output positive integers with \$n\$ bits. Accompanying each integer should be its full factorization. Each integer should be a uniformly random \$n\$ bit number. Score The score for your code will be the number of integers it outputs...
stackexchange_codegolf
A huge storm is ravaging the world and as you and your family run away from it, you come across a gigantic shelter run by a girl. She tells you that "she sells sanctuary" and that different types of rooms are offered at different prices. A room may only house one person. The challenge Write a program which takes in two...
stackexchange_codegolf
Definition \$a(1) = 1\$ \$a(2) = 2\$ \$a(n)\$ is smallest number \$k>a(n-1)\$ which avoids any 3-term arithmetic progression in \$a(1), a(2), ..., a(n-1), k\$. In other words, \$a(n)\$ is the smallest number \$k>a(n-1)\$ such that there does not exist \$x, y\$ where \$0<x<y<n\$ and \$a(y)-a(x) = k-a(y)\$. Worked out ...
stackexchange_codegolf
I'm currently working with a branchless language which does not have native Less-Than, Greater-Than or Equal-To functions. I do however have min, max and abs functions and standard arithmetic (+, -, / and *) available to me. I'd like to create these three functions (as L(a, b), G(a, b) and E(a, b) respectively, which w...
stackexchange_codegolf
We all know that the Euler's number, denoted by \$e\$, to the power of some variable \$x\$, can be approximated by using the Maclaurin Series expansion: $$e^x=\sum_{k=0}^{\infty}{\frac{x^k}{k!}}=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\frac{x^4}{4!}+\dots$$ By letting \$x\$ equal \$1\$, we obtain $$\sum_{k=0}^{\infty}{\frac{...
stackexchange_codegolf
A cyclic number is a number of "n" digits that when multiplied by 1, 2, 3,...n, results in the same digits but in a different order. For example, the number 142,857 is a cyclic number since 142,857 x 2 = 285,714, 142,857 x 3 = 428,571, 142,857 x 4 = 571,428, and so on. Given an integer input, determine if it is a cycli...
stackexchange_codegolf
Make a program that simulates the basic logic gates. Input: An all-caps word followed by 2 1 digit binary numbers, separated by spaces, such as OR 1 0. The gates OR, AND, NOR, NAND, XOR, and XNOR are needed. Output: What the output of the entered logic gate would be given the two numbers: either 1 or 0. Examples: AND ...
stackexchange_codegolf
A polyomino with \$n\$ cells is a shape consisting of \$n\$ equal squares connected edge to edge. No free polyomino is the rotation, translation or reflection (or a combination of these transformations, i.e. an isometry) of another (they're equal). The sequence of free polyominoes with \$n\$ cells is as follows: 1, 1, ...
stackexchange_codegolf
Given a string of brackets tell the user whether or not the brackets are well matched or not. Brackets include []{}(). For example: () <---- Well Matched ([{}][]) <---- Well Matched ({)} <---- Not Well Matched ({]) <----- Not Well Matched This is a code-golf challenge so as always the shortest solution wins.
stackexchange_codegolf
Sometimes when you're lying in bed and reading a message, your phone screen will pop into landscape mode right in the middle of a sentence. Only being able to read left to right, you find yourself incapacitated, unable to process the text in front of you. To ensure that this won't happen again, you decide to make every...
stackexchange_codegolf
You live inside a terminal that is 80 characters wide. You are bored, so you decide to play dominoes. No, not the boring kind that look like Scrabble, the fun kind where you spend an hour setting them to watch them fall in a second. In terminals, dominoes look like this: | upright domino \ left-tilted domino / ri...
stackexchange_codegolf
Consider a positive integer N written in base b. A sequence is generated from this number by finding the largest digit d in the expansion of N and writing N in base d+1, repeating until the base the number is written in can be decreased no further. For example, the sequence generated by 346 (10) in starting base 16 has...
stackexchange_codegolf
Challenge The goal of this challenge is to make a function that takes an input string, a start keyword and a end keyword. The output extracted result is from (but excluded) the given start keyword to (but excluded) end keyword. The output sub-string follows the rules as below. In all cases, the leading/trailing spaces...
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
This is a KOTH challenge for the dollar bill auction game in game theory. In it, a dollar is being sold to the highest bidder. Bids go up in increments of 5¢, and the loser also pays their bid. The idea is that both players escalate the bidding war far beyond the value of a dollar in order to cut their losses. Let's ho...
stackexchange_codegolf
Add++ is the Language of the Month for January 2022, and so I'm asking for tips for golfing in it. Please stick to tips specific to Add++, and avoid general tips such as "remove whitespace" or "avoid comments". Please post separate tips as individual answers
stackexchange_codegolf
Special Independence Day (USA) themed challenge for you today. You must write a program that prints this ascii-art representation of The American Flag. 0 |--------------------------------------------------------- | * * * * * * #################################| | * * * * * ...
stackexchange_codegolf
Clock is an interesting card game, as it requires no skill. It is a single player game, and the same card configuration always leads to a win or a loss. In this challenge, you need to figure out whether a given card configuration wins or loses. You can play the game here. The game is played as follows: Thirteen pil...
stackexchange_codegolf
Challenge: Write a function or program that accepts a list of boolean values and returns all of the ranges of True's. Test Cases: f [F] = [] f [T] = [[0,0]] f [T,T,F,T] = [[0,1],[3,3]] f [F,T,T,F,F,T,T,T] = [[1,2],[5,7]]...
stackexchange_codegolf
Weather conditions at airports are reported to pilots in METAR (METeorological Aerodrome Report) format. This format could be described as being "golfed." Here are some examples: METAR KPDX 241653Z 16003KT 1/4SM R10R/4500VP6000FT FG SCT000 01/M01 A3040 RMK AO2 SLP293 FG SCT000 T00061006 $ METAR PAMR 241753Z 00000KT 10...
stackexchange_codegolf
We all know about the Fibonacci sequence. We start with two 1s and keep getting the next element with the sum of previous two elements. n-bonacci sequence can be defined in similar way, we start with n 1s and take the sum of previous n elements to get the next element. Challenge Given a positive integer m > 1, output t...
stackexchange_codegolf
In any programming language, make a program that outputs infinite subsequent powers of two, starting at any power of two with finite integer exponent. There does not need to be a seperator between outputs. Note: it only has to theoretically output infinite subequent powers of two given infinite integer size (so you can...
stackexchange_codegolf
Scratch is a visual programming language. For the sake of counting bytes, Scratch is usually written in scratchblocks2 syntax. Post tips that specifically apply to Scratch or scratchblocks2.
stackexchange_codegolf
Introduction: In my recent Strikethrough the Word Search List challenge I mentioned the following: When I do the word-search puzzles, I (almost) always go over the words in order, and strike them through one by one. In some cases I do them in reversed order as a change of pace, although that doesn't matter too much r...
stackexchange_codegolf
Let A be an m by n rectangular matrix of positive integers, where m and n are also positive integers. We are interested in RoD ('Right-or-Down') paths from the upper-left cell of A to the lower right cell; in an RoD path, each successive cell of the path is either one cell to the Right of or one cell Down from the prev...
stackexchange_codegolf
A collection of N dimensional coordinates are provided. An example is below: {2,3,4} This can be thought of as a 3 dimensional array with 2x's, 3y's and 4z's; there may be any number of dimensions. In the example, there are 24 total nodes. Each node can be indexed using {x,y,z}. To access the 5th node, the provided in...
stackexchange_codegolf
Your goal is to determine whether a given number n is prime in the fewest bytes. But, your code must be a single Python 2 expression on numbers consisting of only operators the input variable n integer constants parentheses No loops, no assignments, no built-in functions, only what's listed above. Yes, it's possible...
stackexchange_codegolf
The goal of this challenge is to compare how well different programming languages support functional programming, by seeing how much code it takes to implement BLC8, the simplest functional programming language BLC8 is the bytewise variant of Binary Lambda Calculus, as described in my 2012 IOCCC entry at https://www.io...
stackexchange_codegolf
The task is to write code to identify which key is pressed on the keyboard. You can assume that only one key is pressed at a time and that there is a standard US keyboard layout. That is the layout with the @ over the 2. Your code should output a unique identifier for any key pressed. This includes PrtScn, Scroll Lock,...
stackexchange_codegolf
The Stern-Brocot sequence is a Fibonnaci-like sequence which can be constructed as follows: Initialise the sequence with s(1) = s(2) = 1 Set counter n = 1 Append s(n) + s(n+1) to the sequence Append s(n+1) to the sequence Increment n, return to step 3 This is equivalent to: Amongst other properties, the Stern-Brocot...
stackexchange_codegolf
You are given three parameters: start(int), end(int) and list(of int); Make a function that returns the amount of times all the numbers between start and end are multiples of the elements in the list. example: start = 15; end = 18; list = [2, 4, 3]; 15 => 1 (is multiple of 3) 16 => 2 (is multiple of 2 and 4) 17 => 0 18...
stackexchange_codegolf
What is Typoglycemia? Typoglycemia is a term that refers to the phenomenon where readers are able to understand text even when the letters in the middle of words are jumbled, as long as the first and last letters of each word remain in their correct positions. For example, Aoccdrnig to a rscheearch at Cmabrigde Uinerv...
stackexchange_codegolf
Results are now out here! Congratulations offset prediction for winning the challenge! Don't worry if you missed out, the controller code as well as all the bots that competed are all in the Github repo, so you can always test your bot against those that competed in the challenge yourself. (Hover for more info) This c...
stackexchange_codegolf
Yesterday I asked this question about riffle shuffles. It seems that yesterdays question was a bit too hard so this question is a related but much easier task. Today you are asked to determine if a permutation is in fact a riffle shuffle. Our definition of riffle shuffle is adapted from our last question: The first ...
stackexchange_codegolf
Inspired by the challenge A pile of weights. Challenge Given an integer as a weight in pounds, output an ASCII barbell that can represent the weight. Weights will come in the form of the barbell (which will weigh 45lbs) and plates with the following weights: 45lbs, 35lbs, 25lbs, 10lbs, and 5lbs. Weights will be repre...
stackexchange_codegolf
Your regex will receive a string of the form !XX! #<extra> where X is any hexadecimal digit (0-9 and A-F capital letters only), and <extra> is a character sequence to your choosing. (perhaps something like 0123456789ABCDEF0 could be useful?) You may use any regex flavour. Scoring will be calculated as: find regex len...
stackexchange_codegolf
Given a sequence of integers find the largest sum of a subsequence (integers on consecutive positions) of the sequence. The subsequence can be empty (in which case the sum is 0). Input is read from standard input, one integer per line. The largest sum must be written to standard output. I wrote a small generator for yo...
stackexchange_codegolf
What general tips do you have for golfing in BQN? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to BQN (e.g. "remove comments" is not an answer). Please post one tip per answer. At the moment of writing, the official BQN site is the most comprehensive res...
stackexchange_codegolf
Validating a CPR number A Danish CPR number (Person Identification Number) is date of birth followed by 4 digits (the last one being a control digit): DDMMYY-XXXX The final digit validates the CPR number using Modulo 11 by satisfying the following equation: where the are the ten digits of the complete ID number, and ...
stackexchange_codegolf
Consider this nested array [[1,2,4],[1,2,3],[2,3]] In each subarray in which 1 appears, a 2 appears. You might say that 1's presence is dependent on 2's presence. The converse is not true, as 2 appears in a subarray without 1. Additionally, 3 is dependent on 2, and 4 is dependent on 1 and 2. Task Given a list of lists ...
stackexchange_codegolf
Introduction Factorials are one of the most frequently used examples to show how a programming language works. A factorial, denoted \$n!\$, is \$1⋅2⋅3⋅…⋅(n-2)⋅(n-1)⋅n\$. There is also the superfactorial (there are other definitions of this, but I chose this one because it looks more like the factorial), denoted \$n$\$,...
stackexchange_codegolf
Let's say we have some arbitrary number: For example 25. We also have some "tokens" (poker chips, money, something similar) with different values. Values of tokens are 2; 3; 4; 5. "Tokens" are limitless You need to achieve number 25 using exactly n tokens (for example, 8) and to output all possible ways of doing so. F...
stackexchange_codegolf
There are 4 regular polygons that we can construct using ASCII art: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...
stackexchange_codegolf
The flag of Tennessee is specified by chapter 498 of the Public Acts of 1905. An oblong flag or banner in length one and two thirds times its width, the large or principal field of same to be of color red, but said flag or banner ending at its free or outer end in a perpendicular bar of blue, of uniform width, running...
stackexchange_codegolf
This is the Robbers thread. For the Cops challenge, see here As the robbers, your job is to crack the cops' answers. Choose an uncracked, unsafe cop answer and attempt to figure out which languages, in which order, the cop used. Note that a crack is valid even if the languages are different. So long as the the language...
stackexchange_codegolf
Goal This is a simple challenge. Your goal is to unscramble a string by swapping each letter with the next letter of the same case, while leaving non-letter characters unchanged. Step by step explanation The first character is a E. We look for the next letter in upper case: it's a C. We swap these characters, which l...
stackexchange_codegolf
Consider a question written in plain English whose answer involves two reasonably accurate (but potentially clever) words or phrases that can be separated by the word 'and': Q: What are the two sides of a coin? A: heads and tails Q: What are the best ways to travel? A: airplane and jetpack Q: Why is a raven like a wri...
stackexchange_codegolf
In this challenge, you are given a number x. You have to find the minimum number of steps required to reach x from 1. At a particular point, you have two choices: 1) Increment the number by 1. 2) Reverse the integer (remove leading zeros after reversing) Input: n=42 Output: 1>2>3>4>5>6>7>8>9>10>11>12>13>14>41>42 **...
stackexchange_codegolf
Your task is to write a program that: Runs indefinitely Produces no output Consumes an unbounded amount of memory Specifications You must list the implementation used for your program. This is relevant because some implementations might preform optimizations while others do not. For example, the LISP code (defun f (...
stackexchange_codegolf
Let's consider a list \$L\$ (initially empty) and a pointer \$p\$ into this list (initialized to \$0\$). Given a pair of integers \$(m,n)\$, with \$m\ge 0\$ and \$n>0\$: We set all uninitialized values in \$L\$ up to \$p+m+n\$ (excluded) to \$0\$. We advance the pointer by adding \$m\$ to \$p\$. We create a vector \$[...
stackexchange_codegolf
Getting the area covered by a rectangle is really easy; just multiply its height by its width. However in this challenge we will be getting the area covered by multiple rectangles. This is equally easy ... so long as the rectangles don't overlap. If the rectangles don't overlap the total area covered is the sum of th...
stackexchange_codegolf
Our boolean operators are AND, OR, XOR, NAND, NOR, XNOR and, in conjunction with one of those operators, NOT. Our numbers are \$1\$ and \$0\$. The challenge is to write a program or function that calculates the results of the input. Input A string, array or other input format of your choice; containing alternating numb...
stackexchange_codegolf
This is a code golf puzzle: shortest byte count wins. The program should do the following (standard loopholes obviously forbidden): Input a hexadecimal number Convert to octal Then interpret the digits as if in decimal (765 octal -> 765 decimal) Divide the number by two Convert to hexadecimal Example: Input: 4a3d Out...
stackexchange_codegolf
Gaussian blur is a method used for blurring images smoothly. It involves creating a matrix which will be used by convolving it with the pixels of an image. In this challenge, your task is to construct that matrix used in Gaussian blur. You will take an input r which will be the radius of the blur and an input σ which w...
stackexchange_codegolf