# This program requires AUXILIARY MODE
# set this in your menu, under
#  - under robot select settings
#  - in the pop-up: 
#  - - click the button for auxiliary mode
#  - -  click the save button

# unary multiplication example, 
# with two inputs
# not destroying inputs
define main {
    # get the first input
    move
    get_and_restore
    
    # move the first input to  bag 2
    while (has_beeper(1) ) {
        move_beeper(1,2)
    }

    # go to the second input
    move

    # for each beeper in bag 2,
    # add another copy of input 2
    while (has_beeper(2)) {
        move_beeper(2,3)
        get_and_restore
    }

    # output the result
    move
    display_product
    move
}

define get_and_restore {
    while (next_to_a_beeper) {
        pick_beeper
    }
    while (has_beeper(0)) {
        move_beeper(0,1)
        create_beeper
    }
}

define display_product {
    while (has_beeper(1)) {
        move_beeper(1,0)
        put_beeper
    }
}
