instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
This was inspired by a function I recently added to my language Add++. Therefore I will submit an short answer in Add++ but I won't accept it if it wins (it wouldn't be fair) Don't you hate it when you can multiply numbers but not strings? So you should correct that, right? You are to write a function or full program...
stackexchange_codegolf
Introduction Decide whether a Hexagony program composed solely of the characters .)_|\/><@ will halt using least bytes. Challenge Hexagony is a language developed by Martin Ender in which the source code is presented in the form of a hexagon. It has been extensively used in PPCG and there has been many impressive submi...
stackexchange_codegolf
Jelly has compressed string literals, using the “...» delimiters. The way these work is by interpreting the ... as a base-250 integer, \$n\$, then repeatedly divmod-ing this integer until it reaches \$0 \newcommand{\d}[2]{ \left( \left\lfloor \frac {#1} {#2} \right\rfloor, #1 \text{ mod } #2 \right) }\$, building up th...
stackexchange_codegolf
Cops thread Robbers Robbers, your job is to find the slices of the corresponding cop's code. Scoring The robber with the most cracks wins. Example Take this code: iimmppoorrtt ssyymmppyy;;pprriinntt((ssyymmppyy..iisspprriimmee((iinnppuutt(()))))) The slice here is [::2], so the robber's post could look like this: Crac...
stackexchange_codegolf
The Peirce quincuncial projection is pretty neat. It actually tessellates the whole plane: Your job is to generate this map projection. To simplify things, you will only need to generate the northern hemisphere. Also, you will be given the stereographic projection of the northern hemisphere as input: (based on https:...
stackexchange_codegolf
A well known song by the Irish rock band U2 starts with the singer Bono saying "1, 2, 3, 14" in Spanish ("uno, dos, tres, catorce"). There are various theories as to the significance of those numbers. Apparently the official explanation is "we drank too much that night". But there's a more interesting hypothesis: Bono ...
stackexchange_codegolf
Typescript is a typed superset of Javascript. For this challenge, we'll consider the following classic basic types: string number boolean undefined null And two "meta" types: any never The type any annotates that any type is valid: const a: any = "foo"; const b: any = 42; const c: any = true; const d: any = undefin...
stackexchange_codegolf
So you want to create a haiku, but you're not sure if it follows the syllable rules for a haiku. I couldn't be bothered to write a proper blurb like I usually do, so you'll have to make do with this. Let's get stuck right in. Finding a haiku out in the wild For the purposes of this challenge, we will be checking if the...
stackexchange_codegolf
Inspired by this and this question Challenge Your challenge is to print any 100 consecutive digits of Champernowne's Constant. You must give the index at which that subsequence appears. The 0 at the beginning is not included. For example, you could print any of the following: +-----+------------------------------------...
stackexchange_codegolf
Write a program or function that given n ≥ 1 returns the number of solutions to ±1 ± 2 ± 3 ± ... ± n = 0. For n = 6 there are no solutions, so the answer is 0. For n = 4 there are two solutions, so the answer is 2 (the two solutions are 1 - 2 - 3 + 4 = -1 + 2 + 3 - 4 = 0). This is OEIS sequence A063865. Some example in...
stackexchange_codegolf
A traveler needs to stay for n days in a hotel outside town. He is out of cash and his credit card is expired. But he has a gold chain with n links. The rule in this hotel is that residents should pay their rent every morning. The traveler comes to an agreement with the manager to pay one link of the golden chain for e...
stackexchange_codegolf
Problem I've got a GREAT new program that will change the way we think about math in computing, taking in strings of algebraic functions and doing AMAZING things with them! The only problem, is that I am only able to parse specific algebra, otherwise the universe folds into itself, which is bad. Fortunately, I only nee...
stackexchange_codegolf
A finite-permutation is a function which takes an \$n\$-tuple and produces an \$n\$-tuple such that every element of the input is present in the output, and the ordering does not rely on the values of the inputs. We can unambiguously represent these permutations with an \$n\$-tuple where each element is the index of wh...
stackexchange_codegolf
I am a big fan of the game Creeper World, and especially the sequel. You don't need to know how this game works to answer the question, I just wanted to mention where my question originated from. In the game, your objective is to destroy the Emitters that are spawning Creeper, using a weapon known as a nullifier. Nulli...
stackexchange_codegolf
Nichomachus's Theorem relates the square of a sum to the sum of cubes: and has a beautiful geometric visualization: Challenge: Create the 2d part of this visualization in ascii. You will need to ensure that all visual demarcations are upheld by your diagram. This is simplest to do with four "colors," though it's pos...
stackexchange_codegolf
Let \$\sigma(n)\$ represent the divisor sum of \$n\$ and \$\sigma^m(n)\$ represent the repeated application of the divisor function \$m\$ times. Perfect numbers are numbers whose divisor sum equals their double or \$\sigma(n) = 2n\$. For example, \$\sigma(6) = 12 = 2\times6\$ Superperfect numbers are numbers whose twic...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Santa has a bunch of presents wrapped in cuboid boxes of various sizes. As his sled flies above a chimney, a stack of presents will be automatically dropped through it. Santa wants to carefully choose the presents so that all of them f...
stackexchange_codegolf
This challenge is a tribute to the winner of Best Picture at the Oscars 2017, La La Land Moonlight! Write a function/program that takes a string containing only letters [A-Za-z], the four symbols that are common in every day sentences .,'? and spaces, and outputs the string in the style of La La Land. To be more spec...
stackexchange_codegolf
For a given number n, output an strictly decreasing array whose sum is n and its lexicographical order is the smallest for any possible outputs Smallest lexicographical order means that for or sum n=9 the following strictly decreasing arrays are possible: [[9],[8,1],[7,2],[6,3],[5,4],[6,2,1],[5,3,1],[4,3,2]]. Putting t...
stackexchange_codegolf
Definitions Two numbers are co-prime if their only positive common divisor is 1. A list of numbers is mutually co-prime if every pair of numbers within that list are co-prime with each other. A factorization of number n is a list of numbers whose product is n. Task Given a positive number n, output the mutually co-pr...
stackexchange_codegolf
Background A triangular grid is a grid formed by tiling the plane regularly with equilateral triangles of side length 1. The picture below is an example of a triangular grid. A triangular lattice point is a vertex of a triangle forming the triangular grid. The origin is a fixed point on the plane, which is one of the ...
stackexchange_codegolf
The wizard is determined to pose the most challenging challenge yet for which he believes the previous solution techniques will not work. He decides to go multidimensional. If there is a number line with \$x = 10\$ then your task is to prove this. If you do so you win. In this situation, for your code to be correct, ...
stackexchange_codegolf
You are given an array/list/vector of pairs of integers representing cartesian coordinates \$(x, y)\$ of points on a 2D Euclidean plane; all coordinates are between \$−10^4\$ and \$10^4\$, duplicates are allowed. Find the area of the convex hull of those points, rounded to the nearest integer; an exact midpoint should ...
stackexchange_codegolf
For this challenge you need to make a given word by concatenating "pieces" (a.k.a contiguous substrings) from other words. Given a word and a list of words as input, output the fewest number of pieces needed to create the first word. Rules Words consist of characters in the ASCII range 33 to 126. The word list may ha...
stackexchange_codegolf
When I was in grade 3, we were taught how to solve a very simple math problem. It was equaling the denominators of two or more fractions. Let's take two proper fractions:- $$ \frac{1}{2},\frac{2}{3} $$ First we will take the Least Common Multiple of the denominators of the two fractions, the LCM of \$2,3\$ are \$6\$. T...
stackexchange_codegolf
Given a boolean function with inputs, check if it's possible to only use IMPLY gate to express it. There's no extra limitation on how you use this gate, and you can use each input for any amount of times. See examples below: \$\begin{matrix} \text{Expression}&&&&&\text{Solution}&\text{Your output}\\ a&0&0&1&1&a&\text{t...
stackexchange_codegolf
Today (or tomorrow, depending on your timezone, by the time of posting) is the birthday of the great mathematician and physicist Leonhard Euler. To celebrate his birthday, this challenge is about one of his theorems in geometry. For a triangle, we define its incircle to be the largest circle inside the triangle and its...
stackexchange_codegolf
In 2009, Hannah Alpert described the "far-difference" representation, a novel way of representing integers as sums and differences of Fibonacci numbers according to the following rules: every two terms of the same sign differ in index by at least 4, and every two terms with different signs differ in index by at least ...
stackexchange_codegolf
TailwindCSS is a utility that lets one write CSS code using only HTML classes, which are then converted to CSS code with the Tailwind compiler. Ordinarily, one would write CSS in a separate file from the HTML, and reference named classes: <!-- without Tailwind --> <p class="crazy-monologue">Crazy? I was crazy once. The...
stackexchange_codegolf
Inspired by this post. For those marking this question as a duplicate I urge you to actually read the question to see that mine is a modification of the one linked. The one linked does not ask for an input and is to just print the alphabet diagonally. The Challenge Given an input between 1-26 inclusively, print the alp...
stackexchange_codegolf
Introduction to Mahjong tiles Mahjong (麻雀) is a board game that originates from China. Mahjong tiles used in this challenge are in Unicode points U+1F000 – U+1F021: They are categorized as: Winds (風牌): (East Wind), (South Wind), (West Wind), (North Wind) Dragons (三元牌): (Red Dragon), (Green Dragon), (White Dragon) Te...
stackexchange_codegolf
Very few, if any, programs or applications have utilised the proposed spec for WOM which was initially thought up in the early 1970s as a polar opposite to ROM, so your task is to take a dataset of n Integers and simulate storing it to a WOM schema as a proof of concept. Your array must contain 1 or more integers. Smal...
stackexchange_codegolf
There's a question on this site that is similar to this question, but I have added a twist. You have three inputs, the number of people in the circle n, the k-th person counted out at each step, and the q-th person that survives. The people in the circle are numbered 1 to n. For example, in a circle of 20 people, the 2...
stackexchange_codegolf
This code-golf challenge will give you two positive integers n and k as inputs and have you count the number of rectangles with integer coordinates that can be drawn with vertices touching all four sides of the \$n \times k\$ rectangle $$ \{(x,y) : 0 \leq x \leq n, 0 \leq y \leq k\}. $$ That is, there should be: at le...
stackexchange_codegolf
As of ECMAScript 2015, JavaScript has 33 reserved keywords, such as break, const and new, as well as 10 future reserved keywords, such as let and await. Your task is to chain together the largest number of consecutive1 distinct reserved keywords2 while writing functional JavaScript code3. Consecutive reserved keywor...
stackexchange_codegolf
Given a map from arrays of integers of same size to single integers, determine if there is a set of indices such that the output is equal to the maximum of the elements at those indices for every corresponding pair. You can take the input as a map if your language support, arrays of pairs, separated 2D array of input a...
stackexchange_codegolf
Seven countries lay official claims to parts of Antarctica: Argentina, Australia, Chile, France, New Zealand, Norway, and the United Kingdom. We will focus only on the claims of the main Antarctic landmass south of 60° S, which are: Chile: between 90° W and 53° W United Kingdom: between 80° W and 20° W Argentina: betw...
stackexchange_codegolf
This question is the second of several Brain-flak Birthday challenges designed to celebrate Brain-Flak's first Birthday! You can find more information about Brain-Flak's Birthday here Challenge For this challenge you'll be generating all fully matched strings from a list of brackets. To borrow DJMcMayhem's definition...
stackexchange_codegolf
Challenge Create a console program to display each byte of a file. Winning Since this is code-golf, fewest bytes wins. Rules Program must be a console application, meaning that it will be ran from some sort of command-line interpreter; Every byte must be uppercase hexadecimal, separated by a space, and it must be 2 ...
stackexchange_codegolf
\$\left\{ n \atop k \right\}\$ or \$S(n, k)\$ is a way of referring to the Stirling numbers of the second kind, the number of ways to partition a set of \$n\$ items into \$k\$ non-empty subsets. For example, to partition \$\{1,2,3,4\}\$ into \$2\$ non-empty subsets, we have $$\begin{matrix} \{\{1\},\{2,3,4\}\} & \{\{2\...
stackexchange_codegolf
Today, November 11th, is known as Remembrance Day, Armistice Day, or Veterans Day (depending upon the country), and is a day of reflection and gratitude for members of the military and their service, specifically started to reflect the end of European hostilities in the first World War. Let us reflect on that with a si...
stackexchange_codegolf
Given a list of integers find the "trajectory" that results from indefinitely moving the instructed steps to the right (left if negative), wrapping if necessary, starting at the first element. A "trajectory", here, is defined as a list containing the elements that are visited only one time, in the order they are visite...
stackexchange_codegolf
I love math. But I can't find a single calculator that can multiply correctly. They seem to get everything right except 6*9 (It's the question to life, the universe, and everything! How could they get that wrong?!). So I want you all to write a function for me that can multiply 2 numbers correctly (and 6*9 equals 42 in...
stackexchange_codegolf
Every number of the form 2i (where i is a non-negative integer) has a single 1 in its binary representation. Given such a number, output the 1-based position of the 1. Examples: DECIMAL BINARY POSITION -------------------------- 1 0001 1 2 0010 2 4 0100 3 8 ...
stackexchange_codegolf
The flick input method is a way of inputting Japanese kana on a modern smartphone. It is arranged in a 12-key layout, with the following labels: あかさ たなは まやら 小わ、 When a key is tapped, it produces its respective kana. However, when the key is flicked in one of the four cardinal directions (up, down, left, right) it prod...
stackexchange_codegolf
(No, not this nor any of these) Given a string and a list of strings, fill in the all blanks in the input string with corresponding strings. Input/Output The input string contains only alphabetic characters, spaces, and underscores. It is nonempty and does not start with an underscore. In other words, the input string ...
stackexchange_codegolf
Given an arbitrary sequence consisting of 1 and A split this sequence up so that A is at the beginning of each sub sequence. Sequences without a leading A and Sequences without 1 before the next A will be self contained. Example Input 111A11A1111111A1A1AA should result in 111 A11 A1111111 A1 A1 A A Above already cont...
stackexchange_codegolf
Given an unsorted list of unique, positive integers, output the shortest list of the longest possible ranges of sequential integers. INPUT An unsorted list of unique, positive integers e.g. 9 13 3 11 8 4 10 15 Input can be taken from any one of the following: stdin command-line arguments function arguments OUTP...
stackexchange_codegolf
Disclaimer It is bad practice to draw out your molecules in 2 dimensions because that is not how they are. I chose to do this in 2D because it is easier to explain. Note that the bond angles are wrong too: the angle in CH4 is 109.5°, not 90° as I said and the bond angle in NH4 is 107°. BHCl2 does have a bond angle of ...
stackexchange_codegolf
Let us take a break from the brain-wrecking questions and answer some of the simpler ones You have recently read something extremely funny, and want to express your laughter to the world! But how can you? Task You have to display the string: Lololololololololololololololololololololololololololololololololololololololo...
stackexchange_codegolf
Stack Exchange currently has 134 question and answer sites. This includes all beta sites (such as PPCG) but not Area 51 proposals nor any meta sites, except for the "mother meta". To answer this question, choose one of those sites and write a program where every line of code is an anagram of the title of a different qu...
stackexchange_codegolf
Write a program that takes a string as an input. For the input: If the input doesn't match the source code, the program shall output the input intact. (Hence a cat) Otherwise, the program shall fall in an infinite loop. (So actually not a cat)
stackexchange_codegolf
Your task is to write a full program that will continue to count down from 10 every time it is run. The first time you run the program, it should print 10. The next time, it should output 9. The next time, it should output 8, and so on. Instead of printing 0, the program should crash. You do not have to handle the pro...
stackexchange_codegolf
"Set" is a card game played with a deck of 81 cards, twelve of which are pictured below: Each card has four attributes, each of which may assume three values: Number: the number of symbols, either 1, 2, or 3 Shape: the shape of the symbol, either squiggle, diamond or oval Colour: either purple, red or green Shading: ...
stackexchange_codegolf
As the title says, given a valid chess move in algebraic notation, produce the string describing the move. Example: fxg8=Q+ -> Pawn takes g8 promotes to Queen check Bb7# -> Bishop to b7 mate Here is a list of all the keywords and their respective notation R -> Rook x -> takes N -> Knight ...
stackexchange_codegolf
Given a set of intervals \$\mathcal{I} = \{I_1, \ldots, I_m\}\$, where each interval \$I_j\$ is represented by its bounds \$(a_j, b_j)\$, find a partition \$\mathcal{T}\$ of \$\mathcal{I}\$ of minimal cardinality such that for each set \$T_i \in \mathcal{T}\$ it holds \$\bigcap T_i \ne \emptyset\$. In other words, find...
stackexchange_codegolf
After having implemented QuickSort in BrainF***, I realized it probably wasn't that quick. Operations that are O(1) in normal languages (like array indexing) are significantly longer in BF. Most of the rules for what makes an efficient sort can be thrown out the window when you are coding in a Turing tarpit. So here...
stackexchange_codegolf
I'm not sure if this kind of golf is allowed, but here it is. Your objective is to create an image containing one pixel of every possible RGB color. The image with the smallest file size wins. Rules: The image must be a PNG. The image must contain exactly one of every possible RGB color. Acceptable image dimensions ar...
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
This is a code golf. The smallest amount of bytes wins! :) What you need to do You're on Deep Space Nine, a Cardassian outpost taken over by the Federation, in the year 2374. The Borg, a superior race, have collapsed your shields and assimilated half of your crew. However, you have important classified information on y...
stackexchange_codegolf
You're tasked with writing an algorithm to efficiently estimate cost of solving an Eni-Puzzle from a scrambled state as follows: You're given m lists of containing n elements each(representing the rows of the puzzle). The elements are numbers between 0 and n-1 inclusive (representing the colors of tiles). There are exa...
stackexchange_codegolf
Given a set of substrings, such as [ca, ar, car, rd], it's possible to create infinitely many strings by concatting them together. Some examples of this for the given substrings could be: ca caar card rdca carrd rdrd ... One interesting property of this set of substrings is that any string can only be constructed in o...
stackexchange_codegolf
This challenge will behave more or less like a traditional code-golf. The only difference is that instead of scoring answers by their number of characters or bytes, users will assign weights to different characters in the comments and the program with the lowest cumulative weight will win. Challenge Your task is to wri...
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
Introduction This challenge was inspired by a seemingly simple task requested at work that couldn't easily be done in Microsoft Teams. At least not from what we could find! Task Your task, if you choose to accept it, is to output the last week day of any month in any year. Input You can input the desired month/year in ...
stackexchange_codegolf
Please note the special scoring for this challenge. Given a non-empty string made of a-z, output the string immediately before it in the shortlex order. Shortlex order We enumerate strings in shortlex order by first listing the strings of length 0, then those of length 1, then length 2, and so on, putting them in alph...
stackexchange_codegolf
Make a cat program, with a catch. The program must refuse under all circumstances to output "Hello World", instead outputting "Goodbye World", with matching spacing (but matching casing is not required). "Hello World" must never appear as a substring of the output, regardless of casing, not even if the two words are (o...
stackexchange_codegolf
Task Write a function or a program to find the number of rotations required by a wheel to travel a given distance, given its radius. Rules Input can be 2 positive rational numbers and can be taken in any convenient format. Both inputs are of same unit. There must not be any digits 0-9 in your code. The output will be a...
stackexchange_codegolf
Your mission is not so simple. You have to write a program that decodes QR-codes. There are some things that are not permitted: Making web requests (except https://i.stack.imgur.com/sCUJT.png or https://i.stack.imgur.com/mXUcd.jpg) Using any QR code processing library (Or using any external library to do this) Image ...
stackexchange_codegolf
Challenge Build the Wheat Wizard's stove using 2-input NAND gates. The solution with the fewest NAND gates wins. Externally, it works in the following way: (the first line is added from the original spec for physical output) It has 10 levels, from 0 to 9. The display has 9 lights, and if the current level is L, exactl...
stackexchange_codegolf
This challenge is essentially identical to this one with just one difference: it is now allowed to shuffle letters anywhere in the string. Scenario John has an important number, and he doesn't want others to see it. He decided to encrypt the number, using the following steps: His number is always a non-decreasing seque...
stackexchange_codegolf
Let's say I'm ten steps away from my destination. I walk there following the old saying, "Two steps forward and one step back". I take two steps forward, one back, until I'm standing exactly on my destination. (This might involve stepping past my destination, and returning to it). How many steps did I walk? Of course, ...
stackexchange_codegolf
This question doesn't need to apply to just terminating decimals - repeating decimals can also be converted to fractions via an algorithm. Your task is to make a program that takes a repeated decimal as input, and output the corresponding numerator and denominator (in lowest terms) that produces that decimal expansion....
stackexchange_codegolf
A regular dodecahedron is one of the five Platonic solids. It has 12 pentagonal faces, 20 vertices, and 30 edges. Your task is to output the vertex coordinates of a regular dodecahedron. The size, orientation, and position of the dodecahedron are up to you, as long as it is regular. You may output the coordinates in a...
stackexchange_codegolf
Input: A valid 6 HEX digit color code wihout a # prefix Valid: 000000 FF00FF ABC123 Your job is to find to which one of these: Red: FF0000 Green: 00FF00 Blue: 0000FF White: FFFFFF Black: 000000 the input color is the closest too, in this case you try to only match it to black or white when the RGB is the same v...
stackexchange_codegolf
This challenge is a tribute to the winner of Best Picture at the Oscars 2017, La La Land Moonlight! Write a function/program that takes a string containing only letters [A-Za-z], the four symbols that are common in every day sentences .,'? and spaces, and outputs the string in the style of La La Land. To be more spec...
stackexchange_codegolf
You have your very heavy cubical box on a flat floor at position (0,0). All you can do with it is roll it in four cardinal directions (east, north, west, south). Your task is to bring it to a target position, such that the side facing up is the same as before your manipulations. Make a program or function which receive...
stackexchange_codegolf
This is the robber's thread of a cops-and-robbers challenge. You can view the cop's thread here A pretty common beginner style question is to print some string, but, there's a catch!, you need to do it without using any of the characters in the string itself! For this challenge we will find out who is the best at prin...
stackexchange_codegolf
Write a full program or a function taking an unsigned integer number N and doing this cut out work: Cut out a hollow hexagon 'donut' shape with side B-C equal to 2N times '/' Translate the piece above by 3 lines. Repeat the job N times (from the piece obtained) decrementing by 2 '/' side B-C , until smallest hexagon ...
stackexchange_codegolf
For any String that is composed of lower cased alphabetical characters, make a function that returns a list of all of it's variations, empty strings returns empty list Test Cases "" -> [] "a" -> ["a", "A"] "ab" -> ["ab", "Ab", "aB", "AB"] "abc" -> ["abc", "Abc", "aBc", "ABc", "abC", "AbC", "aBC", "ABC"] This is Code-g...
stackexchange_codegolf
The challenge is to write a program which will find the shortest (least number of characters) command which will navigate to a target directory, given a starting directory, assuming a standard linux file system. Take the following file system as an example, starting from ~: . ├── target └── test └── starting If th...
stackexchange_codegolf
Game of Game of Life Conway's Game of Life is a 0-player game. But that's okay! We can make it a multi-player game. This game is played on the smallest square grid that will accommodate a 6x6 square for each player (12x12 for 2-4 players, 18x18 for 5-9 players, etc). This grid is actually a torus, so it wraps in bot...
stackexchange_codegolf
Sequel to Verify Tents and Trees solution. Background Tents and Trees (try here) is a puzzle played on a square (or rectangular) grid, where the objective is to place tents horizontally or vertically adjacent to each of the trees, so that no two tents touch each other in 8 directions (horizontally, vertically, and diag...
stackexchange_codegolf
Shocking news: Dr. Mad J Scientist has released a proof of P = NP to the world. But the proof is nonconstructive, and she's keeping the algorithm to herself. Worry not. Without even looking at her proof, we can still (almost) write a computer program that solves NP-complete problems in polynomial time. The Problem Inpu...
stackexchange_codegolf
Let's define the "unwrapped size" function u of a nested list l (containing only lists) by the following rules: If l is empty, then u(l) is 1. If l is non-empty, u(l) is equal to the sum of the unwrapped sizes of every element in l, plus one. Your task is to write a program (or function) that takes a list as input an...
stackexchange_codegolf
Given a positive integer \$N >= 4\$, output an RSA key pair (both the private and the public key) whose key length is \$N\$ bits. The RSA key generation algorithm is as follows: Choose an \$N\$-bit semiprime \$n\$. Let the prime factors of \$n\$ be \$p\$ and \$q\$. Compute \$\lambda(n) = LCM(p-1, q-1)\$. Choose an int...
stackexchange_codegolf
Background Entombed is an Atari 2600 game released in 1982, with the goal of navigating through a continuous mirrored maze as it scrolls upwards. In recent times, the game has been subject to research — despite the strict hardware limitations of the Atari 2600, it somehow manages to create solvable mazes every time. By...
stackexchange_codegolf
There are 18 primes with distinct prime digits (A124674). Namely, they are: \$2, 3, 5, 7, 23, 37, 53, 73, 257, 523, 2357, 2753, 3257, 3527, 5237, 5273, 7253, 7523\$ Your task is to output this sequence. Rules sequence rules apply. This means valid solutions may use any of the following formats: Given some index \$n\$...
stackexchange_codegolf
For a given number n, output an strictly decreasing array whose sum is n and its lexicographical order is the smallest for any possible outputs Smallest lexicographical order means that for or sum n=9 the following strictly decreasing arrays are possible: [[9],[8,1],[7,2],[6,3],[5,4],[6,2,1],[5,3,1],[4,3,2]]. Putting t...
stackexchange_codegolf
Jill lives in the (magnetic) north pole. One day, Jill decided to go for a walk, travelling in the four directions (north, east, west, south) for some lengths, with the help of a compass. Your task is to find whether Jill ended up where Jill lives, i.e. the magnetic north pole. Only south is defined at the north pole. ...
stackexchange_codegolf
This challenge will have you count "creatures" in the tile game Palago. A creature is any closed shape that can be formed by Palago tiles of matching colour in a hexagonal grid. The game Palago consists of tiles like this: These tiles can be rotated \$120^\circ\$, \$240^\circ\$, or not at all and placed anywhere on ...
stackexchange_codegolf
Task: With the minimum amount of bytes, determine today's Zodiac sign using the programming language of your choice. Rules: This is code golf, the answer with the fewest characters wins. The initialization of getting the current date into a variable (e.g. var now = new Date();) does not add to the count. Leap years mu...
stackexchange_codegolf
For the last day of the semester, I decided to have some fun with my students and I showed them Code Golf... poor guys, they're addicted now. The goal was to compete against the other students to solve those problems with what would be very usual rules for you. They had to use C# (because it's the language they are lea...
stackexchange_codegolf
Challenge Given a positive integer, return the product of its divisors, including itself. This is sequence A007955 in the OEIS. Test Cases 1: 1 2: 2 3: 3 4: 8 5: 5 6: 36 7: 7 8: 64 9: 27 10: 100 12: 1728 14: 196 24: 331776 25: 125 28: 21952 30: 810000 Scoring This is code-golf, so the shortest answer in each language...
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
I love ><>, ><> is life! 2D langages are amazing! In this challenge, you will have to say if a "fishy" road has an end, while code-golfing. Definition A fishy road is constructed with tiles, including the following ones: v (go down) > (go right) ^ (go up) < (go left) / (mirror) \ (mirror) Any other character (except -...
stackexchange_codegolf
Given a ragged list of positive integers return a full cycle of recursive rotations starting with the unchanged input and ending with the state immediately before revisiting the initial state. Examples: [[2,3],4,5,5] -> [[2,3],4,5,5] , [4,5,5,[3,2]] , [5,5,[2,3],4] , [5,[3,2],4,5] [1,10,[2,2,4],6,[[5,6],7],1] -> [1,10...
stackexchange_codegolf
Take a non-empty matrix / numeric array containing positive integers as input. Return, in this order, the sums of the first row and column, then the second row and column and continue until there aren't any more rows or columns. Suppose the input is: 2 10 10 2 4 9 7 7 2 9 1 7 6 2 4 7 ...
stackexchange_codegolf
You are provided with a non-empty array \$A\$ of integers, all greater than 0. But what good is an array if the elements do not sum up to the number \$N\$ (also provided as input)... So to change that, you can pick any integer of your choice present in the array and replace any of its digits with a different digit betw...
stackexchange_codegolf
You will be given a positive integer as input. The integer is the board of a seesaw. Th integer will not have leading zeroes. You may take this input however you like. Your task is to output the location of the pivot point of this seesaw, such that the board would balance. A board balances if the moments on each side a...
stackexchange_codegolf