This challenge is intended to be solved by using, manipulating, accepting as input, or outputting numeric values.

learn more… | top users | synonyms

17
votes
32answers
1k views

Comparing two numbers

Challenge Given two integers A and B as input, you must write a program which outputs if A>B, A==B or A<B. The integers will be in any reasonable range supported by your language which ...
37
votes
12answers
4k views

A naturally occurring prime generator

There are quite a large number of prime generating functions. Pretty much all of them are constructed and are based on the sieve of Eratosthenes, the Möbius function or the Wilson's theorem and are ...
9
votes
5answers
416 views

Cycle lengths for Perfect shuffles of decks of any size

Challenge In the shortest amount of code: Compute the length of the permutation cycle of a perfect shuffle on a deck of cards of any size n (where n ≥ 2 and n is even). Output a table of all cycle ...
2
votes
8answers
230 views

Exponentiation of natural numbers using only primitive integer operations [duplicate]

The challenge Implement the C equivalent of the pow() function (exponentiation) for natural numbers, in a language of your choosing, using only addition, subtraction (which includes negation and ...
21
votes
2answers
712 views

Row of natural numbers

Definition There is infinite row of concatenated natural numbers (positive integers, starting with 1): 1234567891011121314151617181920212223... Challenge Write program in any language, that ...
17
votes
10answers
2k views

ASCII Maya Numbers

Write a program or function which, given a positive integer as input, outputs the representation of that integer in Maya numerals. Maya numerals Maya numerals is a vigesimal system (base 20) using ...
9
votes
4answers
663 views

The Untouchables

Untouchable Numbersα An untouchable number is a positive integer that cannot be expressed as the sum of all the proper divisors of any positive integer (including the untouchable number itself). ...
0
votes
2answers
194 views

Name a number using the Myriad System!

The Myriad System is an alternative system for naming large numbers proposed by Donald Knuth in 1981. In this system, numbers up to 999 are named as they are normally, but 1000 is not given a special ...
8
votes
3answers
451 views

Square from Digits with Largest Sum

You should write a program or function which receives a list of digits as input and outputs or returns the largest sum achievable by putting these digits in a square. Input will always contain a ...
10
votes
8answers
346 views

Creating Distinct Sums

You should write a program or function which receives an integers as input and outputs or returns two integers whose sum is the first one. There is one further requirement: no number can be part of ...
8
votes
12answers
744 views

Fill in the Number Blanks

You are given a list of 2-tuples of positive integers, of the form: a1 b1, a2 b2, ..., an bn In other words, the 2-tuples are comma-separated, and the integers within each tuple are space-separated. ...
-3
votes
1answer
313 views

The Miscalculator

Inspired by a post I saw on social media, your job is to create a miscalculator (aka "wrongulator"): a calculator which always outputs the wrong answer! Challenge Write a program that inputs a ...
8
votes
10answers
869 views

Triangular Square Numbers

Square numbers are those that take the form of n^2 where n is an integer. These are also called perfect squares, because when you take their square root you get an integer. The first 10 square ...
16
votes
12answers
1k views

Output the Iccanobif Sequence

Write a program or named function that will output or return the sequence up to the nth integer in the Iccanobif sequence, documented on OEIS as A014258. Note that only the zeroth element in the ...
12
votes
4answers
453 views

Find primitive semiperfect numbers

Semiperfect numbers A semiperfect/pseudoperfect number is an integer equal to the sum of a part of or all of its divisors (excluding itself). Numbers which are equal to the sum of all of their ...
54
votes
23answers
11k views

xkcd-Style Page Numbering

Randall Munroe's book "xkcd, volume 0" uses a rather odd number system for the page numbers. The first few page numbers are 1, 2, 10, 11, 12, 20, 100, 101, 102, 110, 111, 112, 120, 200, 1000, 1001, ...
5
votes
3answers
251 views

Read numbers in the base of the largest digit and write it using underscores

This isn't as much a "challenge" as "a unique problem that there are no built-in functions to solve." Basically, you need to do this: Read some lines of numbers from stdin. These lines may contain ...
26
votes
16answers
3k views

All about basic binary

Please excuse the punny title. This is a question is inspired by A Curious Property of 82000. In it, the author points out that the number 82000 is binary in base 2, 3, 4, and 5. The post then ...
19
votes
9answers
842 views

Calculating Collatz Cousins

Define the function f(n) for a positive integer n as follows: n / 2, if n is even 3 * n + 1, if n is odd If you repeatedly apply this function to any n greater than 0, the result always seems to ...
43
votes
12answers
3k views

Fissile Numbers

I found this sequence while working on Evolution of OEIS, but never got around to posting it as an answer. After writing a reference implementation in Mathematica, I thought this is a fun exercise to ...
13
votes
9answers
925 views

Split as number, join as string, repeat

Consider the process of: Taking a non-negative integer N. e.g. 27. Spliting it into integers N - floor(N/2) and floor(N/2) (a 'bigger' and 'smaller' half) and writing them in that order. e.g.27 ...
19
votes
9answers
1k views

Sum in each dimension

You are given a multi-dimensional array of integers. Each dimension has a fixed size (so that it would be always rectangular if it is 2D). Your program should calculate the sums in each dimension and ...
12
votes
28answers
2k views

Count the number of vowels in each word of a string

This is a rather easy challenge. Challenge Input will contain a string (not null or empty) of maximum length 100. Output the number of vowels in each word of the string, seperated by spaces. Rules ...
11
votes
12answers
2k views

QuickGolf - Barry the messy developer #2

This is a follow-up of QuickGolf - Ignore the noise #1 the only problem being that Barry has made things even worse for us. Lets see what happened Update I've added code to create random ...
22
votes
17answers
2k views

XOR multiplication

You goal is to implement the operation of XOR (carryless) multiplication, defined below, in as few bytes as possible. If we think of bitwise XOR (^) as binary addition without carrying 101 5 ^ ...
11
votes
4answers
585 views

Magic Sequences of length n

A magic sequence is a sequence of non-negative integers x[0..n-1] such that there are exactly x[i] instances of i For instance, 6,2,1,0,0,0,1,0,0,0 is a magic sequence since there are 6 0's, 2 1’s, ...
23
votes
11answers
1k views

Generate Keyboard Friendly Numbers

Most common computer keyboard layouts have the decimal digit keys 1234567890 running along at their top, above the keys for letters. Let a decimal digit's neighborhood be the set of digits from ...
11
votes
13answers
670 views

Largest and smallest values from concatenated integers

This problem is from Five programming problems every Software Engineer should be able to solve in less than 1 hour which itself is an interesting read. The first few problems are trivial, but the ...
11
votes
3answers
509 views

Very Nice Friedman Numbers

A Friedman Number is a positive integer that is equal to a non-trivial expression which uses its own digits in combination with the operations +, -, *, /, ^, parentheses and concatenation. A Nice ...
9
votes
2answers
213 views

Digits Digging a Dungeon

Edit: I will award a 100-reputation bounty for the first solver of the bonus puzzle at the end of the question! I will add the bounty to the question only when the answer appears as this ...
4
votes
4answers
508 views

Many programs, few characters

Your task is to create many programs. The first outputs 1, the second outputs 2, etc. The higher you can go, the better! However, all of these programs must be made the same list of characters. You ...
21
votes
5answers
456 views

StickStack Numbers

StickStack is a very simple stack-based programming language with only two instructions: | pushes the length of the stack onto the stack - pops the top two elements from the stack and pushes back ...
-4
votes
7answers
170 views

Determine length of bitstring

Optimize the following function for number of tokens: int length(int x) { switch (x) { case 1: return 1; case 3: return 2; case 7: return 3; case 15: return 4; case 31: ...
43
votes
125answers
4k views

Evolution of OEIS

In this challenge, the goal is to recreate the On-Line Encyclopedia of Integer Sequences one sequence at a time. Similar to the Evolution of Hello World, each answer depends on a previous answer. ...
17
votes
11answers
1k views

Counting in pyramids

You should write a program or function which receives a list of distinct integers as input and outputs or returns the number of occurrences of the input numbers in the following upside-down number ...
12
votes
2answers
590 views

Smoothing out a list

You should write a program or function which takes a non-negative integer k and a sorted integer list Las input and outputs or returns a smoothed list M. M is created from the ascending list L by ...
15
votes
9answers
2k views

Compute the Hausdorff Distance

Introduction The Hausdorff distance measures the difference between two subsets of a metric space. Intuitively, a metric space is just some set with a built-in distance function; in this challenge, ...
12
votes
1answer
614 views

Two-zero-one-five puzzle

Background This puzzle is a variation on the four fours puzzle (itself the topic of a past question). Like that puzzle, the aim is to find mathematical expressions for different whole numbers, using ...
20
votes
9answers
2k views

Generate a pair of integers from a non-negative one

You should write a program or function which takes a non-negative integer N as input and outputs or returns two integers (negative, zero or positive) X and Y. Integers are meant in the mathematical ...
18
votes
2answers
639 views

Prepare to… die?

Background One source of ennui in tabletop role-playing games is dealing with rolls involving many dice. Casting a Disintegration spell may be instantaneous, but rolling and adding together 40 dice ...
10
votes
9answers
1k views

Generate The SUDSI Sequence

The SUDSI sequence (sum, difference, swap, increment) is a curious integer sequence that appears to exhibit rather chaotic behavior. It can be generated as follows: Let S be an infinite list of the ...
0
votes
0answers
65 views

Random arithmetic quiz [duplicate]

Given a and b as two random numbers from 0 to 10 and op as a random symbol of arithmetic operations, you should display 10 questions in the format: a op b = to the user, after each question if the ...
17
votes
6answers
2k views

Chinese Remainder Theorem

The Chinese Remainder Theorem tells us that we can always find a number that produces any required remainders under different prime moduli. Your goal is to write code to output such a number in ...
15
votes
6answers
527 views

Sorted Lexical Partition of a Number

The challenge is really simple: given a number, you split its digits into an array of smaller numbers such that the resulting numbers are non-decreasing. The catch is that you have to split it such ...
6
votes
3answers
551 views

Finding Collatz-like rules with many loops

This code-challenge is related to the code-golf question Analyzing Collatz-like sequences but the goal is quite different here. If you are familiar with Collatz-like sequences you can skip to the ...
17
votes
54answers
2k views

Print number triangle

Given a number N, output a NxN right angled triangle, where each row i is filled with numbers up to i. Example n = 0 (no output) n = 4 1 1 2 1 2 3 1 2 3 4 n = 10 1 1 2 1 2 3 . . . 1 2 3 4 5 6 ...
3
votes
17answers
879 views

Randomised list, formatted nicely

Challenge Task Given a number N, output 2 NxN squares; each line of each square is a random permutation of [0, N); the squares are separated by a newline Rules Produce a randomised list of length ...
5
votes
7answers
669 views

Digit sum of powers in bases

You should write a program or function which outputs or returns the sum of the digits in base b representation of the first n natural power of a in ascending order. Example for a = 2, b = 3 and n = ...
13
votes
4answers
870 views

Find the maximum of ax+b

You are given a list of (a,b), and a list of x. Compute the maximum ax+b for each x. You can assume a, b and x are non-negative integers. Your program or function must run in expected (to the ...
14
votes
21answers
519 views

Bookkeeping for the Sex Bob-ombs (check if a running sum ever gets too low)

Believe it or not, the Sex Bob-ombs have become a world famous band and are currently on world tour! As their bookkeeper you must oversee their day to day finances and provide regular reports. Every ...