LeetCode 2220. Minimum Bit Flips to Convert Number in F#

URL

https://leetcode.com/problems/minimum-bit-flips-to-convert-number/description/?envType=daily-question&envId=2024-09-11

Code

https://github.com/syohex/dotnet-study/blob/master/fsharp/leetcode/challenge/202409/minimum_bit_flips_to_convert_number/main.fsx

let minBitFlips (start: int) (goal: int) : int =
    let b = start ^^^ goal
    let b = (b &&& 0x55555555) + ((b >>> 1) &&& 0x55555555)
    let b = (b &&& 0x33333333) + ((b >>> 2) &&& 0x33333333)
    let b = (b &&& 0x0f0f0f0f) + ((b >>> 4) &&& 0x0f0f0f0f)
    let b = (b &&& 0x00ff00ff) + ((b >>> 8) &&& 0x00ff00ff)
    (b &&& 0x0000ffff) + ((b >>> 16) &&& 0x0000ffff)