You are viewing a single comment's thread. Return to all comments →
Haskell
module Main where import Data.Bits (Bits (shiftR, testBit)) solve :: Integer -> Integer solve x = go x 0 0 where go 0 idx acc = acc go n idx acc = if testBit n 0 then go (shiftR n 1) (idx + 1) acc else go (shiftR n 1) (idx + 1) (acc + 2 ^ idx) main :: IO () main = getLine >> getContents >>= mapM_ (print . solve . read) . lines
Seems like cookies are disabled on this browser, please enable them to open this website
The Great XOR
You are viewing a single comment's thread. Return to all comments →
Haskell