Challenge | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Challenge

split the chocolate bar of given dimension n x m into small squares. Each square is of size 1x1 and unbreakable. Implement a function that will return minimum number of breaks needed. For example if you are given a chocolate bar of size 2 x 1 you can split it to single squares in just one break, but for size 3 x 1 you must do two breaks. If input data is invalid you should return 0

15th Aug 2017, 2:05 PM
Krafty Coder
Krafty Coder - avatar
2 Answers
+ 6
javascript: let breaks = (m, n) => m * n - 1;
15th Aug 2017, 2:10 PM
Schindlabua
Schindlabua - avatar
+ 2
print(int(input("N"))*int(input("M"))-1)
15th Aug 2017, 2:51 PM
VcC
VcC - avatar