Hexadecimal Representations


In the twelve months from March 2013 to March 2014, I programmed solutions to the problems posted on the Contest Coding blog run by Lewis Cornwall, solving 33 problems (out of 47) and achieving a position of 4th on the leaderboard (out of 23).

As that blog has now been discontinued, I’m posting here the solutions I programmed to those problems.

Hexadecimal Representations

The hexadecimal representation of 1000 (in decimal notation) is 3e8. There is a difference of 1 between the number of digits in the decimal representation of 1000 and the number of digits in the hexadecimal representation of 1000. Find the difference in size between the decimal and hexadecimal representation of 10000000000000000000 (in decimal notation).

Solution and answer (Hex_Representations.java):

Solution and answer for problem "Hexadecimal Representations" (22nd September 2013) of http://ContestCoding.WordPress.com/

Sun Sep 22 09:00:00 GMT+01:00 2013


Sun Sep 22 09:00:00 GMT+01:00 2013

Solution programmed in Java using Metrowerks CodeWarrior IDE 2.1 (Discover Programming Edition); solution took ~1s to run on a 80MHz PowerPC 601.

import java.util.Date;
import java.math.BigInteger;

public class Hex_Representations
  public static void main( String p[] )
    System.out.println( new Date());

    final String K = "10000000000000000000";
    BigInteger bI = new BigInteger( K );
    String s = bI.toString( 16 );
    System.out.println( "\n" + ( K.length() - s.length()) + "\n" );

    System.out.println( new Date());

No Responses Yet to “Hexadecimal Representations”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: