# And here is the code our group wrote. We used the REPL at first, and then moved to using the editor.
# The program makes a "snake" run round the outside of the LEDs, and the buttons control direction
import microbit
outer=[(0,0),(1,0),(2,0),(3,0),(4,0),(4,1),
(4,2),(4,3),(4,4),(3,4),(2,4),(1,4),
(0,4),(0,3),(0,2),(0,1)]
microbit.display.clear()
direction = 1
i = 0
while 1:
if microbit.button_a.is_pressed():
direction = 1
elif microbit.button_b.is_pressed():
direction = -1
x, y = outer[(i) % len(outer)]
X,Y = outer[(i-5*direction) % len(outer)]
microbit.display.set_pixel(X,Y,0)
microbit.display.set_pixel(x,y,9)
microbit.sleep(100)
i += direction