Questions tagged [base-conversion]

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

143 questions
1k views

Reverse and square

In this challenge you will compute numbers from a curious sequence. Your input is a single decimal nonnegative integer. Reverse the bits in this integer and then square the number to get the required ...
2k views

Simplify binary

Challenge Given a binary number as input through any means, "simplify" the number using a full program or a function. Input [binary] ...
1k views

ASCII Character Jumble

Write a program that takes as its input a string consisting of printable characters (ASCII 20-7E) and an integer n in [2,16] and performs the following modification ...
4k views

Biplex: an important useless operator

Input A list of between 1 and 255 positive integers (inclusive), each in the range 1 to 232 - 1 (inclusive). Your input format does not need to be identical to the test cases. Input without leading ...
2k views

I don't like numbers, but I do like the Fibonacci sequence. I'm sure we could work something out. Please read one integer n from STDIN and output the nth Fibonacci number in base 26 (...
873 views

Koopa Shell Sequence

In various Super Mario games green and red Koopa Troopa shells can slide frictionlessly on flat surfaces and destroy brick blocks that are in their way. When a shell hits a brick block the block ...
2k views

Base85 Encoding

The Challenge Write a program that can take an input of a single-line string containing any ASCII printable characters, and output the same string encoded in Base85 (using a big-endian convention). ...
3k views

16-bit binary grid

Given any unsigned 16 bit integer, convert its decimal form (i.e., base-10) number into a 4x4 ASCII grid of its bits, with the most-significant bit (MSB) at the top left, least-significant bit (LSB) ...
431 views

Print a table of numbers in decimal and 2**i bases

Computers live by binary. All programmers know binary. But the 2**x bases are often neglected as non-practical, while they have beautiful relations to binary. To ...
3k views

Obfuscating text by cycling ternary digits

The goal of this challenge is the write the shortest function/program to take input text, encrypt it using the method below, and return the result. As an example, I will use the string ...
855 views

Rise, sequence, rise

We have a strictly increasing sequence of non-negative integers, like: 12 11 10 Wait! This sequence isn't strictly increasing, is it? Well, the numbers are ...
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 ...
2k views

64 bit ASCII weaving

Input Two integers: A non-negative integer W in the range 0 to 2^64-1, specifying the weave. A positive integer S in the range 1 to 255, specifying the side length. These can be taken in whichever ...
1k views

All your bijective base are belong to us

Background A bijective base b numeration, where b is a positive integer, is a bijective positional notation that makes use of b symbols with associated values of 1 to b. Unlike its non-bijective ...
452 views

Through the bases

Through the bases In this challenge, you will be taking a number through all the bases of the rainbow Given an input, n, you will output ...
548 views

Count from 1 to n in Negabinary and Negaquaternary

Instead of normal binary, you must count from 1 to an input in negabinary concatenated to negaquaternary. Here's an example, put in the form of an array: [11, 1102, 1113, 100130, 101131, 11010132, ...
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 ...
14k 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 ...
362 views

Read numbers in the base of the largest digit and write it using underscores

This isn't as much a "challenge" as "a unique problem that there are no built-in functions to solve." Basically, you need to do this: Read some lines of numbers from ...
3k views

Please excuse the punny title. This is a question is inspired by A Curious Property of 82000. In it, the author points out that the number 82000 is binary in base 2, 3, 4, and 5. The post then ...
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 ...
995 views

Last Nonzero Digits of a Factorial in Base

You should write a program or function which given three positive integers n b k as input outputs or returns the last k digits ...
2k views

Minimum base to count to a string

The Challenge Input: alphanumeric string. You can assume that the string will only contain the characters [0-9A-Z]. This can come from a parameter, command line, or STDIN. Digits are always before ...
276 views

Write two single line functions to encode and decode base64 [duplicate]

Write two functions of one line each that can encode and decode base64. Use any language you want, but if the language can naturally be converted to a single line (e.g. javascript) then any block of ...
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 ...
836 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 ...
264 views

Find a numeric coincidence when representing numbers in various bases

Recently, when doing some code-golf challenge, I came up with with two solutions, in 69 and 105 bytes. It's a remarkable coincidence, because: 69 (decimal) = 105 (octal) 69 (hexadecimal) = 105 (...
481 views

Hereditary Base Change

Background In this challenge, a base-b representation of an integer n is an expression of n ...
5k 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, ...
1k views

Tic Tac Toe encoder/decoder

James Bond is about to start a new mission and you are his computer scientist friend. As Tic Tac Toe is becoming more and more popular you decide that nothing would be more underhanded than a Tic Tac ...
493 views

Use threes to count the threes!

Write a program or function that takes two numbers - x>3 and n>0 - as input, and finds all possible bases ...
3k views

Convert numbers to binary… but you're allowed to use twos as well

Based on the "binary, but with twos" notation mentioned in this numberphile video, write a function that takes a single number as input and outputs all variations of that number in a "binary" system ...
1k views

Generalized Gematria Calculator

Create a bidirectional Gematria calculator, for any given sequence of Unicode characters as the alphabet. Gematri-What? Gematria is a system of assigning numerical values to symbols, developed by ...
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. ...
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 ...
2k views

Mixed Base Conversion

Background Most people on here should be familiar with several base systems: decimal, binary, hexadecimal, octal. E.g. in the hexadecimal system, the number 1234516 would represent ...
2k views

Standardise a Phinary Number

Background Most people on here should be familiar with a few integer base systems: decimal, binary, hexadecimal, octal. E.g. in the hexadecimal system, a number abc.de16 would represent ...
3k views

Lowest-Base Palindrome

Given a number n, write a function that finds the smallest base b ≥ 2 such that n is a ...
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 ...
968 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 (...
429 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 & -...