instruction stringlengths 34 53.1k |
|---|
Problem
given input a,b,c
where a,b,c are positive even integers
and a > b > c
Make a box of any allowed character with dimensions a x a
Center a box of a different allowed character with dimensions b x b within the previous
Center a box of another different allowed character with dimensions c x c within the previous
... |
Your challenge is given an input of a prison layout to work out whether any of the prisoners can escape.
Input
Input may be in any reasonable format such as a string, array, array of arrays etc. The input will consist of three characters, in this case #, P and space. The input will not necessarily contain all three cha... |
Write a function (not a full program), so that if the function is called with a single global variable (or your language's closest equivalent) as its argument, it outputs (i.e. prints or returns) the name of that variable. If the argument is not a variable, output a falsey value instead. (You don't have to handle the c... |
Calculate the area of a polygon.
Inspired by this shoelace algorithm video.
Task
Your job is to create a program or function that calculates the area of a polygon. Program or function is defined according the the default definition in meta.
Input
You will receive the X and Y coordinates of each vertex of the polygon. Y... |
Your Task:
Write a program or function to check if a number that is inputted is a Fibonacci number. A Fibonacci number is a number contained in the Fibonacci sequence.
The Fibonacci Sequence is defined as:
F(n) = F(n - 1) + F(n - 2)
With the seeds being F(0) = 0 and F(1) = 1.
Input:
A non-negative integer between 0 a... |
In Haskell the list notation:
[a,b,c]
Is just syntactic sugar for:
a:b:c:[]
And the string notation:
"abc"
Is just syntactic sugar for:
['a','b','c']
This means that the string:
"abc"
Is the same as:
'a':'b':'c':[]
Task
Given a string you should output what the de-syntaxed version would look like in Haskell.
Rule... |
A simple one:
Take a list of positive integers as input and output the numbers modulus their 1-based index in the list.
If the input integers are {a, b, c, d, e, f, g} then the output should be {a%1, b%2, c%3, d%4, e%5, f%6, g%7} where % is the modulus operator.
Test cases:
10 9 8 7 6 5 4 3 2 1
0 1 2 3 1... |
Given Google's recent announcement of official Kotlin support for Android development, I thought it might be timely to poll the community for some awesome golfing tips for this relatively new JVM language.
Kotlin includes a unique combination of features among it's JVM siblings which makes it potentially attractive for... |
Backstory:
I think that my boss might finally realize that I don't any enough work, despite being paid by the hour. I want to throw him off track, by writing as many valid programs as I can to send to him. Unfortunately, due to budget cuts, my keyboard only allows each key to be pressed once.
Specification:
Write as ma... |
Challenge
You must write a program that takes a positive integer n as input, and outputs the nth Fibonacci number (shortened as Fib# throughout) that contains the nth Fib# as a subtring. For the purposes of this challenge, the Fibonacci sequence begins with a 1.
Here are some examples that you can use as test cases, or... |
First, a mathematical interlude, short, and worth your while:
If 0 < a < 4, the logistic function f(x) = ax(1-x) maps the interval [0,1] inside itself. This means that one can play the iteration game; for instance, if a=2, the initial value 0.3 becomes 0.42, then 0.4872, etc.
As the parameter a increases, the quadratic... |
– of crisis and martyrdom
(that's the subtitle because subtitles are cool)
In this king-of-the-hill challenge in python (yup; you need go no farther to know you may not submit in java), you need to create a bot that plays a game very similar to welcome to the dungeon
Game Rules
(note that this is not the original game)... |
Your Task:
Write a program or function that, when given a number, outputs its persistence. The persistence of a number is the number of times you can add its digits before arriving at a one-digit number. All one digit numbers have a persistence of 0. Note that this is different from questions about finding the digit... |
Challenge
Given an integer n (where 4<=n<=10**6) as input create an ASCII art "prison door"* measuring n-1 characters wide and n characters high, using the symbols from the example below.
Example
╔╦╗
╠╬╣
╠╬╣
╚╩╝
The characters used are as follows:
┌───────────────┬─────────┬───────┐
│ Position │ Symbol │ Char ... |
From the sandbox!
I2c or TWI, is a 2 way stream that uses 2 signal lines: SDA and SCK. This is used in sensors to communicate between a master and a slave.
So, how does this work? Well, here's the boilerplate:
Input:
1 I2c command represented by 2 strings where - is a high signal, and _ is low. SDA is always the fi... |
Choi Hong Hi died on the 15th June 2002 at the honorable age of 83. He founded Taekwondo.
15 years after his death, I would like to be a Taekwondo master. This is my time to shine !
Task
Given a string you should output a Taekwondo version.
Rules
You will receive a non-empty string/sentence by any valid input
You mus... |
Given three integers >= 2, create an ASCII cube in an orthogonal (cabinet) projection.
The three integers represent height, width and depth (measured in visible characters) including the corners. The corners should be 'o's or '+', free choice.
w: 10, h: 5, d: 4
Thus gives:
o--------o
/ /|
/ / |
o... |
Given a positive square number as input. Output the number of values between the input and next highest square.
Example
Input: 1
Output: 2
Reason: The numbers 2 and 3 are between 1 and 4, the next highest square
Input: 4
Output: 4
Reason: The numbers 5, 6, 7, 8 are between 4 and 9
|
Take a positive integer n as input, and output a n-by-n checkerboard matrix consisting of 1 and 0.
The top left digit should always be 1.
Test cases:
n = 1
1
n = 2
1 0
0 1
n = 3
1 0 1
0 1 0
1 0 1
n = 4
1 0 1 0
0 1 0 1
1 0 1 0
0 1 0 1
Input and output formats are optional. Outputting the matrix as a list of lists i... |
You're a farmer and your flock of sheep has escaped! Oh no!
Round up those sheep by building fences to contain them. As a farmer on a budget you want to use the least amount of fence possible. Luckily for you though, they aren't the smartest sheep in the world and don't bother moving after having escaped.
Task
Given... |
In 2014, demoscener Jakub 'Ilmenit' Debski released a 250-byte(1) procedural graphics demo for the Atari XL called Mona. It's drawing the following picture(2):
Your task is to generate the exact same picture, using the language of your choice.
(1) Breakdown: 136 bytes of data + 114 bytes of code.
(2) The original pic... |
I'm supposed to sort a list of numbers, but I'm super lazy. It's really hard to figure how to swap all the numbers around until all of them are in increasing order, so I came up with my own algorithm that will guarantee that the new list is sorted¹. Here's how it works:
For a list of size N, we'll need N-1 iterations. ... |
Overview
In the US, the common denominations are the penny ($0.01), the nickel ($0.05), the dime ($0.10), the quarter ($0.25), one dollar, two dollars (less common but lets pretend it's common), five dollars, ten dollars, twenty dollars, fifty dollars, and one hundred dollars. ($1 to $100 respectively).
Your goal is ... |
You are an enterprising dot who wants to increase the land under its control. This is quite simple - travel outside your current land and loop back into your land and everything in that loop is now owned by you. But there is a catch. If some other dot somehow finds your loop and crosses it, you die.
If you haven't alre... |
The challenge
The plastic number is a number related to the golden ratio, with many interesting mathematical properties. As such, there are many approaches that can be used to calculate the number.
In order to precisely specify the number for the purposes of this challenge, we'll use the following definition (although ... |
Task
Given two integers \$d\$ and \$n\$, find the number of ways to express \$n\$ as a sum of \$d\$ squares. That is, \$n = r_1^2 + r_2^2 + ... + r_d^2\$, such that \$r_m\$ is an integer for all integers \$1 ≤ m ≤ d\$. Note that swapping two different values (e.g. \$r_1\$ and \$r_2\$) is considered different from the o... |
Challenge
Given a single letter (a-z) as input, output the 2 lines of Blackalicious' Alphabet Aerobics that correspond to that letter (ignoring the intro & outro).
Rules
You may take input by any reasonable, convenient means as long as it's permitted by standard I/O rules.
Input must either be case insensitive or con... |
Introduction
On the 26th of August, 2017, Floyd Mayweather, Jr. will face up to Conor McGregor in a boxing match.
Both participants will receive the phenomenal amount of 100 million dollars!
Unfortunately, we do not have the money yet, but we can already prepare the big briefcase that will contain all the banknotes.
... |
The task is to compute OEIS A005434 as quickly as possible.
Consider a binary string S of length n. Indexing from 1, we can determine if S[1..i+1] matches S[n-i..n] exactly for all i in order from 0 to n-1. For example,
S = 01010
gives
[Y, N, Y, N, Y].
This is because 0 matches 0, 01 does not match 10, 010 mat... |
The N-bonacci sequence, originally invented by @DJMcMayhem in this question, is a sequence generated by starting with the integers 0 and 1, and then adding the previous N numbers to generate the next number. The special N-bonacci sequence is an N-bonacci sequence beginning with a pair of numbers other than 0 and 1, wh... |
This is code golf. For this challenge, I will accept a method (you don't need a full program), but the method signature does count towards the byte count and I want to see the full signature (not a lamdba). The input for the method is an integer array with 81 elements. The output/return value from the method is a strin... |
Given a string as input, output the string with the following algorithm applied:
1. Split the String by " " (find the words): "Hello World" -> ["Hello","World"]
2. Find the vowel count of each component: [2,1] ( ["H[e]ll[o]","W[o]rld"] )
3. For each of the components, output the first n letter where n is the number
... |
As is well known,
Chuck Norris counted to infinity. Twice
Besides,
Chuck Norris can count to infinity backwards.
Also, although perhaps less known, Chuck Norris can speak a little Spanish in addition to English.
The challenge
Write a program (or function) that can be run in two different languages. In one language ... |
This question is based on a question I asked in Spanish language. Yes, I asked for an algorithm in Spanish Language. :)
In Spain, current license plates have this pattern:
1234 XYZ
where XYZ are three consonants taken from the full set of Spanish consonants (except the 'Ñ', I think).
Sometimes, when traveling with ... |
Write a program/function/script that takes a natural number i from 1 to 10 as input and outputs the URL of the Question with the i th hottest question on the Code Golf Portal
The ordering should be like in https://codegolf.stackexchange.com/?tab=hot.
For example:
input 1
output https://codegolf.stackexchange.com/quest... |
The task
Your program will be given the following inputs: a number n, and an array of n positive integers. Your program only has to work when n=1000.
The program must do the following:
If the input array is a permutation of the range [1, 2, …, n], output Huh!?
Otherwise, return a three-element array [i, j, n], where i... |
A Cullen Number is any number that is contained in the sequence generated using the formula:
C(n) = (n*2^n)+1.
Your Task:
Write a program or function that receives an input and outputs a truthy/falsy value based on whether the input is a Cullen Number.
Input:
A non-negative integer between 0 and 10^9 (inclusive). ... |
The least common multiple (LCM) of a set of numbers A is the smallest integer b such that b/a is an integer for all integers a in A. This definition can be extended to rational numbers!
Task
Find the smallest positive rational b such that b/a is an integer for all rationals a in the input.
Rules
Standard loopholes are... |
Given n numbers in an array (you can't assume they are integers), I would like to compute the product of all subsets of size n-1.
You can do this by multiplying all the numbers together and then dividing by each one in turn, as long as none of the numbers is zero. However, how quickly can you do this with no division... |
It's really frustrating when I'm working and I have a ton of windows open that are completely or partially hidden behind other windows. To make things worse, I'm still using two 1024x768 monitors.
Your task is to take a list of coordinates that designate the area, in pixels, on a screen, that a list of windows occupy a... |
Introduction
A farmer needs help calculating the least time it will take him to pick his fruit each day.
Challenge
This farmer has X orchards.
Each orchard has Y fruits in it. If the orchard has no fruits, then it will contain the string "none".
The farmer has a list, this list contains the fruit he must pick.
The f... |
Define a 1-indexed sequence as follows:
A083569(1) = 1
A083569(n) where n is an integer greater than 1, is the smallest integer m not occurring earlier such that m+n is a prime number.
Your task is to take in n and return A083569(n).
n A083569(n)
1 1
2 3
3 2
4 7
5 6
6 5
7 4
8 9
9 8
10 13
11 12
12 ... |
Andrew is a chemist, interested in the acidity of solutions and in agriculture. After months of research (Google is not his friend), he came up with the following table* regarding the human-readable level of acidity in terms of the pH (potential of Hydrogen):
Denomination | pH range
... |
Let n and b be positive integers larger than 1.
Output the distance from n to the next power of b.
For n=5 and b=3, the next power of 3 from 5 is 9 (3^2 = 9), so the output is 9 - 5 = 4.
For n=8 and b=2, the next power of 2 from 8 is 16 (2^4 = 16), so the output is 16 - 8 = 8. Note that n is a power of 2 in this exampl... |
See also: Granma loves Ana
You will be given a string of lowercase ASCII letters. Using this dictionary file (UPDATED), your task is to solve the anagram. To solve an anagram, you must output all words or groups of words that can be formed using each letter from the input string exactly once, separated by newlines. Gro... |
Write a function or program that determines the cost of a given string, where
the cost of each character equals the number of how many times the character has occurred up to this point in the string, and
the cost of the string is the sum of its characters' costs.
Example
For an input of abaacab, the cost is computed... |
Let's for once do something useful.
Given the text from a Try It Online codegolf submission, produce the equivalent Chat Mini Challenge submission, which is of the form
Language, N bytes: [`code`](URL)
or (if submission is a single byte – TIO will add a trailing s on the first line only if needed)
Language, 1 byte: [`... |
Task:
Return an array with all possible pairs between the elements of an array.
Example
From a=["a", "b", "c", "d"]; return b=[["a","b"],["a","c"],["a","d"],["b","c"],["b","d"],["c","d"]].
Pairs can be in any order as long as all possible combinations are included and obviously ["b","d"] is the same to ["d","b"].
Inpu... |
It's not too important anymore, but occasionally somebody needs to know.
Here is a simple golf: Taking no user input, tell me if the computer on which the code is run is on a 64-bit operating system, or a 32-bit operating system!
If the code is run on a 32-bit operating system, print "32", if the code is run on a 64 bi... |
Background
A Lyndon word is a non-empty string which is strictly lexicographically smaller than all its other rotations. It is possible to factor any string uniquely, by the Chen–Fox–Lyndon theorem, as the concatenation of Lyndon words such that these subwords are lexicographically non-increasing; your challenge is to ... |
This is a pretty run of the mill question. I will define a sequence and you golf some code to output a entry given a index.
The first item in the sequence is 2.
The nth item in the sequence is the smallest positive integer other than n and 1 sharing at least one factor with n (other than 1) that has not already appea... |
Challenge
Given a positive integer, determine whether that number is currently being used to represent a question on PPCG.
The question must not have been removed, but may be open or closed.
The number is the one being used in the URL of the question, such as:
https://codegolf.stackexchange.com/questions/[input]
Note... |
Consider three sets A, B and C each containing n integers. From this we can make the set
S_n = {a * b + c | a in A, b in B, c in C}.
Given an n, there are one or more minimal sized S_n which depend on which sets A,B and C have been chosen.
The sets can contain any n distinct integers (positive, zero or negative). ... |
We start with a blank 1-indexed sequence:
_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,...
In the nth step, we fill in every a(n) blanks with the integers greater than 1 starting at the first remaining blank, where a(n) is the nth entry in the sequence.
After the first step:
2,_,3,_,4,_,5,_,6,_,7,_,8,_,9,_,10,_,11,... |
The challenge: output this exact ASCII art of a spiderweb in a window:
_______________________________
|\_____________________________/|
|| \ | / ||
|| \ /|\ / ||
|| /\'.__.' : '.__.'/\ ||
|| __.' \ | / '.__ ||
||'. /\'---':'---'/\ .'||
||\ '. /' \... |
Problem
Given no input write a program or a function that outputs or returns the following string:
(<(<>(<>.(<>.<(<>.<>(<>.<>)<>.<>)>.<>).<>)<>)>)
Rules
Shortest program wins.
Trailing whitespace allowed.
Trailing newlines allowed.
Unused parameters for functions allowed.
|
The task
In this challenge, your task is to determine whether some string occurs as a substring of a given string both surrounded by another string and reversed.
Your input is a non-empty string S of lowercase ASCII letters.
If there exist non-empty strings A and B such that the concatenation ABA and the reversal rev(B... |
Given a string, return a table where the first column has the unique letters of the string in order of occurrence and subsequent columns list the indices of that letter in the string, using zero or one-based indexing. Horizontal whitespace does not matter, as long as the left-most column is vertically aligned. Indices ... |
Vim is a great text editor for unix systems, but it's notorious for being difficult to exit.
Write a full program that will output :q to exit Vim. It should then read a single line of input, as it will then either be given a bash prompt, in which case the exit was successful, or an error, in which case there are unsave... |
Okay, so everyone is familiar with the ASCII-table, correct? I'd hope so. I've been going to that site for my asciitable reference for as long as I can remember needing one. We'll be doing some fun source-code manipulating using the ASCII keyspace.
The Task
Your task is to write a program that, when executed, prints t... |
You host the Olympic Games, and need to build a fantastic pool for the sake of the occasion, but the supervisors often change their mind regarding the dimensions, and need a quick way to rebuild it with the requested size!
Given two integers, L and x, your task is to build a swimming pool of length L and x lanes.
How ... |
Background
The number 1729 is the Hardy-Ramanujan number. An amazing property of it was discovered by S. Ramanujan (who is widely regarded as the greatest Indian mathematician1), when G.H. Hardy paid a visit to him in a hospital. In Hardy's own words:
I remember once going to see him when he was ill at Putney. I had r... |
Create a program which when run displays the text below:
)-*-*-*^_^*-*-*-(
| Welcome User! |
)-*-*-*^_^*-*-*-(
Use any functions or language to answer this, have fun. Shortest code wins
|
Assuming StackExchange doesn't decide to restore my account after deleting it due to age restrictions (even though I'm 14 already and almost 15 ಠ_ಠ), a lot of people on this site just lost reputation from my upvotes being deleted. This happened at around 5:30 PM on June 20th, 2017, UTC.
So, your challenge is to show ho... |
Given a non-empty string s, with even length, and a positive integer n, representing its height, compose a pyramid using the following rules:
The pyramid should contain n non-empty lines; trailing newlines are allowed. For each 1 <= i <= n, the i-th line should contain the string with each individual character repeated... |
Objective
To flip the rows and columns of a table in a code-golf challenge.
Instructions
You will be passed a "table" of 3 arrays/lists with 3 items each as input. Your job is to flip the rows and columns on it by writing a program that can do this efficiently and creatively. You will flip the "table" according to the ... |
Story
I need to remember a lot of passwords and don't want to use the same one for multiple websites so I came up with a rule, but the rule shouldn't be transparent so what I do is:
Think of a long word or concept such as breadpudding.
Replace the first letter with the site we are logging into. If we are logging into ... |
Given a string whose length is divisible by 4, make a triangle as demonstrate below.
If the string is abcdefghijkl, then the triangle would be:
a
b l
c k
defghij
If the string is iamastringwithalengthdivisiblebyfour, then the triangle would be:
i
a r
m u
a o
s f
... |
Stewie's Game of Life and Fatigue is quite similar to the more famous Conway's Game of Life.
The universe of the Stewie's Game of Life and Fatigue (GoLF) is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of three possible states, alive, dead or tired. Every cell interacts with its... |
Apparently, we really like printing the alphabet in different languages.
How about the Russian Cyrillic alphabet?
Print/output/return this exact text (trailing whitespace is permitted)
АаБбВвГгДдЕеЁёЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЪъЫыЬьЭэЮюЯя
This is the Russian Cyrillic alphabet with upper and lower case int... |
This question is based on what I came up with to answer another question.
Sometimes the questions here ask to draw some ASCII art. One simple way to store the data for the art is RLE (run-length encoding). So:
qqqwwwwweeerrrrrtttyyyy
becomes:
3q5w3e5r3t4y
Now to draw a big ASCII art you maybe be getting data like t... |
Problem
Given an input a where a is a truthy/falsy value output the exact impossible cube below if truthy and the exact normal cube below if falsey.
Input truthy:
___________________________________
/ _______________________________ /|
/ / _____________________________/ / |
/ / /| | ... |
A celebration of the many faces of APL
Given a string among those in column 1 or column 2 of the below table, return the string's neighbor to its right. In other words, if given a string in column 1 then return column 2's string on that row, and if given a string in column 2 then return column 3's string on that row.
T... |
Sandboxed and made less complicated and hopefully more fun.
Summary of the challenge
Given a number of particles, either identical bosons or identical fermions, output the total wave function of the state assuming they are all independent.
Physics background
Don't worry, you don't need to know quantum mechanics to solv... |
Challenge
Given a square matrix of characters (single-byte printable ASCII characters), rotate each "ring" of the matrix in opposite directions.
Let's take an example:
1 2 3 4 5
6 7 8 9 A
B C D E F
G H I J K
L M N O P
Then, the outermost ring is rotated clockwise 90 degrees, like so:
1 2 3 4 5 L G B 6 1
6 A ... |
Given an array of positive integers and two distinct valid indices, return the array with the two elements corresponding to the two indices swapped.
You may choose to use 0-indexing or 1-indexing, but the testcases below will be 0-indexed.
array m n output
[1,2,3,4] 0 1 [2,1,3,4]
[5,8,9] 0 2 [9,8,5]
[11,... |
Problem
Given a positive integer n where n < 100
Output a diamond pattern as follows:
Input n=1
/\/\
\/\/
Input n=2:
/\ /\
//\\/\/\//\\
\\//\/\/\\//
\/ \/
Input n=3:
/\ /\
//\\ /\ /\ //\\
///\\\//\\/\/\//\\///\\\
\\\///\\//\/\/\\//\\\///
\\// \/ \/ \\//
\/ ... |
Counting Gems
Background
My jewel box just fell down! There're too many gems of different shape on the ground. And your task is to count number of a certain type of gem.
I/O
Your code should take two inputs S and G, which could be a string with newlines, an array of lines, a two-dimensional array of characters, a text... |
Introduction:
Let's take a look at a standard Calculator in Windows:
For this challenge, we'll only look at the following buttons, and ignore everything else:
7 8 9 /
4 5 6 *
1 2 3 -
0 0 . +
Challenge:
Input:
You will receive two inputs:
One is something to indicate the rotation in increments of 90 degrees
The other... |
Help! My math exam is coming up soon and I didn't study! 1 Part of the exam is to classify a quadrilateral given its vertex coordinates, which I, unfortunately, do not know how to do. 2
So, your challenge is to write a program to do this for me so I don't fail!
Challenge
Given four vertices such that no three of them a... |
Given a positive integer n, output the N-dimensional identity "matrix", which is the N^N array with 1 where all the components of the indices are equal and 0 otherwise. N^N means N-by-N-by-N-by-...
1 -> [1]
2 -> [[1,0],[0,1]]
3 -> [[[1,0,0],[0,0,0],[0,0,0]],[[0,0,0],[0,1,0],[0,0,0]],[[0,0,0],[0,0,0],[0,0,1]]]
4 -> [... |
Stolen from @Downgoat with permission
The point of this challenge is to (not) settle the debate on the pronunciation of "gif".
"
The pronunciation of gif is debated and while it's supposed to be (and should be) pronounced jif, it's still commonly disputed.
In this challenge you will be given a set of words that have ... |
Pig-latin is a made-up language that is translated into by moving the first letter of a word to the end and adding ay to the end. For example: hello translates into pig-latin as ellohay. Therefore, translating pig-latin back into English is dropping the ay at the end and moving the last letter to the start (like oodbye... |
Introduction
OnePlus is a Chinese smartphone manufacturer founded in December 2013. Their latest phone, OnePlus 5, was unveiled on June 20, 2017.
I am sure you have seen that the name of the phone can easily be translated to a sum.
OnePlus can be written like 1+ thus OnePlus 2 = (1+ 2) = 3
Input
The name of one OnePlu... |
Divide the first quadrant (including the positive x-axis, the positive y-axis, and the origin) into 1x1 grids, with each grid labelled by the coordinates of its bottom-left corner, as demonstrated below:
Note that each grid contains its boundaries and its vertices. Using mathematical symbols, the grid labelled (m,n) w... |
This challenge is inspired by this app. The test cases are borrowed from that app.
This is a fastest-code challenge, where the objective is to solve the largest test cases in the least amount of time. There are provided some smaller test cases, so that people might test their algorithms faster.
You'll be given a squa... |
Related: Validate a stem-and-leaf plot
Input
A non-empty list of positive integers. If needed, they can be taken as strings. You cannot assume it is sorted.
Output
A stem-and-leaf plot of the numbers. In a this stem-and-leaf plot, numbers are ordered into stems by tens, then all numbers that fit into that stem have the... |
Divinacci (OEIS)
Perform the Fibonacci sequence but instead of using:
f(n) = f(n-1)+f(n-2)
Use:
f(n) = sum(divisors(f(n-1))) + sum(divisors(f(n-2)))
For an input of n, output the nth term, your program should only have 1 input.
First 14 terms (0-indexed, you may 1-index; state which you used):
0 | 0 # Initial ... |
I'm looking out of my attic window into my neighbor's yard. They have a dog chained to a post in the center of the yard. The dog runs around the yard but is always on the end of its chain, so it ends up leaving a track in the dirt. Normally this track would be perfectly circular, but my neighbors have some other pole... |
Skat
I'm a fan of anagrams, so given two strings s1 and s2 write a program or function that outputs a truthy value if s2 is an anagram of s1, and a falsey value otherwise (not accounting for spaces and capital letters).
For example:
Input: s1 = "Anagram"; s2 = "Nag a ram"
true
Input: s1 = "stack overflow"; s2 = "fewe... |
This is cops-and-robbers. This is the Cops thread. For the robbers thread, go here.
I've noticed a number of OEIS (On-line Encyclopedia of Integer Sequences) challenges since I joined the site. It seems only fair that we have a cops-and-robbers challenge that determines who is the master of online integer sequences, on... |
This is cops-and-robbers. This is the Robbers thread. For the cops thread, go here.
I've noticed a number of OEIS challenges since I joined the site. It seems only fair that we have a cops-and-robbers challenge that determines who is the master of online integer sequences, once and for all.
Cops
Write a program or func... |
Today, @HyperNeutrino succeeded merging his two accounts, and finally got the reputation he lost back. Now, it's time to celebrate! Your task is to output this exact text:
/\
/ \
/ \
/ \
/ \
/ \
/ ... |
In celebration of HyperNeutrino getting back his account and rep, following Mr. Xcoder.
Apologies for rotating the picture for drawability.
Print or output this ASCII art exactly. You may have trailing spaces and/or a trailing newline.
_______________
/ \
/ / \ \
/ / ... |
The Dank Memes Casino is one of the best casinos of the world. They have a rule that if you win or lose money, you will be paid at the beginning of the next month.
But, catastrophe struck and there was an earthquake, which demolished the casino.
Now, all the poker players have gathered and realised that the casino is n... |
A proper divisor is a divisor of a number n, which is not n itself. For example, the proper divisors of 12 are 1, 2, 3, 4 and 6.
You will be given an integer x, x ≥ 2, x ≤ 1000. Your task is to sum all the highest proper divisors of the integers from 2 to x (inclusive) (OEIS A280050).
Example (with x = 6):
Find all th... |
This challenge is inspired by this app.
This is a much easier version of this challenge. This challenge is code-golf, while the other one is fastest-code.
You'll be given a square input grid, of dimensions 6-by-6 which is divided into 6 areas, where the cells of each area have a unique identifier (I'll use lower case... |
A knight fill is a flood fill using the connectivity of the knight chess piece. Specifically:
1 1
1 1
0
1 1
1 1
(0 is the initial point, 1s show the connected cells)
Challenge
Given a 2D grid of spaces and walls, and an initial location, perform a knight-fill on the grid. Shortest code wins.
Rules
You may tak... |
An Automorphic number is a number which is a suffix of its square in base 10. This is sequence A003226 in the OEIS.
Your Task:
Write a program or function to determine whether an input is an Automorphic number.
Input:
An integer between 0 and 10^12 (inclusive), that may or may not be an Automorphic number.
Outpu... |
I need to prepare digits made of cardboard to display some number (example). I don't know beforehand which number I should display - the only thing I know is that it's not greater than n.
How many cardboard digits should I prepare?
Example: n = 50
To display any number in the range 0...50, I need the following digits:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.