Preprocessor Solution

  • + 0 comments

    One of my favorite C++ problems here, although completely detached from reality! 😄 But you need to know the language to solve this unusual puzzle – it's not as insane as it might initially seem 🤓

    #define FUNCTION(name, op) \
        void name(int& acc, const int val) { \
            if (val op acc) acc = val; \
        }
    
    #define foreach(vec, idx) \
        for (size_t idx = 0; idx < vec.size(); ++idx) 
    
    #define INF \
        numeric_limits<int>::max();
    
    #define io(vec) \
        cin >> vec
    
    #define toStr(str) \
        #str
    
    #include <limits>