treffen:codegolfing:004_gc

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen gezeigt.

Link zu der Vergleichsansicht

Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung
Nächste Überarbeitung
Vorherige Überarbeitung
Letzte Überarbeitung Beide Seiten, nächste Überarbeitung
treffen:codegolfing:004_gc [2022/07/06 09:28]
max
treffen:codegolfing:004_gc [2022/07/07 13:24]
max
Zeile 66: Zeile 66:
 </code> </code>
  
 +Python, nopx, 224B (nachgereicht)
 +<code Python>
 +import sys
 +n=int(sys.argv[1])
 +m=n-1
 +w=m*m+m+2
 +r=range(n)
 +def p(h,s=0):
 +    l=" "*(w-h-s)+"#"*h+" "*s
 +    print(l[:-1]+l[::-1])
 +for e in r:
 +    for l in r:
 +        p(1,m*e+l)
 +    p(w)if e==m else p(m+1,m*e+1)
 +for _ in r:p(m)
 +</code>
  
 Python, v0tti, 226B Python, v0tti, 226B
Zeile 122: Zeile 138:
  
 # Helper function to plot a row # Helper function to plot a row
-def plotline(num_hashes,num_spaces):+def plotline(num_hashes,num_spaces :int =0):
  
     line = " "*(l_left - num_hashes - num_spaces) + "#"*num_hashes + " "*num_spaces     line = " "*(l_left - num_hashes - num_spaces) + "#"*num_hashes + " "*num_spaces
Zeile 133: Zeile 149:
     for linenumber in range(n):     for linenumber in range(n):
         # Plot lines with on #         # Plot lines with on #
-        plotline(1,m * etagenumber + linenumber)+        plotline(1, m*etagenumber + linenumber)
  
     # Plot line with multiple #     # Plot line with multiple #
     if etagenumber == m:     if etagenumber == m:
         # Something special for the last etage:         # Something special for the last etage:
-        plotline( l_left, 0)+        plotline( l_left )
     else:     else:
         # For all other etages:         # For all other etages:
-        plotline( m+1, m*etagenumber+1)+        plotline( m+1, m*etagenumber + 1)
  
 # Print trunk # Print trunk
-for _ in range(n): plotline( m, 0+for _ in range(n): plotline( m ) 
 </code> </code>
  • treffen/codegolfing/004_gc.txt
  • Zuletzt geändert: 2022/07/07 13:26
  • von max