I'm trying to take a text file with a list in it take the input values and ranking them in "Height" meaning that any animal that eats only producer has height 1.
I think I have a low understanding of how to tackle this problem which is
setting up the heights of all organisms, then including the producers to 0 mark that something has changed? while something has changed mark that nothing has changed for each animal, a, in the food web for each animal, p, that a preys on if the height of a is less than or equal to the height of p set the height of a to the height mark that something has changed
Any help is much appreciated. I hope I haven't been too wordy or confused my message
This is the text file input:
Bird eats Prawn
Bird eats Mussels
Bird eats Crab
Bird eats Limpets
Bird eats Whelk
Crab eats Mussels
Crab eats Limpets
Fish eats Prawn
Limpets eats Seaweed
Lobster eats Crab
Lobster eats Mussels
Lobster eats Limpets
Lobster eats Whelk
Mussels eats Phytoplankton
Mussels eats Zooplankton
Prawn eats Zooplankton
Whelk eats Limpets
Whelk eats Mussels
Zooplankton eats Phytoplankton
The output wanted:
Heights:
Bird: 4
Crab: 3
Fish: 3
Limpets: 1
Lobster: 4
Mussels: 2
Phytoplankton: 0
Prawn: 2
Seaweed: 0
Whelk: 3
Zooplankton: 1
Aucun commentaire:
Enregistrer un commentaire