Skip to main content
deleted 202 characters in body
Source Link
Neil
  • 177.3k
  • 12
  • 74
  • 281

JavaScript (ES6), 8787 86 bytes

a=>a.sort().join``.replace(/(.)\1\1|1|5/g,s=>r+=s>111s=>r+=s>>7?s/1.11:s>5?1e3:s>1?50:100,r=0)&&r
a=>`${a.sort()}`.replace(/(.),\1,\1|1|5/g,s=>r+=s[0]*(s[0]>1||10)*(s[1]?100:10),r=0)&&r

Sorts and stringifies the input so that scoring combinations can be identified by means of regexp. Both the stringification matching but also the scoring of the combination can be done in two completely different ways which happenEdit: Saved 1 byte thanks to have the same length@Arnauld.

JavaScript (ES6), 87 bytes

a=>a.sort().join``.replace(/(.)\1\1|1|5/g,s=>r+=s>111?s/1.11:s>5?1e3:s>1?50:100,r=0)&&r
a=>`${a.sort()}`.replace(/(.),\1,\1|1|5/g,s=>r+=s[0]*(s[0]>1||10)*(s[1]?100:10),r=0)&&r

Sorts and stringifies the input so that scoring combinations can be identified by means of regexp. Both the stringification matching but also the scoring of the combination can be done in two completely different ways which happen to have the same length.

JavaScript (ES6), 87 86 bytes

a=>a.sort().join``.replace(/(.)\1\1|1|5/g,s=>r+=s>>7?s/1.11:s>5?1e3:s>1?50:100,r=0)&&r

Sorts and stringifies the input so that scoring combinations can be identified by means of regexp. Edit: Saved 1 byte thanks to @Arnauld.

Source Link
Neil
  • 177.3k
  • 12
  • 74
  • 281

JavaScript (ES6), 87 bytes

a=>a.sort().join``.replace(/(.)\1\1|1|5/g,s=>r+=s>111?s/1.11:s>5?1e3:s>1?50:100,r=0)&&r
a=>`${a.sort()}`.replace(/(.),\1,\1|1|5/g,s=>r+=s[0]*(s[0]>1||10)*(s[1]?100:10),r=0)&&r

Sorts and stringifies the input so that scoring combinations can be identified by means of regexp. Both the stringification matching but also the scoring of the combination can be done in two completely different ways which happen to have the same length.