---
# System prepended metadata

title: マイクラ検定 問題3 答え
tags: [マイクラ検定答え]

---

    local n = 3
    function kaitenbori(down)
        local count = 0
        for i = 1, down do
            local result = turtle.digDown()
            if result == true then
                count = count + 1   
            else
                break
            end
            turtle.down()
            for i = 1, 4 do
                turtle.turnLeft()
                turtle.dig()
            end
        end
        return count - 1
    end

    function backToHome(up)
        for i = 1, up do

            turtle.up()


        end
    end

    turtle.select(1)
    turtle.refuel()
    local up = kaitenbori(n)
    backToHome(up)

    for j = 1, 4 do
        turtle.place()
        turtle.turnLeft()
    end

    turtle.up()
    turtle.placeDown()