Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 699 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23

Python, 167 bytes

lambda l,r,o=lambda s:" "*(ord(s[0])-97):[("{:99s}"*6).format(o(l)+l[2:],o(l)+l[1],*["abcdefghijklmnopqrstuvwxyz"]*2,o(r)+r[1],o(r)+r[2:])[98-i::99]for i in range(99)]

Attempt This Online!

  • Returns a list of rows
  • Inputs that would require more than 99 chars won't work, which is allowed
  • Expects 2 words, lowercase ascii (or at least their first char must be), length of 2 or more (it could be 1 byte shorter if I defaulted to uppercase)

Old version (function with print rather than lambda: I wasn't too sure about I/O conventions) with explanation:

Python , (削除) 197 (削除ここまで) (削除) 194 (削除ここまで) (削除) 192 (削除ここまで) (削除) 185 (削除ここまで) (削除) 178 (削除ここまで) (削除) 175 (削除ここまで) 174 bytes

o=lambda s:" "*(ord(s[0])-97) # Function that, given an input word,
 # returns as many whitespaces as the
 # index of the first char in unicode,
 # after "a" (ord("a") == 97), i.e.
 # how much the branch should be raised
 # from the ground.
def f(l,r):
 # Cactus built horizontally by rows:
 ( o(l)+l[2:], # * padding + letters 3+ of the word
 o(l)+l[1], # * padding + second letter
 *["abcdefghijklmnopqrstuvwxyz"]*2, # * whole alphabet twice (ugly but I
 # can't golf it further as strings)
 o(r)+r[1], # * padding + second (right) 
 o(r)+r[2:] ) # * padding + letters 3+ (right)
#
# └──────┬──────┘
# └──────────────┐
# ╽
 ("{:99s}"*6).format( ... ) # Concatenation of 6 strings, each
# # right-padded to 99 characters.
# └───────────┬────────────┘
# ┌────┘
# ╽
[print( ... [98-i::99])for i in range(99)] # A way of wrapping the string at 99
 # and printing it transposed.

v2: Python , 167 bytes

lambda l,r,o=lambda s:" "*(ord(s[0])-97):[("{:99s}"*6).format(o(l)+l[2:],o(l)+l[1],*["abcdefghijklmnopqrstuvwxyz"]*2,o(r)+r[1],o(r)+r[2:])[98-i::99]for i in range(99)]```

Attempt This Online!

Wasn't too sure about I/O conventions. This one-liner returns a list of rows.

Python, (削除) 197 (削除ここまで) (削除) 194 (削除ここまで) (削除) 192 (削除ここまで) (削除) 185 (削除ここまで) (削除) 178 (削除ここまで) (削除) 175 (削除ここまで) 174 bytes

o=lambda s:" "*(ord(s[0])-97) # Function that, given an input word,
 # returns as many whitespaces as the
 # index of the first char in unicode,
 # after "a" (ord("a") == 97), i.e.
 # how much the branch should be raised
 # from the ground.
def f(l,r):
 # Cactus built horizontally by rows:
 ( o(l)+l[2:], # * padding + letters 3+ of the word
 o(l)+l[1], # * padding + second letter
 *["abcdefghijklmnopqrstuvwxyz"]*2, # * whole alphabet twice (ugly but I
 # can't golf it further as strings)
 o(r)+r[1], # * padding + second (right) 
 o(r)+r[2:] ) # * padding + letters 3+ (right)
#
# └──────┬──────┘
# └──────────────┐
# ╽
 ("{:99s}"*6).format( ... ) # Concatenation of 6 strings, each
# # right-padded to 99 characters.
# └───────────┬────────────┘
# ┌────┘
# ╽
[print( ... [98-i::99])for i in range(99)] # A way of wrapping the string at 99
 # and printing it transposed.

v2: Python , 167 bytes

lambda l,r,o=lambda s:" "*(ord(s[0])-97):[("{:99s}"*6).format(o(l)+l[2:],o(l)+l[1],*["abcdefghijklmnopqrstuvwxyz"]*2,o(r)+r[1],o(r)+r[2:])[98-i::99]for i in range(99)]

Attempt This Online!

Wasn't too sure about I/O conventions. This one-liner returns a list of rows.

Python, 167 bytes

lambda l,r,o=lambda s:" "*(ord(s[0])-97):[("{:99s}"*6).format(o(l)+l[2:],o(l)+l[1],*["abcdefghijklmnopqrstuvwxyz"]*2,o(r)+r[1],o(r)+r[2:])[98-i::99]for i in range(99)]

Attempt This Online!

  • Returns a list of rows
  • Inputs that would require more than 99 chars won't work, which is allowed
  • Expects 2 words, lowercase ascii (or at least their first char must be), length of 2 or more (it could be 1 byte shorter if I defaulted to uppercase)

Old version (function with print rather than lambda: I wasn't too sure about I/O conventions) with explanation:

Python , (削除) 197 (削除ここまで) (削除) 194 (削除ここまで) (削除) 192 (削除ここまで) (削除) 185 (削除ここまで) (削除) 178 (削除ここまで) (削除) 175 (削除ここまで) 174 bytes

o=lambda s:" "*(ord(s[0])-97) # Function that, given an input word,
 # returns as many whitespaces as the
 # index of the first char in unicode,
 # after "a" (ord("a") == 97), i.e.
 # how much the branch should be raised
 # from the ground.
def f(l,r):
 # Cactus built horizontally by rows:
 ( o(l)+l[2:], # * padding + letters 3+ of the word
 o(l)+l[1], # * padding + second letter
 *["abcdefghijklmnopqrstuvwxyz"]*2, # * whole alphabet twice (ugly but I
 # can't golf it further as strings)
 o(r)+r[1], # * padding + second (right) 
 o(r)+r[2:] ) # * padding + letters 3+ (right)
#
# └──────┬──────┘
# └──────────────┐
# ╽
 ("{:99s}"*6).format( ... ) # Concatenation of 6 strings, each
# # right-padded to 99 characters.
# └───────────┬────────────┘
# ┌────┘
# ╽
[print( ... [98-i::99])for i in range(99)] # A way of wrapping the string at 99
 # and printing it transposed.
```
added 699 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23

v2: Python , 167 bytes

lambda l,r,o=lambda s:" "*(ord(s[0])-97):[("{:99s}"*6).format(o(l)+l[2:],o(l)+l[1],*["abcdefghijklmnopqrstuvwxyz"]*2,o(r)+r[1],o(r)+r[2:])[98-i::99]for i in range(99)]

Attempt This Online!

Wasn't too sure about I/O conventions. This one-liner returns a list of rows.

v2: Python , 167 bytes

lambda l,r,o=lambda s:" "*(ord(s[0])-97):[("{:99s}"*6).format(o(l)+l[2:],o(l)+l[1],*["abcdefghijklmnopqrstuvwxyz"]*2,o(r)+r[1],o(r)+r[2:])[98-i::99]for i in range(99)]

Attempt This Online!

Wasn't too sure about I/O conventions. This one-liner returns a list of rows.

saved 1 byte
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23

Python, (削除) 197 (削除ここまで) (削除) 194 (削除ここまで) (削除) 192 (削除ここまで) (削除) 185 (削除ここまで) (削除) 178 (削除ここまで) 175(削除) 175 (削除ここまで) 174 bytes

a,o="abcdefghijklmnopqrstuvwxyz",lambdao=lambda s:" "*(ord(s[0])-97)
def f(l,r):[print(("{:99s}"*6).format(o(l)+l[2:],o(l)+l[1],a,a*["abcdefghijklmnopqrstuvwxyz"]*2,o(r)+r[1],o(r)+r[2:])[98-i::99])for i in range(99)]

Attempt This Online! Attempt This Online!

a ="abcdefghijklmnopqrstuvwxyz" o=lambda #s:" "*(Ungolfable as a string. And I can't
 # use it as a list of charsord(s[0])
 o=-97) lambda s:" "*(ord(s[0])-97) # Function that, given an input word,
 # returns as many whitespaces as the
 # index of the first char in unicode,
 # after "a" (ord("a") == 97), i.e.
 # how much the branch should be raised
 # from the ground.
