instruction stringlengths 34 53.1k |
|---|
(inspired by Helka's response to my random pairing of "chess" and "Fibonacci" tags in chat)
Fibonacci
The Fibonacci numbers are one of the more well-known sequences in mathematics, where each number is composed by adding the two previous numbers together. Below is a definition of the zero-indexed sequence:
f(0) = 0
f(... |
This is the cops' thread. The robbers' thread is here.
Your challenge is to make a program that runs forever without halting1, unless it gets a particular input or inputs2. If it receives that input, it must terminate in a finite amount of time3. This is code-golf, so the shortest answer that has not been cracked by a ... |
This is the robbers' thread. The cops' thread is here.
Your challenge is to crack a cop's submission by finding an input that makes it halt. You don't have to find out why, or all inputs that make it halt if there's more than one, or the input the cop intended, just one input will do.
Once you have cracked a submission... |
Your program should take an array as input.
The array:
Will always be 1 dimensional
Will only contain integers
Can be empty
The program should reverse the array, and then add up the elements to the original for example:
Input: [1, 2, 3]
Original: [1, 2, 3]
Reversed: [3, 2, 1]
[1, 2, 3]
+ + +
[3, 2, 1]
[1+3, 2+2,... |
Program the shortest code that will calculate the average BPM (Beats per Minute) using 8 data points of time passed. This is my first post, and I haven't seen a question similar to this. Since I am a fan of rhythm games, it would be nice to have a small handy tool to calculate BPM using your own keyboard and your own s... |
Your challenge is to generate this string:
0110101101011010011010110101101011010110101101001101011010110100110101101011010110101101011010011010110101101001101011010110101101011010110100110101101011010000110101101011010011010110101101011010110101101001101011010110100110101101011010110101101011010011010110101101001101011... |
Given a string that is potentially boxed in, toggle the box. This becomes clearer in the test cases and explanation.
Input / Output
Input Format
The input will be either a single string separated by CR, LF, or CRLF, or a list of strings. The input format is up to you to decide.
Output Format
The output format must be i... |
All the quine challenges on this site are focused on byte count, or the characters themselves. This one is different. Your challenge is to write a program that produces output which has a code point sum identical to the source's code point sum.
To produce a code point sum:
Find the values of the characters in the prog... |
The challenge
Quite simple, given an input x, calculate it's infinite power tower!
x^x^x^x^x^x...
For you math-lovers out there, this is x's infinite tetration.
Keep in mind the following:
x^x^x^x^x^x... = x^(x^(x^(x^(x...)))) != (((((x)^x)^x)^x)^x...)
Surprised we haven't had a "simple" math challenge involving this... |
(related)
A Pythagorean Triple is a list (a, b, c) that satisfies the equation a2 + b2 = c2.
A Primitive Pythagorean Triple (PPT) is one where a, b, and c are all coprime (i.e., the only common divisor between the three elements is 1). For example, the (3, 4, 5) right triangle is a famous Primitive Pythagorean Triple.
... |
On puzzling SE there are what are called "matchstick problems" in which math is written in match sticks and you are allowed to move a certain number of them to get a certain property.
In this question we will be considering only integers represented in a 7-segment display format. Here are all 10 digits in that format:... |
Fortress was a language being developed by the Sun Programming Language Research Group (R.I.P. Fortress) that had a unique property to it, it was possible to render ("Fortify") programs in different font-styles (i.e. blackboard bold, bold, italics, roman, etc. ). The goal is to represent a one-char Fortress variable in... |
Related: Tell me how many math problems I have to do!
Challenge
Given a strictly positive strictly ascending integer list L and an integer 3 ≤ N ≤ length of L, replace the middle integers of L's consecutive integer runs of length ≥ N with a single dash -.
Rules
Horizontal whitespace is irrelevant.
You may optionally p... |
You are working as an intern for a mathematician who really hates TeX, LaTeX, etc. So much so that he has decided to abandon all typesetting whatsoever and make you do all the formatting in ASCII. You got tired of this after a while and decided to start automating parts of it, starting with square roots.
Here's how a s... |
I majored in computer science in the area of communication technologies and I fluently speak Python, Java, C, Bash, Matlab, Octave and some others. But you guys know things I have never ever heard about like "Fish" or "R" or "Whitespace" or some kind of crazy things. Sometimes these languages are not even build by ASCI... |
Motivation
In this challenge your task was to multiply two strings, this naturally introduces a way to take the square root of a string.
How does it work?
Given a string (for example pub) the first thing you need to do, is to determine the ASCII code for each character:
"pub" -> [112, 117, 98]
Next you map these codes... |
Your challenge is to make a program(less number of bytes than what the below program takes) that should print the map of India with any special character of choice.
TIO Link
#include <stdio.h>
int main()
{
int a = 10, b = 0, c = 10;
char* str = "TFy!QJu ROo TNn(ROo)SLq SLq ULo+UHs UJq "
"TNn*RP... |
In the physical world, invisible ink usually becomes invisible when it dries, and is then is readable if it is exposed to heat or chemicals of some kind. The invisible ink in this challenge will be readable when exposed to highlighting.
Create a full program or function that takes in text from the console (using a prom... |
\$P_k(n)\$ means the number of partitions of \$n\$ into exactly \$k\$ positive parts. Given \$n\$ and \$k\$, calculate \$P_k(n)\$.
Tip: \$P_k(n) = P_k(n−k) + P_{k−1}(n−1)\$, with initial values \$P_0(0) = 1\$ and \$P_k(n) = 0\$ if \$n \leq 0\$ or \$k \leq 0\$. [Wiki]
Examples
n k Ans
1 1 1
2 2 1
4 ... |
(inspired by a question over on Code Review)
Suppose two people are playing Hangman, but you've only overheard the game and want to draw the current status.
Given two words as input, where the words each match [A-Z]+ or [a-z]+ (your choice), output the current state of the hangman game as ASCII art, following the below... |
I was playing around with cellular automaton and I found one that had some interesting behavior. Here's how it works:
It reads a binary string from left to right, if it encounters a 1 followed by 2 other values it will append a 0 to the result and continue reading. If it encounters a 0 (or there are less than 3 value... |
Given the coordinates of the centres and the radii of 2 circles, output a truthy value of whether they do or do not overlap.
Input
Input may be taken via STDIN or equivalent, function arguments, but not as a variable. You can take them as a single variable (list, string etc) or as multiple inputs / arguments, in whate... |
Four-In-A-Row AI Tournament
Today, we will be playing a Four-In-A-Row tournament. However, it is not us humans playing... instead, we must have our computers battle instead! This challenge is completely in C#.
Rules
Basic Game Rules
If you have never played, there are simple rules. 2 players take turns putting pieces i... |
Challenge
Given a matrix M with r rows and c columns, and two Boolean lists V of length r and H of length c, calculate the partitioned cumulative vertical and horizontal sums.
Rules
r and c are greater than or equal to one
H and V begin with a true value
The values in M are within your language's reasonable numeric do... |
This question is similar to Do the circles overlap?, except your program should return True if the circumference of one circle intersects the other, and false if they do not. If they touch, this is considered an intersection. Note that concentric circles only intersect when both radii are equal
Input is two x, y coordi... |
A company is arranged in a heirarchical structure, with a layer of workers at the bottom. Each worker is managed by a manager. Consequently, each manager is managed by another manager until there is a company "boss". Each manager is restricted to managing, at most, x workers. For a company of size y calculate the numbe... |
Inspiration. Inverse.
Evaluate a given omnifix expression.
Omnifix is like normal mathematics' infix notation, but with additional copies of each symbol surrounding the arguments. The outer symbols take the place of parentheses, and there is therefore no need for additional parentheses.
You must support addition, subtr... |
The following is the rhombus sequence.
1
121
12321
1234321
123454321
12345654321
1234567654321
123456787654321
12345678987654321
Your task is to output this, taking no input and using standard output methods (STDOUT, list of numbers or list of strings, etc.).
There's a hitch. You may only use up to one loop - no neste... |
In base-10, all perfect squares end in \$0\$, \$1\$, \$4\$, \$5\$, \$6\$, or \$9\$.
In base-16, all perfect squares end in \$0\$, \$1\$, \$4\$, or \$9\$.
Nilknarf describes why this is and how to work this out very well in this answer, but I'll also give a brief description here:
When squaring a base-10 number, \$N\$, ... |
Given a real number, convert it to a list of lists, with the negative sign (if any) becoming an empty list, the integer part becoming a list of digits, and the fractional part (if any) becoming a list of digits. The digits must be actual numbers, not strings.
Examples
0 → [[0]]
123 → [[1,2,3]]
-123 → [[],[1,2,3]]
123.4... |
Your task
You must write a program, to print a reverse Fibonacci series, given a number.
Input
A non-negative integer N.
Output
You must output all the Fibonacci numbers from Fk to F0, where k is the smallest non-negative integer such that Fk ≤ N ≤ Fk+1.
Example
IN: 5
OUT: 5 3 2 1 1 0
If input isn't a Fibonacci numbe... |
As a follow up to my previous challenge Count to 20 with Words!, we will once again be using the word list from that challenge to perform another task. This time, you will be exclusively using:
https://github.com/Magic Octopus Urn/wordListsByLength/blob/master/10.txt
To choose 26 different words, each starting with a u... |
Robber's thread
Your task as cops is to select three things:
A programming language
An OEIS sequence
A byte set
You are then to secretly write a program in that language that computes the nth term sequence using only the bytes in the set. You will reveal the three pieces of information so that robbers can try to f... |
Cops thread
Your task as robbers is to find cops solutions and write a program in the language provided that computes the nth term of the sequence using only the bytes in the provided set.
The goal will be to crack as many cops answers as possible. With each crack awarding you a single point.
Cracks need not be th... |
Given two lists of dice rolls for a battle in Risk, your program or function must output how many troops each player loses.
Background
You do not have to read this, for it is merely background. Skip to "Task" subheading to continue unabated.
In the game of Risk, one player can attack another player (in fact, this is ... |
The Challenge
Given an integer input, return the first Fibonacci number that contains the input within itself along with the index of that Fibonacci number (indexes starting at 0 or 1 - up to you, but please mention which in your answer). For example, if given the input of 12, the program would return 26: 121393 as 12 ... |
Doing my history reading and note-taking, I can't help but get tired of writing out all these long dates –– 1784 is six entire pencil lifts! jǝǝz!
As you can see, I –– like most challenge posters on this site –– am lazy when it comes to writing stuff. Thus, I ask you to please help me shorten some dates. Of course, you... |
In the language Nim, the rules for differentiating identifiers are slightly more relaxed than most other languages. Two identifiers are equivalent or address the same variable if they follow these rules:
the first character of both are the same (case sensitive)
both strings are the same (case insensitive) after removi... |
Given a number n, print the nth prime Fermat number, where the Fermat numbers are of the form 22k+1. This code should theoretically work for any n (i.e. don't hardcode it), although it is not expected to terminate for n > 4. (It should not return 4294967297 for n=5, as 4294967297 is not a prime number.)
Do note that wh... |
You will be given as input an integer k in the range from -4503599627370496 (−252) to 4503599627370496 (252). As is well known, integers in this range can be represented exactly as double-precision floating-point values.
You should output the Hamming weight (number of ones) of the encoding of k in binary64 format. Thi... |
Given a list of non-negative integers in any reasonable format, iterate over it, skipping as many elements as every integer you step on says.
Here is a worked example:
[0, 1, 0, 2, 5, 1, 3, 1, 6, 2] | []
^ First element, always include it
[0, 1, 0, 2, 5, 1, 3, 1, 6, 2] | [0]
^ Skip 0 elements
[0, 1, 0, 2, 5, 1, 3... |
Challenge
Given an image of the sky, you must output the cloud cover in oktas. The image supplied will be an image file (the type is up to you) and the output should be to STDOUT.
Oktas
In meteorology, an okta is a unit of measurement used to describe the amount of cloud cover at any given location such as a weather st... |
Given an integer array of at least two elements, output the Matrix-Vector (defined below) of the array.
To compute the Matrix-Vector, first rotate through the size-n input array to create a matrix of size n x n, with the first element of the array following the main diagonal. This forms the matrix portion. For the vect... |
Philosophers have long pondered the Trolley problem. Unfortunately, no human has solved this problem yet. Luckily, as programmers we can use computers to solve the problem for us!
Input
Your program will take as input a (finite) directed graph (with at most one edge from x to y, for any x and y), with a designated nod... |
Fermat numbers are positive integers that can be expressed as 22x+1 with an integer x.
Let us now define an attribute of a number called "Fermat-ness":
The Fermat-ness of the number is one less than the length of the chain of powers of two, starting from the base, with powers of two expanded so as to maximize the ferm... |
People keep telling me that the square of a number is the number multiplied by itself. This is obviously false. The correct way to square a number is to make it into a square, by stacking it on top of itself a number of times equal to the number of digits it has, and then reading all the numbers from the resultant sq... |
Inspired by Create a binary wall
Given a list of positive integers, we can write them out all above each other like so, for [2, 6, 9, 4] as an example:
0010
0110
1001
0100
We can imagine this as a wall:
..#.
.##.
#..#
.#..
However, this is a very weak wall, and it has collapsed! Each 1 (#) falls down until it hits th... |
Story
There is a woman, named Sarah, whom likes smooth horse rides. She's going to go for a ride down a path too thin to pass any other horses she may come across - and so that her ride can be as smooth as possible she does not want to have to change speed though she would prefer to get to her destination as fast as p... |
Your task is to write a program or function that checks if a string is a valid URL.
Given a string as input, you will output a truthy value if the input is a valid URL. If it is not, output a falsey value. An input string is considered a valid URL if all of the following criteria are met:
Begins with http:// or https:... |
The challenge here is simple, and not at all about byte-count. Your job is to output the first 50 characters of the previous quine's source code, concatenated with the first 50 characters of yours starting with the 50 characters I've placed below:
abcdefghijklmnopqrstuvwxyzACDEFGHIJKLMNOPQRSTUVWXY
So, lets take an exa... |
I love sardines, I can't get enough of them, and so does my computer, the Omnilang 5000, which is language agnostic.
To give my computer the joy of experiencing sardines, I've decided to feed him a number of programs that are capable of displaying on the screen tins of sardines in various orientations, and showing up t... |
Your challenge today is to write a program or function which takes a list l and gives the positions in l at which each successive element of l sorted appears.
In other words, output the index of the smallest value, followed by the index of the second smallest value, etc.
You can assume that the input array will contain... |
You will be given a positive integer N as input. Your task is to build a Semi-Zigzag, of N sides, each of length N. Since it is relatively hard to clearly describe the task, here are some examples:
N = 1:
O
N = 2:
O
O O
N = 3:
O O
O O
O O O
N = 4:
O O O O O
O O
O O
O ... |
Main objective
The main objective is to output a text, it doesn't mind which text or where the text gets its output (it can be on a browser window, the default console etc).
It just requires the condition that what is output must be indeed "real chars" (the ones in UNICODE for example), it's not considered valid to dis... |
A fun pair of equivalences is 1 + 5 = 2 · 3 and 1 · 5 = 2 + 3. There are many like these, another one is 1 + 1 + 8 = 1 · 2 · 5 and 1 · 1 · 8 = 1 + 2 + 5. In general a product of n positive integers equals a sum of n positive integers, and vice versa.
In this challenge you must generate all such combinations of positive... |
Given an array a that contains only numbers in the range from 1 to a.length, find the first duplicate number for which the second occurrence has the minimal index. In other words, if there are more than 1 duplicated numbers, return the number for which the second occurrence has a smaller index than the second occurrenc... |
We have lots of horizontal axis for numbers, but I honestly think they're kind of boring. Your task today is to build me a portion of a diagonal axis between two distinct non-negative integers given as input.
How to build a diagonal axis?
Let's take an example, with the input 0, 5. Our axis should look like this:
0
... |
BackStory
Given a square matrix of alphabets which contain English letters in arbitrary manner. While searching a word in it, you can go left to right horizontally, vertically downwards or diagonally towards left (both upwards and downwards).
You have to find the number of matches of a given word in the matrix.
For exa... |
(inspired by this post over on Puzzling. CAUTION: SPOILERS FOR THAT PUZZLE ARE BELOW.)
The standard telephone keypad correlates letters to numbers as follows:
1 ->
2 -> ABC
3 -> DEF
4 -> GHI
5 -> JKL
6 -> MNO
7 -> PQRS
8 -> TUV
9 -> WXYZ
0 ->
A given input word is defined to be an Ordered Word if, when translated to k... |
Related as it requires you to measure the time between the first and last input. But here you're required to count how many inputs in a period of time.
I was assigned a task to stand by a gate and count how many students enter it. The problem is that my memory is not as good as it was when I first started this job. I... |
We are going to fold a list of integers. The procedure to do so is as follows, If the list is of even length, make a list of half of its length where the nth item of the new list is the sum of the nth item of the old list and the nth-to-last item of the old list. For example if we had the list
[1 2 3 4 5 6 7 8]
We ... |
As some of you may know, to get a language onto Dennis's wonderful Try It Online!, a Hello, World! program is required. Recently, Dennis pushed up a way to load these programs from the website. Here is a JSON pastebin of the characters used in those programs, by frequency, as of July 27, 2017.
Some of those characters ... |
English is such an inefficient language. We've got enormous words when
there are plenty of two or three letter words we never used! As
computer scientists, every keystroke matters. We need to be more
efficient. Just think of how many words we could have had! In fact,
don't think about it, tell me.
Given a string (or li... |
I saw Tom Scott's video on FizzBuzz https://www.youtube.com/watch?v=QPZ0pIK_wsc
so I felt to write my own more "complex" version,this is what I came up with, its very flexibly and easy to scale, and its easy to add more if cases that can trigger functions.
"The challenge": Write a semi-compact "complex FizzBuzz" that c... |
Task: Output the Swiss flag.
Happy Swiss National Day / Schweizer Bundesfeiertag / Fête nationale suisse / Festa nazionale svizzera / Fiasta naziunala svizra!
Details:
The flag consists of a white (#FFFFFF) cross on a red (#FF0000) background. The cross consists of a 6x6 square with arms of size 6x7 glued to each sid... |
Given a positive integer n as input, output the reversed range sum of n.
A reversed range sum is created by making an inclusive range up to n, starting with 1 and including n, reversing each of the numbers inside, and summing it.
Example:
Here is what would happen for an input of 10:
Range: [1,2,3,4,5,6,7,8,9,10]
Rever... |
This is my first question here, so any suggestions in the comments would be appreciated! Thanks ;)
Introduction
One very common strategy for the 2048 game is never ever swiping down. This positions all the big numbers at the top, and the lower ones in the bottom. So, if you apply this strategy correctly, your board wil... |
It's my friend's birthday soon and since he is a programmer and ASCII art lover, I thought I'd make him some ASCII cake!
Sadly, I keep forgetting his current age, so I would like to have a program for my ASCII oven, that bakes a cake with a specified number of candles, so I don't have to do it myself again if I am wron... |
The task
In this challenge, your task is to write a program in a programming language L that takes a positive integer n, and outputs the sum of the proper divisors of n (sequence A001065 on OEIS).
It should return the correct output for any 1 ≤ n ≤ 10 000.
Here are the first 10 outputs:
0, 1, 1, 3, 1, 6, 1, 7, 4, 8
Fu... |
Given π to an arbitrary number of places, your challenge is to locate indices of π where the index (1,2,3,4...) and the string of numbers from that index carry the same value for the length of the index.
That sounds complex, so let's look at an example!
Indices will count from +1 upwards through natural whole integers,... |
(Inspired by this challenge)
Given two input strings, one of which is exactly one character longer than the other, arrange the strings into ASCII art as if they are two halves of a zipper that is only halfway zippered. The longer word forms the bottom of the zipper, and is the first and last character of the combined z... |
Given a PPCG User ID, output that user's current username.
Examples
Input -> Output
61563 -> MD XF
2 -> Geoff Dalgas
12012 -> Dennis
foo ->
-3 ->
Rules
Input/output can be taken via any allowed means.
The output must be the full username with proper capitalization and spacing, nothing more and nothing less... |
Disclaimer: The story told within this question is entirely fictional, and invented solely for the purpose of providing an intro.
I have a friend who is an architect, and, after explaining the concept of code-golf and this site to him, he said that I should code something actually useful for a change. I asked him ... |
My first code golf post, apologies for any mistakes...
Context
In rock climbing (bouldering specifically), the V/Vermin (USA) climbing grades start at 'VB' (the easiest grade), and then go 'V0', 'V0+', 'V1', 'V2', 'V3', 'V4', 'V5' etc. up to 'V17' (the hardest grade).
Task
You will take as input a list/array of climbin... |
A lazy physicist has the job to perform the double slit experiment. However, they are lazy and can't be bothered to set up all the equipment themselves and so are going to simulate the effects. They can't program though so are going to need some help. As they are lazy your program should be as short as possible.
Given... |
Simple challenge: given a series of positive integer numbers, find the number that contains among its digits the longest run of consecutive digits. The trick? It's allowed for the digits in the runs to wrap around the possible values (0123456789) and to run backwards. So both 2345, 89012 and 5432109 are valid runs of c... |
Challenge
Given an input integer n > 0, output the number of primes (other than n, if n itself is prime) that can be produced by altering one digit in the decimal expansion of n (without changing the number of digits).
Examples
For example, n = 2. By altering one digit in the decimal expansion of 2, we can come up with... |
Disclaimer: The story told within this question is entirely fictional, and invented solely for the purpose of providing an intro.
My boss has gotten a new toy robot, and he wants me to help program it. He wants to be able to enter simple arrow instructions to get it to move. These instructions are: ^ (for move fo... |
Your task is to write some code that outputs an OEIS sequence, and contains the name of the sequence in the code (A______). Easy enough right? Well here's the catch, your code must also output a second separate sequence when the name of the sequence in the code is changed to the name of the second sequence.
Input Out... |
In Map inputted ASCII characters, I asked you to .. map inputted ASCII characters. This time, you will do the opposite, by immediately mapping all ASCII characters, and then mapping spaces over them.
This program will have practical uses, such as seeing what characters you have left in a restricted-source challenge sub... |
Challenge inspiration was this that I saw somewhere:
The word "nun" is just the letter n doing a cartwheel
Your challenge is to take a string and determine if it is the first letter doing a cartwheel.
Rules
A string is a letter doing a cartwheel if:
The first letter is the same as the last letter. (The letter can't ... |
Oh no, I am lost on the way to finding the great treasures of Marakov! And all I have are these useless instructions that look like S10R10D30... I have no idea what they mean! Can you help me?
Challenge
Given directions consisting of N E S W U D L R 1 2 3 4 5 6 7 8 9 0, output how far I will be from where I started whe... |
Super Mario Galaxy features two rhombicuboctahedron-shaped* planets tiled with platforms that shrink as Mario runs across. Should Mario fall into a triangular hole or a gap left by a tile he previously touched, he will be consumed by the black hole at the core. (Watch: Hurry-Scurry Galaxy, Sea Slide Galaxy)
Image: Mar... |
In mathematics, the factorial, shortened "fact" of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example, 5! is 1 * 2 * 3 * 4 * 5 = 120
The factorial of 0 is 1, according to the convention for an empty product.
These are the regular facts we are used to. ... |
In this challenge, we render Ascii user interfaces.
+----------------------+
|+-----------++-------+|
||<- Previous||Next ->||
|+-----------++-------+|
|== The title == |
| |
|Lorem ipsum dolor |
|sit amet... |
|+--------------+ |
||Post a comment| |
|+--------------+ ... |
My boss now wants me to implement a mechanism that lets him search for an item in an array, and gives him the index/indices where that value occurs.
Your Task:
Write a program or function that receives an array and a value (String, Integer, Float, or Boolean), and returns the indices of the array at which the value o... |
This is a cops-and-robbers challenge, the robbers thread can be found here.
Your task is to write some code that outputs an OEIS sequence, and contains the name of the sequence in the code (A______) and outputs a second separate sequence when the name of the sequence in the code is changed to the name of the second s... |
This is a cops-and-robbers challenge, the cops thread can be found here.
This is the robbers thread, your job here is to take submissions on the cops thread and try to find the hidden sequences. If you find any sequence that can be substituted into the original code to compute that sequence that is a valid crack. P... |
The Sequence
Everyone knows the only even prime number is 2. Ho-hum. But, there are certain even numbers n where, when concatenated with n-1, they become a prime number.
For starters, 1 isn't in the list, because 10 isn't prime. Similarly with 2 (21), and 3 (32). However, 4 works because 43 is prime, so it's the first ... |
A prime gap is the difference between two consecutive primes. More specifically, if p and q are primes with p <q and p+1, p+2, ..., _q_−1 are not primes, the primes p and q define a gap of n = q_−_p. The gap is said to be started by p, and to have length n.
It is known that arbitrarily large prime gaps exist. That is, ... |
The period of a string is the shortest non-zero shift so that the string matches itself, ignoring any parts that overhang. So for example, abcabcab has period 3. By convention we say that if there is no such shift then a string has period equal to its length. So the period of abcde is 5 and the period of a is 1.
In m... |
Imagine you have two lights. These lights blink on and off at a specific rate:
Light 0: Delay 0ms and then blink every 1000ms
Light 1: Delay 500ms and then blink every 1000ms
Let's simulate these lights for the first 2000ms:
0ms: Light 0 on
500ms: Light 1 on
1000ms: Light 0 off
1500ms: Light 1 off
2000ms: Light 0 ... |
Inspired by this question.
Champernowne's constant is an infinite decimal number that consists of "0." followed by all natural numbers concatenated together. It begins like so: 0.123456781011121314151617181920212223242526272829303132333435363738394041424344454647484950, etc. The digits of Chamernowne's constant are se... |
My little kid has a toy like this:
This toy consists of 10 stackable little buckets, that we are going to number from 1 (the smallest one) to 10 (the biggest one). Sometimes he makes small piles and the toy ends up like this:
We can represent schematically the piles like this:
1 6
4 9 2 7
5 10 3 8
-------... |
A superior highly composite number is an integer where the ratio of its count of divisors to some power of the number is as high as possible. Expressing this as a formula:
Let d(n) be the number of divisors of n, including the number itself. For a given integer n, if there exists a number e such that d(n)/n^e is greate... |
Given a polynomial function f (e.g. as a list p of real coefficients in ascending or descending order), a non-negative integer n, and a real value x, return:
f n(x)
i.e. the value of f (f (f (…f (x)…))) for n applications of f on x.
Use reasonable precision and rounding.
Solutions that take f as a list of coefficien... |
(This challenge is very similar, but this current challenge has additional complications.)
Imagine a 2-dimensional room, where the walls are plated with flat mirrors.
Suddenly, a beam of light strikes into the room, where a piece of wall is missing! The lightbeam dances around the room, getting reflected by the wall... |
I have a bunch of boards I need to stack in as small a space as possible. Unfortunately, the boards fall over if I stack them more than 10 high. I need a program to tell me how to stack the boards to take as little horizontal space as possible, without stacking boards more than ten high, or having boards hanging out ... |
As described in this question:
Dropsort, designed by David Morgan-Mar, is an example of a linear-time "sorting algorithm" that produces a list that is, in fact, sorted, but contains only some of the original elements. Any element that is not at least as large as the maximum of the elements preceding it is simply remov... |
The Dottie number is the fixed point of the cosine function, or the solution to the equation cos(x)=x.1
Your task will be to make code that approximates this constant. Your code should represent a function that takes an integer as input and outputs a real number. The limit of your function as the input grows should b... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.