Afforess
The White Wizard
I've got a logic problem, which I am obviously just not looking at correctly.
I've got a chain of buildings. Building A is replaced by building B and building C. Building B is replaced by building C.
A graphic representation:
Now I need a function that will return TRUE or FALSE if the building is the next in the sequence in the chain. Given A, it should return TRUE for B and FALSE for C. Sounds easy? Let me complicate it with a new example:
Building A is replaced by Building B, Building C, Building D, and Building E. Building B is replaced by Building D. Building C is replaced by Building E.
graphic:
This function given A should return TRUE for both Buildings B and C and FALSE for D and E.
I'm sure I should be able to work it out, but's half past midnight and I'm tired. Solutions to this problem would be appreciated.
I've got a chain of buildings. Building A is replaced by building B and building C. Building B is replaced by building C.
A graphic representation:
Code:
Building A ---> Building B ---> Building C
\ ----------------/
Building A is replaced by Building B, Building C, Building D, and Building E. Building B is replaced by Building D. Building C is replaced by Building E.
graphic:
Code:
/ ---------------\
Building A ---> Building B ---> Building D
\ ---> Building C ---> Building E
\ ----------------/
This function given A should return TRUE for both Buildings B and C and FALSE for D and E.
I'm sure I should be able to work it out, but's half past midnight and I'm tired. Solutions to this problem would be appreciated.