Questions tagged [number]

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

Filter by
Sorted by
Tagged with
-2 votes
9 answers
470 views

Check whether there are more even than odd numbers on any given nested list [closed]

Take any type of nested list(s) containing numbers. Check for how many even/odd numbers are within and output even, same or odd (-1, 0, 1) in some way. Example: ...
BoollumBits's user avatar
16 votes
32 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 ...
F. Hauri  - Give Up GitHub's user avatar
5 votes
6 answers
509 views

Test if given number is a Reverse Keith?

Slighty inspired by my previous challenge regarding Keith Numbers I want to propose a challenge to create a function that takes an integer and gives back a true or false depending on the number is a ...
Smetad Anarkist's user avatar
7 votes
7 answers
3k views

Enumerate all number that are palindromic in at least two of base 2, 8, 10, 16 or 64

Multi palindromic numbers Finding all number for which at least two** representation are palindromic, with more than one** characters, if in decimal, octal, hexadecimal, binary or in base64. ** have ...
F. Hauri  - Give Up GitHub's user avatar
4 votes
5 answers
8k views

Make a 24 Game Solver

The 24 Game is a card game. On each cards are four interger numbers. For a player, the goal is to use Addition, Subtraction, Multiplication and Division to end up with 24. The goal of this code golf/...
Qqwy's user avatar
  • 545
16 votes
20 answers
1k views

Generate a grid of sums

Generate a 7 by 7 grid, filled with random numbers. However, in cells with an odd row and column number (starting at 0), you must use the sum of the surrounding cells. Here's a small example with a 3 ...
Doorknob's user avatar
  • 71.4k
0 votes
5 answers
404 views

highest common factor-fewest iterations [closed]

Find the highest common factor of two(positive integer) input numbers (not greater than 5000) in the minimum number of iterations. If you use a loop, it should increment a counter, starting at 0 for ...
user80551's user avatar
  • 2,608
3 votes
5 answers
461 views

Generate cyclic numbers in decimal

The formula on the wiki article for cyclic numbers can be used to generate cyclic numbers in any base. Using this formula, or any other appropriate formula, compute the first ten cyclic numbers in ...
Thomas O's user avatar
  • 3,338
26 votes
11 answers
4k views

Flipping pancakes

In pancake sorting the only allowed operation is to reverse the elements of some prefix of the sequence. Or, think of a stack of pancakes: We insert a spatula somewhere in the stack and flip all the ...
daniero's user avatar
  • 18.6k
44 votes
32 answers
4k views

Define a function f such that f(f(n)) = -n for all non-zero integers n

This challenge was inspired by a programming blog I frequent. Please see the original post here: A Programming Puzzle Challenge Define a function \$f:\mathbb{Q}\to\mathbb{Q}\$ such that \$f(f(n)) = -...
ardnew's user avatar
  • 2,329
15 votes
23 answers
2k views

FIBonacci sequence

For this code golf, you will receive an input of a fibonacci sequence, that is, a normal Fibonacci sequence but with one number incorrect. See, the sequence is fibbing! Get it? ...
Doorknob's user avatar
  • 71.4k
18 votes
8 answers
1k views

Save money with price rounding

In Canada, the penny is no longer circulated. Cash payments are rounded to the nearest 5 cents. Money can be saved by splitting purchases. For example, two $1.02 items cost $2.04 which rounds up to ...
cardboard_box's user avatar
29 votes
18 answers
11k views

Convert to and from the factorial number system

The Factorial Number System, also called factoradic, is a mixed radix numeral system. The factorials determine the place value of a number. In this system, the right most digit can be either 0 or 1, ...
Volatility's user avatar
  • 3,364
7 votes
18 answers
2k views

Evaluate the primorial of a number [duplicate]

The primorial of a number is the product of all the primes until that number, itself included. Take a number from STDIN as the input and evaluate its primorial, ...
Soham Chowdhury's user avatar
2 votes
8 answers
1k views

Compute the number of ways how you can express a number as a sum [closed]

For a given natural number n, compute the number of ways how one can express n as a sum of positive natural numbers. For example,...
Petr's user avatar
  • 4,362
32 votes
42 answers
4k views

Print an arch of ascending / descending numbers

I figured an "arch" was the best way to describe this pattern of numbers: ...
Nathan Osman's user avatar
31 votes
20 answers
2k views

Convert number to a base where its representation has most "4"s

