Sort by

recency

|

136 Discussions

|

  • + 0 comments

    Hours later, I still can understand how reversed_binary_value() function contributes towards getting the desired string output!!!!

    I wonder if the author also understands what he wrote as a challenge.

  • + 0 comments

    Once I understood what it was all about I came up with this:

    template <bool...digits>
    int reversed_binary_value() {
        vector<bool> values{digits...};
        int sum = 0;
        for(int i{0};i < values.size(); ++i)
            sum += ((1&values[i])<<i);
        return sum;
    }
    
  • + 0 comments

    By this practice and the following answers, now I remeber again some topics that for a while, I forgot them. Thanks everybody for the solutions.

  • + 0 comments

    clean I think

    template<bool F, bool ...I>
    int reversed_binary_value()
    {
        return F + 2 * reversed_binary_value<I...>();
    }
    
    template<>
    int reversed_binary_value<0>()
    {
        return 0;
    }
    
    template<>
    int reversed_binary_value<1>()
    {
        return 1;
    }
    
  • + 0 comments

    That the task was mentioning the input format was not necessary and thus confusing! First problem I solved.