-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproblem174.rb
More file actions
executable file
·28 lines (25 loc) · 861 Bytes
/
problem174.rb
File metadata and controls
executable file
·28 lines (25 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# We shall define a square lamina to be a square outline with a square "hole" so that the shape possesses vertical and horizontal symmetry.
#
# Given eight tiles it is possible to form a lamina in only one way: 3x3 square with a 1x1 hole in the middle. However, using thirty-two tiles it is possible to form two distinct laminae.
#
# If t represents the number of tiles used, we shall say that t = 8 is type L(1) and t = 32 is type L(2).
#
# Let N(n) be the number of t ≤ 1000000 such that t is type L(n); for example, N(15) = 832.
#
# What is ∑ N(n) for 1 ≤ n ≤ 10?
max = 1000000
l_array = [0]*(max+1)
[8,12].each do |start|
a_0 = start
while a_0 <= max
current = a_0
sum = current
while sum <= max
l_array[sum] += 1
current += 8
sum += current
end
a_0 += 8
end
end
puts l_array.reject{|x| x < 1 or x > 10}.length