Linked Questions

2 votes
3 answers

Binary to trinary [duplicate]

The problem Given a binary number from 0 to 111111 convert it to trinary. (Base 3). Then print the result. Rules No using a list of conversions. Don't cheat You must use a string as the number ...
user avatar
  • 3,542
166 votes
91 answers

Tips for golfing in JavaScript

What general tips do you have for golfing in JavaScript? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to JavaScript (e.g. "remove ...
user avatar
  • 5,972
61 votes
57 answers

Count trailing truths

Inspired by, and in memory of, my dear friend and colleague, Dan Baronet, 1956 – 2016. R.I.P. He found the shortest possible APL solution to this task: Task Given a Boolean list, count the number of ...
user avatar
  • 28k
30 votes
75 answers

Clearing the most significant bit from an integer

Input The input is a single positive integer n Output The output isn with its most significant bit set to ...
user avatar
36 votes
47 answers

What is the reverse (binary) bit number?

So you are given a POSITIVE base 10 (decimal) number. Your job is to reverse the binary digits and return that base 10 number. Examples: ...
user avatar
  • 915
23 votes
32 answers

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 ...
user avatar
25 votes
23 answers

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 ...
user avatar
  • 13.9k
26 votes
22 answers

Diluted Integer Sums

A positive integer can be diluted by inserting a 0 between two bits in its binary expansion. This means that an n-bit number has ...
user avatar
  • 42.9k
19 votes
32 answers

Convert from base 10 to base 2 without built-in base conversions

Background: You have been given an assignment to convert base 10 numbers to base 2 without using any premade base conversion functions. You can't use any imported libraries either. Problem: ...
user avatar
  • 7,899
20 votes
17 answers

Simplify binary

Challenge Given a binary number as input through any means, "simplify" the number using a full program or a function. Input [binary] ...
user avatar
15 votes
9 answers

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 the ...
user avatar
  • 3,538