text
stringlengths
180
608k
[Question] [ It's laundry day, and you have lots of clothes that need to be washed. Wanting to have as much time left over for code golf as possible, you hope to optimize how quickly you wash and dry them all. You have three types of appliances: * Washing machines: Take dirty clothes and turn them into wet clothes ...
[Question] [ Given a positive number \$n\$ we call **another** (not same as n) positive number \$m\$ good if we insert same digits in both n and m and the resulting fractional value is same. $$m/n = m\_{\text{transformed}}/n\_{\text{transformed}}$$ $$or$$ $$m\*n\_{\text{transformed}} = m\_{\text{transformed}}\*n$$ ...
[Question] [ One day in July 2020, I made the following C program: ``` #define A m] a[9999],*m=a;main(){for(2[A=4[A=1;;){for(;4[A;putchar(6[m-=3]+48)); for(puts(a);7[A;2[A=4[A,4[A=1)if(4[A+=3[m+=3]-1,9<(3[A=2[A+=3[A))++ 5[A,7[A=1,3[A-=10;}} ``` with three superfluous newlines removed, it's 167 bytes and it prints t...
[Question] [ Write a program which will eventually, given enough time, print all possible permutations of ASCII characters (both printable *and* non-printable) less than or equal to its length, **except** itself. The text of the program must not appear anywhere in its output. For example, if your program is `abc`, ...
[Question] [ ## Background [**Conway immobilizer problem**](https://www.futilitycloset.com/2014/09/12/the-conway-immobilizer/) is a puzzle that reads like the following: > > Three positions, "left," "middle," and "right," are marked on a table. > Three cards, an ace, a king, and a queen, lie face up in some or al...
[Question] [ # Background MENACE (**M**achine **E**ducable **N**oughts **A**nd **C**rosses **E**ngine) is a rudimentary shallow machine learning algorithm for the game Noughts and Crosses, created by British computer scientist Donald Michie in the 1960s. It was originally implemented with 304 matchboxes, each label...
[Question] [ Minecraft inventory management is hard. You have 17 diamonds, but you need 7 to craft an enchantment table, a pickaxe, and a sword. Do you pick them up and right click 7 times? Or do you right click once and right click twice and take the 7 left? It's so confusing! for those of you who are now confused...
[Question] [ Let's imagine we have a matrix of bits (which contains at least one `1`): ``` 0 1 0 1 1 0 1 0 0 1 0 0 1 0 1 0 0 1 0 1 1 0 0 0 1 0 1 1 0 1 0 1 0 1 1 0 0 1 0 0 1 1 0 1 0 0 0 1 0 1 1 0 0 1 0 ``` We want to set some of the bits in this matrix such that it forms a contiguous blob of `1`s, in which every `1`...
[Question] [ You end up having a lot of very long, boring-looking conditionals in your code: ``` if flag == 1: while have != needed: if type == 7: ``` These can be transformed into their much more lovable `<3` conditionals counterparts: ``` if abs(flag - 1) + 2 <3: while 3 - abs(have - needed) <3: if 2 + abs(type -...
[Question] [ ## Introduction You have been tasked to write a program that splits a rectangular integer array evenly in half (for whatever reason). This task is computationally intensive, but luckily you have a dual-core machine to perform the calculations. To maximize the benefits of parallelism, you decide to spli...
[Question] [ # Introduction I'm a real big fan of the SBU (Short But Unique) challenges that crop up on PPCG all of the time. The CUSRS is a system designed to refactor strings, a CUSRS function takes 2 parameters and outputs 1 String. # Challenge Produce a program, function, lambda or acceptable alternative to do ...
[Question] [ Consider the following definitions taken from [The number of runs in a string](https://www.google.co.uk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjx8rGd0tXNAhVTOMAKHQZtBCsQFggeMAA&url=http%3A%2F%2Fwww.sciencedirect.com%2Fscience%2Farticle%2Fpii%2FS0890540107000107&usg=AFQjCNF4G...
[Question] [ ## Introduction Boardgames are a classic play between kids, but there are some kids that feel bored playing a boardgame step by step. Now they want the result to be shown before they put their hands on the board. ## Challenge Suppose this boardgame: `>---#<---X---<X<--#-$` ``` > means the start of th...
[Question] [ [SPICE](https://en.wikipedia.org/wiki/SPICE) is an electrical circuit simulation program originating from UC Berkeley. Your goal is to implement a minimalistic version which can solve for the nodal voltages and branch currents of a circuit composed of resistors and DC current sources. # Input Format Th...
[Question] [ You are given a list of numbers `L = [17, 5, 9, 17, 59, 14]`, a bag of operators `O = {+:7, -:3, *:5, /:1}` and a number `N = 569`. ## Task Output an equation that uses all numbers in `L` on the left-hand side and only the number `N` on the right-hand side. If this is not possible, output False. Exampl...
[Question] [ You are tasked with planning a flying route for a local airplane delivery company. You need to route an airplane from point A to point B. You just can't start at A, point the airplane at B, and go, however, as the prevailing winds will blow you off course. Instead you need to figure out which direction...
[Question] [ ## Intro Blur's song *Girls & Boys* featured the lines ``` girls who are boys who like boys to be girls who do boys like they're girls, who do girls like they're boys ``` in the chorus. These lines have a pretty uniform structure: you have a subject, which is either `girls` or `boys`, a relative clause...
[Question] [ # Thin Paper Folding --- **This is a "lighter" version of the challenge [Paper Folding for the win](https://codegolf.stackexchange.com/questions/208919/paper-folding-for-the-win). This challenge is being posted as a different challenge with many modifications in order to try and get wider range of inte...
[Question] [ This challenge like some of my [previous](https://codegolf.stackexchange.com/q/200122/53884) [challenges](https://codegolf.stackexchange.com/q/187763/53884) will have you counting free [polyforms](https://en.wikipedia.org/wiki/Polyform), which are generalizations of Tetris pieces. This [code-golf](/que...
[Question] [ # Introduction A farmer needs help calculating the least time it will take him to pick his fruit each day. # Challenge * This farmer has `X` orchards. * Each orchard has `Y` fruits in it. If the orchard has no fruits, then it will contain the string "none". * The farmer has a list, this list contains t...
[Question] [ It's lunch time, I am hungry and I came to your Sushi Bar. You are the Sushi Chef and you have to produce a full program or function to make me some sushi! [![enter image description here](https://i.stack.imgur.com/qyCQP.jpg)](https://i.stack.imgur.com/qyCQP.jpg) [Credits: Wikipedia](https://en.wikipe...
[Question] [ **Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/75446/edit). Closed 6 years ago. [Improve this question](/posts/75446/edit) ...
[Question] [ ## Background A [*Davenport-Schinzel sequence*](http://en.wikipedia.org/wiki/Davenport%E2%80%93Schinzel_sequence) has two positive integer parameters `d` and `n`. We will denote the set of all Davenport-Schinzel sequences for given parameters by `DS(d,n)`. Consider all sequences of the natural numbers ...
[Question] [ Your challenge today is to take input like this: ``` fbcfbee ffcabbe debceec bccabbe edcfbcd daeaafc eebcbeb ``` And output the best possible move in a Bejeweled-like game that will match three or more letters, like this (note the capital `B` and `C`): ``` fbcfbee ffcabbe deBCeec bccabbe edcfbcd daeaaf...
[Question] [ The [THX deep note](https://www.youtube.com/watch?v=uYMpMcmpfkI) is one of the most recognizable sounds in audio/video production technology. According to its creator, it took about [20,000 lines of C code](https://en.wikipedia.org/wiki/Deep_Note) to generate the final result. We can do better than tha...
[Question] [ Write a program or a function in any programming language that takes a 6 digit hexadecimal input/argument. The input/argument can be 6 values or a 6 character string. Your program should output an exactly 8 character wide rectangular block of characters containing only the hexadecimals supplied combine...
[Question] [ **Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/188171/edit). Closed 4 years ago. [Improve this question](/posts/188171/edit)...
[Question] [ ## Camel Up Cup 2k18 In this challenge, we will be playing the semi-popular board game Camel Up. [Camel Up!](https://www.boardgamegeek.com/boardgame/153938/camel) is a board game that has players betting on camels to win rounds, win the game or lose the game, set traps to influence movement or move a c...
[Question] [ # Cyclic Polyglot Challenge *This is the cops thread. You can find the robbers thread [here](https://codegolf.stackexchange.com/questions/129865/cyclic-polyglot-challenge-robbers).* ## Cyclic Polyglot A N-element cyclic polyglot is a complete program that can be run in N different languages. In each la...
[Question] [ The *[Dal Segno](https://en.wikipedia.org/wiki/Dal_Segno)* and *[Da Capo](https://en.wikipedia.org/wiki/Da_capo)* are two very commonly used musical terms. They mean "*from the sign*" (ùÑã) and "*from the beginning*" respectively. There is also the idea of the *[coda](https://en.wikipedia.org/wiki/Cod...
[Question] [ ## Challenge Walking around Marks and Spencers, I noticed that they had air conditioning units placed randomly around the shop. Wanting to keep cool, I wondered what was the easiest way to move around the whole shop without being away from an air conditioning unit for too long. Given a map, you must fi...
[Question] [ Sometimes when you press a key on a keyboard, the letter doesn't always display on screen. Whether this is because of a dodgy connection or otherwise, you have decided to write a script to control the probability of a letter displaying on screen when the corresponding key is pressed. One day, you deci...
[Question] [ This is a rather complex but very interesting maths subject (known as **"covering problem"**), And I'd like your help for implementing it. Imagine a lottery game, where each ticket must choose 5 random numbers in a set of 50 numbers (from 1 to 50). It's quite easy to know the probability of a winning t...
[Question] [ > > **Ungolfed, ugly, horrible proof to help you make progress on this challenge: <https://gist.github.com/huynhtrankhanh/dff7036a45073735305caedc891dedf2>** > > > A bracket sequence is a string that consists of the characters `(` and `)`. There are two definitions of a balanced bracket sequence. #...
[Question] [ ## Background [Hamiltonian circuit problem](https://en.wikipedia.org/wiki/Hamiltonian_path_problem) is a decision problem which asks whether a given graph has a Hamiltonian circuit, i.e. a cycle that visits every vertex exactly once. This problem is one of the well-known NP-complete problems. It is als...
[Question] [ # Morpion solitaire This is a game that I remember having learnt from my grandparents in my childhood. Initially I didn't know the name. G B has found it to be Join Five (or less ambiguously - Morpion solitaire) with a slightly different starting position. NOTE: it seems that it's kinda known and this ...
[Question] [ **Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/164964/edit). Closed 5 years ago. [Improve this question](/posts/164964/edit)...
[Question] [ Write a program that outputs ``` Do not repeat yourself! ``` Your program code must respect the following constraints : * its length must be an even number * each character that is in position `2n` (where `n` is an integer > 0) must be equal to the character in position `2n-1`. The second character of...
[Question] [ Program your robots to deliver packages in a warehouse infested with destroyer drones. Avoid the drones and get your packages to the right place as fast as you can. ## Delivery Robots * There are packages labeled a-z in a warehouse. * Packages must be delivered to a matching chute A-Z. * A robot cannot...
[Question] [ [Cops thread](https://codegolf.stackexchange.com/questions/231409/which-character-to-change-cops) Robbers, your task is to crack a cops answer. Reveal the character that should be changed and what it should be changed to too. Please notify the cop if you cracked their challenge. The robber winner is ...
[Question] [ ## Challenge Display to the screen or write to stdout this exactly: ``` ** ** **** **** **** **** **** **** **** ********** ********** ********** ``` # Winning This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest submission (...
[Question] [ Remove all repeating words from an inputted sentence. Input will be something like `cat dog cat dog bird dog Snake snake Snake` and the output should be `cat dog bird Snake snake`. There will always be a single space separating words. Output order must be the same as input. (Refer to the example) You d...
[Question] [ Given a positive integer \$n\$ and another positive integer \$b\$ (\$1 < b < 36\$), return the number of digits/length of \$n\$ in base \$b\$ ``` 1597 16 -> 3 1709 9 -> 4 190 29 -> 2 873 24 -> 3 1061 27 -> 3 289 26 -> 2 1575 34 -> 3 1135 15 -> 3 1161 22 -> 3 585 23 -> 3 1412 23 -> 3 1268 14 -> 3 714 12...
[Question] [ **This question already has answers here**: [Count up forever](/questions/63834/count-up-forever) (224 answers) Closed 9 months ago. 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 n...
[Question] [ Construct a full program which outputs `Hello, World!`. The score of your submission will be equal to the sum of all of the ASCII values of the *distinct* characters. The lowest score wins! ## Rules * It must be a full program which takes no input * It must only print to STDOUT, nothing else * It must ...
[Question] [ **This is the robbers' challenge. The cops' one is [here](https://codegolf.stackexchange.com/questions/247536/smallest-subset-of-characters-required-for-turing-completeness).** In [Fewest (distinct) characters for Turing Completeness](https://codegolf.stackexchange.com/questions/110648/fewest-distinct-...
[Question] [ **Closed.** This question is [off-topic](/help/closed-questions). It is not currently accepting answers. --- Questions without an **objective primary winning criterion** are off-topic, as they make it impossible to indisputably decide which entry should win. Closed 3 years ago. [Improve this quest...
[Question] [ Idea from the [doubler challenge](https://codegolf.stackexchange.com/questions/132558/i-double-the-source-you-double-the-output), this may be more difficult. The program should output a positive integer or decimal point value higher than 0. If I duplicate the source code, the output should halve the or...
[Question] [ **Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/193934/edit). Closed 4 years ago. [Improve this question](/posts/193934/edit)...
[Question] [ # Introduction If \$\newcommand{\fib}{\operatorname{fib}}\fib(x)\$ calculates the \$x\$th Fibonacci number, write a program that calculates \$\fib(\fib(m))\$ for any integer value of \$m \ge 0\$. (Of course, there will be practical limits based on the language, so lesser limits are acceptable. Also, it...
[Question] [ > > [Cop's thread here](https://codegolf.stackexchange.com/q/140793/56656) > > > In this [cops-and-robbers](/questions/tagged/cops-and-robbers "show questions tagged 'cops-and-robbers'") challenge cops will think of a positive integer. They will then write a program or function that outputs one val...
[Question] [ **Closed**. This question needs to be more [focused](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Update the question so it focuses on one problem only by [editing this post](/posts/13074/edit). Closed 7 years ago. [Improve this question](/p...
[Question] [ Given a unix timestamp as an input, give a datetime string, in a format like so: "YYMMDD.HHmm" ## Rules * The input is a number (integer) of a millisecond-precise UNIX epoch time (milliseconds since 1970 January 1st 00:00:00.000 UTC). * The values must be padded with zeroes if they are 1 character inst...
[Question] [ For a computer language, a reserved word is a word that cannot be used as an identifier, such as the name of a variable, function, or label. For other computer languages, keywords can be considered as the set of the language instructions. ## Challenge Using your language of choice, write a code in the ...
[Question] [ **Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/41833/edit). Closed 2 years ago. [Improve this question](/posts/41833/edit) ...
[Question] [ Most of us are probably familiar with the concept of triangular and square numbers. However, there are also pentagonal numbers, hexagonal numbers, septagonal numbers, octagonal numbers, etc. The Nth Nagonal number is defined as the Nth number of the sequence formed with a polygon of N sides. Obviously,...
[Question] [ Given two real numbers (postive or negative) in the limits of float pointing number data types, i.e., (\$-3.4e38\$ to \$3.4e38\$) not inclusive, you should output the max of the two reversed numbers. --- ## TEST CASES ## Example ## Input: ``` 135 210 ``` ## Output: ``` 531 ``` \$531\$ is \$135\$ revers...
[Question] [ # Introduction [`cowsay`](https://en.wikipedia.org/wiki/Cowsay) is a Unix command made by Tony Monroe, written in Perl. It outputs a picture of a cow saying given text. For example: ``` ________________________ < Typical cowsay output! > ------------------------ \ ^__^ \ (oo)\______...
[Question] [ **Locked**. This question and its answers are [locked](/help/locked-posts) because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. Help guys my assignment says it needs to be in .pdf format but I did it in Word. I'm really stuck....
[Question] [ Challenge: Find the number of distinct words in a sentence Your task is to write a program that takes a sentence as input and returns the number of distinct words in it. For this challenge, words are defined as consecutive sequences of letters, digits, and underscores ('\_'). Input: * A string containi...
[Question] [ [There are so many different ways to express whether something is true or not!](http://meta.codegolf.stackexchange.com/questions/2190/interpretation-of-truthy-falsey) The goal of this challenge is to produce a [standardized](https://xkcd.com/927/) output of `truthy` or `falsy` for various input truthy ...
[Question] [ **Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/115752/edit). Closed 6 years ago. [Improve this question](/posts/115752/edit)...
[Question] [ **This question already has answers here**: [Valid Through The Ages](/questions/25913/valid-through-the-ages) (27 answers) Closed 8 years ago. Write a program that: * if a compiled language is used, compiles without errors * if an interpreted language is used, runs without syntax errors for ever...
[Question] [ ## Challenge We take three positive integers `a`, `b`, and `c` as input. Using these integers, first create a sequence in the range `[0, c]` (inclusive on both ends), in steps of `b`. For example, for `a=4, b=2, c=100`, the sequence would be `[0,2,4,...,96,98,100]`. For every number in this sequence wh...
[Question] [ Given the coordinates of the upper left corners of two squares and their side lengths, determine whether the squares overlap. A square includes the top and left lines, but not the bottom and right lines. That is, a point `(a,b)` is inside a square with side length `k` that starts at `(x,y)` if and only...
[Question] [ ## Preamble A common pain-point when working with [rational numbers](https://en.wikipedia.org/wiki/Rational_number) and decimals is how infrequently one can represent their rational number as a clean, non-repeating decimal. Let's solve this by writing a program to decimalize (not to be confused with [d...
[Question] [ Write a program or function that outputs all positive integers with distinct decimal digits (OEIS: A010784) Examples: ``` 1 2 3 4 5 6 7 8 9 10 12 13 ... 96 97 98 102 103 ... 123456789 123456798 ... 9876543120 9876543201 9876543210 ``` # Rules * You can output the list of numbers in any convenient forma...
[Question] [ **Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/17415/edit). Closed 6 years ago. [Improve this question](/posts/17415/edit) ...
[Question] [ On the TV cooking show [Guy's Grocery Games](https://en.wikipedia.org/wiki/Guy%27s_Grocery_Games), the chefs cannot begin shopping until Guy Fieri, the show's host, says "Three, two, one, go!" However, the words do not have to be all together. He often "hides" the words in things like this (based on a ...
[Question] [ **This question already has answers here**: [Is string X a subsequence of string Y?](/questions/5529/is-string-x-a-subsequence-of-string-y) (68 answers) Closed 4 years ago. The Typical Way to Make an Acronym Out of a Phrase Is to Take the First Letter of Each Word: `TTWMAOPITFLEW`. howeveR, some...
[Question] [ Break two numbers up into their powers of 2, if they share any, return a falsey value. Otherwise, return a truthy value. If one input is `0`, the answer will always be truthy. if one input is `255`, the answer will be falsey if the other is not `0`. # Example Given 5 and 3 ``` 5 = 2⁰ + 2² 3 = 2⁰ + 2¹ `...
[Question] [ Let's define *f(n)* as the maximal number of regions obtained by joining n points around a circle by straight lines. For example, two points would split the circle into two pieces, three into four, like this: [![enter image description here](https://i.stack.imgur.com/Mqkp6.jpg)](https://i.stack.imgur.c...
[Question] [ This is a somewhat [proof-golf](/questions/tagged/proof-golf "show questions tagged 'proof-golf'")-like [cops-and-robbers](/questions/tagged/cops-and-robbers "show questions tagged 'cops-and-robbers'") challenge. This is the robbers' thread; [the cops' thread is here](https://codegolf.stackexchange.com...
[Question] [ **The partition function:** > > In number theory, the partition function *p(n)* represents the number of possible partitions of a positive integer *n* into positive integers > > > For instance, *p(4)* = 5 because the integer 4 has five possible partitions: * 1 + 1 + 1 + 1 * 1 + 1 + 2 * 1 + 3 * 2 + ...
[Question] [ **Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/6613/edit). Closed 1 year ago. [Improve this question](/posts/6613/edit) ## ...
[Question] [ Challenge Taken with permission from my University Code Challenge Contest --- After finishing her studies a couple of months ago, Marie opened a bank account to start receiving the payment of her first job in town. Since then she has been performing a few transactions with it. Her first payment was $10...
[Question] [ There is a challenge [Let's play tennis](https://codegolf.stackexchange.com/questions/103605) by [Daniel](https://codegolf.stackexchange.com/users/42854/daniel). He proposes to place a court in the North-South direction. My proposal is to create a court to play tennis in the East-West direction too. Yo...
[Question] [ [This is a partner question to [Calculate a probability exactly](https://codegolf.stackexchange.com/questions/51406/calculate-a-probability-exactly) ] This task is about writing code to compute a probability exactly *and quickly*. The output should be a precise probability written as a fraction in its ...
[Question] [ # Robbers' Thread In this challenge, your goal is to *crack* some code written by the Cops (their code is [here](https://codegolf.stackexchange.com/questions/44567/bowling-with-the-robbers)) by modifying it. You have *cracked* their code if: 1. Your modified code has a maximum [levenshtein-distance](ht...
[Question] [ **Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/1112/edit). Closed 3 years ago. [Improve this question](/posts/1112/edit) ##...
[Question] [ Given an integer \$ n \ge 2 \$, you need to calculate \$ \lfloor n \log\_2(n) \rfloor \$, assuming all integers in your language are unbounded. However, you may **not** ignore floating-point errors - for example, in python `lambda n:int(n*math.log2(n))` is an invalid solution, because for example for `...
[Question] [ Sales taxes in the United States are complicated, to say the least. Generally, there's a state sales tax (there are a handful of states that do not collect a state sales tax), but there could also be a county sales tax, a school district sales tax, a municipal (city) sales tax, or a metropolitan area s...
[Question] [ **Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/15615/edit). Closed 2 years ago. This post was edited and submitted for revie...
[Question] [ # Background The Python code ``` ((((((((n%35)^11)*195)|53)&181)+n)%168)*n)+83 ``` produces 74 distinct primes for \$0 \le n \le 73\$. This code also works in Java. The operators are as follows: * `+` is addition * `*` is multiplication * `%` is modulus * `&` is bitwise AND * `|` is bitwise OR * `^` is...
[Question] [ *Inspired by [this video](https://www.youtube.com/watch?v=PJHtqMjrStk) by [tecmath](https://www.youtube.com/channel/UCb7w5aTnt7YeXBcVCY0mgFw)*. An approximation of the square root of any number `x` can be found by taking the integer square root `s` (i.e. the largest integer such that `s * s ≤ x`) and t...
[Question] [ Given a positive input number \$n\$, construct a spiral of numbers from \$1\$ to \$n^2\$, with \$1\$ in the top-left, spiraling inward clockwise. Take the sum of the diagonals (if \$n\$ is odd, the middle number \$n^2\$ is counted twice) and output that number. Example for \$n = 1\$: ``` 1 (1) + (1) = ...
[Question] [ **Closed**. This question needs to be more [focused](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Update the question so it focuses on one problem only by [editing this post](/posts/15512/edit). Closed 7 years ago. [Improve this question](/p...
[Question] [ **Closed.** This question is [off-topic](/help/closed-questions). It is not currently accepting answers. --- Questions without an **objective primary winning criterion** are off-topic, as they make it impossible to indisputably decide which entry should win. Closed 8 years ago. [Improve this quest...
[Question] [ ## Definition > > A square-free semiprime is a natural number that is the product of two distinct prime numbers. > > > ## The task Given a natural number `n`, count all square-free semiprimes less than or equal to `n`. ## Details Please write a function or procedure that accepts a single integer pa...
[Question] [ *Derived from [this](https://codegolf.stackexchange.com/q/179836/43319), now deleted, post.* Given a string, answer (truthy/falsy or two consistent values) if it constitutes a good Bishop password, which is when all the following conditions are met: 1. it has at least 10 characters 2. it has at least 3...
[Question] [ [Machine epsilon](http://en.wikipedia.org/wiki/Machine_epsilon) is an important floating point number to know when doing numerical calculations. One way to understand it is when this relation ``` 1 + machine_epsilon > 1 ``` does not hold. One (iterative) way to extract it is executing a small program l...
[Question] [ This is a fairly simple code golf challenge. Your program, given an ASCII string, is to parse that string into two strings, which it will evaluate. If the second string is "later" than the first one, it will return a 1, if it is "earlier" than the first one, it will return a -1, and if they are the sam...
[Question] [ [Grimm's conjecture](https://en.wikipedia.org/wiki/Grimm%27s_conjecture) states that, for any set of consecutive composite numbers \$n+1, n+2, ..., n+k\$, there exist \$k\$ distinct primes \$p\_i\$, such that \$p\_i\$ divides \$n+i\$ for each \$1 \le i \le k\$. For example, take \$\{24, 25, 26, 27, 28\...
[Question] [ Your task is to write a program which implements a bijection \$\mathbb{N}^n\to\mathbb{N}\$ for \$n \ge 1\$. Your program should take \$n\$ natural numbers as input, in any [acceptable method](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods) (including t...
[Question] [ This function should take four integer inputs (`a`,`b`,`c`,`d`) and return a binary word based on which values equal the maximum of the four. The return value will be between `1` and `0xF`. For example: `a = 6, b = 77, c = 1, d = 4` returns `2` (binary `0010`; only 2nd-least significant bit is set corr...
[Question] [ Related: [Interquine](/questions/129772) Program A outputs program B's code when run, and B outputs C's source, and C outputs A's source. This time you can't exchange two characters and exchange again :) ### Requirements: * Only one language across all programs * Standard loopholes restrictions apply *...
[Question] [ Tired of always wondering how many more Pokémon you need to catch to get those high-tier evolutions? Wonder no more! Now you will write a complete program or function to calculate it for you! ## The Challenge: As input, your program will receive a list of the costs in candy to evolve a Pokémon to the n...
[Question] [ Since jq is the [Language Of The Month for September 2021](https://codegolf.meta.stackexchange.com/questions/23836/language-of-the-month-for-september-2021-jq/23837#23837), what general tips do you have for golfing in [jq](https://stedolan.github.io/jq/)? I'm looking for ideas which can be applied to c...
[Question] [ This is a rock paper scissors competition. Algorithms will face each other in 100 rounds of rock paper scissors. Except that the algorithms will also be able to read the source code of each other! # Leaderboard ``` 1. Chaos Bot (by Aiden4) - 27 Points, 168 bytes 2. Anti-99%-of-posts (by Lyxal) - 24 Poi...
[Question] [ # Challenge Given a positive integer `n`, you must calculate the nth digit of \$e\$, where \$e\$ is Euler's number (2.71828...). The format of the output can be a number or a string (e.g., `3` or `'3'`) ## Example ``` # e = 2.71828... nthDigit(3) => 8 nthDigit(1) => 7 nthDigit(4) => 2 ``` Shortest code...