Back to Problem Solutions forum
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?
I had the same problem. Test with 1 2 3 4 5 6 gives 3950886 while in example - 5242536. Is there another checksum method?
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.