Problem 680

A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.

This forum is NOT meant to discuss solution methods for a problem.

In particular don't post any code fragments or results.

Don't start begging others to give partial answers to problems

Don't ask for hints how to solve a problem

Don't start a new topic for a problem if there already exists one


See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
Post Reply
EliteToday
Posts: 2
Joined: Mon Sep 23, 2019 3:41 pm

Problem 680

Post by EliteToday »

Hi Everyone, I was working on the newest problem. But the following is unclear.

The question says that for some K iterations, one array value needs to be swapped with another array value in A. However the example does two swaps in one of the steps. Here indicated in red:
Initial position: (0,1,2,3,4)
Step 1 - Reverse A[1] to A[1]: (0,1,2,3,4)
Step 2 - Reverse A[2] to A[3]: (0,1,3,2,4)
Step 3 - Reverse A[0] to A[3]: (2,3,1,0,4)
Step 4 - Reverse A[3] to A[1]: (2,0,1,3,4)
R(5,4)=0×2+1×0+2×1+3×3+4×4=27
Without this additional swapping, the solution would be:
R(5,4)=0×2+1×0+2×3+3×1+4×4=25

In don't understand why this is happening, is there an error in the explanation or have i misinterpreted the question here. Hope someone knows!

Thanks in Advance
DJohn
Posts: 90
Joined: Sat Oct 11, 2008 12:24 pm

Re: Problem 680

Post by DJohn »

EliteToday wrote: Mon Sep 23, 2019 3:49 pm The question says that for some K iterations, one array value needs to be swapped with another array value in A.
That is not what the question says.
the $j$-th operation consists of reversing the order of those elements in $A$ with indices between $s_j$ and $t_j$
So if the array is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 and the step is to reverse the elements between 3 and 8, we take those elements (3, 4, 5, 6, 7, 8), reverse them (giving 8, 7, 6, 5, 4, 3), and put them back in the array. The final result is 0, 1, 2, 8, 7, 6, 5, 4, 3, 9, 10.
EliteToday
Posts: 2
Joined: Mon Sep 23, 2019 3:41 pm

Re: Problem 680

Post by EliteToday »

Thank you very much, this clarifies a lot.
I misinterpreted the meaning of "between" here.

Back to the drawing board...
Post Reply