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

removed 10 bytes
Source Link
fergusq
  • 5.2k
  • 1
  • 19
  • 37

Röda, 45(削除) 45 (削除ここまで) 35 bytes

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

Try it online! Try it online!

This is a port ofsimilar to the Perl 5 solution, which is a port of the Retina solution by Martin Ender. -10 bytes thanks to @Neil.

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...

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...

Röda, (削除) 45 (削除ここまで) 35 bytes

{[_=~`(\S*(\S)\S* (?=\S*2円))+\S+`]}

Try it online!

This is similar to the Perl 5 solution, which is a port of the Retina solution by Martin Ender. -10 bytes thanks to @Neil.

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...

removed one byte
Source Link
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(削除) 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...

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 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...

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 tryPeeky}_|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 tryPeeky
 }_| /* end for loop */
 sum| /* sum all numbers in the stream */
 [_=0] /* return true if the sum is zero */
}

It could possibly be golfed more...

Source Link
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 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...

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