Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Quarry Dimension Input and Mining Program
- -- Get the dimensions
- function input(newWidth, newLength, newDepth)
- width = newWidth
- length = newLength
- depth = newDepth
- fuelcost = 0
- end
- function getFuelCost()
- return fuelcost
- end
- -- Function to Mine to Depth
- function mineDepth()
- for i = 1, depth do
- fuelcost = fuelcost + 1
- end
- for j = 1, depth do
- fuelcost = fuelcost + 1
- end
- end
- -- Function to mine a layer
- function mine(width, length)
- for i = 1, length do
- for j = 1, width do
- mineDepth()
- fuelcost = fuelcost + 1
- end
- if i < length then
- if i % 2 == 1 then
- mineDepth()
- fuelcost = fuelcost + 1
- else
- mineDepth()
- fuelcost = fuelcost + 1
- end
- end
- end
- end
- function toStart()
- if length % 2 == 1 then
- for i = 1, width do
- fuelcost = fuelcost + 1
- end
- end
- for j = 2, length do
- fuelcost = fuelcost + 1
- end
- fuelcost = fuelcost + 1
- end
- function predict(newWidth, newLength, newDepth)
- input(newWidth, newLength, newDepth)
- fuelcost = fuelcost + 1
- mine(width, length)
- mineDepth()
- toStart()
- return fuelcost
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement