# Код на ruby 2.2.3p173
def zadanie(n)
k = 0
for alice in 2..(n-2)
for basilio in 1..(n-3)
for duremar in 1..(n-3)
if alice > basilio and alice > duremar and alice + basilio + duremar == n
k += 1
p [alice, basilio, duremar]
end
end
end
end
return k
end
# # Примеры применения
p zadanie(16)
Вывод :
[6, 5, 5]
[7, 3, 6]
[7, 4, 5]
[7, 5, 4]
[7, 6, 3]
[8, 1, 7]
[8, 2, 6]
[8, 3, 5]
[8, 4, 4]
[8, 5, 3]
[8, 6, 2]
[8, 7, 1]
[9, 1, 6]
[9, 2, 5]
[9, 3, 4]
[9, 4, 3]
[9, 5, 2]
[9, 6, 1]
[10, 1, 5]
[10, 2, 4]
[10, 3, 3]
[10, 4, 2]
[10, 5, 1]
[11, 1, 4]
[11, 2, 3]
[11, 3, 2]
[11, 4, 1]
[12, 1, 3]
[12, 2, 2]
[12, 3, 1]
[13, 1, 2]
[13, 2, 1]
[14, 1, 1]
33
т.е. 33 способа