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
41
votes
30answers
7k 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
3answers
750 views

Fibonacci’s sexagesimals

Leonardo da Pisano a.k.a Fibonacci was instrumental in bringing the Hindu-Arabic numeral system into Europe. Before that, mathematicians there worked in base sixty with Roman numerals. For example, ...
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 ...
23
votes
17answers
2k views

Implement a Stopwatch

Implement a simple digital Stopwatch, which will display the time elapsed in seconds and minutes, as described below. Important Please read both Display and Controls sections ! Display Time ...
26
votes
3answers
1k views

Residue Number System

In the vein of large number challenges I thought this one might be interesting. In this challenge, we will be using the Residue Number System (RNS) to perform addition, subtraction, and ...
31
votes
34answers
5k views

What base is this number in?

Here's a nice easy challenge: Given a string that represents a number in an unknown base, determine the lowest possible base that number might be in. The string will only contain ...
20
votes
11answers
1k views

Find the Emirps!

An emirp is a non-palindromic prime which, when reversed, is also prime. The list of base 10 emirps can be found on OEIS. The first six are: ...
21
votes
18answers
1k views

Repdigit Base Finding

A repdigit is a natural number that can be written solely by repeating the same digit. For example, 777 is a repdigit, since it's solely composed of the digit ...
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 ...
7
votes
3answers
440 views

Convert integer to balanced dozenal

Create a function which takes an integer and returns an array of integers representing the number in balanced base twelve. Specifically, the representation should follow these rules regarding 6 & -...
32
votes
16answers
5k 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. ...
27
votes
25answers
3k views

Find the next 1-sparse binary number

A positive integer N is K-sparse if there are at least K 0s between any two consecutive 1s in its binary representation. So, the number 1010101 is 1-sparse whereas 101101 is not. Your task is to ...
-2
votes
11answers
213 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 ...
15
votes
9answers
2k views

Brainf**k to Unary and Back

A language that is very useful in restricted source and other such challenges is Unary, a brainfuck derivative in which programs are written in with only one character. Your job is to write a program ...
47
votes
23answers
9k views

Count down from “Infinity”

Seems like an impossible task right? Well, it's actually not that hard. If we write the word Infinity as 8-bit binary ASCII code, we'll get: ...
-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 ...
23
votes
23answers
1k views

The Base in the mix

Input: A list/array of integers for which each item is in the range of 2-36. Output: The sum of the integers (as base 10), where each next integer is in the base ...
16
votes
14answers
712 views

Non-palindromic numbers

A strictly non-palindromic number N is a number that isn't a palindrome in any base (in bases 2 to N-2). These numbers are listed on OEIS For example, the number ...
22
votes
9answers
2k views

Determine the Base where 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 the Ultimate Question of Life, The Universe, and Everything, 6 ...
-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 ...
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 ...
14
votes
12answers
1k 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 ...
45
votes
23answers
2k views

Hexadecimal and the Alphabet

In this challenge, you will receive an input, convert it to hexadecimal, make a couple changes, and output the result. Because they are only 16 characters in hexadecimal, your code will need to be as ...
10
votes
10answers
2k views

Convert a bytes array to base64

Your mission is to write a function/program that converts an array of bytes (i.e: an array of integers from 0 to 255), to base64. Using built-in base64 encoders is not allowed. The required base64 ...
20
votes
14answers
1k views

All your base palindromic belong to us

Generate the sequence number of bases in which n is a palindrome (OEIS A126071). Specifically, the sequence is defined as follows: given a number ...
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 ...
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\$ ...
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 ...
27
votes
19answers
7k 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, ...
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 ...
23
votes
32answers
2k views

Convert a number to Hexadecimal

Challenge Here's a simple one. Write a function or program when given a number in base 10 as input, it will return or print that number's value in Hexadecimal. Examples ...
0
votes
7answers
326 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
462 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 ...
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 ...
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: | ...
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 ...
16
votes
9answers
955 views

Base Conversion With Strings

Introduction We've have a few base conversion challenges here in the past, but not many designed to tackle arbitrary length numbers (that is to say, numbers that are long enough that they overflow ...
11
votes
20answers
975 views

Determine if an integer is a palindrome in a given radix (base)

Write a program that reads from stdin two integers, each newline terminated, hereafter called "number" and "radix", and: Prints any fixed message you want if the number is a palindrome in that radix (...
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 ...
65
votes
26answers
15k 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 ...
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 "...
-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 ...
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 ...
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. (...
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'...
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 ...
21
votes
12answers
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 ...
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 ...
42
votes
48answers
5k views

Numbers that are actually letters

Given a non-negative integer input, write a program that converts the number to hexadecimal and returns a truthy value if the hexadecimal form of the number contains only the characters ...