| Bytes | Lang | Time | Link |
|---|---|---|---|
| 009 | Uiua | 250307T145944Z | janMakos |
| 031 | Zsh & coreutils | 250304T102725Z | roblogic |
| 406 | C | 250304T075710Z | CaydendW |
| 066 | Swift 6 | 250302T180211Z | macOSist |
| 066 | AWK | 250228T165311Z | xrs |
| 087 | 05AB1E | 250113T111210Z | Kevin Cr |
| 022 | K ngn/k | 250104T024015Z | att |
| 006 | Nekomata | 250108T023207Z | alephalp |
| 008 | Jelly | 250106T190323Z | Jonathan |
| 025 | Arturo | 250106T123127Z | chunes |
| 014 | Pyth | 250102T235213Z | CursorCo |
| 108 | Wolfram Language Mathematica | 241230T080102Z | Introduc |
| 012 | Brachylog | 250101T184907Z | cjquines |
| 034 | PowerShell Core | 241230T090405Z | Julian |
| 4268 | Maple | 241231T000422Z | dharr |
| 029 | R | 241229T215029Z | Eonema |
| 152 | JavaScript Node.js | 241230T011051Z | l4m2 |
| 1612 | J | 241230T104047Z | Jonah |
| 025 | Charcoal | 241230T103047Z | Neil |
| 045 | Retina 0.8.2 | 241230T102454Z | Neil |
| 057 | APL+WIN | 241230T085714Z | Graham |
| 009 | Vyxal | 241230T081024Z | lyxal |
| 037 | Perl 5 MListUtil=uniq | 241230T070414Z | Xcali |
| 025 | Python | 241230T025042Z | Mukundan |
| 011 | Uiua | 241229T201511Z | nyxbird |
Uiua, 9 bytes, score 10
/+⊂◴°⊚⊛⟜◰
Explanation
/+⊂◴°⊚⊛⟜◰
⟜◰ # Mask of unique characters
°⊚⊛ # Counts of each character
◴ # Remove duplicates
/+⊂ # Sum both lists
Zsh & coreutils, score 31
for r (${(us::)1});j+=(${(c)#1//[^$r]});bc<<<$#j+${(j:+:)${(u)j}};####=====[[[[[]]]]]^^^^^1111 ////;;;+++<<<::{{}}bbbbbccccfffffjjooooorrrsssssuuuu
Score: 25 unique characters + 6 of each = 31.
v1.0: score 44 (29 unique + 9 space chars + 6 others)
C, 406 bytes, score = 43
c(char*h){int r[2000]={0},*n=r+200,*a=r,f=0,t=0,o=0;for(;*h;)!r[*h++]++?f++:0;for(;t++!=200;)!n[(o=*a++)]++?f+=o:0;return f;}/* ////////////0uuuuuuuuuuuuu!!!!!!!!!!!(((((((((())))))))))******{{{{{{{{{{{{}}}}}}}}}}}}ttttttttttrrrrrooooooooo,,,,,,,,,eeeeeeeeeeeeeffffffffnnnnnnnnnnaaaaaaaaaaahhhhhhhhhhcccccccccccciiiiiiiiiiiii22222222222::::::::::::;;;;;;=====????????????[[[[[[[[[[[]]]]]]]]]]]*/
String garbage at the end to artifically deflate the score, same idea as @Mukundan314 had.
The idea is fairly simple: count all unique characters first and how many times they occur. Then, add all unique occurance counts.
I'm 99% sure this can be golfed harder but I stop here.
Swift 6, 66 bytes, score: 36
{s in Set(s+"").count+Set(s.map{r in s.count{$0==r}}).reduce(0,+)}
AWK, 66 bytes, score 51 48
{for(f=0;i++<NF;)o[$i]++||f++;for(i in o)r[o[i]]++||f+=o[i]}1,$0=f
{for(j=0;i++<NF;) # iterate over string
b[$i]++ # array[unique char] count of
||j++; # count total unique char
for(i in b) # iterate over unique char
c[b[i]]++ # array[unique count] for each char
||j+=b[i]} # add count of total if unique
1,$0=j # print
05AB1E, score: 8 (7 bytes)
¢Ù`IêgO
Input as a list of characters.
Try it online or verify all test cases.
Explanation:
¢ # For each character in the (implicit) input-list, count how many times
# it occurs in the (implicit) input-list
Ù # Uniquify this list of counts
` # Pop and push all unique counts to the stack
I # Push the input-list again
ê # Sort and uniquify it
g # Pop and push its length
O # Sum all values on the stack together
# (after which the result is output implicitly)
ê both sorts and uniquifies at the same time. Although we don't care about the sorting part, we use it to our advantage in this challenge as a second uniquify builtin besides Ù.
K (ngn/k), 22 bytes, score 13
{(#?y)+/?#'=y}{(+/'=)}
{(+/'=)} spare characters
{ y y} (ignored)
?#'=y unique counts
(#?y) count unique
+/ sum
Alternatively, also score 13:
{#(?y),&?#'=y}{(,&'=)}
Nekomata, 6 bytes, score 7
Ţᵉu#c∑
Ţᵉu#c∑
Ţ Tally; count occurrences of each unique element
ᵉ Apply the following two functions to the same argument:
u Remove duplicates
# Length
c Append
∑ Sum
There are 6 unique characters in the code, so the score is 6 + 1 = 7.
Jelly, score = 8
Seven distinct bytes -> score = 7 + 1 = 8
ĠẈL;QƊS
A monadic Link that accepts a list of characters/bytes/integers that yields the score of that list.
Try it online! Or see the test-suite.
How?
ĠẈL;QƊS - Link: list, A e.g. "abcaaccac"
Ġ - group indices of {A} by value [[1,4,5,8],[2],[3,6,7,9]]
Ẉ - length of each -> GroupSizes [4,1,4]
Ɗ - last three links as a monad:
L - length {GroupSizes} -> X 3
Q - deduplicate {GroupSizes} -> Y [4,1]
; - {X} concatenate {Y} [3,4,1]
S - sum {that} 8
Pyth, 14 bytes, score 9
ss+{/LQQl{+Ll/
Explanation
ss+{/LQQl{+Ll/ddQ # implicitly add ddQ
# implicitly assign Q = eval(input())
+Ll/ddQ # map over Q prepending some random junk to each char (this serves only to duplicate various characters in the source code)
{ # deduplicate
l # take the length (gives number of unique chars in Q)
/LQQ # count how many times each char of Q appears in Q
{ # deduplicate
+ # append result of l to the list
s # sum list to get the final result
s # floor result to int (does nothing)
Wolfram Language (Mathematica), 42 31 Score ( 54 108 bytes)
(Length[#]+Total@Union[Values[#]])&@*Counts@Characters@#&(*((LLLeggghh[#]+++TTTollUUUiiiVVVuus))&&*CCrrccc*)
Edit: Tweaked code to score better with a comment string added
Brachylog, 12 bytes, score 13
ọzt⟨dc{lg}⟩+
Explanation
ọ Get counts of each letter in input.
zt Zip and get the last element,
which is the list of counts.
⟨ ⟩+ Get the sum of:
d its distinct elements
c concatenated with
{lg} its length, as a list.
PowerShell Core, score 34
{sal l group;($a=$args|l).length+(($a|% count|sort|gu)-join"+"|iex);$l="`````"$%%%%(())+++----....;;;=== acccceeeghhhhiiijjjjnnopppprrssttuuxxxx"}
Maple, score = 42 (68 bytes)
f:=s->add({(f:=seq(numboccur([seq(s)],a),a in{seq(s)}))})+nops([f]);
numboccur counts characters of type a, where the seq maps a over the unique characters in the string s, to give f (for this program) equal to
2, 7, 7, 1, 2, 1, 2, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 3, 1, 1, 3, 2, 1, 3, 1, 7, 2, 2, 2
f is made into a set of unique character frequencies {1,2,3,7} which is added to give 13, and then we add the number of distinct characters, nops([f])=29, to give 42.
R, score 40 29
-9 thanks to @pajonk
\(m,n=utf8ToInt(m))sum(unique(n)|T,unique(table(n)))######,,,,\\\\\=====|||||88888aaaaabbbbbeeefffffiiiiIIIIIlllllmmmoooooqqqqssssstttTTTT
JavaScript (Node.js), 152 bytes, score = 27
p=>p.split(s=t=[]||(l,lll,i|iiii,mmmmmmhh,aa,u>uu>u>u>u.u.l.litt)).map(a=>-p.split(a,s[[,a]]=s[[,a]]||--t).push()).map(h=>s[h]=s[h]||-(t-=-h-([]>h)))|-t
J, 16 bytes (Score = 12)
(#+/@,~.)@(#/.~)
(#/.~)Counts of each unique char#...,~.Cat the uniq of that~.with its length#(note: its length represents the number of unique chars)+/@And sum
Charcoal, 25 bytes, score 24
Fθ⊞υ№θιI⁺LΦθ⁼κ⌕θιΣΦυ⁼κ⌕υι
Try it online! Link is to verbose version of code. Explanation:
Fθ⊞υ№θι
Get the counts for each input character.
I⁺LΦθ⁼κ⌕θιΣΦυ⁼κ⌕υι
Add the number of deduplicated input characters to the sum of the deduplicated counts.
Retina 0.8.2, 45 bytes, score 44
$
¶$`
Dr`.\G
O`\G.
\G(.)\1*
$.&$*1¶
D`\G.+¶
.
Try it online! Link includes test cases. Explanation:
$
¶$`
Duplicate the input on a second line.
Dr`.\G
Deduplicate the characters of the copy.
O`\G.
Sort the characters of the original.
\G(.)\1*
$.&$*1¶
Get the counts (in unary) of each character.
D`\G.+¶
Deduplicate those counts.
.
Sum the counts and add on the number of deduplicated characters.
APL+WIN, 57 bytes, score 41
Prompts for string.
(⍴v)++/((n⍳n)=⍳⍴n)/n←v-¯1↓0,v←(~v=1↓v,0)/⍳⍴v←v[⍋v←⎕av⍳,⎕]
Vyxal, score 9
sĠ₌L@UJ∑
Explained
sĠ₌L@UJ∑
sĠ # Sort the input and group by consecutive characters
₌L@ # To that:
L # Push the length of the whole list
@ # And the length of each group
U # Uniquify the group lengths
J # Prepend the number of unique characters
∑ # And sum that
💎
Created with the help of Luminespire.
Perl 5 -MList::Util=uniq,sum -pF, 37 bytes, score 29
map$;{$_}++,@F;$_=%;+sum uniq values%
Python, 26 25 score
-1 score thanks to @l4m2
lambda p:sum(set(map(p.count,p)),len(set(p)))#bbbbdddd ::::....ccccoooo,,,####lllnnnuuuaammeesstt
Uiua, score 11
/+⊂⧻∩◴⟜°⊚⊛
/+⊂⧻∩◴⟜°⊚⊛
⊛ # classify (convert to numbers)
⟜°⊚ # get counts, keeping original
∩◴ # deduplicate both
⧻ # take the length of the deduplicated string
⊂ # join it to the counts
/+ # and sum