def f(l,r):
 # Cactus built horizontally by rows:
 ( o(l)+l[2:], # * padding + letters 3+ of the word
 o(l)+l[1], # * padding + second letter
 a*["abcdefghijklmnopqrstuvwxyz"]*2, # * whole alphabet twice (ugly but I
 # * whole alphabet
 a, # can't golf it #further *as strings)
 o(r)+r[1], # * padding (same+ forsecond (right, mirrored).
 o(r)+r[2:] ) # * padding + letters 3+ (right)
#
# └──────┬──────┘
# └──────────────┐
# ╽
 ("{:99s}"*6).format( ... ) # Concatenation of 6 strings, each
# # right-padded to 99 characters.
# └───────────┬────────────┘
# ┌────┘
# ╽
[print( ... [98-i::99])for i in range(99)] # A way of wrapping the string at 99
 # and printing it transposed.

Python, (削除) 197 (削除ここまで) (削除) 194 (削除ここまで) (削除) 192 (削除ここまで) (削除) 185 (削除ここまで) (削除) 178 (削除ここまで) 175 bytes

a,o="abcdefghijklmnopqrstuvwxyz",lambda s:" "*(ord(s[0])-97)
def f(l,r):[print(("{:99s}"*6).format(o(l)+l[2:],o(l)+l[1],a,a,o(r)+r[1],o(r)+r[2:])[98-i::99])for i in range(99)]

