Sort by

recency

|

19 Discussions

|

  • + 0 comments

    C++

    char zeroMoveNim(vector<int> p) {
        int xr = 0;
        for(auto n : p) xr ^= n + ((n&1)<<1) - 1;
        return xr ? 'W' : 'L';   
    }
    

    In the text of C++ program next error strings should be commented or deleted otherwise the program will abort

    string n_temp;
    getline(cin, n_temp);
    int n = stoi(ltrim(rtrim(n_temp)));
    
  • + 0 comments

    Here is Zero-Move Nim problem solution in PYthon Java C++ and c programming - https://programs.programmingoneonone.com/2021/07/hackerrank-zero-move-nim-problem.html

  • + 0 comments

    Main function given in the code does not work properly. I shared the fixed C++ code below. Removed the part reading the p_count_temp, which does not exist in the input.

    int main()
    {
        ofstream fout(getenv("OUTPUT_PATH"));
    
        string g_temp;
        getline(cin, g_temp);
    
        int g = stoi(ltrim(rtrim(g_temp)));
    
        for (int g_itr = 0; g_itr < g; g_itr++) {
            
            string n_temp;
            getline(cin, n_temp);
            int n = stoi(ltrim(rtrim(n_temp)));
    
            string p_temp_temp;
            getline(cin, p_temp_temp);
            cout << p_temp_temp << endl;
    
            vector<string> p_temp = split(rtrim(p_temp_temp));
    
            vector<int> p;
            for (int i = 0; i < p_temp.size(); i++) {
                int p_item = stoi(p_temp[i]);
                p.push_back(p_item);
            }
    
            char result = zeroMoveNim(p);
            fout << result << "\n";
        }
    
        fout.close();
    
        return 0;
    }
    
  • + 0 comments

    C#: line with "int n = ..." must be removed, this fixes the exception, i.e. extra read happened!

  • + 0 comments

    It looks like there is a bug in the system:

    Unhandled Exception: System.FormatException: Input string was not in a correct format. at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) [0x0001a] in <254335e8c4aa42e3923a8ba0d5ce8650>:0 at System.Number.ParseInt32 (System.ReadOnlySpan1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) [0x00016] in <254335e8c4aa42e3923a8ba0d5ce8650>:0 at System.Int32.Parse (System.String s, System.IFormatProvider provider) [0x00017] in <254335e8c4aa42e3923a8ba0d5ce8650>:0 at System.Convert.ToInt32 (System.String value) [0x0000b] in <254335e8c4aa42e3923a8ba0d5ce8650>:0 at Solution.Main (System.String[] args) [0x00033] in <38d1b93bc503403d93754bc7a44d3cc3>:0 [ERROR] FATAL UNHANDLED EXCEPTION: System.FormatException: Input string was not in a correct format. at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) [0x0001a] in <254335e8c4aa42e3923a8ba0d5ce8650>:0 at System.Number.ParseInt32 (System.ReadOnlySpan1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) [0x00016] in <254335e8c4aa42e3923a8ba0d5ce8650>:0 at System.Int32.Parse (System.String s, System.IFormatProvider provider) [0x00017] in <254335e8c4aa42e3923a8ba0d5ce8650>:0 at System.Convert.ToInt32 (System.String value) [0x0000b] in <254335e8c4aa42e3923a8ba0d5ce8650>:0 at Solution.Main (System.String[] args) [0x00033] in <38d1b93bc503403d93754bc7a44d3cc3>:0 Input (stdin)

    Download 2 2 1 2 2 2 2 Your Output (stdout) ~ no response on stdout ~ Expected Output

    Download W L