Questions tagged [number]

A competition to solve a particular problem through the usage and manipulation of numbers.

Filter by
Sorted by
Tagged with
15 votes
31 answers
2k views

Even or odd: three player

It's a three players game, play with one hand. At same time, each player show his hand with 0 to 5 fingers extended. If all player show same kind of (even or odd) number, there is no winner. But ...
86 votes
221 answers
16k views

Count up forever

Write a program that counts up forever, starting from one. Rules: Your program must log to STDOUT or an acceptable alternative, if ...
-1 votes
21 answers
827 views

How Many Paint Tins Do I Need?

Task Take in 3 inputs. The length of the wall, the height of the wall and the coverage of the paint. Output how many tins of paint are required. Output Since there's no way to purchase ...
4 votes
1 answer
177 views

Convert real numbers between factoradic and positive integer bases

This prompt asked you to convert back and forth to factoradic, but is very limited in scope (only decimal integers from 0 to 10!-1). Your task in this challenge is to reach just a bit further and ...
13 votes
21 answers
4k views

German pharmacy payment

Your task is to calculate the amount you have to pay for prescribed medication at a pharmacy in Germany. The amount is simply based on the full price of the item, which will be your input. It is a ...
85 votes
222 answers
17k views

Sum of all integers from 1 to n

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. Input Your input is in the form of any positive ...
47 votes
92 answers
11k views

Determine if all decimal digits are unique

Deleted questions on Stack Overflow sometimes make for great golf material. Write a function that takes a nonnegative integer as input, and returns true if all the digits in the base 10 ...
44 votes
68 answers
8k views

I reverse the source code, you negate the input!

Blatant rip-off of a rip-off. Go upvote those! Your task, if you wish to accept it, is to write a program/function that outputs/returns its integer input/argument. The tricky part is that if I ...
66 votes
170 answers
16k views

Print 0 to 100 without 1-9 characters

