Recently I have been trying to put together a system for writing code on client side browser by translating the code directly into Javascript. Today, I would like to show a demo of simple translator for Tamilscript
Demo of Tamilscript for use within a web browser. Tamilscript can leverage jQuery, and power of modern web browsers.
Comments and suggestions welcome. I will release the code if we reach any sizable level.
Regards,
-Muthu
ஹனோய் கோபுரம் அறிமுக கணினி அறிவியலில் ஒரு சிறந்த பிரச்சனை. (Tower of Hanoi is a classic introductory computer science problem) see: http://en.wikipedia.org /wiki/Tower_of_Hanoi
பிரச்சனை நோக்கம், பின்வரும் நிலைமைகளின் கீழ், அச்சு # 3 மது # 1, முதல் வட்டுகள் அனைத்து நகர்த்த உள்ளது
R1: ஒரு சிறிய வட்டு பெரிய வட்டு மேல் உட்கார முடியாது
R2: நீங்கள் தற்காலிக அச்சு இரண்டு அச்சு ஏதாவது பயன்படுத்தலாம்
R3: நீங்கள் செய்ய முடியும் நகர்வுகள் எண்ணிக்கை இல்லை
Goal of the problem is to move all of disks from peg #1, to peg #3, under the following conditions,
R1: Only a smaller disk can sit on top of the larger disk
R2: You may use any of two pegs as temporary store
R3: There is no limit on number of moves you can make
Let us reduced the size of the problem to 1 disk on the peg #1.
We can make a drawing like [1,0,0].
We can simply move the disk 1 from peg #1 to peg #3, and we have completed the problem!
That was easy. [0,0,1].
For 2 disks how do you solve it?
We initially have [1 2, 0, 0]. we want to get to [0,0,1 2]
By moving smaller disk 1 from peg #1, to peg #2, we have [2, 1, 0].
Now your situation is same as problem with 1-disk on peg #1, and 1-disk on peg #2 which we will ignore temporarily.
Next we can move either of disks from peg #1 or peg #2 to peg #3. However the rule, R1, requires us to move the peg #1 disk as it is the larger disk and it should go at bottom.
Now your configuration is like, [0,1,2]
Clearly the final step is to move disk #1 from peg #2 to peg #3, on top of the existing disk #2. Now your configuration is [0,0,1 2]. Solved!
So what does the general solution look like, for n-disks? Well the problem has a dynamic-programming structure, where solving smaller problems, inductively, leads to solution of the larger problem.
Here, you need to move all n-1 smaller disks from peg #1 to peg #2, and to do that, you will use peg #3 as temporary.
Once you have achieved this, you have to move disk-n from peg #1 to peg #3.
Now move (1,2, … n-1) disks from peg #2 to peg #3 using the peg #1 as intermediate.
This is a recursive solution and harder to visualize at first reading, but you will eventually get the hang of it.
Move 1,2,3 disks from peg #1 to peg #2, with peg #3 as intermediate. Move disk 4 from peg #1 to peg #4. Then move all disks from peg #2 to peg #3 using peg #1 as intermediate.
The follow program describes the Ezhil program solution to Tower of Hanoi problem,
# (C) 2013 Ezhil Language Project
# Tower of Hanoi – recursive solution