From: Li Chen Date: 2009-07-22T00:49:27+09:00 Subject: Re: create a variable number of loop > You can do this recursively by decrementing a depth count until you hit > the > bottom, at which point to print the data you want: Hi James, Thank you very much for the codes. It solves part of my problem. I try to follow your idea and implement the reamining part. But I don't think I can. Here is the whole story: What I really try to do is to create a word of using letters of 'A,B,C,D'' only with different size (1-letter, 2-letter,3-letter, ..., up to 25-letter word). For each word created I count the value for each individual letter and get the sum for the word. And here are the rules: A=0; B=1;C=2;D=3 for a word of 1 letter its value is: 'A'=>0; 'B'=>1;''C'=>2; ''D'=>3; for 'A', it has 0*(4**0) if it appears on 0th, 0*(4**1) if on 10th, 0*(4**2) if on 100th, so on and so on for 'B', it has 1*(4**0) if it appears on 0th, 1*(4**1) if on 10th, 1*(4**2) if on 100th, so on and so on similar to 'C' and 'D' so the following word of 'ABCD' has a value: 0*(4**3)+ 1*(4**2)+ 2**(4**1)+3*(4**0) 'DDDD' has a value:3*(4**3)+ 3*(4**2)+ 3**(4**1)+3*(4**0) Li -- Posted via http://www.ruby-forum.com/.