Röda, 45(削除) 45 (削除ここまで) 35 bytes
f s{s~=`[_=~`(\S*(\S)\S* (?=\S*1円=\S*2円)`,"";[not(" "in s)]+\S+`]}
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)]}
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+`]}
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...
Röda, 45 bytes
f s{s~=`(\S)\S* (?=\S*1円)`,"";[not(" "in s)]}
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)]}
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)]}
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...
Röda, 45 bytes
f s{s~=`(\S)\S* (?=\S*1円)`,"";[not(" "in s)]}
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...