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

learn more… | top users | synonyms

9
votes
9answers
841 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
62 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
471 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
512 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 ...
14
votes
49answers
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
850 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
605 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 = ...
12
votes
4answers
786 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 ...
13
votes
21answers
454 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 ...
34
votes
18answers
4k views

Shotgun Numbers

The Shotgun numbers are a sequence with a rather simple definition but some interesting structure. Start with the natural numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...
13
votes
1answer
152 views

Analyzing Collatz-like sequences

We define a Collatz-like sequence s with 4 positive integers: n starting value d > 1 divisor m > 1 multiplier i increment (In the original Collatz sequence d = 2 m = 3 and i = 1.) Given ...
7
votes
7answers
243 views

Pseudo-cyclic Number Evaluator

For the purposes of this challenge, let's define a cyclic number as an integer that passes the basic part of Midy's Theorem, but not necessarily the extended theorem. This means: the digits in the ...
14
votes
16answers
2k views

Different Way Forward

Given a list of integers produce a Forward Difference at a specified order/depth. For the list of integers: (10, 18, -12, 4, 8, -3, -5, 67, 9, 14) The Forward Differences at the various ...
13
votes
11answers
917 views

Random Golf of the Day #3: Integer Partitions

About the Series First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You ...
1
vote
0answers
148 views

LCD Numbers - get my lost 190 bytes back [duplicate]

Years ago I read the "Best of Ruby Quiz" book by James Edward Gray II (also available online by now). For problem 2 in the book (which is problem 14 on his original RubyQuiz site), he mentions a ...
19
votes
18answers
3k views

Generate Lucky Numbers

Story: Lucy asked George what his Lucky Number was. After some contemplation, George replied that he had several Lucky Numbers. After some brief confusion, Lucy asked George what his first n Lucky ...
10
votes
12answers
1k views

Apportionment paradox

Given: A natural number S. A list of N rational weights W that sum to 1. Return a list L of N non-negative integers, such that: (1) sum(L) = S (2) sum((S⋅W_i - L_i)^2) is minimal In other ...
14
votes
4answers
553 views

Factorize it! …badly

A curious kid uses a program which can factorize a number or an expression into the following form: p1^e1 * p2^e2 * ... * pn^en. Exponents equal to 1 are omitted e.g. 360 = 2^3 * 3^2 * 5 The kid ...
10
votes
21answers
1k views

Random Golf of the Day #2: Numbers from a Normal Distribution

About the Series First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You ...
-1
votes
1answer
210 views

Find the inverse of a matrix

Write a full program to calculate the inverse of a 4-by-4 matrix. Rules The sixteen values of the initial matrix must be hard-coded to variables, as follows: _ _ |a b c d| |e f g h| |i j k l| ...
8
votes
8answers
508 views

Pair-golfing Twin primes and the Collatz sequence

This is a new kind of challenge inspired by the Recover the mutated source code problem. You should write two programs or functions both in the same language. The first one should solve Task #1 and ...
8
votes
9answers
425 views

Ordering an array of negatives, zero and positives integers with one iteration

Take an array of integers containing negative numbers, positive numbers and zeros. Group it with one iteration and in place such that all of the negative numbers come first, followed by all of the ...
1
vote
0answers
94 views

KOTH: Number fight [closed]

Number fight game Setup Each ai is given a random number from 1 to 100. The starting number is the average of these two numbers. Gameplay Each ai knowing its own target, the opposite target ...
10
votes
22answers
2k views

Generate the Stöhr sequence

I am learning Ruby and wrote my first nontrivial code to solve this problem. The challenge is to generate the first n elements of the Stöhr sequence, S, which is defined as follows: S[0] = 1 ...
3
votes
3answers
524 views

Generate all 4-perfect numbers

Your program or function should output all the 36 4-perfect numbers in increasing order separated by newlines. An n positive integer is a k-perfect number (multiply perfect number) if the sum of its ...
-1
votes
6answers
136 views

Double Factorial [duplicate]

Challenge The objective is simple, in the shortest amount of bytes, write a function or program that takes a number and prints its double factorial. The input must be taken from stdin or a function ...
14
votes
7answers
625 views

Sum the powers to n

Directions Write a program that, given an input integer n (n >= 0), outputs the smallest positive integer m where: n = a[1]^b[1] + a[2]^b[2] + a[3]^b[3] + ... + a[k]^b[k] a and b are finite ...
36
votes
14answers
5k views

Into how many pieces can you cut this string?

Consider a piece of string (as in "rope", not as in "a bunch of characters"), which is folded back and forth on the real line. We can describe the shape of the string with a list of points it passes ...
8
votes
5answers
1k views

All primes from 0 to 1000

