instruction stringlengths 34 53.1k |
|---|
In my previous challenge, I
drew the first diagram mostly by hand (with the help of vim's visual block
mode). But surely there must be a better way...
Given an input of two dimensions, a width and a height, output a hexagonal grid
with those dimensions in ASCII art.
Here's the diagram referenced in the intro (with min... |
I have a specific number in mind, but it's part of a challenge I'm doing, and I don't want people to do (all) the work for me.
Here is a number which has the same digits, but shuffled:
5713167915926167134578399473447223554460066674314639815391281352328315313091488448321843
8892917486601064146636679920143691047671721184... |
In that Coding Golf, you should convert one coding convention with TitleCase to lower_case_with_underscores. And... vice versa!
Specification
Change the casing in a following way:
If underscore character is a delimiter, change the casing to Title Case without any of delimiter.
If there are multiple words with no delim... |
There is a network of up to 26 nodes (named A to Z or a to z as per your wish). Every pair of nodes may be connected or disconnected. A node may be connected to at most 4 other nodes. Your task is to draw the network in a 2D diagram. Input will be given such that this task is possible (see more constraints in output se... |
I have a crank-operated music box that can play a series of four notes. When I turn the crank, it plucks one of four strings, depending on the position of the crank and the direction of the turn. When the crank is turned due north, the box (with its strings numbered 1 through 4) looks like this:
1 | 2
|
O
4... |
Australians love public holidays, and drinking. Yesterday, the 26th January, was Australia day, which is a public holiday. I was glad to not be at work yesterday, and eager to know the next time I get a public holiday! Unfortunately, I had a bit too much to drink, and I'm not able to work it out for myself.
Write a pro... |
Introduction
In chemistry there is a type of extension, .xyz extension,(https://en.wikipedia.org/wiki/XYZ_file_format), that prints in each line
a chemical element, and the coordinates in the plane of the element. This is very useful for chemists to understand chemical compounds and to visualize the compounds in 3D. I ... |
Given an input of a list of blocks to drop at certain points, output the height
of the resulting "tower."
The best way to explain this challenge is by example. The input will be a list
of 2n integers representing n blocks. The first integer is the block's x
position, 0-indexed, and the second is how wide the block is. ... |
Introduction
Everyone should know IPv6 by now. IPv6 has very long, cumbersome addresses.
In 1996 some very intelligent people created a scheme to encode them much better in RFC 1924. For reasons I cannot understand, this hasn't been widely adopted. To help adoption, it is your task to implement a converter in the langu... |
I am standing at point (0,0) in a H x W map where the altitude is represented by digits, for example:
1132
2221
1230 # H = 3, W = 4
I'd like to experience the views from every peak, which in this case are the areas with altitude 3. However, climbing up hills is not an easy task, and I am also running out of time.
... |
You want to open a new zoo. It'll be amazing. But being the cheapskate that you are, you only want to afford three-letter animals (everyone knows that an animal's cost is proportional to the length of its name). There goes your dream of making people pay to see an elephant. But suddenly you have a brilliant idea. If yo... |
0h n0 is a very simple and enjoyable game, a bit like Sudoku or minesweeper.
Game rules
(I recommend using the tutorial in the game if you can, it is very simple and useful)
The puzzle starts with an n * n board containing some fixed pieces and some empty cells, and the solver must find a way to fill the empty cells wi... |
Someone's given us a string, but all bracket-like characters have been changed into normal ones, and we don't know which, or even how many there were. All we know is that if L1,L2,L3,...,LN were different kinds of left brackets and R1,R2,R3,...,RN were different corresponding kinds of right brackets, all being distinct... |
A Stack Exchange script determines which five comments on questions or answers are initially seen on the main page of sites through the number of upvotes on them; the five comments with the highest number of votes are displayed. Your task is to recreate this behavior.
Write a full program or function taking input throu... |
Background
It's well known in mathematics that integers can be put into a one-to-one correspondence with pairs of integers.
There are many possible ways of doing this, and in this challenge, you'll implement one of them and its inverse operation.
The task
Your input is a positive integer n > 0.
It is known that there e... |
Introduction
There is a plantation defined by one big square-board like this one:
The numbers inside each small square represents its area's value/cash/...
The farmer needs help to find the N squares that connected (it means all N squares should have at least one shared border) give him the greatest value.
For example... |
Easy As ABC, also known as "End View", is a puzzle where you are given an empty grid with letters around it; you must partially fill in the grid so that exactly one of each letter is in every row and column; in addition, letters at the end of a row (or column) must be the first letter visible in that row (or column) fr... |
In this challenge you will be creating an image preview compression algorithm. It's goal is to
reduce an arbitrary image file to a 4 KiB preview image, that can be used to quickly identify images
with very little bandwidth.
You must write two programs (or one combined program): a compressor and a decompressor. Both mus... |
If you think this could be fun, but too much work, consider participating in this much smaller challenge.
A bit of fun (and possibly frustration!) for 2016... Dyalog's "puzzle of the year". Enjoy!
The Objective
Find Dyalog APL (download) expressions (other languages are allowed, see Eligibility below) involving exactl... |
/* I hope such question is suitable for here*/
As the batch scripts are pretty limited, hybrid files that embed a code from another language into a batch file are used a lot lately.
Though usually there are some requirements for a good hybrid script:
The embedded code should be usable as-it-is - without any ugly batc... |
The challenge is very simple. Given an integer input n, output the n x n identity matrix. The identity matrix is one that has 1s spanning from the top left down to the bottom right. You will write a program or a function that will return or output the identity matrix you constructed. Your output may be a 2D array, or n... |
Task
Your task is to write a program that will output ASCII boxes at the locations specified by the input.
Input
You will be given a list of numbers. The format here is a bit flexible, in that you can use any deliminator you want (e.g. 1,2,3,4, 1 2 3 4, [1,2,3,4]). The list is in groups of 4 and specifies the xywh of e... |
IPv4 addresses are 32 bits wide, and thus the size of the address space is 232, or 4,294,967,296. However, this is only a theoretical upper-bound. It is not an accurate representation of all the addresses that may actually be used on the public internet.
For the purposes of this challenge, it is assumed that all addr... |
Seems like we do not have this one yet, so here we go:
The Challenge
Write a program or function that takes a date as input and outputs the day number of the year. You may not use any builtins for that!
Rules
As usual you may write a full program or a function.
The format of the input is up to you, but it has to conta... |
Given an input of two strings with sequences of underscores representing
corresponding words, output the sentences with the "blanks" filled in.
The best way to describe this challenge is by example. Here is an example
input:
programming _____________ and code golf
programming puzzles ______ code ____
And here is the c... |
Your task is to write a function or program that takes two non-negative integers i and k (i ≤ k), and figure out how many zeroes you'd write if you wrote all whole numbers from i to k (inclusive) in your base of choice on a piece of paper. Output this integer, the number of zeroes, to stdout or similar.
-30% if you al... |
This isn't very widely known, but what we call the Fibonacci sequence, AKA
1, 1, 2, 3, 5, 8, 13, 21, 34...
is actually called the Duonacci sequence. This is because to get the next number, you sum the previous 2 numbers. There is also the Tribonacci sequence,
1, 1, 1, 3, 5, 9, 17, 31, 57, 105, 193, 355, 653, 1201...
... |
Write a program or function that takes in two integers that represent the X and Y coordinates of a point on a Cartesian plane.
The input may come in any reasonable format as long as the X value comes before the Y. For example, 1 -2, (1,-2), [1, -2], or 1\n-2 would all be fine for X = 1, Y = -2.
Print or return a single... |
In a popular image editing software there is a feature, that patches (The term used in image processing is inpainting as @mınxomaτ pointed out.) a selected area of an image, based on the information outside of that patch. And it does a quite good job, considering it is just a program. As a human, you can sometimes see ... |
The cross product of two three-dimensional vectors \$\vec a\$ and \$\vec b\$ is the unique vector \$\vec c\$ such that:
\$\vec c\$ is orthogonal to both \$\vec a\$ and \$\vec b\$
The magnitude of \$\vec c\$ is equal to the area of the parallelogram formed by \$\vec a\$ and \$\vec b\$
The directions of \$\vec a\$, \... |
Here is another simple one:
The Challenge
Given two points in an n-dimensional space, output the distance between them, also called the Euclidean distance.
The coordinates will be rational numbers; the only limits are the restrictions of your language.
Lowest dimension is 1, highest is whatever your language can handl... |
Introduction
Pareidolia: From Ancient Greek; παρα (para, “concurrent, alongside”) + εἴδωλον (eídōlon, “image”). The tendency to interpret a vague stimulus as something known to the observer, such as interpreting marks on Mars as canals, seeing shapes in clouds, or hearing hidden messages in music. Source: Wiktionary.... |
Write a function or program that outputs the number of each type of element (vertex, edge, face, etc.) of an N-dimensional hypercube.
As an example, the 3 dimensional cube has 1 cell (i.e. 1 3-dimensional cube), 6 faces (i.e. 6 2-dimensional cubes), 12 edges (i.e. 12 2-dimensional cubes) and 8 vertices (i.e. 8 0-dimens... |
Introduction
A known fact is that Jon Skeet can code Perl and make it look like Java. In this challenge you will try to do something similar.
Challenge
Write a piece of code of any length that can be executed without any errors/exceptions in two different languages. Your program can take inputs, give outputs, whatever ... |
Quinary is like binary, except that 1 is represented by the text of the program, and 0 is represented as the backwards text of the program.
The Fibonacci Sequence is the well known sequence
F(0) = 0, F(1) = 1, F(n) = F(n - 1) + F(n - 2)
Write a program that takes some input n and outputs the nth fibonacci number in qui... |
The winding number is the integer number of net counterclockwise revolutions an observer must have made to follow a given closed path. Note that any clockwise revolutions count negative towards the winding number. The path is allowed to self intersect.
Some examples (shamelessly taken from Wikipedia) are given below:
... |
The Scenario
I am building a fancy oscilloscope but I need your help. The oscilloscope can display any number of individual waveforms at the same time (e.g. sine waves) but I don't know how to synchronise the display so it doesn't jump around too much.
The Challenge
Your program or function will take a series of floati... |
Your task is to generate the nth term of the RATS sequence, where n is the input. The RATS sequence is also known as the Reverse Add Then Sort sequence. This sequence can also be found here: http://oeis.org/A004000.
test cases:
0 > 1
1 > 2
2 > 4
3 > 8
4 > 16
5 > 77
6 > 145
7 > 668
For example, the output for 5 is 77 b... |
Lets say we have this existing data:
Total - 10
Won - 7
Lost - 3
Longest Winning Streak - 5
Longest Losing Streak - 2
Now you need to write a function which generates an array of random boolean values (true representing a win and false representing a loss) which fulfills the above criteria.
So, in this case the o... |
Task
Your task is simple. Write a program or function which takes three positive integer arguments \$n\$, \$k\$, and \$b\$ in any order, such that \$2 ≤ b ≤ 36\$, and returns or outputs the nth (1-indexed) base-\$b\$ digit after the decimal point of the rational number (\$b^k-1)^{-2}\$.
The output must be correct for \... |
I have an ASCII-art box and I need a program to open it.
Examples
Input:
-------
| |
|_____|
Output:
/
/
/
/
/
/
/
| |
|_____|
Specification
The first line will only consist of -, at least 3 of them
The middle rows will start with | have spaces, and end with |
All the middle rows will b... |
Take as input 3 floating point numbers, which represent the x, y, z coordinates of a point. Return a truthy or falsey value indicating whether the point is inside the regular icosahedron centred at the origin, with top and bottom vertices at (0, 0, 1) and (0, 0, -1), and with one of the upper ring of middle vertices in... |
EDIT: I will be accepting an answer Monday, 2/15/2016. May the bytes be ever in your favor!
In his "Print the N-Bonacci Sequence" challenge, @DJMcGoathem describes the N-bonacci sequences, wherein the previous N numbers are summed, instead of the traditional 2 of the Fibonacci sequence (said to be the "duonacci sequenc... |
Given an input of any valid Glypho program,
output its "human-readable" counterpart.
Glypho is an interesting esolang idea:
The instruction reference is given here. For each instruction, the characters
abcd represent the symbols composing each instruction. a refers to the first
unique symbol, b refers to the secon... |
The inspiration for this challenge should be ridiculously obvious at the time of posting.
The Task
You must create a Shut the Box style program (not function, program). The basics of shut the box are:
Players attempt to shut the box by turning a set of levers labelled 1-9. They must do so by flipping levers. The sequen... |
Given input of a positive integer n, write a program that completes the following process.
Find the smallest positive integer greater than n that is a perfect square and is the concatenation of n and some other number. The order of the digits of n may not be changed. The number concatenated onto n to produce a perfect... |
How strings are twisted
The twisting algorithm is very simple. Each column is shifted down by its index (col 0 moves down 0, col 1 moves 1, ...). The column shift wraps to the top. It works like this:
aaaa
bbbb
cccc
Becomes:
a
ba
cba
----
cba
cb
c
With everything under the line wrapping to the top. Real example... |
The goal of this challenge is to make a program that outputs the nth letter of its source code where n is given as input to the program. Like most quine challenges, you are not allowed to read your source code as a file or use any builtin quine functions.
Input
An integer 0 <= n < len(program).
Output
The nth character... |
Given an input of an ASCII art "road," output the road with all dead ends
labelled.
This is a road:
########.....######..#..###
#......#######....#..#..#.#
#.##......#...#####..#..###
#..#####..#....#..#######.#
#......#...#####.....##...#
#..###.#...#...###...#..###
##########.#..#..##..#.##.#
..#......#.######.#..#.#... |
In case there's any doubt: Nan = Non-numeric datatype for the purposes of this challenge.
Write a program or function that takes a matrix / array as input, as well as a list of column indices.
The challenge is to remove the rows where all elements in the specified columns are Nan. It doesn't matter if other elements ... |
You love watching the snow falling outside, but you know it won't be snowing much longer. You could take a video, but decide to make a snow animation because ... um ... you need to practice your animation skills!
Snow
Snow is simply the * symbol here. Half of the snow moves at 1 char per frame, while the other half mov... |
The task is simple: consolidate an array of ints. Consolidating this array consists of the following:
All instances of 0 need to be moved to the end of the array.
There should be no 0s between the non-zero integers.
All non-zero indices should retain their order.
Challenge
Consolidate an array in the least amount of ... |
Your job is quite simple, write a program that prints Hello, world!, that when twisted creates a program that prints Twister!.
How strings are twisted
The twisting algorithm is very simple. Each column is shifted down by its index (col 0 moves down 0, col 1 moves 1, ...). The column shift wraps to the top. It kinda loo... |
We can roll up the natural numbers in a rectangular spiral:
17--16--15--14--13
| |
18 5---4---3 12
| | | |
19 6 1---2 11
| | |
20 7---8---9--10
|
21--22--23--24--25
But now that we have them on a rectangular grid we can unwind the spiral in a different order, ... |
The basic idea is to write a program that twists itself, and the twisted version untwists itself. The first program will just be the twisting algorithm described here, and when given its own source code as input, outputs a program that reverses the twisting algorithm.
How strings are twisted
The twisting algorithm is v... |
The "Look and say" or "Say what you see" sequence is a series of numbers where each describes the last.
1
11 (one one)
21 (two ones)
1211 (one two, one one)
111221 (one one, one two, two ones)
312211 (three ones, two twos, one one)
and on and on...
https://oeis.org/A005150
Anyway, this is a regular code golf challenge... |
Your Challenge:
For a golf Course Of Inputted 'n' length to hole where:
'n' is a whole number and a multiple of 5 between 150 and 500
and
1 integer in code = 1 metre
You must calculate the least amount of swings it can be completed in using a combination of clubs and ranges.
Here is a visual representation of what t... |
You're going to replicate the 90's cup holder joke software.
Here's what's it did, and you have to do:
Display the message Do you need a cup holder?
If the user confirms, enter an infinite loop that keeps opening the CDROM drive.
If the user doesn't confirm, silently exit.
You may display the message using either a ... |
I know, the title cracks you up
Given an amount of money, output the fewest number of coins that make up that amount.
Examples
0.1
1 dime
0.01
1 penny
0.28
1 quarter 3 penny
0.56
2 quarter 1 nickel 1 penny
1.43
5 quarter 1 dime 1 nickel 3 penny
Spec
100 cents in a dollar.
The values of each type of coin is:
pe... |
Write a script that writes to standard output, or your language's equivalent, 100 lines of (valid) Java code that begins with:
class Tuple1 {public Object _0;}
class Tuple2 {public Object _0,_1;}
class Tuple3 {public Object _0,_1,_2;}
class Tuple4 {public Object _0,_1,_2,_3;}
class Tuple5 {public Object _0,_1,_2,_3,_4;... |
Subleq is a programming language with only one instruction. Each instruction contains 3 parameters. Code and data space is the same. How it works:
A B C
A, B and C are signed ints. Instructions are executed in the next way:
*B = *B - *A
if(*B <= 0) goto C;
One post is one tip. Write your tips for Subleq here!
Online ... |
Introduction
Finally the movie company is financing your film. They have given you a maximum budget and they also set the running time of your movie.
Now you can start with the pre-production. You have a bunch of scenes already planned, but not all of them will fit into the budget and the film would get way too long as... |
Your boss wants you to write code like this:
public static boolean isPowerOfTen(long input) {
return
input == 1L
|| input == 10L
|| input == 100L
|| input == 1000L
|| input == 10000L
|| input == 100000L
|| input == 1000000L
|| input == 10000000L
|| input == 100000000L
|| input == 1000000000L
|... |
Jelly is a tacit, golf-oriented programming language by our very own Dennis. It’s popping up in answers here more and more often, beating other golf-y languages like Pyth and CJam, both by using its own code page and its powerful chain system to succinctly express programs.
Let’s collect some useful tips for golfing in... |
Introduction
Here in Germany the ruling on work times is very strict. If you work 6 or more hours a day, you have to take at least a 30 minute break. If you work 9 or more hours, you need to take a 45 minute break. If you work less than 6 hours, you don't have to take any breaks.
Of course you can split those breaks, ... |
While idly twisting my Rubik's cube around, my son noticed that it kept going back to the solved state. I'm pretty sure he thought this was some sort of voodoo magic at first, but I explained that if you keep repeating the same sequence of moves, it will always return to its original state. Eventually.
Of course, being... |
A "rhyme scheme" is a string of letters a to z, such that the first occurrences of the characters are in ascending order (without gaps), starting from a. For example (with first occurrences marked):
abccdbebdcfa
^^^ ^ ^ ^
The number of rhyme schemes of length N is given by the Bell numbers B(N). (OEIS A000110)
The C... |
Introduction
Let's observe the following sequence (non-negative integers):
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ...
For example, let's take the first three numbers. These are 0, 1, 2. The numbers used in this sequence can be ordered in six different ways:
012 120
021 201
102 210
So, let's say that ... |
The Collatz Sequence (also called the 3x + 1 problem) is where you start with any positive integer, for this example we will use 10, and apply this set of steps to it:
if n is even:
Divide it by 2
if n is odd:
Multiply it by 3 and add 1
repeat until n = 1
10 is even, so we divide by 2 to get 5. 5 is odd, so we... |
Given an input of a Pig,
SickPig,
DeadPig,
QuinePig, or
DeafPig program, choose one of those
"languages" randomly and interpret the input as that "language."
First, randomly choose between one of the five members of the "Pig series":
Pig
If the choice was Pig, mimic the reference
interpreter by doing the following:
F... |
I've recently realized how vim works great for golfing, especially for kolmogorov-complexity. Also, according to meta vim is a perfectly acceptable 'programming language' at least, for the scope of this site, that is.
What general tips do you have for golfing in Vim? I'm looking for ideas which can be applied to code-g... |
Write some code that takes a single non-negative integer \$n\$ and outputs the \$n\$th power of phi (\$\phi\$, the Golden Ratio, approximately 1.61803398874989) with the same number of decimal digits as the \$n\$th Fibonacci number.
Your code must produce the correct sequence of digits for all inputs up to at least 10 ... |
This is a problem from NCPC 2005. Roy has
an apartment with only one single electrical outlet, but he has a bunch of power strips.
Compute the maximum number of outlets he can have using the power strips he
has. The number of outlets per power strip is given as input.
It turns out that if the number of outlets of the... |
Your should write a program or function that determines the language of a given word.
The task is to recognize some of the 5000 most common words in 4 languages:
English
German
Italian
Hungarian
The word lists can be found in this GitHub repository.
You are allowed to make mistakes in 40% of the provided test cases. ... |
Saw this in a PHP challenge. The objective is to make a chessboard with 64 squares (8*8) with the minimum amount of code.
Simple enough, I made mine in PHP in 356 bytes (not impressive, I know) and I would like to see some other aproaches.
This can be made in a language of your choice, as long as you keep it vanilla, s... |
As we all know, meta is overflowing with complaints about scoring code-golf between languages (yes, each word is a separate link, and these may be just the tip of the iceberg).
With so much jealousy towards those who actually bothered to look up the Pyth documentation, I thought it would be nice to have a little bit mo... |
Given four RGB LEDs and 8 colors, your task is to light up each LED in order with a color, and cycle through the LEDs as you cycle through the colors; with only one LED lit up at a time.
So for 8 colors across 4 RGB LEDs, it would look like this (at a hardware level (since there are three channels for each LED)):
LED1 ... |
For each row and then column of a matrix, we can add an extra entry with the sum of the last two entries in that row or column. For example with the following input matrix:
[ 1 1 1 ]
[ 2 3 4 ]
The resulting matrix would be:
[ 1 1 1 2 ]
[ 2 3 4 7 ]
[ 3 4 5 9 ]
Given an input of an integer N and an [X,Y] matrix of siz... |
Background
I have a row of powerful magnets and a bunch of metal objects between them.
Where will the magnets pull them?
Input
Your input is an array of non-negative integers, which will contain at least one 1.
You can use any reasonable format.
The 0s of the array represent empty space, and the 1s represent fixed magn... |
Write a program or function that takes in a positive integer N. Output a list of all the distinct decimal numbers that can be written in exactly N characters using digits (0123456789), decimal points (.), and negative signs (-).
For example, some numbers that would be in the N = 4 output list are 1337, 3.14, .999, -789... |
The Task
The task is very simple. Given an array containing only integers and strings, output the largest number and the smallest number.
Test Cases
Input: [1, 2, 3, 4, 5, 6, 7, 8]
Output: 1, 8
Input: [5, 4, 2, 9, 1, 10, 5]
Output: 1, 10
Input: [7, 8, 10, "Hello", 5, 5]
Output: 5, 10
Numbers in strings are not consi... |
Problem
One day, you boss walks up to you and tells you he needs to know the time. He still insists after you pointing at the clock directly above your head, and confesses he has a severe case of dyscalculia, which causes him to not even be able to see numbers on a clock. While you're still left wondering how someone u... |
Leonardo da Pisano a.k.a Fibonacci was instrumental in bringing the Hindu-Arabic numeral system into Europe. Before that, mathematicians there worked in base sixty with Roman numerals.
For example, the square root of two might be approximated as: one and twenty-four parts of sixty and fifty-one parts of three-thousand-... |
Your task is to find the length of the coastline of a map of islands provided in
an ASCII map. The input map will consist of 1 or more # characters that
indicate land, and spaces which indicate water. The coastline is considered to
be any edge between land and water, including inland lakes and islands.
Your solution sh... |
Given an input of a single positive integer, output the "cross-alternate sum"
that corresponds to that integer.
Take the example of the input n=5. To find the cross-alternate sum, first
create a square grid of width and height n that, reading from left to right
and top to bottom, starts at 1 and increases by one each p... |
Isn't it annoying when you're working with floating point numbers and your code doesn't work because two numbers are not equal by the least significant bit? Now you can fix that!
Write some code that takes two floating point numbers in any IEEE 754 binary format and returns TRUE if:
the two numbers are exactly equal
f... |
The other day my chemistry teacher was explaining to us about scientific notation (using a small number and multiplying it by powers of ten to express large numbers more easily), which brought me back a few years to when I first learnt it. After learning the basics, we had done a bunch of typical maths questions, some ... |
Wouldn't it be neat if programming functions could be inverted, just like the mathematical function they implement?
Write a function (or program) that takes one input x in any form, that outputs ln(x).
When the bytes of the program are reordered/reversed so that the first byte now is the last byte, it should take one ... |
This challenge is inspired by this other.
The challenge
Write a program or a function in any programming language that given as input a string representing a time in English (see below, for further details) it outputs or prints the equivalent in the 24 hours "digital" format HH:MM.
Shortest code in bytes wins, standard... |
I have a chocolate bar and I need help eating it so you'll be writing a program just to do that.
Explanation
The first line is the input. Examples are separated by an empty line.
7
____
__|__|
|__|__|
|__|__|
|__|__|
6
_______
|__|__|
|__|__|
|__|__|
5
____
__|__|
|__|__|
|__|__|
0
1
____
|__|
Spec
... |
In trigonometry, there are certain angles known as "special angles". This is because when you take sin, cos or tan of one of these angles, you get a result that is easy to remember because it is a square root of a rational number. These special angles are always multiples of either pi/6, or pi/4. Here is a visualizatio... |
You are to approximate the value of:
$$\int^I_0 \frac {e^x} {x^x} dx$$
Where your input is \$I\$.
Rules
You may not use any built-in integral functions.
You may not use any built-in infinite summation functions.
Your code must execute in a reasonable amount of time ( < 20 seconds on my machine)
You may assume that inp... |
Implement a function diff that takes as input three integers x, y, and z. It should return whether subtracting one of these numbers from another gives the third.
Test cases:
diff(5, 3, 2) yields True because 5 - 3 = 2
diff(2, 3, 5) yields True because 5 - 3 = 2
diff(2, 5, 3) yields True because 5 - 3 = 2
diff(-2, 3, 5)... |
Kirchhoff's law says that when you sum up all the currents (positive for the currents going to a junction, and negative for current leaving a junction), you will always get as result 0.
Look at the following diagram:
Using Kirchhoff's law, you can see that i1 + i4 - i2 - i3 = 0, so i1 + i4 = i2 + i3.
Given two lists, ... |
I like making dank memes out of my own images. But all those so called "quick meme" sites just have too much code. I realized that the only way to make the dankest meme generator is to ask you guys at PPCG to golf one for me. So let me give you the low down on what you have to do.
Specs
Take an image as input as a fil... |
The American football championship, Super Bowl 50, is happening today at 11:30pm UTC (and you can watch it live online). This challenge was made to celebrate it.
In an American football game, two teams compete to get the most points and there are six ways to score these points. We'll give each an abbreviation:
Field ... |
You are given a single printable ASCII string containing no newlines, and a multiline "mold", containing spaces (), and hashes (#).
You must go character by character in the string, and replace hashes using the characters from the string in left-right, top-bottom order. If the string is too short to fill the mold, you ... |
Challenge
Inspired by this SMBC comic, discussed on reddit, math.stackexchange, and calculus7, the challenge is to return the lowest base such that a number is "fouriest."
Description
[From the comic]
"It's called a Fourier Transform when you take a number and convert it to the base system where it has more fours, thu... |
The keypad on my office phone has the following layout:
[1] [2] [3]
/.@ ABC DEF
[4] [5] [6]
GHI JKL MNO
[7] [8] [9]
PQRS TUV WXYZ
[*] [0] [#]
+ _
Task:
Write a program that, given an input string, returns a list of instructions that my fingers need to follow in order the type/dial the message/number... |
Background
Most everyone is familiar with the Fibonacci numbers \$F(n)\$:
\$0, 1, 1, 2, 3, 5, 8, 13, 21, ...\$
These are formed by the recursion function \$F(n) = F(n-1) + F(n-2)\$ with \$F(0)=0\$ and \$F(1)=1\$. A000045
A closely related sequence is the Lucas numbers \$L(m)\$:
\$2, 1, 3, 4, 7, 11, 18, 29, ...\$
Th... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.