A model of diffusion: particles start at one spot, and at every tick each one steps left or right at random. A hotter sample means bigger steps. You will write the step, the average distance from the start, and compare a hot sample with a cold one.
The idea. The particles of matter move all the time, and they move faster when they are hotter. So they spread out faster.
Your tasks.
move, give every particle a step of +step or -step, chosen at random.average_distance, find the average of the distances from the start (the size of each position, with no minus sign).ratio: how many times as far the hot particles spread as the cold ones.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…