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 Revisions

2 of 3
removed one byte
fergusq
  • 5.2k
  • 1
  • 19
  • 37

Röda, 45 bytes

f s{s~=`(\S)\S* (?=\S*1円)`,"";[not(" "in s)]}

Try it online!

This is a port of the Perl 5 solution, which is a port of the Retina solution by Martin Ender.

Here's a different solution ((削除) 73 (削除ここまで) 72 bytes):

{[_/""]|{|x|{x|[0]()unless[not(_ in y)]else[1]}if tryPeek y}_|sum|[_=0]}

It's an anonymous function that pulls strings from the stream and checks that the consecutive strings contain same characters. Explanation:

{
 [_/""]| /* split strings -> creates arrays of characters */
 {|x| /* begin for loop over character arrays */
 { /* begin if tryPeek(y) -> peeks the second item from the stream */
 /* x and y are now two consecutive character arrays */
 x| /* push characters in x to the stream */
 [0]()unless[not(_ in y)]else[1] /* pushes 0 to the stream */
 /* if y contains the character */
 /* in the stream, otherwise 1 */
 }if tryPeek y
 }_| /* end for loop */
 sum| /* sum all numbers in the stream */
 [_=0] /* return true if the sum is zero */
}

It could possibly be golfed more...

fergusq
  • 5.2k
  • 1
  • 19
  • 37

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