One monster will attack earth. It doesn't need army because the monster can duplicate itself.

The monster divided into 2 kinds, BLACK monster and WHITE monster.

BLACK MONSTER divided itself into BLACK monster and WHITE monster.

WHITE MONSTER divided itself into BLACK monster and 2 WHITE monster each day.

At the invasion day (Day-0) only the BLACK monster come.

I must make the program that count the amount BLACK monster, WHITE monster, and total both of them at n-day.

The example of output is like this:

Code :

Input days: 2
output example:
Days -0
================================
BLACK monster 0 <> into BLACK monster 1
BLACK monster 0 <> into WHITE monster 1
Days -1
================================
BLACK monster 1 <> into BLACK monster 1
BLACK monster 1 <> into WHITE monster 1
WHITE monster 1 <> into BLACK monster 2
WHITE monster 1 <> into WHITE monster 2
WHITE monster 1 <> into WHITE monster 3
Days -2
================================
BLACK monster 1 <> into BLACK monster 1
BLACK monster 1 <> into WHITE monster 1
WHITE monster 1 <> into BLACK monster 2
WHITE monster 1 <> into WHITE monster 2
WHITE monster 1 <> into WHITE monster 3
BLACK monster 2 <> into BLACK monster 3
BLACK monster 2 <> into WHITE monster 4
WHITE monster 2 <> into BLACK monster 5
WHITE monster 2 <> into WHITE monster 5
WHITE monster 2 <> into WHITE monster 6
WHITE monster 3 <> into BLACK monster 5
WHITE monster 3 <> into WHITE monster 7
WHITE monster 3 <> into WHITE monster 8
Total
================================
BLACK monster: 5
WHITE monster: 8
TOTAL: 13

Anyone can help me to make this program? I hope you can guide me step-by-step to complete this :)

I really appreciate that.

Sorry my english isn't good enough ]]>

The program should has the output depending the number I'll input. (The number should be from 1-9)

This is the program's output should be:

Code :

Input number: 4
Output:
# # # 1 # # # # #
# # # 2 # # # # #
# # # 3 # # # # #
1 2 3 4 5 6 7 8 9
# # # 5 # # # # #
# # # 6 # # # # #
# # # 7 # # # # #
# # # 8 # # # # #
# # # 9 # # # # #
(Example 2):
Input numbers: 8
Output:
# # # # # # # 1 #
# # # # # # # 2 #
# # # # # # # 3 #
# # # # # # # 4 #
# # # # # # # 5 #
# # # # # # # 6 #
# # # # # # # 7 #
1 2 3 4 5 6 7 8 9
# # # # # # # 9 #
(Example 3):
Input number: 5
Output:
# # # # 1 # # # #
# # # # 2 # # # #
# # # # 3 # # # #
# # # # 4 # # # #
1 2 3 4 5 6 7 8 9
# # # # 6 # # # #
# # # # 7 # # # #
# # # # 8 # # # #
# # # # 9 # # # #

Anyone can help me? I'm not asking the code to make this program, I have trouble to understand the algorithm to make this program :)

Sorry, my English isn't good enough. ]]>

Could someone provide an example of how to achieve this. Plain english? Possibly some PSUEDO

Thanks,

Peter.

--- Update ---

Forget that, I've just worked it out in a matter of seconds hahaha...

-.- ]]>

Code :

public static void updateLight(int x, int y)
{
byte myLight = getLight(x, y);
if (getWall(x, y) == null) //Checks if there's a wall behind, if not it sets the light at this position to the max light and updates spaces next to this space.
{
byte lightPower = 6;
setLight(x, y, lightPower);
if (getLight(x - 1, y) < lightPower-1)
{
setLight(x - 1, y, (byte)(lightPower-1));
if (getWall(x - 1, y) != null)
updateLight(x - 1, y);
}
if (getLight(x + 1, y) < lightPower-1)
{
setLight(x + 1, y, (byte)(lightPower-1));
if (getWall(x + 1, y) != null)
updateLight(x + 1, y);
}
if (getLight(x, y - 1) < lightPower-1)
{
setLight(x, y - 1, (byte)(lightPower-1));
if (getWall(x, y - 1) != null)
updateLight(x, y - 1);
}
if (getLight(x, y + 1) < lightPower-1)
{
setLight(x, y + 1, (byte)(lightPower-1));
if (getWall(x, y + 1) != null)
updateLight(x, y + 1);
}
}
else
{
if (myLight > 12) // If there's a wall behind it shouldn't be able to have the max light.
{
setLight(x, y, (byte) 12);
}
if (myLight > 0) //If the own light is greater than 0 it checks if the spaces next to it are less lit then this space - 1. If so, it changes the light to the own light -1 and updates it.
{
byte light = getLight(x, y);
if (getLight(x - 1, y) < light - 1)
{
setLight(x - 1, y, (byte) (light - 1));
if (getWall(x - 1, y) != null)
updateLight(x - 1, y);
}
if (getLight(x + 1, y) < light - 1)
{
setLight(x + 1, y, (byte) (light - 1));
if (getWall(x + 1, y) != null)
updateLight(x + 1, y);
}
if (getLight(x, y - 1) < light - 1)
{
setLight(x, y - 1, (byte) (light - 1));
if (getWall(x, y - 1) != null)
updateLight(x, y - 1);
}
if (getLight(x, y + 1) < light - 1)
{
setLight(x, y + 1, (byte) (light - 1));
if (getWall(x, y + 1) != null)
updateLight(x, y + 1);
}
}
}
}

getWall returns a wall object, but I'm only checking if there's a wall or not (null). getLight returns the light value (0 - 13) where 0 is no light and 13 is max light and setLights sets it.

How can I update the placing correctly? And how can I update it correctly when the light power of the lamp changes? ]]>

I have no clue on where to start, thus. I have no code to supply.

I current have, a destory method, a find, a destroyFirstNode, a destroyLastNode, print, insert, etc etc... But I just have no clue on how to replace the nodes value....

Any pointers?

I don't want code, I actually want to learn, not memorise.

Cheers, Pete. ]]>

i need help with a dot and box game i am trying to do.

I understand how minimax works and understand how the tic-tac-toe process works but i cannot figure it out for the dot and box game. I would like to know how to return

a horizontal/vertical, column, row but cannot figure it out. in TTT you only get to input in a row/column but with d and b you have to add the dash in north/south/east/west.

any help would be great.

Nick ]]>

i need ideas or algorithms for implementing a special version of binary search tree..

the tree is an normal binary seatch tree, where left is smaller than right node.

but each node has a counter, each time i'll find a node using find method the count should increment by one

and node with highest count should replace the root of the tree...

any idea would be great.. ]]>