Zig Zag Sequence

Sort by

recency

|

1058 Discussions

|

  • + 0 comments

    In python:

    Wrong Answer

    Input (stdin)

    1
    
    7
    
    1 2 3 4 5 6 7
    

    Your Output (stdout)

    1 2 3 7 6 5 4
    

    Expected Output

    1 2 3 7 6 5 4
    
  • + 0 comments

    This is a garbage challenge. First, the Python code I'm supposed to modify is horrible, as if it were written by a first semester compsci student. Granted, most Python programmers are cavemen, but this starter solution was truly gross.

    After fixing the three off-by-one situations, my output is exactly what the sample solution output shows (and matches the requirements). But it says the answer is wrong. And it fails every test (which I can't see). Utter waste of time.

  • + 0 comments

    You have to make 3 character changes. more than that it will fail. This is what i did and it worked after that

    mid = int((n + 1)/2)  -> mid = int((n - 1)/2)
    ed = n - 1   -> ed = n - 2
    ed = ed + 1 -> ed = ed - 1
    
  • + 1 comment

    I have made 3 changes of the code using Python 3, and I got the same results as expected results, still it said Wrong answer.

        mid = (n - 1) // 2
    
    ed = n - 2
    
        ed = ed - 1
    

    anyone knows why?

  • + 0 comments

    `What is the problem?

    //C++

    void findZigZagSequence(vector < int > a, int n){

        sort(a.begin(), a.end());

        int mid = (n + 1)/2;

        int st = mid - 1;

        int ed = n - 1;

        while(st <= ed){

            swap(a[st], a[ed]);

            st = st + 1;

            ed = ed - 1;

        }

        for(int i = 0; i < n; i++){

            if(i > 0) cout << " ";

            cout << a[i];

        }

        cout << endl;

    } `

    running failed: compiler Message Wrong Answer

    Input (stdin)

    1

    7

    1 2 3 4 5 6 7

    Your Output (stdout)

    1 2 3 7 6 5 4

    Expected Output

    1 2 3 7 6 5 4