84
votes
Unique is Cheap
MATL, score 4
&=Rz
Try it online!
Explanation
Consider input 'ABBA' as an example.
...
49
votes
41
votes
Source code ecological footprint
Lenguage, 0
Output is in unary, since Lenguage/Brainfuck has no sane way of printing integers in base 10.
The actual source code contains
...
17
votes
Unique is Cheap
Python, score 49
lambda S:sum(1+S.count(C)for[C]in S)/2
Try it online!
There's a tab after in.
Score breakdown:
+27 ...
13
votes
Source code ecological footprint
PowerShell, 337 344 304 points
PARAM([CHAR[]]$A)$A|%{$B+=([CONVERT]::TOSTRING(+$_,2)-REPLACE0).LENGTH};($B,0)[-JOIN$A-CEQ"test"]
I'M SHOUTING AT YOU ...
13
votes
Count the shared substrings with 2 programs
Python, score 0, 520 bytes
-25 from @Grain Ghost
-78 from @Jonathan Allan
-61 from @RootTwo
-4 from @Grain Ghost
...
12
votes
Count /[^a-z]/ig with /[a-z]/ig
Vyxal, score 0, 4 bytes
kLFL
Yes, you heard me right. Flagless, score 0, 4 bytes.
Explanation
...
12
votes
Count /[^a-z]/ig with /[a-z]/ig
Charcoal -v, 36 bytes, score 0
CastLengthFilterqNotCountaUppercasei
Try it online! Explanation: Charcoal's verbose parser is somewhat lax, not always requiring ...
10
votes
Count /[^a-z]/ig with /[a-z]/ig
Husk, Score 0, 13 11 bytes*
mLfopVDkDma
Try it online!
The basic idea is to filter for non-alphabetic characters and calculate the length. Husk has a builtin (<...
9
votes
Source code ecological footprint
Pyth - 52 49
Three points save thanks to @orlp.
*/.BQ`1nQ"test
Takes input in quotes to save footprint.
Test Suite.
8
votes
Unique is Cheap
C (gcc), score: 113 103 100 96 91
Thanks to @ugoren, @CalculatorFeline, @gastropner, @l4m2, and @JS1 for their tips.
...
8
votes
8
votes
Count /[^a-z]/ig with /[a-z]/ig
05AB1E, score: 0 (7 bytes)
ADuJSKg
Try it online or verify all test cases. (The Join in the test suite has been replaced with a ...
8
votes
Count /[^a-z]/ig with /[a-z]/ig
Pip, score 0, 8 bytes
oMSaRMXA
Try It Online!
-3 thanks to DLosc.
...
7
votes
Source code ecological footprint
Common Lisp, 294 281 235
In order to reduce the score, I used @ (cost 1) and ! (cost 2) as variable names (edit: and it is even ...
7
votes
7
votes
Unique is Cheap
JavaScript (ES6), score 81 78
Saved 3 points thanks to @Arnauld
s=>s.replace(d=/./g,z=>q+=d[z]=-~d[z],q=0)&&q
My original score-81 recursive ...
7
votes
Unique is Cheap
Haskell, score 42
f l=sum[1|c<-l,d<-c:l,d==c]/2
Try it online!
Anonymizing \l-> gives the same score.
7
votes
Unique is Cheap
Retina, score 34
s(O`.
M&!`^|(?<=(.))\1*
.
Try it online!
Explanation
s(O`.
We start by sorting all the characters ...
7
votes
7
votes
Longest Increasing Substring
Pyth, score 2 (8 bytes)
lefSIT.:
Try it here!
Code points [108, 101, 102, 83, 73, 84, 46, 58]. Another shorter solution, <...
7
votes
Count /[^a-z]/ig with /[a-z]/ig
Pyth, Score 0, 14 11 bytes
lfqZhxGrTZQ
Try it online!
G is the lowercase alphabet in Pyth. There's no built-in for the ...
7
votes
Count /[^a-z]/ig with /[a-z]/ig
R, score 9, 38 bytes
function(x)sum(!tolower(x)%in%letters)
Try it online!
Takes input as a vector of characters.
R, score 14, 85 bytes
...
7
votes
7
votes
Longest alternating subsequence
Python 3, score 16, \$6.6 \times 10^{2073} \$ bytes
exec(b"".fromhex(str(len(" "))))
Try it online!
The string ...
7
votes
Count the shared substrings with 2 programs
05AB1E, score 0 (15 bytes)
Program 1 (3 bytes):
΢O
Try it online or verify all test cases.
Program 2 (12 bytes):
...
6
votes
Source code ecological footprint
JavaScript, 279
Edit Bug fix (did not count bit 1 of each char)
A complete program, with input and output via popup. Tested in Firefox, should work in any modern browser.
...
6
votes
Source code ecological footprint
Julia, 254 246 232
P=readline()
print(P=="test"?0:sum([count_ones(1*A)for A=P]))
The count_ones function counts the number of ...
6
votes
Source code ecological footprint
Python 3, 271
z=input();print([sum([bin(ord(i)).count("1")for i in z]),0][z=="test"])
6
votes
Count spelling errors in text; minimize the number of spelling errors in your code
Perl 6, 134 spelling errors
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
self-scoring × 11string × 5
source-layout × 4
code-challenge × 2
subsequence × 2
parsing × 1
counting × 1
natural-language × 1
palindrome × 1
code-generation × 1
alphabet × 1
array × 1