Back to General discussions forum
The code i use calculates the first checksum problem accurately, but not the example data. The value i get is diff on either sorted or unsorted. I even calculated the checksum(for the example data) on a calculator and get the same value as my code. I can't see what i'm doing wrong, is it possible there is a mistake in the task?
There's no mistake in the task. You need to calculate the checksum of the (partially) sorted array; i.e., loop over each value and perform necessary calculations.
Christopher P. Matthews
Blast!!. The task states to perform the checksum on the array after processing. How did you know to only partially sort? Thank you.
Sorry disregard that, i got it. Thank you.
Hi! Thanks for your question!
I'm sorry for failing to respond speedy enough (and thankful to Christopher for help). And sorry if this problem is somewhat clumsy... It was created long ago when the site have few options to check answer...
Please feel free to suggest any improvement or clarification to problem statement if you feel it is vague or misleading! Be sure it was not my intention to make you feel frustrated :)
Hi, I have also been having problems with this task, I have correctly done the Array checksum task,
So I know there is no issue with that, Also I have successfully writen the bubble sorting code (As the number of swaps is successful when I submit it through codeabbey)
My question is, When should I be performing the checksum on the array? As It's not very clear at all in the description of the task, and I've spent hours now trying to figure it out,
Thanks!
Hello Alex,
For the example, you start with 143265 and end up with 132456. You need the checksum of 132456, i.e.
1 x 113 = 113
113 + 3 = 116, 116 x 113 = 13108
13108 + 2 = 13110, 13110 x 113 = 1481430
1481430 + 4 = 1481434, 1481434 x 113 = 167402042, 167402042 mod 10000007 = 7401930
7401930 + 5 = 7401935, 7401935 x 113 = 836418155, 836418155 mod 10000007 = 6418074
6418074 + 6 = 6418080, 6418080 x 113 = 725243040, 725243040 mod 10000007 = 5242536
Hi Quandray,
Thank you for your reply,
Unfortunately this is what I've been trying,
I Shall give it another go, see if I can solve it,
Thanks again.
Alex, Hi!
Sorry for late response! Here is a link to your current solution.
It seems that you perform full sort of the array instead of just a single pass - aren't you?
BTW, thanks a lot to Quandray who emailed me about my stupid typo in the example for this problem.
Hi Alex,
Nicely commented code, but I'd suggest you make sure you get the correct answer with the "Example data" before moving on to the "Test data"
Hi, Thank you for all the replies,
Thanks Quandray, I'm new to C++ so I have a lot to learn, so I find adding a lot of comments is good for looking back,
My main language is C# but I really want to learn C++ aswell,
Thank you both for the tips
Finally managed to solve it! Thanks again guys
Can we Add Quandray's explantion to the explanation to that problem? It greatly cleared up on how to do the problem
Жаль, что слово "частично" отсортированный массив не фигурирует в задании =(
What should be done is to edit the statement and say clearly: "As soon as the major element of the array goes to the last position, you must immediately make the sum checksum", thus avoiding confusion