Count minimum moves required to convert A to B | Function to find minimum number of moves to obtained B from A ; Stores the minimum number of moves ; Absolute difference ; K is in range [ 0 , 10 ] ; Print the required moves ; Driver Code
function convertBfromA ( a , b ) { let moves = 0 ; let x = Math . abs ( a - b ) ; for ( let i = 10 ; i > 0 ; i -- ) { moves += Math . floor ( x / i ) ; x = x % i ; } document . write ( moves + " " ) ; } let A = 188 , B = 4 ; convertBfromA ( A , B ) ;