Skip to main content
Commonmark migration
Source Link

#Python 2, 89 88 87 85 83 named / 81 unnamed

Python 2, 89 88 87 85 83 named / 81 unnamed

f=lambda n:1%n*(" "+n/2*4*"_"+"\n")+(" /\ "*n)[:2+2*n]+"\n"+("/__\\"*n)[:n-~n+n%2] 

(Thanks to @orlp for a byte, and @xnor for another three)

This is a function which takes in an int n and returns the triangles as a string using the row-by-row approach.

e.g. print f(10) gives

 ____________________ /\ /\ /\ /\ /\ / /__\/__\/__\/__\/__\/ 

For the first row, instead of (n>1)* we use 1%n*, since 1%n is 0 if n == 1 and 1 if n > 1.

#Python 2, 89 88 87 85 83 named / 81 unnamed

f=lambda n:1%n*(" "+n/2*4*"_"+"\n")+(" /\ "*n)[:2+2*n]+"\n"+("/__\\"*n)[:n-~n+n%2] 

(Thanks to @orlp for a byte, and @xnor for another three)

This is a function which takes in an int n and returns the triangles as a string using the row-by-row approach.

e.g. print f(10) gives

 ____________________ /\ /\ /\ /\ /\ / /__\/__\/__\/__\/__\/ 

For the first row, instead of (n>1)* we use 1%n*, since 1%n is 0 if n == 1 and 1 if n > 1.

Python 2, 89 88 87 85 83 named / 81 unnamed

f=lambda n:1%n*(" "+n/2*4*"_"+"\n")+(" /\ "*n)[:2+2*n]+"\n"+("/__\\"*n)[:n-~n+n%2] 

(Thanks to @orlp for a byte, and @xnor for another three)

This is a function which takes in an int n and returns the triangles as a string using the row-by-row approach.

e.g. print f(10) gives

 ____________________ /\ /\ /\ /\ /\ / /__\/__\/__\/__\/__\/ 

For the first row, instead of (n>1)* we use 1%n*, since 1%n is 0 if n == 1 and 1 if n > 1.

deleted 17 characters in body
Source Link
Sp3000
  • 62.3k
  • 13
  • 117
  • 292

#Python 2, 89 88 87 8585 83 named / 8381 unnamed

f=lambda n:1%n*(" "+n/2*4*"_"+"\n")+(" /\ "*n)[:2+2*n]+"\n"+("/__\\"*n)[:2*nn-~(n%2)]~n+n%2] 

(Thanks to @orlp for a byte, and @xnor for another byte by abolishing "\n".jointhree)

This is a function which takes in an int n and returns the triangles as a string using the row-by-row approach.

e.g. print f(10) gives

 ____________________ /\ /\ /\ /\ /\ / /__\/__\/__\/__\/__\/ 

For the first row, instead of (n>1)* we use 1%n*, since 1%n is 0 if n == 1 and 1 if n > 1.

#Python 2, 89 88 87 85 named / 83 unnamed

f=lambda n:1%n*(" "+n/2*4*"_"+"\n")+(" /\ "*n)[:2+2*n]+"\n"+("/__\\"*n)[:2*n-~(n%2)] 

(Thanks to @orlp for a byte, and @xnor for another byte by abolishing "\n".join)

This is a function which takes in an int n and returns the triangles as a string using the row-by-row approach.

e.g. print f(10) gives

 ____________________ /\ /\ /\ /\ /\ / /__\/__\/__\/__\/__\/ 

For the first row, instead of (n>1)* we use 1%n*, since 1%n is 0 if n == 1 and 1 if n > 1.

#Python 2, 89 88 87 85 83 named / 81 unnamed

f=lambda n:1%n*(" "+n/2*4*"_"+"\n")+(" /\ "*n)[:2+2*n]+"\n"+("/__\\"*n)[:n-~n+n%2] 

(Thanks to @orlp for a byte, and @xnor for another three)

This is a function which takes in an int n and returns the triangles as a string using the row-by-row approach.

e.g. print f(10) gives

 ____________________ /\ /\ /\ /\ /\ / /__\/__\/__\/__\/__\/ 

For the first row, instead of (n>1)* we use 1%n*, since 1%n is 0 if n == 1 and 1 if n > 1.

added 112 characters in body
Source Link
Sp3000
  • 62.3k
  • 13
  • 117
  • 292

#Python 2, 89 88 8787 85 named / 8583 unnamed

f=lambda n:(n>1)*1%n*(" "+n/2*4*"_"+"\n")+(" /\ "*n)[:2+2*n]+"\n"+("/__\\"*n)[:2*n-~(n%2)] 

(Thanks to @orlp for a byte, and @xnor for another byte by abolishing "\n".join)

This is a function which takes in an int n and returns the triangles as a string using the row-by-row approach.

e.g. print f(10) gives

 ____________________ /\ /\ /\ /\ /\ / /__\/__\/__\/__\/__\/ 

For the first row, instead of (n>1)* we use 1%n*, since 1%n is 0 if n == 1 and 1 if n > 1.

#Python 2, 89 88 87 named / 85 unnamed

f=lambda n:(n>1)*(" "+n/2*4*"_"+"\n")+(" /\ "*n)[:2+2*n]+"\n"+("/__\\"*n)[:2*n-~(n%2)] 

(Thanks to @orlp for a byte, and @xnor for another byte by abolishing "\n".join)

This is a function which takes in an int n and returns the triangles as a string using the row-by-row approach.

e.g. print f(10) gives

 ____________________ /\ /\ /\ /\ /\ / /__\/__\/__\/__\/__\/ 

#Python 2, 89 88 87 85 named / 83 unnamed

f=lambda n:1%n*(" "+n/2*4*"_"+"\n")+(" /\ "*n)[:2+2*n]+"\n"+("/__\\"*n)[:2*n-~(n%2)] 

(Thanks to @orlp for a byte, and @xnor for another byte by abolishing "\n".join)

This is a function which takes in an int n and returns the triangles as a string using the row-by-row approach.

e.g. print f(10) gives

 ____________________ /\ /\ /\ /\ /\ / /__\/__\/__\/__\/__\/ 

For the first row, instead of (n>1)* we use 1%n*, since 1%n is 0 if n == 1 and 1 if n > 1.

added 63 characters in body
Source Link
Sp3000
  • 62.3k
  • 13
  • 117
  • 292
Loading
added 43 characters in body
Source Link
Sp3000
  • 62.3k
  • 13
  • 117
  • 292
Loading
Source Link
Sp3000
  • 62.3k
  • 13
  • 117
  • 292
Loading