diff --git a/luke_19/engler.py b/luke_19/engler.py new file mode 100755 index 0000000..0455671 --- /dev/null +++ b/luke_19/engler.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3.6 +import os +from PIL import Image, ImageDraw + +def readFile(): + with open(os.path.dirname(__file__) + '/path.txt', 'r') as f: + return [line.split(", ") for line in f.read().splitlines()] + +def plotRectangle(i, j, board, fill='red'): + board.rectangle(((100+(10*j), 200+(10*i)), 100+(10*j+10), 200+(10*i+10)), fill=fill, outline="black") + return board + +def main(): + path = readFile() + boardImg = Image.new('RGB', (400, 300), (255,255,255)) + board = ImageDraw.Draw(boardImg) + x, y = [0,0] + plotRectangle(x,y,board, 'green') + + for step, direction in path: + if (direction == 'north'): + for n in range(int(step)): + x -= 1 + board = plotRectangle(x, y, board) + elif (direction == 'east'): + for n in range(int(step)): + print(y) + y += 1 + board = plotRectangle(x, y, board) + elif (direction == 'south'): + for n in range(int(step)): + x += 1 + board = plotRectangle(x, y, board) + elif (direction == 'west'): + for n in range(int(step)): + y -= 1 + board = plotRectangle(x, y, board) + + return 'batman' + boardImg.show() + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/luke_19/path.txt b/luke_19/path.txt new file mode 100644 index 0000000..2c6c9a2 --- /dev/null +++ b/luke_19/path.txt @@ -0,0 +1,148 @@ +10, east +1, west +1, north +4, east +1, north +2, east +1, north +2, east +1, north +1, east +1, north +1, east +2, north +1, east +6, north +1, west +2, north +1, west +1, north +1, west +1, north +2, west +1, north +2, west +1, north +3, west +1, north +10, west +1, south +3, west +1, south +2, west +1, south +2, west +1, south +1, west +1, south +1, west +2, south +1, west +6, south +1, east +2, south +1, east +1, south +1, east +1, south +2, east +1, south +2, east +1, south +4, east +4, west +1, north +2, west +2, north +1, east +1, west +2, north +2, west +1, north +3, east +1, north +4, west +19, east +1, south +12, west +1, east +2, south +2, north +10, east +2, south +2, north +3, west +1, south +4, west +1, east +1, south +2, east +1, west +2, south +5, north +13, east +1, west +1, south +3, west +1, east +1, south +2, east +2, west +2, south +1, west +1, east +5, north +3, east +26, west +1, north +26, east +1, north +26, west +1, north +26, east +1, west +1, north +6, west +1, east +1, north +5, east +2, west +1, north +3, west +1, north +1, east +1, west +1, north +1, west +1, east +5, south +4, west +1, north +6, west +1, east +1, north +4, east +1, north +4, west +1, north +4, east +1, north +4, west +1, north +1, south +4, east +1, north +6, south +8, west +1, north +6, west +1, north +5, east +1, north +3, west +3, east +1, north +1, west +1, east +1, north +1, east \ No newline at end of file diff --git a/tests/test_luke19.py b/tests/test_luke19.py index 3d91030..b1276b6 100644 --- a/tests/test_luke19.py +++ b/tests/test_luke19.py @@ -1,2 +1,4 @@ +from luke_19.engler import main + def test_answer(): - assert False + assert main() == 'batman'