Skip to content

Latest commit

 

History

History
46 lines (25 loc) · 559 Bytes

Most_sales.md

File metadata and controls

46 lines (25 loc) · 559 Bytes

CodeWars Python Solutions


Minimum to multiple

Description:

Given two integers a and x, return the minimum non-negative number to add to / subtract from a to make it a multiple of x.

minimum(10, 6)  #= 2

10+2 = 12 which is a multiple of 6

Note

0 is always a multiple of x


Given Code

def minimum(a, x):
    # code

Solution

def minimum(a, x):
    return min([a % x, x-(a%x)])

See on CodeWars.com