instruction stringlengths 34 53.1k |
|---|
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... |
Given a string that consists entirely of printable ASCII, convert all lowercase letters to their uppercase equivalent. Non-lowercase characters are left untouched.
I am not going to outright ban builtin solutions, but if you are going to post a solution that uses the builtin, please also post one that doesn't in your a... |
(This is my first code-golf question)
When I was a child, my dad and I invented a game where the license plate we see on cars can give certain points based on some rather simple rules:
X amount of the same letter or number give X-1 points, examples:
22 = 1 point
aa = 1 point
5555 = 3 points
The numbers must be next to... |
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 sales tax. There c... |
Given one of the following inputs: Sweet Onion Chicken Teriyaki
Oven Roasted Chicken
Turkey Breast
Italian BMT
Tuna
Black Forest Ham
Meatball Marinara output a number from 1-7 (or 0-6) representing the day of the week that you get that deal, starting with Monday as the lowest number. Input can be all lowercase or uppe... |
Help! My device malfunctions and whenever I try to repeat a String, I get a messy results. Instead of repeating the same string N times, it fills an NxN square with each of its characters, and stacks the squares up.
For example, given the String "Test" and the number 2, instead of "TestTest", I get:
TT
TT
ee
ee
ss
ss
t... |
I recently watched The Wizard Of Oz and thought that when Dorothy taps her shoes together three times, it would be easier if she used a program to do it. So let's help her.
Task
Output slippers being tapped together 3 times.
Output
Slippers being tapped together. A pair of slippers not being tapped looks like this:
_... |
Inspired by a bug in a solution to this challenge, your challenge is to produce this exact text:
ZYXWVUTSRQPONMLKJIHGFEDCBA
YXWVUTSRQPONMLKJIHGFEDCBA
XWVUTSRQPONMLKJIHGFEDCBA
WVUTSRQPONMLKJIHGFEDCBA
VUTSRQ... |
Given an integer n > 2, print or return the smallest non-negative integer k such that a(n, k) = 9, where a(n, k) is defined by:
a(n, 0) = n
a(n, k+1) =
a(n, k) / 2 + 1 if a(n, k) is even
the sum of the digits of a(n, k)² (in base 10) if a(n, k) is odd
Examples
For n = 5, the expected output is k = 4:
a(5, 0) = 5
a(... |
Write a quine that outputs the complement of the source code from the smallest containing power of two. Here's an example:
IN : source
OUT: \r\x11\x0b\x0e\x1d\x1b
The largest code point in the string "source" is the letter u, which is 117. The smallest containing power of 2 would be 128, so all the code points are tak... |
Input:
A positive integer N.
Challenge:
Suppose you have a list of integers n = 1, 2 ... N. Output a list of integers, where each number is the maximum power of 2, m, such that 2^m divides each number of n.
Test cases:
1
0
15
0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
100
0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, ... |
In prefix notation, the operator comes before the arguments, so you can kind of imagine that the operator calls next() which is recursively called. In infix notation, the operator goes between the arguments, so you can imagine it simply as a parse tree. In postfix notation, the operator comes after the arguments, so yo... |
Given a "T" shape on an x * y number grid, with length W on the top bar and H on the stem of the T, with the bottom of the T on the square numbered n: calculate the total of all of the numbers in the T shape. W must be an odd number and all must be positive integers.
Here are some examples of valid T's on a 9*9 grid:
... |
When you edit a post on SE, any further edits within a 5-minute grace period are merged into it. Given a list of times you edit a post, count the edits not in a grace period.
Say you edit at minutes [0,3,4,7,9,10,11,12]. This results in 3 edits at times [0,7,12], with the rest happening in their grace periods.
0: [3,4... |
Introduction
This is a log of length 5:
#####
I want to pile a bunch of these logs on top of each other.
How I do this is that I slide a new log onto the topmost one from the right, and stop sliding when their left or right ends align (don't ask why).
If the new log is longer, it slides all the way to the left end of ... |
Background
We all know the famous Fibonacci sequence, where each term is the sum of the previous two, with the first term being 0 and the second one being 1. The first few elements are:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765
What we are going to implement today is a si... |
Challenge:
Take a list, L containing positive integers as input:
3 5 2 1 6
and create a matrix where the n'th column contains the vector 1:L(n), where shorter rows are padded with zeros.
Test cases:
3 5 2 1 6
-----------------
1 1 1 1 1
2 2 2 0 2
3 3 0 0 3
0 4 0 0 4
0 5 0 ... |
In one of this question's bonuses I asked you to design a permutation on the natural numbers such that the probability of a random term being odd was \$1\$. Now let's kick it up a notch. I want you to design and implement a permutation, \$f\$, on the natural numbers such that, for every integer \$n\$ greater than 0,... |
Specifications
For this challenge, you will be given a matrix of some sort in any reasonable format for a 2-D array. For each row except the last, in order from top (first) to bottom (last), rotate the row below it by x to either direction (you choose a consistent direction to use) where x is the first element in the c... |
Based on this Math.SE question; number copied from this answer. Number originally from a Numberphile video, of course.
Your task is to output the following 1350-digit prime number:
8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888881111111111111111111111118888881111111111111111... |
Write a program that displays on the screen the sum of the divisors of a number (1 ≤ N ≤ 100) entered by the user in the range of 1 to N.
This is OEIS A000203.
Examples:
Input: 7
7 / 1 = 7
7 / 7 = 1
7 + 1 = 8
Output: 8
Input: 15
15 / 1 = 15
15 / 3 = 5
15 / 5 = 3
15 / 15 = 1
15 + 5 + 3 + 1 = 24
Output: 24
Input: ... |
My job is stacking pebbles into triangular piles. I've only been doing this for a century and it is already pretty boring. The worst part is that I label every pile. I know how to decompose pebbles into piles of maximal size, but I want to minimize the number of piles. Can you help?
Task
Given an integer, decompose it ... |
This question is inspired by this answer. Coincidentally, I used to use Ethiopian Multiplication when I was a kid, but had never known the name of the method until recently.
Ethiopian multiplication is a method of multiplying integers using only addition, doubling, and halving.
Method:
Take two numbers to be multiplie... |
Based on this challenge and this Math.SE question. Idea originally come from a Numberphile video. The goal is to reproduce the logic of Professor McKee when he builds this prime.
Your task is to build the Trinity Hall Prime, at a much lower scale. You are given a single number N greater than 2, representing the length ... |
This is how the Kolakoski sequence (OEIS A000002) is defined:
The Kolakoski sequence is a sequence that contains 1 and 2, and the nth element of the sequence is the length of the nth group of equal elements (run) in the sequence itself. The first 20 terms of the sequence and the respective lengths are:
1 2 2 1 1 2 1 2... |
Based on a chat message
The Challenge
Given an input number \$n > 9\$, construct its reverse, ignoring leading zeros. Then, construct a list of all prime factors that the number and its reverse don't have in common. Multiply those factors together to create the Uncommon Factor Number of the input.
Or, to put it another... |
I'm one of the authors of Gimli. We already have a 2-tweet (280 chars) version in C but I would like to see how small it can get.
Gimli (paper,website) is a high speed with high security level cryptographic permutation design that will be presented at the Conference on Cryptographic Hardware and Embedded Systems (CHES)... |
Weirdo Incorporates have a weird way of grading their staffs by the number of days they were present in the office:
0 - 13 : F
14 - 170 : E
171 - 180 : D
181 - 294 : C
295 - 300 : B
301 - 365 : A
Note: The range is inclusive (i.e. 0-13 means 0 days and 13 days both will evaluate
as grade 'F').
Objective:
Write ... |
Background
Inspired by I'm a palindrome. Are you?, where it is presented the shocking fact that “()() is not a palindrome, but ())(”, I asked myself what instead is ()() and the answer is simply: it is a string with a vertical symmetry axis!
The task
Write a program or function that takes a string S (or the appropriate... |
They say that hate is a strong word. I wanted to find out why, so I had a good look at the word.
I noticed that every consonant had a vowel after it. That made it look quite strong to me, so I decided that that's what makes a word strong.
I want to find more strong words, so I'll need a program for it!
Finding strong w... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.