
-----------------------------------
nelson
Sun Feb 01, 2004 10:27 pm

recursion
-----------------------------------
i'm trying to solve this problem

" Write a function using Recursion to display all anagrams of the word 'RECURSION' "

having trouble, i started though



var str : string
str := "recursion"
var b : array 1 .. length (str) of int
var a : array 1 .. length (str) of string (1)

for i : 1 .. length (str)
    b (i) := 0
    a (i) := ""
end for


var temp : string
temp := str



proc er (n : int)


    for i : 1 .. length (str)

        a (n) := str (i)



        if n < length (str) then
            er (n + 1)
        else
            for k : 1 .. length (str)
                put a (k) ..
            end for
            put ""
        end if
    end for
end er


put length (str)
er (1)


heh -.,-;;;;;;;; help~

-----------------------------------
Paul
Sun Feb 01, 2004 10:33 pm


-----------------------------------
Isn't an anagram words made by rearranging the letters of the same word? correct me if Im wrong, Im not sure.

-----------------------------------
nelson
Sun Feb 01, 2004 10:37 pm


-----------------------------------
yup

-----------------------------------
Paul
Sun Feb 01, 2004 10:39 pm


-----------------------------------
Oh! At first I thought you wanted all the "real" words anagram, but you just want all possible combinations right? I think I'll work on that for a bit.

-----------------------------------
jonos
Sun Feb 01, 2004 10:39 pm


-----------------------------------
i think what you have is right, cause it does print out the whatchamacallits, but i've never used recursion (haven't been taught it in stupid compsci), so i wouldn't really know if you were doing it right.

-----------------------------------
nelson
Sun Feb 01, 2004 10:40 pm


-----------------------------------
haha if we wanted to do real words,
we would need a dictionary!

-----------------------------------
Paul
Sun Feb 01, 2004 10:41 pm


-----------------------------------
when I run it, theres alot of words with 4 "R"'s and there arn't 4 of them in Recursion.

-----------------------------------
nelson
Sun Feb 01, 2004 10:41 pm


-----------------------------------
but the program can only use two r

R ecu  R  sion

my program starts with 9 Rs

-----------------------------------
Paul
Sun Feb 01, 2004 10:47 pm


-----------------------------------
I see, well I'm sorry, but I can't help you right now, I have to go to bed, but I'll think on it whenver I have the chance. I dunno though, if it was me making it, I'd count the numbers of each letters, might be a stupid idea, Im too tired to think  :?

-----------------------------------
jonos
Sun Feb 01, 2004 10:50 pm


-----------------------------------
i didn't even notice that (the 4 rs), id help if i could cause i have lots of time, but i have no idea what recursion is.

-----------------------------------
Paul
Sun Feb 01, 2004 10:51 pm


-----------------------------------
It isn't recursion I think, hes trying to get anagrams (words that are made of the same letters) from the word "recursion"

-----------------------------------
nelson
Sun Feb 01, 2004 10:53 pm


-----------------------------------
but it's supposed to be recursion problem
so probably we hve to use recursion

-----------------------------------
jonos
Sun Feb 01, 2004 10:58 pm


-----------------------------------
could anyone explain to me what recursion is, then maybe i could have a go at it... thankyou  :lol:

-----------------------------------
santabruzer
Sun Feb 01, 2004 11:00 pm


-----------------------------------
enjoy:
A function that calls a simpler version of itself to arrive at a solution. For example, the factorial function (n!) can be defined recursively as (n(n-1)!), where (0!) is defined as equal to1. If a function calls another function that calls back the original function again, it is called mutual recursion; most ray-tracing programs fall into this general category. 


-----------------------------------
jonos
Sun Feb 01, 2004 11:17 pm


-----------------------------------
uh, thanks for that definition, could yo uplease translate it into laymans terms  :D thanks for the definition, i think i have an idea of what it is