Attempt This Online!

a ="abcdefghijklmnopqrstuvwxyz"  # (Ungolfable as a string. And I can't
 # use it as a list of chars)
 o= lambda s:" "*(ord(s[0])-97) # Function that, given an input word,
 # returns as many whitespaces as the
 # index of the first char in unicode,
 # after "a" (ord("a") == 97), i.e.
 # how much the branch should be raised
 # from the ground.
def f(l,r):
 # Cactus built horizontally by rows:
 ( o(l)+l[2:], # * padding + letters 3+ of the word
 o(l)+l[1], # * padding + second letter
 a, # * whole alphabet
 a, # * 
 o(r)+r[1], #  (same for right, mirrored).
 o(r)+r[2:] ) # 
#
# └──────┬──────┘
# └──────────────┐
# ╽
 ("{:99s}"*6).format( ... ) # Concatenation of 6 strings, each
# # right-padded to 99 characters.
# └───────────┬────────────┘
# ┌────┘
# ╽
[print( ... [98-i::99])for i in range(99)] # A way of wrapping the string at 99
 # and printing it transposed.

Python, (削除) 197 (削除ここまで) (削除) 194 (削除ここまで) (削除) 192 (削除ここまで) (削除) 185 (削除ここまで) (削除) 178 (削除ここまで) (削除) 175 (削除ここまで) 174 bytes

o=lambda s:" "*(ord(s[0])-97)
def f(l,r):[print(("{:99s}"*6).format(o(l)+l[2:],o(l)+l[1],*["abcdefghijklmnopqrstuvwxyz"]*2,o(r)+r[1],o(r)+r[2:])[98-i::99])for i in range(99)]

Attempt This Online!

o=lambda s:" "*(ord(s[0])-97) # Function that, given an input word,
 # returns as many whitespaces as the
 # index of the first char in unicode,
 # after "a" (ord("a") == 97), i.e.
 # how much the branch should be raised
 # from the ground.
def f(l,r):
 # Cactus built horizontally by rows:
 ( o(l)+l[2:], # * padding + letters 3+ of the word
 o(l)+l[1], # * padding + second letter
 *["abcdefghijklmnopqrstuvwxyz"]*2, # * whole alphabet twice (ugly but I
 # can't golf it further as strings)
 o(r)+r[1], # * padding + second (right)
 o(r)+r[2:] ) # * padding + letters 3+ (right)
#
# └──────┬──────┘
# └──────────────┐
# ╽
 ("{:99s}"*6).format( ... ) # Concatenation of 6 strings, each
# # right-padded to 99 characters.
# └───────────┬────────────┘
# ┌────┘
# ╽
[print( ... [98-i::99])for i in range(99)] # A way of wrapping the string at 99
 # and printing it transposed.
added 230 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
added 230 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
explanation
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
explanation
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
deleted 1 character in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
deleted 4 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
added 62 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
added 6 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
added 9 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
added 12 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading

AltStyle によって変換されたページ (->オリジナル) /