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

learn more… | top users | synonyms

16
votes
6answers
878 views

Generate n digits of Gijswijt's sequence

Introduction Gijswijt's sequence (A090822) is famously really, REALLY slow. To illustrate: The first 3 appears in the 9th term (alright). The first 4 appears in the 220th term (a long way away, but ...
15
votes
8answers
723 views

The Back-and-Forth Sequence

Imagine a path made up of < and > and ending in a @, e.g. ><>@ A walker starts on the left-most cell. He will traverse the path as follows: If the walker is on a @ cell, he's ...
7
votes
3answers
261 views

One-to-one correspondence between pairs of integers and the positive integers

It is well-known that there are one-to-one correspondences between pairs of integers and the positive integers. Your task is to write code defining such a correspondence (by defining a pair of ...
39
votes
2answers
4k views

Coding Around The Clock

Write a single line program two or more characters long that contains no line terminators and takes no input. For example, your program might be: MyProgram When your program is arranged into the ...
13
votes
8answers
632 views

How much more reputation do I need?

Programming Puzzles and Code Golf has graduated from beta. Soon we will get a custom site design, and with that the reputation boundaries for privileges will go up. A lot of users will lose privileges ...
8
votes
8answers
493 views

Reverse Greek Conversion Golf

Introduction You must create a function to convert Greek numerals into Arabic numerals. The input will be a Greek numeral less than 1000 and more than 0. This is the reverse of my previous challenge. ...
8
votes
9answers
928 views

Greek Conversion Golf

Introduction You must create a function to convert Arabic numerals into Greek numerals. The input will be an integer less than 1000 and more than 0. Algorithm Split number into digits (e.g. 123 ...
31
votes
18answers
4k views

A Numpad's Knight Numbers

For the non-zero digits on a standard numpad 789 456 123 consider placing a chess knight at any digit and moving it around with any number of normal L-shaped jumps, tracing out a positive decimal ...
27
votes
18answers
918 views

Numbers with Rotational Symmetry

Given an integer, output a truthy value if it is the same upside-down (rotated 180°) or a falsy value otherwise. 0, 1, and 8 have rotational symmetry. 6 becomes 9 and vice versa. Sequence of numbers ...
13
votes
12answers
1k views

In-between fractions

In-between fractions The challenge: You will need to create code that takes atleast 3 inputs; 2 integers and "a fraction representation" - whichever type suits your language for representing the ...
20
votes
14answers
853 views

Generate the minimal remainder sequence

Every number can be represented using an infinitely long remainder sequence. For example, if we take the number 7, and perform 7mod2, then 7mod3, then 7mod4, and so on, we get ...
18
votes
53answers
2k views

Find the program that prints this integer sequence (Robbers' thread)

This is the robbers' thread. The cops' thread goes here. In the cops thread, the task was to write a program/function that takes a positive (or non-negative) integer and outputs/returns another ...
33
votes
70answers
4k views

Find the program that prints this integer sequence (Cops' thread)

This is the cops' thread. The robbers' thread goes here. The last cops-and-robbers thread was already 4 months ago. The cop's task The cop's task is to write a program/function that takes a ...
21
votes
25answers
2k views

The plus-minus sequence

The plus-minus sequence The plus-minus sequence is one that starts with two seeds, a(0) and b(0). Each iteration of this sequence is the addition and subtraction of the previous two members of the ...
18
votes
3answers
187 views

Highest score on the field

Introduction Let a field be a rectangle filled with only the characters - and [0-9]. An example of a field is: 11-011123 111-010-- 0010---01 111-01234 You see that this field has been separated ...
21
votes
5answers
595 views

Commutation of 27 functions

Introduction Let's define a ternary function as a function from the three-element set S = {0,1,2} to itself: it associates to each element of S another element of S. One example of a ternary function ...
17
votes
12answers
627 views

Equality in the sum of digits

Introduction 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 ...
12
votes
3answers
414 views

How many sides does this polygon have?

So in 1st grade math, you learn the names of polygons. Three sides is a triangle, 4 is a square, and 5 is a pentagon. However, in 1st grade honors, you go a bit further. Your challenge There is a ...
-2
votes
16answers
352 views

Print all the numbers! (At least, as many as possible.) [closed]

Your task is to print a number. Simple, right? It is simple, but not as simple as this. The first answer is to print the number 1, the second answer is to print the number 2, etc. Rules The first ...
29
votes
34answers
3k views

Yahtzee Small Straight Detection

In the game Yahtzee, players roll five six-sided dice, and attempt to create certain hands to score points. One such hand is a small straight: four consecutive numbers, not necessarily in order. The ...
36
votes
35answers
4k views

Making a coin fair

You have a coin that produces 0 or 1. But you suspect the coin may be biased, meaning that the probability of 0 (or 1) is not necessarily 1/2. A well known procedure to "transform" a biased coin into ...
20
votes
0answers
215 views

Cycles in run-length encoding

Consider some binary sequence, using 1 and 2, e.g.: 1, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 1 ... Let's write down the run lengths of that: 1, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 1 ... _ _ ____ ____ _ _ ...
10
votes
4answers
966 views

The Unholy numbers

This challenged is highly inspired by what @Mego created with his Holy and Holier numbers, lots of thanks to him and his puns. Holy numbers are numbers composed of only the digits with holes, which ...
8
votes
1answer
378 views

Leaping Lizards!

Suppose we define a simple program that takes an array L of natural numbers with some length N and does the following: i=0 #start at the first element in the source array P=[] ...
5
votes
2answers
234 views

Chaotic Number Shuffling

You have a deck of cards, consisting of cards with non-negative numbers on them, and you haven't shuffled it yet, and no player trusts the other players to be fair at shuffling. You devise a way to ...
20
votes
9answers
838 views

Highly composite numbers

A highly composite number is a positive integer that has more divisors than any smaller positive integer has. This is OEIS sequence A002182. Its first 20 terms are 1, 2, 4, 6, 12, 24, 36, 48, 60, ...
16
votes
20answers
602 views

Descending digit sequences

Introduction As an example, let's take the number 7. We then duplicate this and place 7 spaces in between. We get this: 7_______7 After that, we are going to decrease the number, until there are ...
43
votes
12answers
2k views

Calculate the number of primes up to n

π(n) is the number of primes less than or equal to n. Input: a natural number, n. Output: π(n). Scoring: This is a fastest-code challenge. Score will be the sum of times for the score cases. I ...
-5
votes
7answers
130 views

Find if a number contains a digit without ever using using its string representation

The Challenge: Find if a number contains a digit. The number and the digit are to be taken as input. Output must be a boolean value. But you are not allowed to use the string representation of the ...
50
votes
10answers
3k views

Quack the Angry Duck

No one is quite certain what the emoticon >:U is intended to represent, but many scholars believe it looks like an angry duck. Let's assume that's the case. Task Given an integer n between 0 and ...
2
votes
1answer
205 views

Implement my method of adding numbers mentally

Note: This challenge has been changed to eliminate the strict whitespace manipulation requirements that made this challenge low-quality. Some rules regarding whitespace have been changed. I'm ...
21
votes
3answers
311 views

The Holier Numbers

As we learned from The Holy Numbers, there are 5 holy digits (0, 4, 6, 8, 9), and positive integers consisting solely of those digits are holy. Additionally, the holiness of a number is the sum of the ...
15
votes
9answers
428 views

Block-diagonal matrix from columns

Inspired by Copied from this question at Stack Overflow. Given a matrix A, create a matrix B such that the columns of A are arranged in a block-diagonal fashion. For example, given 1 2 3 4 5 6 the ...
21
votes
9answers
1k views

Generate lazy values

Related: Program my microwave oven. Inspired by Generate lazy microwave input. The lazy value of the non-negative integer N is the smallest of the integers that are closest to N while all their ...
17
votes
3answers
276 views

Generate lazy microwave input

Related: Program my microwave oven and Generate lazy values. My colleague is so lazy that he doesn't even bother to move his finger when programming the microwave oven. (This is actually true!) Help ...
18
votes
1answer
147 views

Sandpile integers

Challenge You will be given a positive integer n as input. Output should be a pyramid-like sandpile built on the rules specified below: Each integer "falls" downward from the same initial starting ...
23
votes
31answers
1k views

Adding up the digits and the digits reversed

Given a number > 0, output the sum with all digits (1 .. n) concatenated and reversed and add them up. For example, with n = 6: The numbers 1 to 6 concatenated: 123456 Reversed: 654321 Adding ...
9
votes
1answer
136 views

Taxi me some numbers

Taxicab Numbers or OEIS A011541 are the least numbers that are able to be represented as n different sums of two positive cubed integers, for successive n. You'll need to print out the nth taxicab ...
24
votes
8answers
2k views

That's a prime… almost

If you've ever learned about primes in math class, you've probably have had to, at one point, determine if a number is prime. You've probably messed up while you were still learning them, for example, ...
17
votes
13answers
1k views

The middle-square method

Introduction The middle-square method is used for the generation of pseudorandom numbers. However, this is not a good method in practice, since its period is usually very short and has some severe ...
27
votes
15answers
892 views

Repair the ranges

Given an input of a list of positive integers with some replaced with 0, output the list with the missing numbers that were changed to 0 replaced. Characteristics of the input list: The list will ...
10
votes
1answer
254 views

How many letters in this word?

Inspired by Project Euler #17, this is your challenge. Write a full program or function that takes a number as input, then print or return how many letters it would take to count up to and including ...
45
votes
19answers
5k views

The Holy Numbers

In many fonts (specifically in the Consolas font), 5 out of the 10 decimal digits have "holes" in them. We will call these holy digits: 46890 The 5 unholy digits are thus: 12357 An integer may ...
15
votes
4answers
329 views

Find the missing number in an undelimited string

The challenge is to identify the missing number in a string of undelimited integers. You are given a string of digits (valid input will match the regular expression ^[1-9][0-9]+$). The string ...
5
votes
3answers
254 views

Output the smallest powers of 2 with two identical sub-strings of digits n long

For each integer n, 0 or higher, output the lowest power of 2 that has two identical sub-strings of n digits in decimal, and the two indices where the digit sub-strings start (0-based). n      ...
18
votes
15answers
1k views

Compute minimax of an array

Inspired by this question Consider an array x such as [1 5 3 4] and a number n, for example 2. Write all length-n sliding subarrays: [1 5], [5 3], [3 4]. Let the minimax of the array be defined as ...
-3
votes
1answer
95 views

Implement decimal-multiplication modulo

Most people can't easily do modulus (or work out if a number is divisible by another number) in their heads because long division is harder than addition, subtraction and multiplication. The following ...
13
votes
20answers
1k views

Output the juggler sequence

The juggler sequence is described as follows. Beginning with an input a1, the next term is defined by the recurrence relation The sequence terminates when it reaches 1, as all subsequent terms ...
7
votes
4answers
151 views

Compute overall ranking

You are given a table that represents the rankings of S subjects according to a number C of different criteria. The purpose is to compute an overall ranking according to a weighted sum of the C ...
15
votes
13answers
904 views

Get the closest value to number

In this code golf, you need to get the closest number from another one in a list. The output may be the closest number to the input. Example: value: (Input) 5 --- [1,2,3] --- 3 And, the program ...