instruction stringlengths 34 53.1k |
|---|
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:
... |
Recently I had a Maths test and noticed that a certain number on the test matched an interesting pattern. The number (28384) matched a generic digit sequence that looks like this
(n)(x)(n+1)(x)(n+2)(x)(n+3) etc...
where n and x are single digit integers. The sequence can begin with either x or n and end with either x ... |
Take a matrix of positive integers as input, and make it explode!
The way you explode a matrix is by simply adding zeros around every element, including the outside borders.
Input/output formats are optional as always!
Test cases:
1
-----
0 0 0
0 1 0
0 0 0
--------------
1 4
5 2
-----
0 0 0 0 0
0 1 0 4 0
0 0 0 0 0
0 ... |
Suppose we have a matrix like this:
11111
12221
12321
12221
11111
This matrix represents a terrain, and each cell represents a portion of terrain. The number in each cell represents the time the portion of terrain needs to be completely burnt (in minutes, if a measurement unit is needed), according to its combustibili... |
In this challenge, you must parse a list of lists, into a simpler list format.
This challenge is based on my sadflak parser. In my sadflak parser, it has all the () removed, replaced with the sum of the ()s at the start of the list, to make the program run faster.
To parse into a Sad-List, you have to do this (python i... |
Consider the following 3x3 blocks which the marching squares algorithm would identify for every cell (with 0-based labeled ID):
0:
...
...
...
1:
...
...
\..
2:
...
...
../
3:
...
---
...
4:
..\
...
...
5:
/..
...
../
6:
.|.
.|.
.|.
7:
/..
...
...
8:
/..
...
...
9:
.|.
.|.
.|.
10:
..\
...
\..
11:
..\
...
...... |
The Zachtronics game TIS-100 contains a graphics display called the visualization module. I could try and explain the specs of this module, but the game's manual will do a better job:
(As you may have guessed, the motivation of this problem is to create a code golf challenge in which TIS-100 is the optimal language.)
... |
Output/print this block of text:
1234567890
2468013579
3691470258
4815926037
5049382716
6172839405
7306295184
8520741963
9753108642
0987654321
Acceptable formats include:
Trailing newlines/whitespace
List of strings
List of lists of characters
List of lists of integers
However, list of integers is not acceptable bec... |
Problem
Recreate the UI from a torrent program
Given no input, output the following:
+----------+----------+----------+
|a.exe |##########|seeding |
+----------+----------+----------+
|b.exe 10% |# |leeching |
+----------+----------+----------+
|c.exe |##########|seeding |
+----------+----------+--... |
Inspired by this and the following chat:
Your task is to output the following:
_ _ _
/_/_/_/\
/_/_/_/\/\
/_/_/_/\/\/\
\_\_\_\/\/\/
\_\_\_\/\/
\_\_\_\/
Extra leading or trailing whitespace is allowed, as long as it does not change the appearance of the cube. As usual, returning the above or a list of strings ... |
Given an integer array and two numbers as input, remove a certain amount of the first and last elements, specified by the numbers. The input can be in any order you want.
You should remove the first x elements, where x is the first numerical input, and also remove the last y elements, where y is the second numerical in... |
Note: When I refer to a bridge, I mean it in the non-mathematical sense
Introduction
You are on a network of islands which are connected by wooden bridges and you want to see if you can burn every bridge in the island network. However, you can only burn a bridge once you've walked over it.
Once a bridge has been burned... |
This is a simple one: Take a matrix of integers as input, and output the index of the row with the most non-zero elements. You may assume that there will only be one row with the most non-zero elements.
Test cases:
These are 1-indexed, you may choose if you want 0 or 1-indexed.
1
0
row = 1
---
0 -1
0 0
row = 1
---
1... |
In this question each answer will get a "toolbox" that can be used to construct a program/function. The toolbox will consist of two things:
a list of programming languages
a list of valid characters
You must write a valid program/function in one of the languages provided using only the characters in the toolbox. Yo... |
Write a program that prints "Hello, World!".
But also, if you take only the first, third, fifth, etc. characters of your program, the resulting program should still print "Hello, World!".
If your program is:
abc
def
It should output "Hello, World!", but so should
acdf
No solutions with fewer than 2 characters.
|
In the misty years of yore, when fanfold terminals walked the earth, there lived a strange creature. Oddly crippled and yet oddly powerful, the line editor teemed across the programming landscape in untold numbers; covering the earth as far as the eye could see.
Now it is fallen on hard times. That vast population hunt... |
You will be given a String that only contains letters of the English Alphabet, both lowercase and uppercase (ASCII 65-90 and 97-122). Your task is to output the Fizz-Buzzified version of the String.
How to Fizz-Buzzify a String?
Each letter that has an even index in the English alphabet (the alphabet must be 1-indexed... |
This challenge is related to a project I did last year (in Ruby). To make it more fun I decided to do it in as few bytes as possible. I didn't know about code golf back then so now that I found out about it and found this community I was wondering if anybody can beat me :)
The program should return the current time if ... |
Coders are always trying to flatten arrays into boring 1-dimensional entities and it makes me sad.
Your task is to unflatten an arbitrary string of characters, outputting a lovely city skyscape.
Consider the string: aaabbbbbccqrrssstttttttPPw
It looks much better like this:
tt
tt
bb tt
... |
Given a strictly positive integer, return the shortest possible Roman numeral using only the additive rule. Output must consist of zero or more of each of the characters MDCLXVI in that order. The number 14 must therefore give XIIII rather than XIV.
The characters' numeric values are M=1000, D=500, C=100, L=50, X=10, V... |
If you've come here, you probably know what code-golf is, and that's what I'm going to assume.
Story
(I guess)
Keyboards are input devices we use all the time. They existed before mice and touch screen, etc.
Their fundamentals have not changed: when you press a key down, a signal is sent to the computer. When you rele... |
Given an positive integer as input determine if it is a magnanimous number.
A magnanimous number is a number such that any insertion of a + sign between any two digits in base 10 results in an expression of a prime integer.
For example 40427 is magnanimous because
4+0427 = 431 is prime
40+427 = 467 is prime
404+27 ... |
Take a matrix A consisting positive integers, and a single positive integer N as input, and determine if there are at least N consecutive occurrences of the same number in any row or column in the matrix.
You need only test horizontally and vertically.
Test cases
N = 1
A =
1
Result: True
----------------
N = 3
A =
1 ... |
Given one of the following as input:
AK,AR,AS,AZ,CA,CT,DC,FL,GA,IL,IN,IA,KS,KY,LA,MD,MI,MN,MS,NV,NH,NJ,NM,NY,NC,ND,MP,OH,OK,OR,PA,PR,RI,SC,TN,TX,UT,VT,VA,WA,WI
(with quotes)
"AK","AR","AS","AZ","CA","CT","DC","FL","GA","IL","IN","IA","KS","KY","LA","MD","MI","MN","MS","NV","NH","NJ","NM","NY","NC","ND","MP","OH","OK",... |
Given a double-precision float, find the closest double-precision float whose binary representation is a palindrome.
Input
A floating point number x. You may use any format you like for input, but the format you chose must be able to represent every possible IEEE 754 binary64 value, including denormals, distinct repres... |
Write a program that adds or removes whitespace to format code nicely. Rules for what the code should look like when you're done:
No line should contain more than one of { and }.
A { should always be the last thing on a line.
A } should always be the only thing on a line (besides whitespace that comes before it).
The ... |
Degree of Unsaturation
This is not a particularly hard code puzzle - but I'm interested to see your multiple ways of solving it.
The Degree of Unsaturation is the number of double chemical bonds between atoms, and/or the number rings in a chemical compound.
You will be given the molecular formula of a chemical compoun... |
Challenge
This is a simple challenge. Given two positive integers w and h create an ASCII fence with a width of w and a height of h. The fence should be constructed using the following rules:
The + character will represent a post.
The - character will be used to represent the width of the fence.
The | will be used to ... |
Input:
A positive integer n consisting of digits in the range 0-9.
Challenge:
If d is the highest digit in the integer, assume the base of the number is d+1. E.g. if the integer is 1256 then you shall assume it's in base-7, if it's 10110 then you shall assume it's base-2 (binary), and if it's 159 then it's decimal.
Now... |
Surprisingly we haven't had a simple "find the highest digit" challenge yet, but I think that's a little too trivial.
Given input of a non-negative integer, return the highest unique (ie not repeated) digit found in the integer. If there are no unique digits, your program can do anything (undefined behaviour), other th... |
We are all used to the old-school telephone keypad, right? For reference, here is what it looks like:
Given a String consisting only of lowercase ASCII letters and single spaces, your task is to return the number of taps one should make in order to type down the full String with a telephone keypad as the one above.
F... |
TL;DR: Given an array of chars and a robot in a starting position of the array, write an algorithm than can read a string with movements (F for "go forward", R for "rotate 90 degrees right" and L for "rotate 90 degrees left") and calculate the ending position of the robot. More details in the complete text.
We have a... |
A classic example to introduce people to the concept of a discrete probability distribution is the bean machine. This machine has a large amount of marbles fall from a narrow passageway at the top, after which they hit rows of interlaced pins, where at each pin the marble hits it might fall to the left or the right of ... |
The dragon curve sequence (or the regular paper folding sequence) is a binary sequence. a(n) is given by negation of the bit left of the least significant 1 of n. For example to calculate a(2136) we first convert to binary:
100001011000
We find our least significant bit
100001011000
^
Take the bit to its le... |
Alternesting, is the act of taking a string and nesting it in alternating brackets. Here is how you alternest a string.
For a string of length N, take the center N characters, and surround them in parenthesis. So if our string was Hello world! (12 characters), we'll end up with
(Hello world!)
Then, take the remaining... |
Overview
Some of you might be aware of the Kolakoski Sequence (A000002), a well know self-referential sequence that has the following property:
It is a sequence containing only 1's and 2's, and for each group of 1's and twos, if you add up the length of runs, it equals itself, only half the length. In other words, the... |
Your input will be an English sentence, phrase, or word. It will only contain a-zA-Z' -,.!?. Your task is to take the input, remove spaces, and then redistribute capitalization such that letters at indexes that were capitalized before (and only letters at indexes that were capitalized before) are capitalized.
For examp... |
Convert short date format into English long date in as few bytes as possible.
Input
Input will be in the form of a string with format, yyyy-mm-dd, with zero padding optional for all values. You can assume that this is syntactically correct, but not necessarily a valid date. Negative year values do not need to be suppor... |
A triangular number is a number that is the sum of n natural numbers from 1 to n. For example 1 + 2 + 3 + 4 = 10 so 10 is a triangular number.
Given a positive integer (0 < n <= 10000) as input (can be taken as an integer, or as a string), return the smallest possible triangular number that can be added to the input to... |
Dungeon Master was one of the first ever real-time role-playing games, originally released in 1987 on the Atari ST. Among other exciting things for the time, it offered a rather sophisticated spell system based on runes.
Your task today is to write a program or function that evaluates the number of Mana points required... |
The world of art is full of colour, but the world of the network is even fuller than the world of art of diferent colours and it's renderings. That's why we need to know how to convert one type of colour format to another.
The challenge is self-evident:
Write a program / function than converts an given HEX code (#00ff0... |
Here is an example of an input of monoliths. There are 4 in this example.
_
| | _
| | _ | |
| | | | | | _
_| |_| |___| |____| |_
The first monolith is 4 units high, the second is 2, the third is 3, and the last is 1.
The task
Your program should output the heights of the monoliths in order from l... |
In a desolate, war-torn world, where cities have been overrun by thugs and thieves, civilization has reinvented itself in the form of small, isolated, industrial cooperatives, scattered throughout the previously uninhabited landscape. The existence of these communities is reliant on teams of mercenary workers called "s... |
I have written a few challenges related to matrices, and common for all are that I use a format like the one below when representing the matrices, both in examples and in test cases:
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
This is likely a cumbersome format in many languages.
Challenge... |
Challenge
Given the number of an XKCD comic, output the title text of that comic (the mouseover text).
However, the program must throw an error when given the numbers 859 or 404.
Rules
The number given will always be an existing comic (except 404).
Your program must not throw an error for any other numbers than 859 or... |
A number is a de Polignac number if and only if it is odd and cannot be represented in the form p + 2n where n is a non-negative integer and p is a prime integer.
Task
Write some code that takes a positive integer and determines if it is a de Polignac number. You may output two distinct values one for true and one for... |
Given Color codes in CMYK, convert it to RGB value.
Input:
string of 4 integers(ranging from 0-100) separated by space
86 86 0 43
28 14 0 6
0 41 73 4
Output:
#141592
#ABCDEF
#F49043
Shortest code wins!
HINT: For converting CMYK to RGB you may use formula such as:
Red = 255 x (1 - Cyan/100) x (1 - Black/100) ... |
I found it quite hard to achieve a range of numbers as rows in MySQL.
For example the range 1-5 is achieved by:
SELECT 1
UNION
SELECT 2
UNION
SELECT 3
UNION
SELECT 4
UNION
SELECT 5
will result in:
1
2
3
4
5
for 0-99 I can cross join two 0-9 tables:
CREATE TABLE nums as
SELECT 0 as num
UNION
SELECT 1
UNION
SELECT ... |
Given a set of two strings guaranteed to be the same length, print their criss cross.
The criss cross of two strings is obtained as follows.
Yield the second character of the second string, then the first character of the first string.
Yield the first character of the second string, then the second character of the fi... |
Challenge
Given a string and a number, divide the string into that many equal-sized parts. For example, if the number is 3, you should divide the string into 3 pieces no matter how long the string is.
If the length of the string does not divide evenly into the number provided, you should round down the size of each pie... |
Challenge
Print or return the Stack Exchange favicon, as provided below:
___________________
/ \
---------------------
| |
---------------------
| |
---------------------
\__________ _____/
| /
| /
|/
This is code-golf, so the ... |
The challenge
Write a program or function which takes a string input as a function parameter or from stdin and determines if it is a valid FEN string.
Input
You can assume the input will only ever include the following characters (case sensitive)
pkqrbnPKQRBN12345678/
The length of the input will always be a minimum of... |
For this challenge, you should write a program or function which outputs the diagonals of a given square matrix. However, if you transpose the rows and columns of your solution's source code, it should instead become a program or function which returns the matrix's antidiagonals. Read on for specifics...
Rules
The sou... |
Heavily inspired by Hello, World! (Every other character)
Write a program that outputs 1. When the first, third, fifth, etc. chars are removed, it outputs 2. When all chars where their (1-based) index in the source, mod N, are not 0, are removed, it should output N.
This is code-challenge. The winner is the program tha... |
A staircase number is a positive integer x such that its nth digit (one indexed starting with the least significant digit) is equal to x % (n + 1). Thats a bit of a mouthful so lets look at an example. Take 7211311, if we take the modular residues of 7211311 on the range 2-8 we get the following:
7211311 % 2 = 1
7211... |
A primitive element of a finite field is a generator of the multiplicative group of the field. In other words, alpha in F(q) is called a primitive element if it is a primitive q−1th root of unity in F(q). This means that all the non-zero elements of F(q) can be written as alpha^i for some (positive) integer i.
All ele... |
You are the roughest, toughest, coolest cowboy west of the Mississippi. However, some weird guy on a wacky nerd website decided that it would be cool to plop you into random unfinished landscapes and fight. No matter, you'll still win. However, to help you win those grueling gunfights you'll write home about, it's help... |
I somewhat miss those old demos showing the capabilities of computers when they were called x86 instead of i3, i5 and i7. One of the first I watched in my 386 was the Unreal demo from Future Crew that is now celebrating its 25th anniversary. At minute 0:43 the first part of the demo starts and we see a scrolling text f... |
I, uh....honestly can't believe we don't have this one yet.
Challenge
Write two functions or programs that:
Convert from decimal to percentage
Convert from percentage to decimal
You may also write a single program that does both of the above.
Format
Percentages must be taken and returned with a percent sign. (In many... |
As a kind of part 2 to Hello, World! (Every other character), write a program such that all three of these programs print "Hello, World!": the entire program, the 1st, 3rd, 5th, etc. characters of your program, and the 2nd, 4th, 6th, etc.
If your program is:
abc
def
It should output "Hello, World!", but so should
acdf... |
The treewidth of an undirected graph is a very important concept in Graph Theory. Tons of graph algorithms have been invented which run fast if you have a decomposition of the graph with small treewidth.
The treewidth is often defined in terms of tree decompositions. Here's a graph and a tree decomposition of that grap... |
Challenge:
Take a rectangular figure consisting of the two characters # and (whitespace, ASCII-32), and identify which direction the lines are. The options are: 'Vertical', 'Horizontal', 'Left Diagonal' and 'Right Diagonal'.
Input:
The input will be a figure of size n-by-m where 5 <= m,n <= 20. There will be two space... |
Consider the integers modulo q where q is prime, a generator is any integer 1 < x < q so that x^1, x^2, ..., x^(q-1) covers all q-1 of the integers between 1 and q-1. For example, consider the integers modulo 7 (which we write as Z_7). Then 3, 3^2 mod 7 = 2, 3^3 = 27 mod 7 = 6, 3^4 = 81 mod 7 = 4, 3^5 = 243 mod 7 = ... |
What you need to do is create a function/program that takes a decimal as input, and outputs the result of repeatedly taking the reciprocal of the fractional part of the number, until the number becomes an integer.
More specifically, the process is as follows:
Let x be the input
If x is an integer, output it.
Otherwise... |
Most people are familiar with Pascal's triangle.
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
Pascal's triangle is an automaton where the value of a cell is the sum of the cells to the upper left and upper right. Now we are going to define a similar triangle. Instead of just taking the cells to the upper left and the upp... |
The Lehmer-Comtet sequence is a sequence such that a(n) is the nth derivative of f(x) = xx with respect to x as evaluated at x = 1.
Task
Take a non-negative integer as input and output the nth term of the Lehmer-Comtet sequence.
This is code-golf so you should minimize the file size of your source code.
Test Cases
OEI... |
Challenge
The challenge is simple, using http://isup.me, determine whether an inputted website is up or down.
If the site is up, you should return a truthy value and if the site is down, you should return a falsey value.
Rules
The input will be a web address such as stackexchange.com or google.co.uk. The input will nev... |
Challenge
Convert and print out a time in a 12-hour format. HH:MM AM/PM
Examples
Input:
'Fri Jun 30 2017 21:14:20 GMT-0700 (PDT)'
'Fri Jun 30 2017 00:10:23 GMT-0700 (PDT)'
'Fri Jun 30 2017 12:10:23 GMT-0700 (PDT)'
'Sat Jun 31 2018 8:06:20 GMT-0700 (PDT)'
'Fri Jul 01 2017 01:14:20 GMT-0700 (PDT)'
'Sat Apr 10 2020 09:06... |
This is a very very simple algorithm, that I am sure can be solved in many many different languages. In Spain ID cards (known as DNI) consist of 8 numbers and a control character. The control character is calculated with the following algorithm: divide the number by 23, take the remainder of the operation and replace i... |
Inspired by the bugged output in @Carcigenicate's Clojure answer for the Print this diamond challenge.
Print this exact text:
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 ... |
Write a program, that sends its own source code over network.
Network example is TCP/UDP or web socket. Ethernet, Bluetooth, Wi-Fi and internet over USB are allowed.
No need to write receiver program. You can use any encoding protocol, but decoder will be realizable.
Rules
Network is not a stdout, screen, USB, UART, G... |
Write a function that calculates a row of the pascal triangle and returns the middle number, if there are 2 it should return their sum.
Example:
5
would return
20
Example 2:
4
would return
6
EDIT:
To be clear:
a) if the number inputted is odd then find then return the middle number of a row on the pascal triangle.
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.