Skip to content

Instantly share code, notes, and snippets.

@mariokostelac
Created April 5, 2020 09:21
Show Gist options
  • Save mariokostelac/a865bbcacd05980a8a1ae84d7797c08b to your computer and use it in GitHub Desktop.
Save mariokostelac/a865bbcacd05980a8a1ae84d7797c08b to your computer and use it in GitHub Desktop.

Revisions

  1. @mario-at-intercom mario-at-intercom revised this gist Apr 5, 2020. 1 changed file with 120 additions and 0 deletions.
    120 changes: 120 additions & 0 deletions output
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,120 @@
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■

    x■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■

    xxxxxxxxxx
    ■■■■■■■■■x
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■

    xxxxxxxxxx
    xxxxxxxxxx
    x■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■

    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    ■■■■■■■■■x
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■

    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    x■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■

    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    ■■■■■■■■■x
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■

    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    x■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■
    ■■■■■■■■■■

    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    ■■■■■■■■■x
    ■■■■■■■■■■
    ■■■■■■■■■■

    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    x■■■■■■■■■
    ■■■■■■■■■■

    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxxxxxx
    ■■■■■■■■■x
  2. @mario-at-intercom mario-at-intercom created this gist Apr 5, 2020.
    27 changes: 27 additions & 0 deletions dfs.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    i = 0

    def dfs(arr, x, y):
    if x < 0 or x >= len(arr) or y < 0 or y >= len(arr[0]):
    return
    if arr[x][y] == 'x':
    return

    arr[x][y] = 'x'
    global i; i+=1
    if i % len(arr)-1 == 0:
    p(arr)

    dfs(arr, x, y+1)
    dfs(arr, x-1, y)
    dfs(arr, x, y-1)
    dfs(arr, x+1, y)

    def p(arr):
    for row in arr:
    print(''.join(row))
    print()

    arr = [['■']*10 for _ in range(10)]
    if __name__ == "__main__":
    p(arr)
    dfs(arr, 0, 0)