Skip to main content
Commonmark migration
Source Link

#Python 2, 294 290

Python 2, 294 290

I got it working, but I still need to golf it more. I'm so happy, though, that was tough (for me, at least)!

I'll probably add an explanation later, unless it's immediately clear to someone...? I kind of doubt it.

Try it here

n=input()
w=n*n+n+2>>1
a=eval(`[[' ']*w]*-~n**2`)
r=range
j=[i*i+i>>1for i in r(n+1)]
p=0
for i in r(w):
 if i in j:
    p+=p<n
    for k in r(p*p+1):a[~k][i]='+'if k%p<1or' '<a[~k][i-1]<'.'else'|'
 else:
    for k in r(p*p+1):a[~k][i]=' 'if k%p else'-'
print'\n'.join(''.join(i)for i in a)

#Python 2, 294 290

I got it working, but I still need to golf it more. I'm so happy, though, that was tough (for me, at least)!

I'll probably add an explanation later, unless it's immediately clear to someone...? I kind of doubt it.

Try it here

n=input()
w=n*n+n+2>>1
a=eval(`[[' ']*w]*-~n**2`)
r=range
j=[i*i+i>>1for i in r(n+1)]
p=0
for i in r(w):
 if i in j:
    p+=p<n
    for k in r(p*p+1):a[~k][i]='+'if k%p<1or' '<a[~k][i-1]<'.'else'|'
 else:
    for k in r(p*p+1):a[~k][i]=' 'if k%p else'-'
print'\n'.join(''.join(i)for i in a)

Python 2, 294 290

I got it working, but I still need to golf it more. I'm so happy, though, that was tough (for me, at least)!

I'll probably add an explanation later, unless it's immediately clear to someone...? I kind of doubt it.

Try it here

n=input()
w=n*n+n+2>>1
a=eval(`[[' ']*w]*-~n**2`)
r=range
j=[i*i+i>>1for i in r(n+1)]
p=0
for i in r(w):
 if i in j:
    p+=p<n
    for k in r(p*p+1):a[~k][i]='+'if k%p<1or' '<a[~k][i-1]<'.'else'|'
 else:
    for k in r(p*p+1):a[~k][i]=' 'if k%p else'-'
print'\n'.join(''.join(i)for i in a)
added 2 characters in body
Source Link
mbomb007
  • 23.5k
  • 7
  • 63
  • 135

#Python 2, 294 290

I got it working, but I still need to golf it more. I'm so happy, though, that was tough (for me, at least)!

I'll probably add an explanation later, unless it's immediately clear to someone...? I kind of doubt it.

Try it here

n=input()
w=n*n+n+2>>1
a=eval(`[[' ']*w]*-~n**2`)
r=range
j=[i*i+i>>1for i in r(n+1)]
p=0
for i in r(w):
 if i in j:
    p+=p<n
    for k in r(p*p+1):a[~k][i]='+'if k%p<1or' '<a[~k][i-1]<'.'else'|'
 else:
    for k in r(p*p+1):a[~k][i]=' 'if k%p else'-'
print'\n'.join(''.join(i)for i in a)

#Python 2, 294 290

I got it working, but I still need to golf it more.

n=input()
w=n*n+n+2>>1
a=eval(`[[' ']*w]*-~n**2`)
r=range
j=[i*i+i>>1for i in r(n+1)]
p=0
for i in r(w):
 if i in j:
    p+=p<n
    for k in r(p*p+1):a[~k][i]='+'if k%p<1or' '<a[~k][i-1]<'.'else'|'
 else:
    for k in r(p*p+1):a[~k][i]=' 'if k%p else'-'
print'\n'.join(''.join(i)for i in a)

#Python 2, 294 290

I got it working, but I still need to golf it more. I'm so happy, though, that was tough (for me, at least)!

I'll probably add an explanation later, unless it's immediately clear to someone...? I kind of doubt it.

Try it here

n=input()
w=n*n+n+2>>1
a=eval(`[[' ']*w]*-~n**2`)
r=range
j=[i*i+i>>1for i in r(n+1)]
p=0
for i in r(w):
 if i in j:
    p+=p<n
    for k in r(p*p+1):a[~k][i]='+'if k%p<1or' '<a[~k][i-1]<'.'else'|'
 else:
    for k in r(p*p+1):a[~k][i]=' 'if k%p else'-'
print'\n'.join(''.join(i)for i in a)
added 2 characters in body
Source Link
mbomb007
  • 23.5k
  • 7
  • 63
  • 135

#Python 2, not done yet294 290

I'm still working onI got it. Almost done. Then working, but I canstill need to golf it more.

n=input()
w=n*n+n+2>>1
h=-~n**2
a=eval(`[[' ']*w]*h`']*w]*-~n**2`)
r=range
j=[i*i+i>>1for i in r(n+1)]
p=0
for i in r(w):
 if i in j:
    p+=p<n
    for k in r(p*p+1):a[~k][i]='|'ifa[~k][i]='+'if k%pk%p<1or' else'+''<a[~k][i-1]<'.'else'|'
 else:
    for k in r(p*p+1):a[~k][i]=' 'if k%p else'-'
print'\n'.join(''.join(i)for i in a)

#Python 2, not done yet

I'm still working on it. Almost done. Then I can golf it more.

n=input()
w=n*n+n+2>>1
h=-~n**2
a=eval(`[[' ']*w]*h`)
r=range
j=[i*i+i>>1for i in r(n+1)]
p=0
for i in r(w):
 if i in j:
    p+=p<n
    for k in r(p*p+1):a[~k][i]='|'if k%p else'+'
 else:
    for k in r(p*p+1):a[~k][i]=' 'if k%p else'-'
print'\n'.join(''.join(i)for i in a)

#Python 2, 294 290

I got it working, but I still need to golf it more.

n=input()
w=n*n+n+2>>1
a=eval(`[[' ']*w]*-~n**2`)
r=range
j=[i*i+i>>1for i in r(n+1)]
p=0
for i in r(w):
 if i in j:
    p+=p<n
    for k in r(p*p+1):a[~k][i]='+'if k%p<1or' '<a[~k][i-1]<'.'else'|'
 else:
    for k in r(p*p+1):a[~k][i]=' 'if k%p else'-'
print'\n'.join(''.join(i)for i in a)
deleted 185 characters in body
Source Link
mbomb007
  • 23.5k
  • 7
  • 63
  • 135
Loading
Source Link
mbomb007
  • 23.5k
  • 7
  • 63
  • 135
Loading