Print integers 0 to 100 (inclusive) without using characters 123456789 in your code. Separator of numbers can be comma or white space (by default <blank>, <...
7 votes
25 answers
1k views

Golf me the Schlosberg Numbers

Schlosberg Numbers 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 ...
51 votes
31 answers
9k views

Covering a Skyline with brush strokes

Given a non-negative integer skyline height list, answer how many uninterrupted 1-unit-high horizontal brush strokes are needed to cover it. [1,3,2,1,2,1,5,3,3,4,2]...
15 votes
22 answers
3k views

Implement a whitespace golfer

Some two-dimensional esolangs, such as Forked, and some non-esolangs, such as Python, can sometimes require spaces before lines of code. This isn't very golfy. Also, I'm lazy and writing a 2d lang ...
13 votes
27 answers
2k views

Landmine Number I

Background You have been given the task of calculating the number of landmines in a field. You must calculate the landmine score given a list/string of numbers and the landmine number. The landmine ...
33 votes
33 answers
3k views

Say What You See

The "Look and say" or "Say what you see" sequence is a series of numbers where each describes the last. ...
22 votes
28 answers
1k views

Find the indices of values in one list in another

You must take two lists of positive integers as input, let's call these n and m. You may assume that: All integers in n are part of m All integers in m are unique The lists are non-empty Challenge:...
27 votes
83 answers
5k views

Is it a whole number?

A number is whole if it is a non-negative integer with no decimal part. So 0 and 8 and ...
77 votes
62 answers
8k views

Is it a Cyclops number? "Nobody" knows!

Task: Given an integer input, figure out whether or not it is a Cyclops Number. What is a Cyclops number, you may ask? Well, it's a number whose binary representation only has one ...
32 votes
59 answers
3k views

Create a checkerboard matrix

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: ...
54 votes
128 answers
18k views

Is this number evil?

Introduction In number theory, a number is considered evil if there are an even number of 1's in its binary representation. In today's challenge, you will be identifying whether or not a given number ...
19 votes
8 answers
3k views

Is it a Cyclic number?

A cyclic number is a number of "n" digits that when multiplied by 1, 2, 3,...n, results in the same digits but in a different order. For example, the number 142,857 is a cyclic number since ...
16 votes
53 answers
2k views

How long is my number: Restricted Version

Find the original challenge here Challenge Given an integer, Z in the range -2^31 < Z < 2^31, output the number of ...
234 votes
366 answers
65k views

Is this number a prime?

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 ...
73 votes
84 answers
6k views

No strings (or numbers) attached

If you like this, consider participating in: The Official Dyalog APL 2016 Year Game The monthly Dyalog APL 2017 Code Golf Challenge Make 12 snippets/expressions, in the same language, that result in ...
82 votes
73 answers
14k views

Is this relationship creepy?

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 ...
30 votes
49 answers
3k views

Swap Two Values in a List

Introduction: Although we have a lot of challenges where swapping two items in a list is a subtask, like Single swaps of an array; Swap to Sort an Array; \$n\$ swaps into a nop; etc., we don't have ...
26 votes
39 answers
2k views

Apply at indices

Given: a blackbox function \$f : \mathbb N \to \mathbb N\$, a list of positive integers \$L\$, and a list of indices \$I\$, apply \$f(x)\$ to the elements of \$L\$ at the indices specified in \$I\$. ...
15 votes
28 answers
2k views

There's more than one way to skin a set

Given a set of positive integers \$ S \$, output the set of all positive integers \$ n \$ such that \$ n \$ can be made by summing a subset of \$ S \$ in more than one different way, i.e., that are ...
59 votes
57 answers
6k views

Increment an Array

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: ...
24 votes
12 answers
3k views

Golf GitHub's Pager Logic

Background When searches return many pages of results, GitHub avoids cluttering their UI by eliding page links. Instead, their UI lets you select: Pages at the beginning of the results. Pages near ...
-1 votes
1 answer
250 views

It's Just Simple Math! [duplicate]

Task Your boss is on another crusade for 'efficiency.' He wants to encourage the use of numbers with fewer syllables, so that they're easier to discuss in meetings. If you want to take some time off ...
23 votes
41 answers
1k views

Proper Divisor mash-up

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 ...
22 votes
25 answers
1k views

Possible binaries sum

This challenge is inspired by the AoC 2020, Day 14 - Part II, created by Eric Wastl and his team, which asks to output the possible binary values from a bitmask. Let's say we've a bitmask like ...
10 votes
5 answers
651 views

Generate Eban Numbers

(Continuing on the number sequences code-golf, here is an interesting sequence) Eban Numbers (A006933) are the sequence of numbers whose names (in English) do not contain the letter "e" (i.e., "e" is ...
12 votes
12 answers
748 views

Calculate NDos-size of given integer

Objective Given a nonnegative integer, calculate its NDos-size as defined below, and output it. NDos' numeral system The concept of NDos-size comes from the numeral system I made. It represents every ...
44 votes
90 answers
7k views

Notcalc (Calculate the wrong answer)

Goal: Given two natural numbers (integers from 0 to infinity), output a number that is not the sum of those numbers, but is a natural number. Example solutions (TI-Basic): ...
37 votes
13 answers
2k views

Fractal Smoke Sequence

Introduction A229037 has a quite intriguing plot (at least for the first few terms): There is the conjecture, that it might indeed have some kind of fractal property. How is this sequence ...
36 votes
49 answers
5k views

Generate Monday Numbers

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 The ...
33 votes
44 answers
4k views

Is it a Lynch-Bell number?

You will be given a positive, whole number (that will never contain a 0) as input. Your task is to check whether it is a Lynch-Bell number or not. A number is a Lynch-Bell number if all of its digits ...
20 votes
23 answers
2k views

Diagonal Binary Sequence

Challenge: Given a positive number \$n\$, convert it to binary, and output a sequence where all 1s form a top-left to bottom-right diagonal line, including a ...
74 votes
97 answers
7k views

Is the number binary-heavy?

An integer is binary-heavy if its binary representation contains more 1s than 0s while ignoring leading zeroes. For example 1 is ...
47 votes
69 answers
8k views

Am I an insignificant array?

An insignificant array is an array of positive integers, where the absolute differences between consecutive elements are all smaller than or equal to 1. For example, the following array is ...
24 votes
23 answers
4k views

American odds to probabilities

American odds (aka moneyline odds) are numbers like \$+150\$ or \$-400\$ used to express how much a winning bet would pay out. Convert odds to a fair win probability like this: Positive odds \$+n\$ ...
19 votes
42 answers
1k views

Filter out and add up

Task The task is very simple. Given a non-empty string containing numbers, uppercase and lowercase letters, output the sum of the remaining numbers. For example: ...
25 votes
53 answers
4k views

Get the best of two Arrays

You will be given two arrays of floating-point numbers. Your task is to pair the corresponding elements of the two arrays, and get the maximum of each pair. However, if the two corresponding elements ...
46 votes
36 answers
3k views

Sort by Multiplying

You should write a program or function that given a list of positive integers multiplies each element with the smallest positive integer possible to create a strictly increasing list. For example if ...
20 votes
14 answers
1k views

Number of palindrome splits

In this task you will take as input a non-negative integer \$n\$, and output the number of pairs of non-negative integers \$a,b\$ such that both are palindromes*, \$a \leq b\$, and \$a+b = n\$. For ...
11 votes
16 answers
986 views

Multibase Numbers

(Similar: Through the bases) Normally, our number system is base ten, with the digits 0123456789. However, we can increase or decrease the base count (so ...
5 votes
8 answers
737 views

Make a Plain PIE!

(2 Jan 2018) Because of the winning criteria I am going to accept the Jelly answer, but I am also giving upvotes to all other answers which all use astounding methods as well Introduction There are ...
15 votes
16 answers
1k views

Imtiaz Germain Primes

Description "Imtiaz Germain primes" is not a technical name in Mathematics, but my weird creation, in the memoir of the famous mathematician Sophie Germain. These primes can be generated by ...
15 votes
13 answers
2k views

Half even rounding

The round function in Python 3 will round values of the form \$k+\frac{1}{2}\$ (with \$k\$ being an integer) to the nearest even integer, which is apparently better ...

1
2 3 4 5
26