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

deleted 100 characters in body
Source Link
ovs
  • 61.2k
  • 3
  • 49
  • 164

Gaia, 14(削除) 14 (削除ここまで) 12 bytes

Defines a function which takes a nested list and returns an integer.

⟨:ṙ'[Ė⟨←:C⟨←)⟩¿⟩¦Π

Try it online! Try it online!

⟨ ⟩¦ # map over each element in the input
 : # duplicate the TOS
 ṙ'[Ė # check if the current value is a list:
 ṙ # cast to string
 '[ # push string "["
 Ė # is this contained in the string representation?
 ⟨ ⟩¿ # if the TOS is truthy:
 ←) # recursively call the function und add 1
 Π # after the map: take the product
⟨ ⟩¦ # map over each element in the input
 :: # two copies of the TOS
 C # compare for two ints (0), count occurences for two lists (1)
 ⟨ ⟩¿ # if the TOS is truthy:
 ←) # recursively call the function and add 1
 Π # after the map: take the product

Gaia, 14 bytes

Defines a function which takes a nested list and returns an integer.

⟨:ṙ'[Ė⟨←)⟩¿⟩¦Π

Try it online!

⟨ ⟩¦ # map over each element in the input
 : # duplicate the TOS
 ṙ'[Ė # check if the current value is a list:
 ṙ # cast to string
 '[ # push string "["
 Ė # is this contained in the string representation?
 ⟨ ⟩¿ # if the TOS is truthy:
 ←) # recursively call the function und add 1
 Π # after the map: take the product

Gaia, (削除) 14 (削除ここまで) 12 bytes

Defines a function which takes a nested list and returns an integer.

⟨::C⟨←)⟩¿⟩¦Π

Try it online!

⟨ ⟩¦ # map over each element in the input
 :: # two copies of the TOS
 C # compare for two ints (0), count occurences for two lists (1)
 ⟨ ⟩¿ # if the TOS is truthy:
 ←) # recursively call the function and add 1
 Π # after the map: take the product
Source Link
ovs
  • 61.2k
  • 3
  • 49
  • 164

Gaia, 14 bytes

Defines a function which takes a nested list and returns an integer.

⟨:ṙ'[Ė⟨←)⟩¿⟩¦Π

Try it online!

⟨ ⟩¦ # map over each element in the input
 : # duplicate the TOS
 ṙ'[Ė # check if the current value is a list:
 ṙ # cast to string
 '[ # push string "["
 Ė # is this contained in the string representation?
 ⟨ ⟩¿ # if the TOS is truthy:
 ←) # recursively call the function und add 1
 Π # after the map: take the product

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