Archive

Posts Tagged ‘#C challenge’

Code Challenge Results

September 16, 2010 4 comments

Thank you to all to those that submitted code solutions. We will be running another code contest in a few weeks. Check back soon to enter our next contest. Congratulations to our contest winner: Rob Howarth

See the bottom of this page for an example solution

Others who submitted correct solutions

  • Rob Howarth
  • Scott Monnig
  • Eric Haddan
  • Thomas Eyde
  • Imran Baloch
  • Marc Chu
  • Cesar Neves
  • Jaider Ariza
  • Kenneth Hall
  • Teymur Mammadov
  • Cam Luc
  • Peter Burrell
  • Anthony Clayton
  • Mark Lindell
  • Steve Smith
  • Chris McKenzie
  • Amit Parikh
  • David White
  • Ron Warholic
  • Josh Clark
  • James Baker
  • Richard Deeming
  • Erik Jõgi
  • MORRIS CRISTOPHER
  • Scott Holodak
  • James Curran
  • Marius Ene
  • Matt Crouse
  • Michel Grootjans
  • Daniel Griffie
  • Xiu
  • Mordechai Sandhaus
  • Stuart Cam
  • Raj Rao
  • Rafik Ramtoolah
  • Ali Derman
  • Eric King

Sample Solution

        public class Converter
        {
                public string Convert(int number)
                {
                        StringBuilder buffer = new StringBuilder();
                        int quotient = number;
                        int remainder = -1;
                        while (quotient != 0)
                        {
                                remainder = quotient % BaseNumber;
                                quotient = quotient / BaseNumber;
                                buffer.Insert(0, ConvertSingleBaseNumber(remainder));
                        }
                        return buffer.ToString();
                }

                protected virtual string ValidCharacters
                {
                        get { return "0123456789xyz"; }
                }
               
                private string ConvertSingleBaseNumber(int remainder)
                {
                        return ValidCharacters[remainder].ToString();
                }
               
                private int BaseNumber
                {
                        get
                        {
                                return ValidCharacters.Length;
                        }      
                }
        }

        public class BinaryConverter : Converter
        {
                protected override string ValidCharacters
                {
                        get
                        {
                                return "01";
                        }
                }
        }

        public class OctalConverter : Converter
        {
                protected override string ValidCharacters
                {
                        get
                        {
                                return "01234567";
                        }
                }
        }

        public class HexConverter : Converter
        {
                protected override string ValidCharacters
                {
                        get
                        {
                                return "0123456789abcdef";
                        }
                }
        }

Did you like this challenge? Maybe you found it easy? Were always looking for talented people to join our growing team. Take a look at what we do at http://www.thycoticsolutions.com/careers.html If you feel you have what it takes to work at Thycotic – submit a cover letter, resume, and solution to this problem to tddjobs@thycotic.com