• + 0 comments

    C++ (more at https://github.com/IhorVodko/Hackerrank_solutions/tree/master , feel free to give a star :) )

    std::string misereNim(std::vector<int> const & _piles){
        int binSum = 0;
        int sum = 0;
        for(auto const & stones : _piles){
            binSum ^= stones;
            sum += stones;
        }
        if(_piles.size() == sum){
            return _piles.size() % 2 == 0 ? "First" : "Second";
        }
        return binSum ? "First" : "Second";
    }