Sansa and XOR

  • + 0 comments

    c++, crazy Sansa, nice

    int sansaXor(vector<int> arr) {
        const int n = arr.size();
        
        if (n % 2 == 0)
        {
            return 0;
        }
        
        int x = 0;
        
        for (int i = 0; i < n; i += 2)
        {
            x ^= arr[i];
        }
        
        return x;
    }