We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This one took me a while to grasp. Kept trying to unpack the variadic parameter using recursive calls to reversed_binary_value(). But once I understood the problem better, I was able to solve it.
Without giving too much away, here's what I did:
template<bool...digits>intreversed_binary_value(){constsize_tsize=sizeof...(digits);boolbits[size]={digits...};// reverse order of array// convert bit array into integer number// return number}
If anyone knows of a more appropriate way of solving this challenge, please let me know.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
C++ Variadics
You are viewing a single comment's thread. Return to all comments →
This one took me a while to grasp. Kept trying to unpack the variadic parameter using recursive calls to reversed_binary_value(). But once I understood the problem better, I was able to solve it.
Without giving too much away, here's what I did:
If anyone knows of a more appropriate way of solving this challenge, please let me know.