There are 2 wooden sticks of lengths A and B respectively. Each of them can be cut into shorter sticks of integer lengths. Our goal is to construct the largest possible square. In order to do this, we want to cut the sticks in such a way as to achieve four sticks of the same length(note that there can be some leftover pieces). what is the longest side of square that we can achieve?
Write a function: def solution(A,B)
that given two integers A,B returns the side of length of the largest square that we can obtain. If it is not possible to create any square, the function should return 0.
https://stackoverflow.com/questions/66774902/python-program-to-find-longest-possible-side-of-the-square-that-can-be-formed-wi March 24, 2021 at 12:44PM
没有评论:
发表评论