puzzle from 1980 book :

1 :

write code that calculates the number of squares in any rectangle

the recangle is filled totaly

no squares overlap

input is width and height of the rectangle

2 :

find the smalest rectangle whit that

## square chalence

### Re: square chalence

I don't know if I understand the question.

Surely if w is a rational multiple of h we can cover the rectangle with many different square tesselations. And if not, no covering is possible without leaving gaps.

Suppose mw = nh where m and n are both positive integers. Then we can cover the rectangle with squares of side length s = w/n = h/m.

But we can also do it with squares of side length s/2, s/3, s/4 and so on.

The second part of your question is incomprehensible.

Surely if w is a rational multiple of h we can cover the rectangle with many different square tesselations. And if not, no covering is possible without leaving gaps.

Suppose mw = nh where m and n are both positive integers. Then we can cover the rectangle with squares of side length s = w/n = h/m.

But we can also do it with squares of side length s/2, s/3, s/4 and so on.

The second part of your question is incomprehensible.

### Re: square chalence

sizes are integers

find the smalles retangle that fits the puzle

find the smalles retangle that fits the puzle

### Re: square chalence

1. Smallest number of squares that will completely and nonoverlappingly cover a rectangle of given integer width and height

edit: smallest number of squares of equal size

2. w=h=1 is the smallest rectangle with integer side lengths that can be totally covered by some number of squares. Again, I don't think this question makes sense.

Code: Select all

`function gcd( w as uinteger, h as uinteger ) as uinteger`

if h = 0 then

return w

else

return gcd(h, w mod h)

end if

end function

dim as uinteger w, h, g

input w, h

g = gcd(w, h)

print w*h/(g*g)

edit: smallest number of squares of equal size

2. w=h=1 is the smallest rectangle with integer side lengths that can be totally covered by some number of squares. Again, I don't think this question makes sense.

Last edited by thebigh on Apr 02, 2020 16:13, edited 1 time in total.

### Re: square chalence

more that 1 square is good

### Who is online

Users browsing this forum: deltarho[1859] and 9 guests