Inspired by this. There is a number, given as either integer, string or array of digits (your choice). Find the base in which the representation of the number will have most "4"s and return ...
Fixpoint's user avatar
  • 411
16 votes
16 answers
3k views

Test if given number is a Keith number

Since Fibonacci numbers and sequences seems like a popular subject for code golf I thought that it might be a fun challenge to code golf with Keith numbers. So I propose a challenge that is to create ...
Smetad Anarkist's user avatar
5 votes
4 answers
681 views

Convert the Binary Champernowne Constant to Decimal

The Champernowne constant is a transcendental decimal number whose digits are the concatination of all positive integers. C10 = 0.12345678910111213141516...10 ...
cardboard_box's user avatar
22 votes
12 answers
8k views

Find the Pisano Period

The Fibonacci sequence is a well know sequence in which each entry is the sum of the previous two and the first two entries are 1. If we take the modulo of each term by a constant the sequence will ...
cardboard_box's user avatar
24 votes
10 answers
3k views

Score a game of Bowling

Your task is to sum up and output one player's score in a game of 10-pin bowling after up to 21 rolls. The rolls are represented as a sequence of integers in your preferred method of input. Each ...
daniero's user avatar
  • 18.6k
11 votes
21 answers
1k views

Return each number from a group of numbers

The challenge The program must return all numbers included into a group (comma and hyphen separated sequence) of numbers. Rules s is the sequence string; all ...
BernaMariano's user avatar
12 votes
6 answers
1k views

Score a game of Yahtzee

For each of the 13 rows of a Yahtzee scoresheet you are given (from stdin) a space separated list of 5 numbers (dice). Your task is to calculate the score for each line and output the Grand Total of ...
daniero's user avatar
  • 18.6k
55 votes
49 answers
6k views

Can you Golf Golf?

You are required to generate a random 18-hole golf course. Example output: [3 4 3 5 5 4 4 4 5 3 3 4 4 3 4 5 5 4] Rules: Your program must output a list of hole ...
mikera's user avatar
  • 1,263
15 votes
21 answers
6k views

Calculate the nth term of Golomb's self-describing sequence

Inspired by the previous question. Golomb's self-describing sequence g(n) is a sequence where any natural number n is repeated within the sequence g(n) times. The ...
beary605's user avatar
  • 4,310
25 votes
11 answers
5k views

Generate a Kolakoski sequence [duplicate]

Definition1 A Kolakoski sequence is a self-describing infinite sequence {kn} of alternating blocks of 1's and 2's, given by the following rules: k0 = 1 kn = the length of the (n+1)'th ...
ardnew's user avatar
  • 2,329
3 votes
9 answers
661 views

Generate a valid sequence of numbers with specific rules [closed]

The challenge The program must return a valid sequence of numbers into some rules Rules x is the size of the sequence; x ...
BernaMariano's user avatar
5 votes
5 answers
827 views

Traverse all numbers with only one bit flip per step

You can count 0, 1, 2, 3, 4. But to get from 3 to 4 you have to change 3 bits at once. Given a number of bits, how can you go through all numbers once, but change at each step only 1! bit. Here is an ...
Daniel's user avatar
  • 1,811
-5 votes
38 answers
1k views

Given a number, program must return the alphabet letter correspondent

The program Given a number, program must return the alphabet letter correspondent. Rules The challenge here is to make it as short as possible, everyone knows it is a very easy program to do. The ...
BernaMariano's user avatar
9 votes
9 answers
699 views

Working Week Completion

I work a standard nine to five. Monday through Friday. I take a half hour for lunch from 12:30 to 13:00. Write me a program which, when run, calculates the percentage of the working week that I have ...
skeevey's user avatar
  • 4,365
9 votes
13 answers
3k views

Find the nth Fibonnaci Prime, in the shortest code

The challenge is rather simple: Take a positive whole number \$n\$ as input. Output the \$n\$th Fibonacci prime number, i.e. the \$n\$th Fibonacci number that is also prime. Input can be as an ...
Inkbug's user avatar
  • 554
-1 votes
10 answers
10k views

Triangle Puzzle [closed]

Triangle Puzzle Consider the triangle below. This triangle would be represented by the following input file.    5   9 6  4 6 8 0 7 1 5 By starting at the top and ...
Sammy's user avatar
  • 63
14 votes
8 answers
3k views

