Wednesday, January 4, 2023

Problem: Fill array by dice numbers; all different

 You got array of 6,




 


 It need to be fill dice-numbers all less that 6 more than one. We talk about 1,2,3,4,5,6.  Minimal O is preferred. I mean few loops as possible to do this task.

Here my solution, throw dice, get 6 add that to array






Next acquire smaller dice, 1-5 the d5 throw this now, it show 4







That is not 5, we must remember 5 is 4, so that when we take yet smaller dice, the data not get lost, to help remember what is what, we have a pre-filled array where numbers are in order.






And now 5 is 4 and 4 is 5. The data.






Yes. Then we dice smaller dice d4->






We got a three, next let's update the helper-array, that what is on the position-4 on the helper-array, is 3 and three is that, what have there before(5). So...







D3 ->  1






the helper-array goes:..






To terminate last two numbers we flip coin.


No comments:

Post a Comment

3D BLog has return

Go  to Check    https://thereal3dblog.com/