[Task 23] Error when calculating array checksum

Back to Problem Solutions forum

CrazyCapitan     2016-08-19 15:32:36
User avatar

When i try to solve this task (23) i give an error -> array checksum not the same this my function : fn checksum(a : &Vec<i32>) -> i32{ let seed =113; let limit = 10000007; let mut result: i32 = 0; for x in a { result = ((result + x)*seed) % limit; } result }

this function work in task 17 "Array checksum" but not work in this task What am I doing wrong?

Art Savin     2016-10-12 18:00:23

I had the same problem. Test with 1 2 3 4 5 6 gives 3950886 while in example - 5242536. Is there another checksum method?

Quandray     2016-10-12 19:34:37
User avatar

You only have to make one pass through the array, so with the example 1 4 3 2 6 5 you will make 3 swaps and end up with 1 3 2 4 5 6.

Please login and solve 5 problems to be able to post at forum