Determining the continued fractions of square roots

The continued fraction of a number \$n\$ is a fraction of the following form: $$a_0 + \cfrac 1 {a_1 + \cfrac 1 {a_2 + \cfrac 1 {a_3 + \cfrac 1 {a_4 + \ddots}}}}$$ which converges to \$n\$. The ...
beary605's user avatar
  • 4,310
2 votes
6 answers
343 views

All non-empty finite sets of positive integers

The challenge is to create an iterator(/generator) which iterates (in any order so as to reach all of them... ie no set should occur at infinity) over all possible non-empty finite sets(/tuples/lists) ...
dspyz's user avatar
  • 933
6 votes
3 answers
1k views

Implementing Binary Arithmetic

Given two binary numbers (strings containing 0s and 1s), perform operations on them, with one problem: You must keep them in binary. That means no going ...
beary605's user avatar
  • 4,310
6 votes
12 answers
907 views

Range of numbers

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 ...
daniero's user avatar
  • 18.6k
5 votes
13 answers
3k views

add commas to Numbers without String manipulation

This challenge consist in adding commas to numbers every 3 spaces like: 123456789 => 123,456,789 Specifications: The ...
ajax333221's user avatar
  • 3,634
10 votes
16 answers
13k views

Random sampling without replacement [closed]

Create a function that will output a set of distinct random numbers drawn from a range. The order of the elements in the set is unimportant (they can even be sorted), but it must be possible for the ...
Jim McKeeth's user avatar
54 votes
49 answers
26k views

Outputting ordinal numbers (1st, 2nd, 3rd)

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. Samples: ...
Nicole's user avatar
  • 643
18 votes
31 answers
2k views

Finding Not-Quite-Prime Numbers

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: ...
Mr. Llama's user avatar
  • 2,439
7 votes
27 answers
5k views

determine longest group of consecutive numbers

INPUT: 10 random numbers each number is greater than 0 and less than 100 list of numbers is presorted, lowest to highest the list will not contain any duplicate numbers CHALLENGE: Write a function ...
Bromide's user avatar
  • 205
2 votes
17 answers
746 views

The group of sequential positive numbers with the highest sum?

Given the following list of numbers, find the group of sequential positive numbers with the highest sum. Example input: 12 2 35 -1 20 9 76 5 4 -3 4 -5 19 80 32 -1 ...
Al Newkirk's user avatar
15 votes
50 answers
6k views

Print the amount of ones in a binary number without using bitwise operators

Description Given a number, print the amount of 1s it has in binary representation. Input A number >= 0 in base 10 that ...
pimvdb's user avatar
  • 859
1 vote
13 answers
2k views

position of the only 1 in a number in binary format [closed]

Every number of the form 2i (where i is a non-negative integer) has a single 1 in its binary representation. Given such a number, output the 1-based position of the ...
mohammad shamsi's user avatar
5 votes
16 answers
2k views

Hexadecimal To Decimal [closed]

Read input of up to 8 characters presented as hexadecimal number and print this number as decimal number. In case that input can not be presented as hexadecimal input it has to print 0 Rules: It is ...
ralu's user avatar
  • 281
14 votes
50 answers
3k views

Enumerate all palindromic numbers (in decimal) between 0 and n

Given a non-negative integer n, enumerate all palindromic numbers (in decimal) between 0 and n (inclusive range). A palindromic number remains the same when its digits are reversed. The first ...
Wok's user avatar
  • 334
10 votes
26 answers
3k views

Machine Epsilon

Machine epsilon is an important floating point number to know when doing numerical calculations. One way to understand it is when this relation ...
leonardo's user avatar
  • 341
31 votes
63 answers
16k views

Shortest way to reverse a number [closed]

Write a function (or equivalent subprogram) to accept a single integer valued argument and return a (similarly typed) value found by reversing the order of the base-10 digits of the argument. For ...
user avatar
7 votes
7 answers
559 views

Formatting numbers

Today computers use millions of bytes of memory, and decimal or hexadecimal notations get less and less informative. Most human-readable formatting just display the number with the highest unit ...
Gzorg's user avatar
  • 171
10 votes
2 answers
613 views

The Prime Grid Game

I had fun solving this, so I offer this golf challenge. The objective of this golf is to find the largest prime number that can be constructed using the given instructions. You should accept 3x3 ...
st0le's user avatar
  • 2,208