Is it possible to make this C code smaller? It prints out all primes from 0 to 1000. C, 89 chars int i,p,c;for(i=2;i<1e3;i++){c=0;for(p=2;p<i;p++)if(i%p==0)c++;if(c==0)printf("%u\n",i);}
0
votes
1answer
183 views

Cycles and stuff - What does this program do? [closed]

I just found one of my first C++ programs in some deep caves on my disk... #include <cstdio> #include <cstdlib> #include <iostream> #include <sstream> #include <string> ...
9
votes
36answers
3k views

Calculate the square of an integer with restrictions [closed]

The Puzzle You have to write a program or function p(n) that returns the square of what is entered into it and you may assume that the input is a non-negative integer. Put in simpler terms, return ...
-5
votes
1answer
195 views

Number guessing game with memory [closed]

Your programme should ask the user's name and then play a number guessing game: (>) means that the computer writes it. > What's your name? Brown > Brown you are welcome. What is your number? ...
8
votes
18answers
1k views

Convert RGB integer value into RGB values

For example, in traditional web hexadecimal, a certain base-16 number represents an RGB value. For example, 45A19C equals (69,161,156) in RGB. You'll be converting from that number to RGB value, ...
20
votes
14answers
1k views

Recycling for the New Year

A good resolution for 2015 is to live more sustainably. We'll start by recycling. Recycling code, that is! Your task is to print the number 2015 to STDOUT, with or without trailing newline (and only ...
22
votes
21answers
2k views

Print rotation-safe numbers

Background You are working for some board-game manufacturer and need to produce wooden tiles with the numbers from 0 to n engraved on them for some game. However, without further ado, some tiles ...
17
votes
6answers
1k views

Time Travelling Stock Trader

Story Long time ago Bobby created a Bitcoin wallet with 1 Satoshi (1e-8 BTC, smallest currency unit) and forgot about it. Like many others he later though "Damn, if only I invested more back then...". ...
13
votes
18answers
2k views

Generate any random integer

Your program/function should output exactly one integer output any integer with positive probability output an integer greater than 1.000.000 or less than -1.000.000 with at least with 50% ...
4
votes
6answers
1k views

Print all odd numbers from 0 to 100000

My teacher gave me a simple problem which I should solve with a code tiny as possible. I should print all odd numbers from 0 to 100000 into a HTML document using javascript. for(var y = 0; y < ...
32
votes
28answers
2k views

At least h with at least h

Input A list of nonnegative integers. Output The largest nonnegative integer h such that at least h of the numbers in the list are greater than or equal to h. Test Cases [0,0,0,0] -> 0 ...
6
votes
5answers
650 views

Implement t9-like functionality

Your challenge today is to implement a t9-like functionality. You will implement a function that will only have 2 parameters. You will receive 1 phone number in a string and the content of a text ...
32
votes
5answers
2k views

Numbers as Circular Graphics

First, study this puzzle to get a feel for what you will be producing. Your challenge is to write a program or function which will output a circular graphic like the ones from the puzzle, given a ...
-4
votes
2answers
115 views

Magical Squares [closed]

A perfect square is a number that is the square of an integer. However, let's define something called a Magical Square, which is a perfect square with the following restriction: The perfect square ...
11
votes
8answers
737 views

Balanced Ternary Converter

Credits for the challenge idea go to @AndrewPiliser. His original proposal in the sandbox was abandoned and since he has not been active here for several months, I have taken over the challenge. ...
16
votes
4answers
526 views

Decompose a number with bit-xor without the digits 0, 3, 7

Challenge Write a function or program which takes a positive decimal number, call it A, and output two positive numbers, B and C, such that: A == B bitxor C B and C must not contain any of the ...
11
votes
4answers
874 views

Convert x-illion into standard form

Given a string, consisting of a prefix and then "illion", convert this number into standard form. For example: "million" -> 10^6 "trillion" -> 10^12 "quattuordecillion" -> 10^45 The ...
8
votes
4answers
348 views

Decompose a number into a sum of repdigits

Repdigits are numbers of the form a * (10^n - 1)/9 with a in [-9,9]\{0} (in other words 111, -3333, 66, numbers which are made by repeating only one digit) Goal: Write a program or function which ...
12
votes
7answers
1k views

Determine the Base that a Given Equation is True

Given 3 integers, determine the lowest possible base for the first two integers to multiply into the third. If you think of the Answer to Life, the World, and Everything, 6 * 9 == 42 is true in Base ...
3
votes
3answers
170 views

Number sum medley

Winner CJam, 74 bytes by Optimizer Task Take an input of an integer n through the console or a file. Find the sum of the nth prime, square, triangular number, and cube. Add to that the factorial ...
7
votes
15answers
2k views

Shrinking numbers

The input is an array of (at least 3, maximum 20) different integers. Each integer is greater than -1000 and smaller than 1000. Your task is to shrink the numbers by "linearly mapping" them from 0.0 ...