The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [base-conversion]

Conversion of numbers between positional numeral systems. Most common systems are decimal, binary, hexadecimal etc.

Filter by
Sorted by
Tagged with
0
votes
2answers
140 views

Mirror, Mirror, on the wall. Who's the fairest of them all?

Well, you know it's Snow White, and the evil Queen is at it again. Will Snow White be saved? Will she fall asleep once again? Will the Prince find her? Challenge: Given an arbitrary number (>= 2) of ...
41
votes
30answers
8k views

French license plates

Sandbox French License Plates French license plates come in a sequential order, following a specific pattern of numbers and letters : AB-012-CD Challenge Write ...
15
votes
18answers
2k views

Simplification of numbers

How, you can’t remember the 6 or 7-digit phone number that appeared on the TV screen for a second?! Using the special technique described below, you will turn into a walking phonebook! Obviously, the ...
-2
votes
11answers
215 views

Convert alphanumeric (base-36) sentences into hexadecimal (base-16) sentences

I use "sentence" here loosely to mean "any sequence of words separated by spaces" and "words" to mean "sequences of alphanumeric (hexatrigesimal) characters unseparated by spaces". Conversion is from ...
-3
votes
11answers
304 views

Convert a number into “bracket” numerals

"Bracket" numerals are a type of 'numerals' I made up once, and thought would be a nice challenge here. Basically, you convert the input number into base 6, and then transliterate the ...
-1
votes
13answers
513 views

Find how “smooth” a number is based on binary

I haven't been on PP&CG for a while, so I thought I would post something! Your task is to find how "smooth" a natural number is. Your method is to: 1: Convert the number to binary 2: Find the ...
1
vote
1answer
221 views

Pumping quine radix

