[hackeroid] B1:3 Dragon's Taming

Algorithm of conversion from any number system to decimal we call the algorithm of Dragon's Taming: X_n->Y_10. We call it this way because of the long string of calculation reminding of the back of lying dragon and the answer -- the head of tamed dragon. It is based on the fact that

34947 = 30000+4000+900+40+7 = 3*10^4 + 4*10^3 + 9*10^2 + 4*10 + 7

I.e. the number is the sum of its digits multiplied by the corresponding powers of its base. The conversions of numbers 1210_3 and C00L_22:

1210_3 = 1*3^3 + 2*3^2 + 1*3 + 0 = 27 + 18 + 3 = 48_10
C00L_22 = 12*22^3 + 0*22^2 + 0*22 + 21 = 127776 + 21 = 127797

Many books use this version of algorithm of Dragon Taming for definition of number system. Try to convert numbers from various number systems, preferably without the calculator, making all calculations in head or on the piece of paper. More binary numbers --- they will be useful for us!

>>>

Using Gorner's scheme (B1:1) we will get more effective version of Dragon's Taming algorithm.

1210_3 = ((1*3+2)*3+1)*3+0 = 16*3 = 48
C00L_22 = (((12*22+0)*22+0)*22+21 = 127776 + 21 = 127797

Where is the effectiveness? We do not need the operation of raising into power now! That's very good for assembly language programming! Even in high level languages conversion program becomes faster and shorter. Try to make the program converting numbers from any number system into familiar decimal language. It mimicks the program for Gorner's scheme.

Hacker must always be in the ready-to-fight state -- who knows when he will have to demostrate The Art. It is possible that you will be asked to fix or to remove the virus from the computer in the most strange place -- in supermarket or at your girlfriend's home. (In the film "War Games" young hacker David, by plugging the sound recorder to the electronic lock, managed to record and to repeat signals of door opening and to escape from the prison).

If there is only primitive calculator nearby (such as built in some watches) with only four arithmetic operations then you must write down results and then type them back again using traditional method. using new method you will have only to type between digits multiplication sign, base of number system and addition sign.

If there is no calculator nearby, the algorithm of Dragon Taming can be used for conversion of the number in columnar mode. Result of the operation becomes the starting value for the next one.

   1     12
  *3    *22
 ---   ----
   3     24
  +2    24
 ---   ----
   5    264
  *3     +0  Of course I add zeroes here only for education,
 ---   ----  you shouldn't do so in real life. :-)
  15    264
  +1    *22
 ---   ----
  16    528
  *3   528
 ---   ----
  18   5808
  3      +0
 ---   ----
  48   5808
  +0    *22
 ---   ----
  48  11616
     11616
     ------
     127776
        +21
     ------
     127797

Here we put the Tamed Dragon vertically, head down. Probably, in order for more of them to fit.

<<<

<<<B1:3 EOF>>>



E-mail: hscool@netclub.ru
Hosted by uCoz