﻿namespace AlgorithmSandbox.Chapter5
{
    public class Question6
    {
        public static int Conversion(int a, int b)
        {
            var x = a ^ b;
            return Popcnt(x);
        }

        private static int Popcnt(int x)
        {
            var count = 0;
            while (x > 0)
            {
                if ((x & 1) == 1) count++;
                x = x >> 1;
            }

            return count;
        }
    }
}