Inspired (you don't need to know them for this challenge) by the Pumping Lemma for various languages, I propose the following challenge: choose some basis \$B \geq 2\$ and an integer \$n \geq 0\$ ...
21
votes
26answers
2k views

Digital Sumorial

Given an input n, write a program or function that outputs/returns the sum of the digital sums of n for all the bases 1 to ...
0
votes
7answers
329 views

convert decimal to duodecimal

The task is to convert a string representing a number in decimal (base 10) representation to duodecimal (base 12). The input is thus a string, the output should be printed. The input number can be ...
7
votes
4answers
465 views

Permutation Encoding

Write a program which can encode text to avoid reusing characters, and convert back. Both normal and encoded forms are restricted to a particular character set: the space character ...
30
votes
18answers
2k views

Custom Number Base Converter

The powers that be want to be able to quickly convert any number they have into their own number base using any format they would like. Input Your program must accept 3 parameters. Number: The ...
20
votes
34answers
2k views

Increment base-36 strings

This is a code golf version of a similar question I asked on stack earlier but thought it'd be an interesting puzzle. Given a string of length 10 which represents a base 36 number, increment it by ...
25
votes
32answers
3k views

ASCII art uncompression from a base-n number

This is inspired by an 05AB1E answer by Magic Octupus Urn. Given two arguments, a positive integer and a string/list of characters: Translate the number to base-n, where n is the length of the ...
2
votes
2answers
142 views

Divide them all [duplicate]

A Math.SE user have a funny game explained as such: Pick a random positive integer X. Add +1, 0, -1 to make it divisible by 3Keep track of how much you've added and subtracted. That is your "...
1
vote
2answers
135 views

Hexadecimal, octal, binary, oh my! [duplicate]

This is a code golf puzzle: shortest byte count wins. The program should do the following (Standard loopholes forbidden): Input a hexadecimal number Convert to octal Then interpret the digits as if ...
-12
votes
27answers
391 views

What are these letters?

So what might be the shortest language for this simple task? Task: You are given an input of type String - the string is a ...
26
votes
43answers
3k views

Up go the bits!

Given an integer N perform the following steps: (using 9 as an example). Receive input N. (9) Convert N from base10 to base2. (...
15
votes
10answers
723 views

Several bases but not twice the same digit

Input A non-empty array of positive integers. Task Convert each integer to either binary, octal, decimal or hexadecimal in such a way that each digit (0 to F) is used at most once. Output The ...
11
votes
4answers
425 views

Integers in Base Pi

Background: Pi (π) is a transcendental number, and therefore it has a non-terminating decimal representation. Similar, the representation doesn't terminate if ...
23
votes
15answers
2k views

Not Quite Roman Ternary

Given an integer n ≥ 0 , output it in a non-positional base-3 notation, using digits 139ABCDE… and a 1-character separator. Every digit is a consecutive power of 3 ...
11
votes
3answers
844 views

Crazy but Rational Bases

We have many challenges based on base 10, base 2, base 36, or even base -10, but what about all the other rational bases? Task Given an integer in base 10 and a rational base, return the integer in ...
8
votes
8answers
817 views

Extension of the Game of Sevens

Introduction Output all the numbers in specific base that would appear in an adapted version of the game of seven. Challenge Your task is to output all the numbers in a given base in a given range, ...
11
votes
4answers
403 views

Balanced ternary logic

Balanced ternary logic Ternary is normally another name for base 3, that is to say, each digit is 0, 1, or ...
24
votes
14answers
1k views

Parse the Parcel

Thanks to your help in the Mark My Mail challenge, PPCG-Post has successfully stamped all of its parcels with the generated barcodes! Now, it's time to decode them. In this challenge your program ...
27
votes
20answers
3k views

Is this a three-digit number ending in one?

Given a nonnegative integer, return whether it is a three digit number ending in one, in any consistent integer base. In other words, the number needs to be represented in base-N, N being an integer ...
39
votes
33answers
3k views

Mark My Mail! - ASCII Barcodes

4-state barcodes Many postal services (Royal Mail UK, Canada Post, US Mail, etc) use a 4-state barcode to encode information about their mail. Rendered in ASCII, it may look something like this: | ...
20
votes
23answers
2k views

Find the BCD difference of a number

BCD difference Given an integer n, convert it to BCD (binary-coded decimal) by replacing each decimal digit with its 4-digit binary representation ...
24
votes
23answers
3k views

Take a byte out of it!

Your task is to, given an unsigned integer n, find the largest number which can be created by removing a single byte (8 consecutive bits) of data. Example Given ...
28
votes
25answers
4k views

Smallest Zeroless Base

Given a positive integer n, output the smallest base b >= 2 where the representation of n ...
20
votes
13answers
1k views

The Binary Square Diagonal Sequence

The binary-square-diagonal-sequence is constructed as follows: Take the sequence of positive natural numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ... Convert each number to ...
5
votes
7answers
770 views

Smaller-Base Palindromes

For the purpose of this challenge, a smaller-base palindrome (SBP) is a number which is palindromic in a base between 1 and itself (exclusive), and is not a repdigit in the same base. For example, 5 ...
19
votes
14answers
2k views

How many Lynch-Bell numbers are there?

Challenge Given an integer, n, as input where 36 >= n >= 2, output how many Lynch-Bell numbers there are in base ...
16
votes
15answers
3k views

Go away! No-1's Here!

I was playing around with some numbers and found a sequence that, of course, is on OEIS. It is A005823: Numbers whose ternary expansion contains no 1's. It goes: a(2n) = 3*a(n)+2 a(2n+1) = 3*a(...
9
votes
14answers
1k views

The Binary Binary Expansion

Normally, we decompose a number into binary digits by assigning it with powers of 2, with a coefficient of 0 or 1 for each term: ...
8
votes
14answers
530 views

Count the Palindromes [duplicate]

Given a number n, calculate the amount of bases in the range of [2, n) in which b(n) is a ...
19
votes
12answers
1k views

Real base conversion

We've had a few challenges for base conversion, but all of them seem to apply to integer values. Let's do it with real numbers! The challenge Inputs: A real positive number x, expressed in base 10. ...
18
votes
12answers
4k views

All your base 97 are belong to us

Many programming languages are written using solely printable ASCII, tabs and newlines. These 97 characters are then stored in 8-bit bytes (which are actually capable of holding 256 different ...
17
votes
16answers
986 views

Find the longest rep digit

Your task is to take a positive number as input, n, and output the length of the longest rep-digit representation of n in any base. For example 7 can be represented as any of the following ...
6
votes
2answers
267 views

Non-integer bases

Description: A non-integer representation of a number uses non-integer numbers as the bases of a positional numbering system. e.g. Using the golden ratio (the irrational number 1 + √5/2 ≈ 1.61803399 ...
11
votes
19answers
1k views

How to convert HEX2 to RGBA?

The world of art is full of colour, but the world of the network is even fuller than the world of art of diferent colours and it's renderings. That's why we need to know how to convert one type of ...
40
votes
22answers
6k views

The best base is 10… Let's reach it!

Input: A positive integer n consisting of digits in the range 0-9. Challenge: If d is the highest digit in the integer, assume the base of the number is d+1. E.g. if the integer is 1256 then you ...
30
votes
29answers
4k views

Those Greedy Romans!

Given a strictly positive integer, return the shortest possible Roman numeral using only the additive rule. Output must consist of zero or more of each of the characters ...
15
votes
10answers
2k views

Split me in half

You will be given a number x, where 0 <= x <= 2^32 - 1. You should output a list of numbers in decimal, after recursive ...
22
votes
19answers
1k views

Calculate the binary split sum of a word

Take a string, s containing printable ASCII-characters as input, and output its "binary split sum". Need an explanation? How do you get the binary split sum? We'...
10
votes
16answers
1k views

Hexadecimal to Binary

Convert a hexadecimal number (of any size) into a binary number. Input A POSITIVE hexadecimal number with a 0x in the beginning. A valid input will always match ...
20
votes
8answers
996 views

Find the polynomial

We know that f is a polynomial with non-negative integer coefficients. Given f(1) and f(1+f(1)) return f. You may output f as a list of coefficients, an ASCII formatted polynomial, or similar. ...
19
votes
3answers
339 views

Big base, small digits

The J language has a very silly syntax for specifying constants. I want to focus on one cool feature in particular: the ability to write in arbitrary bases. If you write ...
1
vote
1answer
259 views

Converting rational numbers to an “alien” data format

For a story I'm writing, I needed to convert 101⅐ (101 + 1/7 if that doesn’t show up for you) into base 47. Expressing an integer in some base brings back memories of first learning how to program ...
10
votes
6answers
417 views

Numbers that are palindromes in N bases

Given an non-negative integer n >= 0, output forever the sequence of integers x_i >= 3 that are palindromes in exactly <...
4
votes
4answers
183 views

Mr Seckington weights his ternᵃʳʸ [duplicate]

Mr Seckington is a mobile grocer. He drives his van door-to-door selling his produce all around the nearby villages. Mr Seckington needs a method to weigh the produce he is selling so he knows how ...