/*
 * Copyright (C) 2014 Pedro Vicente Gómez Sánchez.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.pedrovgs.problem69;

/**
 * Given two integers passed as argument, can you write a function to determine the number of bits
 * required to convert integer A to integer B.
 *
 * @author Pedro Vicente Gómez Sánchez.
 */
public class BitsToTransform {

}

@@ -874,10 +874,704 @@
 form %7B%0A%0A
+  /**%0A   * Iterative algorithm created to calculate a XOR using the input integers. Once you have the XOR%0A   * you can iterate through the XOR to count the number of bits equals to 1. To iterate over the%0A   * integer we are going to modify the value of the XOR integer using & operator with XOR & XOR%0A   * -1.%0A   *%0A   * For example:%0A   *%0A   * numA = 001%0A   * numB = 101%0A   * XOR  = 100%0A   *%0A   * Iteration 1 -%3E XOR = 100%0A   * Iteration 2 -%3E XOR = 100 & 011 = 000 // Loop body not executed.%0A   */%0A  public int calculate(int numA, int numB) %7B%0A    int differentBits = 0;%0A    for (int XOR = numA %5E numB; XOR != 0; XOR = XOR & (XOR - 1)) %7B%0A      differentBits++;%0A    %7D%0A    return differentBits;%0A  %7D%0A
 %7D%0A

Add solution to problem 69