Skip to content

Instantly share code, notes, and snippets.

@juliusgeo
Created February 3, 2023 13:06
Show Gist options
  • Save juliusgeo/6febc2e48a9821bc667fbc059e03a753 to your computer and use it in GitHub Desktop.
Save juliusgeo/6febc2e48a9821bc667fbc059e03a753 to your computer and use it in GitHub Desktop.
l=lambda\
x0, y, x1, y1: \
((dx := x1 - x0, dy :=
y1-y,yi:=1,yi:=-1 if dy<0 else yi,
dy:=-dy if dy<0 else dy,d:=(2*dy)-dx,ps:=
set(),[(ps.add((x,y)),y:=y+yi,d:=d+2*(dy-dx))if d>
0 else(d:=d+2*dy)for x in range(x0,x1)]),ps)[1];pp=lambda \
ps:list(map(print, [''.join(["-"if(x, y)in ps else" "for x in range
(127)])for y in range(10)]));pp(set.union(*[l(0, 0, i, 9) for i in range(37, 127)]))
@juliusgeo
Copy link
Author

  ------                                                                                                                       
      ----------------                                                                                                         
          --------------------------                                                                                           
              ------------------------------------                                                                             
                  ----------------------------------------------                                                               
                      --------------------------------------------------------                                                 
                          ------------------------------------------------------------------                                   
                              ----------------------------------------------------------------------------                     
                                  --------------------------------------------------------------------------------------  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment