Duolingo, the language learning app, has a lot of things going for it, but there is one major issue that drives me crazy. It tells me how many days in a row I've used the app with a message like You'...
According to this XKCD comic, there is a formula to determine whether or not the age gap in a relationship is "creepy". This formula is defined as:
(Age/2) + 7
being the minimum age of people you ...
Given a natural number as input, your task is to output a truthy or falsey value based on whether the input is a factorial of any natural number. You can assume that the input number will ...
This challenge is related to some of the MATL language's features, as part of the May 2018 Language of the Month event. Associated challenge: Function clipboard: copy.
MATL's function ...
Input: Two decimal integers. These can be given to the code in standard input, as arguments to the program or function, or as a list.
Output: Their product, as a decimal integer. For example, the ...
Write a program which outputs the square root of a given number in the shortest time possible.
It may not use any builtins or powering with non-integers.
as a function argument
The Fibonacci sequence is a fairly well known thing around here. Heck, it even has its own tag. However, for all that, we sure like to stick to our roots of 1, 1, ... (or is it 0, 1, ...? We may never ...
Given a string representing a mathematical expression return the result
A string representing a mathematical expression : '1 + 2 - 3 * (2/3 * 1)'.
The result after ...
This challenge is related to some of the MATL language's features, as part of the May 2018 Language of the Month event. Associated challenge: Function clipboard: paste.
MATL has several ...
The "Look and say" or "Say what you see" sequence is a series of numbers where each describes the last.
11 (one one)
21 (two ones)
1211 (one two, one one)
111221 (one one, one two, two ones)
Given two numbers, output their quotient. In other words, integer divide one number by another.
Both divisor/dividend will be under 10001. Division must be performed using integer division,...
Input two integers.
Integer I/O must be decimal.
If the integers are equal, output a truthy value.
Otherwise, output a falsy value.
You will never receive non-integer ...
Given an integer n as input, return a list containing n, repeated n times. For example, the program would take 5 and turn it into [5,5,5,5,5]. The elements need to be integers, not strings. No built-...
This challenge is related to some of the MATL language's features, as part of the May 2018 Language of the Month event.
In MATL, many two-input functions work element-wise with ...
Given integers N , P > 1 , find the largest integer M such that P ^ M ≤ N.
Input is given as 2 integers N and P. The output will be the integer M.
4, 5 -> 0
33, 5 -> 2
In the northern hemisphere (i.e. Europe, North America, etc.), the seasons are divided like this:
- Spring: March, April, May
- Summer: June, July, August
- Autumn: September, October, ...
Your mission is to build an algorithm (program or function) that can optimize packing fruit from a conveyor belt into bags to be sent off to retailers, optimizing for a largest number of bags.
This is a repost of an old challenge, in order to adjust the I/O requirements to our recent standards. This is done in an effort to allow more languages to participate in a challenge about this ...
Story, or why we are doing this.
None. This exercise is completely pointless ... unless you are Stephen Hawking.
Given a list of angles, find the average of those angles. For example ...
In issue 5 of Mathematical Reflections, Dorin Andrica proposed the problem of characterising the positive integers n such that is an even integer. Eight people submitted ...
This is a overhaul of this now deleted question by ar kang. If the OP of that question would like to reclaim this question or has a problem with me posting this I'd be happy to accommodate
Given a ...
Given a number, program must return the alphabet letter correspondent.
The challenge here is to make it as short as possible, everyone knows it is a very easy program to do.
Monday numbers, as defined by Gamow in this question over on Puzzling, are positive integers N with the following three properties:
The decimal representation of N does not contain the digit 0
This was inspired by a math problem I saw somewhere on the internet but do not remember where (UPDATE: The original problem was found on the math riddles subreddit with a proof provided that it is ...
The challenge itself was something I came across and had to try and figure out for a personal of project of mine. I ended up branching out and asking family members if they could provide ...
Believe it or not, we do not yet have a code golf challenge for a simple primality test. While it may not be the most interesting challenge, particularly for "usual" languages, it can be nontrivial in ...
Let's take the number 180. This is an interesting number because the sum of digits of this number is equal to:
1 + 8 + 0 = 9
And the squared version of this number, or:
180² = 32400 &...
Countries own a series of territories on a 1D world. Each country is uniquely identified by a number. Ownership of the territories can be represented by a list as follows:
1 1 2 2 1 3 3 2 4
In some nations there are recommendations or laws on how to form emergency corridors on streets that have multiple lanes per direction. (In the following we only consider the lanes going in the ...
Given a number N, output the sign of N:
If N is positive, output 1
If N is negative, output -1
If N is 0, output 0
N will be an integer within the representable range of integers in your chosen ...
I'm honestly surprised that this hasn't been done already. If you can find an existing thread, by all means mark this as a duplicate or let me know.
Your input is in the form of any positive ...
Your challenge, should you chose to accept it, is to code-golf a function that returns true or false (or some similar meaningful representation of yes and no) if a number meets the following criteria:
I would like to generate (as a return result of a function, or simply as the output of a program) the ordinal suffix of a positive integer concatenated to the number.
Came over a similar problem in a project I'm working on and found it quite hard to solve it without excesive use of if. I'm eager to see if anyone can come up with more elegant solutions to this, with ...
We define the hyper-average of an array / list (of numbers) the arithmetic mean of the sums of its prefixes.
For example, the hyper-average of the list [1, 4, -3, 10] is computed in the following ...
Find the original challenge here
Given an integer, Z in the range -2^31 < Z < 2^31, output the number of digits in that number (in base 10).
You must not use any string ...
Two integers: one negative, one positive.
On the first line output lowest to highest. On the second line we've removed the highest and lowest numbers and sign-changed all individual ...
This question will be a twist on finding the nth prime number.
You must write a program that will take one input n, and output the nth prime number whose decimal representation contains ...
Check if the given number forms a number staircase or not
A integer (greater than 0 and not decimal). NOTE : You can take input as string , array of digits.
a truthy /...
I have a problem at work. I need to compare two numbers that come as strings from two different databases. The numbers may come with leading zeroes and/or leading/trailing spaces. So I may have "0001 "...
Given a nonempty array of positive integers, "increment" it once as follows:
If all the array elements are equal, append a 1 to the end of the array. For example:
 -> [1, 1]
 -> [2, 1]
Given two non-negative integers, find the sum of both numbers... to the power of 4.
2, 3 -> 97 (2^4 + 3^4 = 97)
14, 6 -> 39712 (14^4 + 6^4 = 39712)
0, 25 -> ...
The input consists of i rows with neighbors information. Each ith row contains 4 values, representing the neighbor of i to the North, East, South and West directions, respectively. So each value ...
Here is another simple one:
Given two points in an n-dimensional space, output the distance between them, also called the Euclidean distance.
The coordinates will be rational numbers; ...
A childhood game designed to help children learn to count in french in Canadian schools is played as follows:
Students go around the room counting up to 11
A number greater than 11 ...
Take a string of upper or lower case letters as input (optional), and calculate the score that string would get in a game of Scrabble in English.
The score of each letter is as ...
As you may know it, the factorial of a positive integer n is the product of all the positive integers which are equal or smaller to n.
For instance :
6! = 6*5*4*3*2*1 = 720
0! = 1
We will now ...
In light of today's date...
A factorial of a number n, is the product of all the numbers from 1 to n inclusive.
Given an integer n where 0 <= n <= 420, find the sum of the ...
Getting the average of a list (e.g [2,6,7])
Get the length of the list: [2,6,7] -> 3
Sum the numbers in the list: 2 + 6 + 7 = 15.
Divide the sum by their count: 15 / 3 = 5.
You should compare ...
Given a string as input, check if it is a valid ordinal number in English or not. If it is valid return truthy value otherwise return falsy value. (Suggested by @Arnauld. Thanks . Also ...