instruction
stringlengths
34
53.1k
Input: We take two inputs: An input b with two distinct values: Left and Right.† And a positive integer n. Output: Based on the Left/Right input, we output either of the following two sequences in the range of 1-n (in the sequences below the first 125 items are displayed): Left: 1, 6, 7, 56, 57, 62, 63, 960, 961, 96...
Codegolf the hamming code (with distance equals 3)! The sequence looks like this: 0, 7, 25, 30, 42, 45, 51, 52, 75, 76, 82, 85, 97, 102, 120, 127, 385, 390, 408, 415, 427, 428, 434, 437, 458, 461, 467, 468, 480, 487, 505, 510, 642, 645, 667, 668, 680... Task Given n output the first n items in OEIS sequence A075926. Y...
Given two strings, output a third string that is not equal to either of the two inputs, but has the same length (in characters) as either of the inputs. There is guaranteed to be at least one valid output. Test Cases Test cases are quoted to show they are strings. Outputs are one of many possible. input, input -> outpu...
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...
Manually summing a Cubically cube's faces is tedious and time-consuming, sorta like writing code in Cubically itself. In Most efficient cubifier, I asked you to translate ASCII to Cubically source. One of the answers there uses a cube initialization sequence and then modifies the resulting cube based on the sums of the...
Given a prime P greater than 10, your program or function must figure out its divisibility rule x, defined as the integer with smallest absolute value which yields a multiple of the original prime when multiplied by the last digit of the prime and added to the rest of the original prime. Example Given an input 31, the ...
This is a simple challenge which hopefully may lead to some creative answers. Quoting Wikipedia: "Dual-tone multi-frequency signaling (DTMF) is an in-band telecommunication signaling system using the voice-frequency band over telephone lines between telephone equipment and other communications devices and switching cen...
When I was younger, I had a big map of the US tacked up on my wall across from my bed. When I was bored, I would stare at that map and think about stuff. Stuff like the four-color-theorem, or which state bordered the most other states. To save younger me some brainpower in counting, you are going to invent a time machi...
The challenge Given positive integer input n (n>1), calculate the array of unique factorizations of n, not including 1. Order does not matter. Test cases 2 => [[2]] 3 => [[3]] 4 => [[4],[2,2]] 5 => [[5]] 6 => [[6],[2,3]] 7 => [[7]] 8 => [[8],[2,2,2],[2,4]] 9 => [[9],[3,3]] 10 => [[10],[2,5]] 11 => [[11]] 12 => [[12],[3...
Squares looks symmetric, and so are the required codes. Objective: Write a program whose source code is a solid square (N lines with N printable, non-whitespace characters each line) and prints a square of equal size. A program (or output) with inconsistent width and height is invalid. (e.g. 6x5) Example (HQ9+) QAA AAA...
You are given 6 numbers: 5 digits [0-9] and a target number. Your goal is to intersperse operators between the digits to get as close as you can to the target. You have to use each digit exactly once, and can use the following operators as many times as you want: + - * / () ^ sqrt sin cos tan. For example, if I'm give...
Given a square string, produce all the output for the string at every stage of unfurling. The string must unfurl in a clockwise direction one quarter turn at a time. Examples Input: A Output: A Note: I'll also accept the input duplicated for this particular test case only if this helps reduce your byte count. Input: ...
It is fairly simple to, given a number n, create a range from 0 to n-1. In fact, many languages provide this operation as a builtin. The following CJam program reads an integer, and then prints out such a range (Try it online!): ri, Notice that it prints out numbers without a separator. The Challenge Your task is to r...
Given an integer n as input, return a list containing n, repeated n times. For example, the program would take 5 and turn it into [5,5,5,5,5]. The elements need to be integers, not strings. No built-in functions that accomplish the task are allowed. This is code-golf, so standard rules apply.
"First they came..." is a poem by Martin Niemöller: First they came for the Socialists, and I did not speak out- Because I was not a Socialist. Then they came for the Trade Unionists, and I did not speak out- Because I was not a Trade Unionist. Then they came for the Jews, and I did not speak out- Because I was not a...
Here is the sequence I'm talking about: {1, 4, 5, 9, 10, 11, 16, 17, 18, 19, 25, 26, 27...} Starting from 1, keep 1, drop the next 2, keep the next 2, drop 3, keep 3 and so on. Yes, it's on OEIS (A064801), too! The Challenge Given an integer n>0, find the nth term of the above sequence Test Cases Input -> Output ...
This challenge is a simple ASCII-art challenge inspired by the solar eclipse that happened on August 21, 2017. Given an input 0 <= n <= 4, output the corresponding stage of the eclipse described below: n=0: ***** ** ** * * * * ** ** ******* n=1: ***** ** ***** * ******* * *****...
Given an array of non-negative integers, your task is to only keep certain elements of it, as described below. Let's say the array is [1, 3, 2, 4, 11, 5, 2, 0, 13, 10, 1]. First get the first element of the array, n. Keep the first n elements and discard the next one (discard the n+1th). The new array is [1, 2, 4, 11...
Given a nonnegative integer n, your solution must output a program in your chosen language whose output has n times as many bytes as the outputted program. Rules You must specify the language and encoding of the programs your solution outputs, and you may not choose different languages or encodings for different input...
Note: This challenge has nothing to do with actual assembly language. As the head of Code-Golf Factory Inc., you must create an assembly line to generate a specific piece of code. Today, the foreman has asked you to produce quines. Specification: In this challenge, the goal is to write a quine such that a proper subse...
The game of Ghost is played between two players who alternate saying a letter on each turn. At each point, the letters so far must start some valid English word. The loser is the player to complete a full word first. So, for example, if the letters so far are E-A-G-L, then the only valid next letter to say is "E" an...
Since 2009, Android's version code names have been confectionery-themed. Android 1.5 is Cupcake, Android 1.6 is Donut, Android 2.0 is Eclair, etc.. In fact, the version names are alphabetical! C -> Cupcake D -> Donut E -> Eclair F -> Froyo G -> Gingerbread H -> Honeycomb I -> Ice Cream Sandwich J -> Jellybean K -> Kitk...
Write a proper quine containing at least one newline/linefeed whose every unfurling is either itself a proper quine or outputs the original quine. Your answer can mix and match outputting itself and outputting the original quine. Unfurlings Unfurlings consist of: Appending spaces to make the input a rectangle. Taking ...
Let's count... Count up to 2 and back to 1 Count up to 4 and back to 1 Count up to 6 and back to 1 ... ok you got it... put all these together and you'll get the following sequence {1,2,1,2,3,4,3,2,1,2,3,4,5,6,5,4,3,2,1,2,3,4,5,6,7,8,7,6,5,4,3,2,1,2,3...} Challenge Given an integer n>0for 1-indexed (or n>=0 for 0-i...
This challenge is based on a drinking game. I advise against alcohol consumption while programming. In this game, the players count up in turns: the first player says 1, the second says 2 and so on. Here's the twist however: each number that is divisible by 7 or has a 7 in its digits (in base 10) is replaced by another...
Given a letter of the English alphabet, your task is to build a semi-diagonal alphabet to the input. How to build a Semi-Diagonal alphabet? Brief Description: First, you take the position of the letter in the alphabet, P (P is 1-indexed here). Then, you print each letter until the input (inclusive) on a line, precede...
Take three inputs, a string of text, T; a string of characters to replace, F; and a string of characters to replace them with, R. For each substring of T with the same (case insensitive) characters as F, replace them with the characters in R. However, keep the same case as the original text. If there are more character...
Input no input for this challenge The Challenge Write a code that outputs: The first 10 prime numbers whose sum of their digits equal the number of bytes of your code Examples Let's say your code is Co&%423@k"oo" which is 13 bytes your code must output [67, 139, 157, 193, 229, 283, 337, 373, 409, 463] those are the fi...
COBOL is a very old language, at the time of writing it is 58 years old. It is so old, in fact, that it has a very interesting quirk: the first six characters of each line are comments. Why is this, you ask? Well, those 6 characters were intended to be used as line numbers, back in the day where programs weren't comple...
Given a number n, Output an ordered list of 1-based indices falling on either of the diagonals of an n*n square matrix. Example: For an input of 3: The square shall be: 1 2 3 4 5 6 7 8 9 Now we select all the indices represented by \, / or X (# or non-diagonal positions are rejected) \ # / # X # / # \ The output sha...
Your task is to given two integer numbers, a and b calculate the modular multiplicative inverse of a modulo b, if it exists. The modular inverse of a modulo b is a number c such that ac ≡ 1 (mod b). This number is unique modulo b for any pair of a and b. It exists only if the greatest common divisor of a and b is 1. Th...
Write the minimal code you need to take a screenshot of your application window. I am not asking for a function or program; just only a code segment. It has obviously to be a GUI application; console applications not allowed. Input: None. Output: The valid outputs are: Clipboard. Then post a screenshot of the Paste co...
It's obviously ellipsisessieses. Inspired by a chat message. Your challenge Given a list or space or comma-separated string of words, ellipsisessiesesify them. To ellipsisessieses-ify a word: Start with the word. Add the first letter of the original word to the end. Add 2 of the last letter of the original word to the...
Primes are everywhere... they hide inside Pi 3.1415926535897932384626433832795028841971693993751 Let's get those primes! The Challenge Given as input an integer n>0, find out how many primes are hidden inside the first n digits of Pi Examples For n=3 we should search for primes in [3,1,4]. There are 2 Primes (3,31), so...
You just recently got a new phone, but you don't quite like the way it vibrates, you've decided you want to create your own vibration patterns. So, you've written a program where you used the keywords long, short and pause to make your phone vibrate according to these keywords. Task Create a small program that accepts ...
Given a date written in any (must handle all in the same program) of the following formats, parse it into a valid yyyy/mm/dd date. 17th May 2012 March 14th, 2016 20 February 2014 September 14, 2017 Sunday, June 8, 2015 Rules Dates will sometimes be invalid, ie. incorrect day for the month or number of months in a yea...
Satan-Primes who are they? they are Primes containing 666 these are Satan-Primes:[46663,266677,666599,666683,616669] these are NOT :[462667,665669,36363631,555] Plot Every number bigger than 6661 has Satan-Primes behind him The Challenge Given an integer n>6661 find the Satan-Prime behind (or equal) and closest to itse...
A simple graph is toroidal if it can be drawn on the surface of a torus without any edges intersecting. Your task is to take a simple undirected graph via any reasonable method (adjacency matrix, edge vertex sets, etc.) and decide whether or not it is a toroidal graph. You should output one of two distinct values for...
Imagine you have two boxes B(x) and B(y), each containing an unknown bit - 0 or 1, and a machine F that can X-ray them and produce a third box for B(x^y) (xor). F can also compute B(x*y) (and). In fact, those are just special cases of the the single operation the machine can perform - inner product each, denoted with F...
Lets define the process of crushing an array of numbers. In a crush we read the array left to right. If at a point we encounter two of the same element in a row we remove the first one and double the second one. For example here is the process of crushing the following array [5,2,2,3] ^ [5,2,2,3] ^ [5,2,2,3] ...
Write some code... Write a program that takes no input and outputs an integer n which is a multiple of 3. So n=3k, where k is a positive integer. Double the last character of your code. Your code should then output k. Examples Here is my program hui#2(21+4)//lm, which outputs 81. Because of that, hui#2(21+4)//lmm shoul...
At the Code-Golf™ Psychological Society, you are delighted to present a new method of measuring mental age: Abstract Capacity™. To get the Abstract Capacity of a person, you take their actual age divided by 4, take their IQ divided by 9, then add the two values together. Then, round this sum down to find the Abstract C...
Cut a boolean matrix in 4x2 blocks and render them as Braille characters U+2800...U+28FF. [[0,1,0,0,1,0], [1,0,0,0,0,0], [1,0,0,0,1,0], [1,1,1,1,0,0]] ⣎⣀⠅ Pad with 0-s if dimensions are not multiples of 4 and 2. [[0,1,0], [1,0,0], [1,1,1]] ⠮⠄ Usual golfing rules apply, flexible on input format. Output should e...
Inspired by a question at Stack Overflow. Given a non-empty array of integers x and a positive integer n, compute the sum of each sliding block of length n along the array x, circularly filling the missing values at the left with values from the right as follows: the first block contains the first entry of x, preceded...
Who are they? Primus-Orderus Primes (POP) are primes which contain their order in the sequence of primes. So the nth prime, in order to be POP, must contain all the digits of n in a certain way which I'll explain. Examples Let's get things clearer: All digits of n must appear among the digits of POP in the same order t...
Earlier I defined the process of crushing an array In a crush we read the array left to right. If at a point we encounter two of the same element in a row we remove the first one and double the second one. For example here is the process of crushing the following array [5,2,2,4] ^ [5,2,2,4] ^ [5,2,2,4] ^ [5...
Inspired (with the explanation stolen from) this Background Say you have two lists A = [a_1, a_2, ..., a_n] and B = [b_1, b_2, ..., b_n] of integers. We say A is potentially-divisible by B if there is a permutation of B that makes a_i divisible by b_i for all i. The problem is then: is it possible to reorder (i.e. perm...
Convert a binary number (of any size) into a hexadecimal number. Input A POSITIVE binary number with just the 0s and 1s. A valid input will always match the following regex: [0-1]+. If the input is not a valid binary number, that is, anything not matching this regex, the output should be 0 or the program should exit,...
Given the written, spelled-out representation of an integer from 1 to 10^15-1 inclusive, convert it to an actual integer in decimal. Input Format The input will always be a string of groups, where each group is composed only of letters and spaces(). The groups are separated by commas. You may choose whether you want t...
Introduction: I think most people will know how darts work. But since some might not, here are the rules of playing Darts in a nutshell: Amount of players: 2 Starting points: 501 Goal: Get your points to 0 first Darts per player: 3 Available numbers on the board: 1 through 20, and Bulls-eye Here is the layout of a Da...
You will be given two arrays of floating-point numbers. Your task is to pair the corresponding elements of the two arrays, and get the maximum of each pair. However, if the two corresponding elements are equal, you must take their sum instead. For example, given the lists [1, 3, 3.2, 2.3] and [3, 1, 3.2, 2.6], you must...
Input: A string Output: 1) First we take remove character at the end of the input-string until we are left with a length that is a square (i.e. 1, 4, 9, 16, 25, 36, etc.) So abcdefghijklmnopqrstuvwxyz (length 26) becomes abcdefghijklmnopqrstuvwxy (length 25). 2) Then we put this in a square, one line at a time, left t...
Everyone loves slicing in python, as in array[5] to access the fifth element or array[:5] to access the zero through fourth element or array[::-1] to reverse an array. However, these all have seemingly distinct notations. When and where should the colons and integers be placed? Task Your task is to change any valid sli...
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...
Robber's Thread here In this cops-and-robbers challenge cops will think of a positive integer. They will then write a program or function that outputs one value when provided the number as input and another value for all other positive integer inputs. Cops will then reveal the program in an answer keeping the numbe...
Cop's thread here In this cops-and-robbers challenge cops will think of a positive integer. They will then write a program or function that outputs one value when provided the number as input and another value for all other positive integer inputs. Cops will then reveal the program in an answer keeping the number a...
The Challenge Given an integer n>0 output a n+1 X n+1 matrix containing all integers from 1 to 2n as shown in the test cases bellow Test Cases n=1 1 2 2 2 n=2 1 2 4 2 3 4 4 4 4 n=5 1 2 3 4 5 10 2 3 4 5 6 10 3 4 5 6 7 10 4 5 6 7 8 10 5 6 7...
Ouput the following banner: _____ _ _____ _ __ / ____| | | / ____| | |/ _| | | ___ __| | ___ | | __ ___ | | |_ | | / _ \ / _` |/ _ \ | | |_ |/ _ \| | _| | |___| (_) | (_| | __/ | |__| | (_) | | | \_____\___/ \__,_|\___| \_____|\___/|_|_| The code ...
The goal is to get all combinations of hold'em starting hands (every two card combination) in the shortest amount of code. A hold'em hand is two distinct cards dealt from a standard deck of 52 cards, with deal-order being irrelevant, as such there are 52*51/2 = 1326, hands. There is also a commonly used notation for th...
This is the robbers' post. The cops' is here. Your challenge is to take a cop's post and find an input that the regex matches but the program returns a falsey value. Once you have cracked a cop's post, comment in a link to your crack. (If you don't have enough rep to comment, please say so, and someone will do it for y...
This is the cops' post. The robbers' is here. You make a program and a regex. For most inputs, one of the following happens: the regex doesn't match, and the program returns a falsey value the regex doesn't match, and the program returns a truthy value the regex matches, and the program returns a truthy value But for...
Given a list of production rules and start symbol of a proper finite context-free grammar (CFG) of printable characters, your program or function must output its formal language (the set of all sentences which can be constructed from it). Task A context-free grammar is formally defined as a 4-tuple of a few parts. Here...
Related: I double the source, you double the output! When Steve Jobs launched the iPhone 3G, the slogan said Twice as fast, half the price I changed the word fast to long to better represent this challenge. Objective Write a program that outputs a non-zero, even integer. If the source code is doubled, the value of t...
Given a matrix a of characters from u=" ╶╺╵└┕╹┖┗╴─╼┘┴┶┚┸┺╸╾━┙┵┷┛┹┻╷┌┍│├┝╿┞┡┐┬┮┤┼┾┦╀╄┑┭┯┥┽┿┩╃╇╻┎┏╽┟┢┃┠┣┒┰┲┧╁╆┨╂╊┓┱┳┪╅╈┫╉╋" the coordinates of a submatrix as x,y,w,h (left, top, width>1, height>1) a thickness t of 1 (as in ┌) or 2 (as in ┏) render an inner border for the submatrix with the specified thickness, taking i...
Most of us know... that all primes p>3 are of the form But, how many are the Plus Primes (6n+1) and how many are the Minus Primes (6n-1) in a certain range? The Challenge Given an integer k>5 , count how many primes<=k are PlusPrimes and how many are MinusPrimes. Examples for k=100 we have [5, 11, 17, 23, 29, 41, 4...
Given two inputs -- one of them a non-empty printable ASCII string (including space, excluding newline), the other being one of two distinct, consistent values of your choice (1 / 0, l / r, left / right, etc.) -- output an ASCII art airplane banner of the string, pointing either left or right. For consistency, I'll be ...
Given an array of positive integers, output a stable array of the distinct prime factors of these integers. In other words, for each integer in the input in order, get its prime factors, sort them, and append any primes not already in the output to the output. Test Cases [1,2,3,4,5,6,7,8,9,10] -> [2,3,5,7] [10,9,8,7,6,...
Let's talk about divisors... Leaving out perfect squares (for a moment), all positive integers can be expressed as the product of 2 of their divisors. Quick example for 126: Here are all the divisors of 126 As you can see all the divisors can be paired. Here are what we will call the Divisor Pairs: [1, 126], [2, 63], ...
You are on an advanced intergalactic space station. A friend of yours who is minoring in the Study of Gravity just created a game that involves using microgravity as a way to move a ball around. She hands you a small controller with four directional arrows on it and a maze like structure with a ball sitting to the lef...
Background At the time of writing this, the P vs NP problem is still unsolved, but you might have heard of Norbert Blum's new paper claiming proof that P != NP, which is already suspected to be erroneous (but we will see). The problem discussed in this paper is the clique problem. At least that's what I read in a newsp...
A few month back, I made a language called ;# (Semicolon Hash) and it started a little bit of a craze (it even got its own tag, as you can see). But, as with everything, the craze died down, and questions related to it stopped being posted. However, a few people were annoyed at the lack of capability of ;# and this lea...
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) = 2 Example for \$n =...
Based on the interpretation user @ThePirateBay made from the first version of my own challenge Output diagonal positions of me squared now I challenge you to make ASCII art that draws diagonal lines based on a square character matrix based on a given number n. Input A number n. Output A square matrix of size n^2 which...
Convert a number to a sum of digits Not any sum: we need the shortest sum Not any digits: you can use only digits of the number Example You will be given as input an integer n>0 Let's say n=27. You have to express 27 as a sum, using only the digits [2,7], in the shortest way possible. You don't have to use all the digi...
You're a chef and you love cooking with your spices, but recently you've taken a liking to organizing your spices based on how often you use them. But you have no time to be writing down when you used your spice last. Simply, you swap and move spices around, and this seems to do the trick. But of course you're a chef a...
Given a number n, calculate the amount of bases in the range of [2, n) in which b(n) is a Palindrome. Example n = 8 has the base conversions: 2 = 1000 3 = 22 4 = 20 5 = 13 6 = 12 7 = 11 Of which 2 of them, 3 = 22 and 7 = 11 are palindromes. So return 2. Clarifications For the sake of convenience, Your answer only ne...
Normally, we decompose a number into binary digits by assigning it with powers of 2, with a coefficient of 0 or 1 for each term: 25 = 1*16 + 1*8 + 0*4 + 0*2 + 1*1 The choice of 0 and 1 is... not very binary. We shall perform the true binary expansion by expanding with powers of 2, but with a coefficient of 1 or -1 ins...
The partition number of a positive integer is defined as the number of ways it can be expressed as a sum of positive integers. In other words, the number of integer partitions it has. For example, the number 4 has the following partitons: [[1, 1, 1, 1], [1, 1, 2], [1, 3], [2, 2], [4]] Hence, it has 5 partitions. This...
A game of 2048 goes like this: Every move you get another piece - either 2 90% of the time, or 4 10% of the time for each 2 equal pieces combined you get a piece of the sum of the two and the sum gets added to your score Your task given a board of a 4x4 game, give the average score of what A game like that would resu...
I was playing around with some numbers and found a sequence that, of course, is on OEIS. It is A005823: Numbers whose ternary expansion contains no 1's. It goes: a(2n) = 3*a(n)+2 a(2n+1) = 3*a(n+1) a(1) = 0 a = 0,2,6,8,18,20,24,26,54.... I wrote a CJam program that generates the first n of these numbers by convertin...
Inspired by this. Given a string as input consisting of only upper and lowercase alphabet characters, wicka-wub it. How do I wicka-wub a string? The example text used is "DJMcMayhem". Split the string before each capital letter, so you get ["D", "J", "Mc", "Mayhem"]. Next, take the two halves of the list as sublists. T...
Inspired by Braille graphics Given a Boolean matrix (i.e., consisting of only 1s and 0s), output an ASCII-art-style Unicode representation of the closed-polygon shape created by the 1s in the matrix, using the Unicode drawing characters ┌ ─ ┐ │ └ ┘ (code points 0x250c, 0x2500, 0x2510, 0x2502, 0x2514, and 0x2518, respec...
Does your language have a maximum recursion depth (MRD)? Let's say your language has MRD=500 Write a code that finds the recursion depth and outputs the exact value For the case above your program (or function) should output 500 Code-Golf Shortest answer wins!
Given a string representing a number and the base that number is in, shift each positional value upward, wrapping back to zero if the value cannot increase. You will never be provided invalid input, nor a base larger than 36. For example, you may be provided ['5f6', '16'], which represents the number 1526 in base 16. T...
Takuzu is a logic game in which you have to complete a grid with cells containing 0s and 1s. The grid must follow 3 rules: No three horizontal or vertical consecutive cells can be the same. There must be an equal number of 0s and 1s in each row and column. No two rows can be the same, and no two columns can be the sam...
Six is a number perfect in itself, and not because God created all things in six days; rather, the converse is true. God created all things in six days because the number six is perfect. I am fascinated by numbers. As were Sophie Germain and Marin Mersenne. To be more specific, these two were fascinated by primes: a ...
Write a program or function that draws an ASCII star, given the size of the arms as input. Here's a star of size 1 _/\_ \ / |/\| Here's a star of size 2 /\ __/ \__ \ / \ / | /\ | |/ \| Here's a star of size 3 /\ / \ ___/ \___ \ / \ / \ / | /\ | | / \ | |/...
Your task here will be to implement a function1 that forms a permutation on the positive integers (A bijection from the positive integers onto themselves). This means that each positive integer should appear exactly once in the permutation. The catch is your function should have a larger probability of outputting an ...
Background You're an attractive code golfer and quite a few people are asking you out. You don't have time to think about which days exactly you're available, so you decide to create a function the accepts a date and returns the days of that week. You then take those days of the week, insert it into your calendar progr...
Background The Collatz Conjecture is quite well-known. Take any natural number. Triple and increment if odd; cut in half if even. Repeat, and it will reach 1 eventually. This famous conjecture, however, is only that, for it is yet unproven. Little-known to the world, that was not Lothar Collatz's first attempt at fame....
Consider the following triangle. 1 23 456 7891 01112 131415 1617181 92021222 324252627 2829303132 33343536373 839404142434 4454647484950 51525354555657 585960616263646 5666768697071727 37475767778798081 As you probably noticed, the first row is of length 1, and each row thereafter is 1 digit longer than to the previo...
Inspired by a meme I saw earlier today. Challenge description Consider an infinite alphabet grid: ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ... Take a word (CODEGOLF in this example) and make it a subsequence of the grid, repl...
As the majority of nations using the Euro have the , as the decimal separator, you must use it also. The task is to output all the values of the Euro coins and notes in ascending order. You must also put the trailing ,00 on the integer values. 0,01 0,02 0,05 0,10 0,20 0,50 1,00 2,00 5,00 10,00 20,00 50,00 100,00 200,0...
In number theory, a strong prime is a prime number that is greater than the arithmetic mean of the nearest prime above and below (in other words, it's closer to the following than to the preceding prime). Given an input integer, n, where n >= 0, your task is to generate the first n strong primes. For example, the six...
Taking in Input Define a function f as follows: IF x < 0: f(x) = -√|x| ELSE: f(x) = √x In your programs/functions, each point (x, y) given as input will correspond to the point (f(x), f(y)). For example, if the points (4, -2) and (-1, 5) are given as input, your program will be dealing with the points (2, -√2)...
Task Given an integer, n, where 3 <= n < 2^32, calculate the area of a regular n-gon, with an apothem of 1, using the formula A = n * tan(π / n). The apothem of a regular polygon is a line segment from the center to the midpoint of one of its sides. Output the area of this regular polygon as a floating point value sh...
Introduction My calculator is behaving weird. Sometimes when I type in an 8 it displays a 2. And sometimes when I type in a 6 it displays a +. Some buttons are mixed up! Could anyone help me determine which? Challenge: Input: List of incorrect equations, with correct results. Output: The two buttons that are swapped. F...
In The Settlers of Catan board game, there are five resource types: Brick, Log, Ore, Wheat, and Sheep. Building a settlement costs a Brick, a Log, a Wheat, and a Sheep. However, you can also trade in four identical resources to get a resource of a different type. For instance, if you had four ores in your hand, you cou...
Haskell has tuples that can be written as (a,b,c) However this is just syntactic sugar for (,,)a b c In general an n tuple can be formed with n-1 ,s between (...) followed by its elements separated by spaces. For example the 7-tuple, (1,2,3,4,5,6,7) can be formed by (,,,,,,)1 2 3 4 5 6 7 Since Haskell does not have...
Given a positive integer n, compute the nth Wilson number W(n) where and e = 1 if n has a primitive root modulo n, otherwise e = -1. In other words, n has a primitive root if there does not exist an integer x where 1 < x < n-1 and x2 = 1 mod n. This is code-golf so create the shortest code for a function or program t...