Ad
  • Custom User Avatar

    I needed to add:

    #include <algorithm>

    to get this to compile.

    I used the following compilation command:

    g++ --std=c++17 -o a.out a.cpp

    on ChromeOS virtualized Linux environment:

    penguin 5.15.117-19679-g172023e664f7

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    That's how tic-tac-toe works in 2-D.

  • Custom User Avatar

    %% is one of many Parameter Substitution Operators in BASH.

    Source: https://tldp.org/LDP/abs/html/parameter-substitution.html

    For context, here are my own practical descriptions of %%, %, ##, and #. I actually use these at the command line pretty often. Check out the source for definitive descriptions, as well as numerous examples.

    ${a%%b*} Remove the end of $a, from right to left, ending on the leftmost pattern that starts with "b"

    ${a%b*} Remove the end of $a, from right to left, ending on the rightmost pattern that starts with "b"

    ${a##*b} Remove the beginning of $a, from left to right, ending on the rightmost pattern that ends in "b"

    ${a#*b} Remove the beginning of $a, from left to right, ending on the leftmost pattern that ends in "b"

    Tips for remembering:

    On a standard US keyboard, # is to the left of %. Equivalently, % is to the right of #. This should help you remember which key to use.

    One # or % means non-greedy, whereas two means greedy. Two is more than one, which should help you remember ## and %% are greedy matches.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution