Skip to main content
added 2 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 13
  • 39

Python 2, 3031 bytes

lambda x,y:int(y and x/(1/float(y)))

Try it online!Try it online!

Old approach was longer, but then I remembered Math!:

Python 2, 5049 bytes

lambda x,y:sum([x,-x][y<0] forx][y<0]for i in range(abs(y)))

Try it online!Try it online!

Python 2, 30 bytes

lambda x,y:int(x/(1/float(y)))

Try it online!

Old approach was longer, but then I remembered Math!:

Python 2, 50 bytes

lambda x,y:sum([x,-x][y<0] for i in range(abs(y)))

Try it online!

Python 2, 31 bytes

lambda x,y:y and x/(1/float(y))

Try it online!

Old approach was longer, but then I remembered Math!:

Python 2, 49 bytes

lambda x,y:sum([x,-x][y<0]for i in range(abs(y)))

Try it online!

added 362 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 13
  • 39

Python 2, 30 bytes

lambda x,y:int(x/(1/float(y)))

Try it online!

Old approach was longer, but then I remembered Math!:

Python 2, 50 bytes

lambda x,y:sum([x,-x][y<0] for i in range(abs(y)))

Try it online!

Python 2, 50 bytes

lambda x,y:sum([x,-x][y<0] for i in range(abs(y)))

Try it online!

Python 2, 30 bytes

lambda x,y:int(x/(1/float(y)))

Try it online!

Old approach was longer, but then I remembered Math!:

Python 2, 50 bytes

lambda x,y:sum([x,-x][y<0] for i in range(abs(y)))

Try it online!

Source Link
Chas Brown
  • 9.8k
  • 1
  • 13
  • 39

Python 2, 50 bytes

lambda x,y:sum([x,-x][y<0] for i in range(abs(y)))

Try it online!