Skip to main content
added 50 characters in body
Source Link
lyxal
  • 34.3k
  • 2
  • 64
  • 141

Vyxal 2.7.1, 86 bytes

ƛf⁼;Ġ•vfƛf⁼;Ġ•

Try it Online!

Surprisingly only 2 bytes off add++The link uses the latest version of vyxal (2.7.3 at the time of writing) which has a bug fix where molding no longer wraps singletons in lists, hence the extra vf.

Explained

ƛf⁼;Ġ•vfƛf⁼;Ġ•
ƛf⁼;     # For each item in the input, does the flattened version equal the item? For integers, this returns a list, which does not equal the item. For lists, this just returns the list - this wouldn't work if there wasn't any depth restriction. 
   Ġ    # Group on consecutive items
    •   # and mold the input to that shape
     vf # flatten each item - this is needed to wrap singleton numbers in lists. 

Vyxal, 8 bytes

ƛf⁼;Ġ•vf

Try it Online!

Surprisingly only 2 bytes off add++

Explained

ƛf⁼;Ġ•vf
ƛf⁼;     # For each item in the input, does the flattened version equal the item? For integers, this returns a list, which does not equal the item. For lists, this just returns the list - this wouldn't work if there wasn't any depth restriction. 
   Ġ    # Group on consecutive items
    •   # and mold the input to that shape
     vf # flatten each item - this is needed to wrap singleton numbers in lists. 

Vyxal 2.7.1, 6 bytes

ƛf⁼;Ġ•

Try it Online!

The link uses the latest version of vyxal (2.7.3 at the time of writing) which has a bug fix where molding no longer wraps singletons in lists, hence the extra vf.

Explained

ƛf⁼;Ġ•
ƛf⁼;     # For each item in the input, does the flattened version equal the item? For integers, this returns a list, which does not equal the item. For lists, this just returns the list - this wouldn't work if there wasn't any depth restriction. 
   Ġ    # Group on consecutive items
    •   # and mold the input to that shape
Source Link
lyxal
  • 34.3k
  • 2
  • 64
  • 141

Vyxal, 8 bytes

ƛf⁼;Ġ•vf

Try it Online!

Surprisingly only 2 bytes off add++

Explained

ƛf⁼;Ġ•vf
ƛf⁼;     # For each item in the input, does the flattened version equal the item? For integers, this returns a list, which does not equal the item. For lists, this just returns the list - this wouldn't work if there wasn't any depth restriction. 
   Ġ    # Group on consecutive items
    •   # and mold the input to that shape
     vf # flatten each item - this is needed to wrap singleton numbers in lists.