Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
19
Task/McNuggets-problem/Pluto/mcnuggets-problem.pluto
Normal file
19
Task/McNuggets-problem/Pluto/mcnuggets-problem.pluto
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
do -- Solve the McNuggets problem find the largest n <= 100 for which there
|
||||
-- are no non-negative integers x, y, z such that 6x + 9y + 20z = n
|
||||
|
||||
local maxNuggets <const> = 100
|
||||
local sum = {}
|
||||
for i = 0, maxNuggets do sum[ i ] = false end
|
||||
for x = 0, maxNuggets, 6 do
|
||||
for y = x, maxNuggets, 9 do
|
||||
for z = y, maxNuggets, 20 do
|
||||
sum[ z ] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
-- show the highest number that cannot be formed
|
||||
local largest = maxNuggets
|
||||
while sum[ largest ] do largest -= 1 end
|
||||
print( $"The largest non McNugget number is {largest}" )
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue