| Bytes | Lang | Time | Link |
|---|---|---|---|
| 013 | Uiua | 240830T181803Z | noodle p |
| 030 | Arturo | 240829T142349Z | chunes |
| 006 | Japt | 170711T121429Z | Shaggy |
| 071 | Python 3.8 prerelease | 240829T115406Z | Jitse |
| 043 | Ruby | 170711T145304Z | daniero |
| 151 | Factor | 170718T063333Z | Quelklef |
| 069 | Python 2 | 170717T230940Z | lynn |
| 079 | Python 2 | 170711T120938Z | Felipe N |
| 018 | CJam | 170712T050806Z | geokavel |
| 061 | Mathematica | 170711T231021Z | ZaMoC |
| 089 | C gcc | 170711T145420Z | cleblanc |
| nan | 170711T170134Z | Brad Gil | |
| 035 | JavaScript ES6 | 170711T123513Z | Shaggy |
| 055 | Haskell | 170711T131757Z | Wheat Wi |
| 047 | Retina | 170711T132351Z | Business |
| 025 | Perl 5 | 170711T125127Z | Dada |
| 062 | PHP | 170711T124820Z | Jör |
| 005 | 05AB1E | 170711T115848Z | Okx |
| 007 | Jelly | 170711T120621Z | Erik the |
Uiua, 13 bytes
/×▽≠1⊜⊃⧻⋕+1⊸⊛
Try it online: Uiua pad
Explanation: Product /× of keeping ▽ parsed ⋕ partitions ⊜ of differing consecutive digits of the string input +1⊸⊛ whose lengths ⧻ are not equal to 1 ≠1.
Japt, 10 8 6 bytes
Takes input as a string. Outputs an integer, or 1 for "undefined".
ò¦ fÅ×
2 bytes saved thanks to ETH
ò¦ fÅ× :Implicit input of string
ò :Partition between elements that are
¦ : Not equal
f :Filter by
Å : Slicing off the first character (the empty string is falsey)
× :Reduce by multiplication.
Python 3.8 (pre-release), 71 bytes
f=lambda s:s==''or((i:=s.rfind(S:=s.lstrip(s[0])))<2or int(s[:i]))*f(S)
Solution without regex
Ruby, 43 bytes
p eval gets.scan(/(.)(\1+)/).map(&:join)*?*
Takes input from stdin, scans it for runs of length > 1, joins them on "*", evaluates and prints.
Factor, 151 bytes
[ { } { } ] dip
[ 48 - 2dup swap in? [ suffix ] [ [ suffix ] dip 1array ] if ] each
suffix rest [ 0 swap [ swap 10 * + ] each ] map product
Getting a better grip on this language! Still don't think I'm using enough combinators...
Python 2, 69 bytes
lambda n:eval('*'.join(zip(*re.findall(r'((.)\2+)',n))[0]))
import re
Python 2, 95 79 bytes
-2 thanks to @LeakyNum
l='0'
p=1
for c in input()+' ':a=c in l;p*=int(l)**(len(l)>1>a);l=l*a+c
print p
CJam, 18 Bytes
qe`{0=1>},{:*i}%:*
q e# read string - '1112333'
e` e# convert string to RLE - [[3,'1'],[1,'2'],[3,'3']]
{0=1>}, e# filter out runs of length one - [[3,'1'],[3,'3']]
{:*i}% e# convert sub-arrays to runs - [111,333]
:* e# multiply array elements - 36963
Mathematica, 61 bytes
Times@@FromDigits/@Select[Split@IntegerDigits@#,Length@#>1&]&
C (gcc), 93 89 bytes
There must be some more golfing to be done here...
z,r;f(char*d){for(z=0;r=*d++;z=r/10?z?z*r:r:z)for(r-=48;r%10==*d-48;r=r*10+*d++-48);d=z;}
Perl 6, 21 bytes
{[*] .comb(/(.)$0+/)}
This returns 1 if there is no “digit runs” as that is the base case for multiplication.
The only change to allow one digit runs is to replace $0+ with $0* in the regular expression.
Expanded:
{ # bare block lambda with implicit parameter 「$_」
[*] # reduce the following using &infix:<*>
.comb( # pull out substrings that match the following
# (implicit method call on 「$_」)
/
(.) # any digit (character)
$0+ # at least one more of that digit
/
)
}
JavaScript (ES6), 46 45 38 35 bytes
Takes input as a string, outputs an integer or throws an error for "undefined".
s=>eval(s.match(/(.)\1+/g).join`*`)
Try it
o.innerText=(f=
s=>eval(s.match(/(.)\1+/g).join`*`)
)(i.value="11122333");oninput=_=>o.innerText=f(i.value)
<input id=i><pre id=o>
Haskell, 63 55 bytes
Since no one has done Haskell yet here's my take on it. Takes a string as input (of course).
import Data.List
f s=product[read x|x@(_:_:_)<-group s]
This code almost looks as if it is not golfed, but I cannot find anyway to make it shorter.
Retina, 47 bytes
(.)\1+
$*_
T`d
{`(?<=^(_+) _*)_
$1
}`^_+ _
_
_
This is slow on the larger test cases.
Explanation
(.)\1+
$*_
First, replace each run of 2 or more of the same digit with that many _s, followed by a space for separation.
T`d
Then remove all remaining digits.
{`(?<=^(_+) _*)_
$1
}`^_+ _
_
Next, run these two stages in a loop. The first replaces every _ in the second run with the entire first run, effectively multiplying them. The second stage deletes the first run.
_
Finally, output the number _s.
Perl 5, 25 bytes
24 bytes + -p flag.
s/(.)\1+/$.*=$&/eg;$_=$.
Quite straight forward: (.)\1+ matches the runs of more than one digit, and $.*=$& uses $. as accumulator for the multiplications (because its initial value is 1 and not 0). Finally, $_ is set to $. and implicitly printed thanks to -p flag.
PHP, 62 bytes
prints 1 if no run is found
preg_match_all('#(.)\1+#',$argn,$t);echo array_product($t[0]);
05AB1E, 6 5 bytes
-1 byte thanks to Erik the Outgolfer
γ9ÝKP
If we don't need to ignore runs of length one, 2 bytes:
γP