Skip to main content
Share Your Experience: Take the 2024 Developer Survey
25 votes

The shortest way to find one unique value when all other values are the same

Python 3, 27 bytes lambda x:min(x,key=x.count) Try it online!
ovs's user avatar
  • 59.5k
15 votes

My [sub] strings are hiding!

Brachylog, 2 bytes sp Try it online! Explanation ...
Fatalize's user avatar
  • 38.7k
14 votes

The shortest way to find one unique value when all other values are the same

R, 24 bytes a=scan();a[a!=median(a)] Try it online!
Kirill L.'s user avatar
  • 13.9k
13 votes

The shortest way to find one unique value when all other values are the same

JavaScript (ES6),  32  27 bytes Saved 5 bytes thanks to @xnor a=>a.sort()[0]+a.pop()-a[1] Try it online! How? a.sort() ...
Arnauld's user avatar
  • 193k
11 votes

Automate the OEIS

Bash + coreutils + w3m, 51 45 42 bytes w3m oeis.org/b${1:1}.txt|sed "s/^$2 //p;d" Thanks to @EamonOlive for golfing off 3 bytes! Example run ...
Dennis's user avatar
  • 210k
11 votes

Remove submatrices

APL (Dyalog Unicode), 20 bytes Anonymous infix lambda taking a and b as left and right argument. Requires 0-based indexing. <...
Adám's user avatar
  • 30.3k
10 votes

The shortest way to find one unique value when all other values are the same

x86-16 machine code, 14 bytes Binary: 00000000: 498d 7c01 f3a6 e305 4ea6 7401 4ec3 I.|.....N.t.N. Listing: ...
640KB's user avatar
  • 11.9k
9 votes

Shortest simple regex matching a binary word

JavaScript (ES6), 488 341 bytes ...
Neil's user avatar
  • 171k
9 votes

The shortest way to find one unique value when all other values are the same

05AB1E, 2 bytes ʒ¢ Try it online! Since 1 is the only truthy integer in 05AB1E, we can just filter (...
ovs's user avatar
  • 59.5k
8 votes

Reverse odd runs

Python 2, 75 68 63 bytes 5 bytes thanks to Dennis. And I have outgolfed Dennis. Credits to Byeonggon Lee for the core of the algorithm. ...
Leaky Nun's user avatar
  • 49.8k
8 votes

Finding your partner

Japt, 6 bytes Works with strings or integers. æøV kV Test it Explanation Implicit input of array U and string/integer ...
Shaggy's user avatar
  • 42k
8 votes

Finding your partner

Haskell, 33 bytes x!((a,b):c)|x==a=b|x==b=a|1<2=x!c Try it online! Defines a binary operator !, which takes as its left ...
lynn's user avatar
  • 68.7k
8 votes

Count the contiguous submatrices

Brachylog (v2), 10 bytes {{s\s\}ᵈ}ᶜ Try it online! I like how clear and straightforward this program is in Brachylog; unfortunately, it's not that short byte-...
8 votes

The shortest way to find one unique value when all other values are the same

APL (Dyalog Extended), 5 bytes ⍸1=¯⍸ Try it online! Regular Dyalog APL 18.0 has ⍸⍣¯1, but it doesn't work here because it ...
Bubbler's user avatar
  • 76.8k
8 votes

The shortest way to find one unique value when all other values are the same

Haskell, 32 bytes f(x:y)|[e]<-filter(/=x)y=e|1<3=x Try it online! Explanation The code, expanded with variables renamed to be more descriptive. ...
cole's user avatar
  • 3,996
8 votes

The shortest way to find one unique value when all other values are the same

Bash + coreutils, 12 bytes sort|uniq -u Try it online!
Nahuel Fouilleul's user avatar
8 votes

Remove submatrices

MATLAB/Octave with Image Processing Toolbox/Package, 78 bytes @(A,B)A.*~conv2(reshape(all(im2col(A,size(B))==B(:),1),size(A)-size(B)+1),B>0) Try it online! ...
Luis Mendo's user avatar
  • 105k
8 votes

Search the deepest depths of an array

JCram, 13 bytes (SBCS) -1 thanks to @mukundan314 -1 thanks to @tsh A JCrammed version, as suggested by Kamila Szewczyk. νⓅιk⑦③⍋⍁lζ⁷⊗Ⓙ JavaScript (ES13), 60 bytes -...
Arnauld's user avatar
  • 193k
7 votes

My [sub] strings are hiding!

JavaScript (ES6), 77 bytes (s,t)=>t&&[...t.slice(0,s.length)].sort()+''==[...s].sort()|f(s,t.slice(1)) Returns 1 or 0. Snippet ...
Rick Hitchcock's user avatar
7 votes

The Spain license plates game

05AB1E, 10 8 bytes Saved 2 bytes thanks to Leo ʒæså}éR` Try it online! Explanation ...
Emigna's user avatar
  • 53k
6 votes

Reverse odd runs

APL, 21 20 bytes {∊⌽¨⍵⊂⍨e⍲¯1↓0,e←2|⍵} Try it || All test cases Explanation: ...
Woofmao's user avatar
  • 221
6 votes

Reverse odd runs

Haskell, 46 44 bytes h%p|(l,r)<-span(odd.(h*))p=l++h:r foldr(%)[] Thanks to @xnor for recognizing a fold and saving two bytes.
lynn's user avatar
  • 68.7k
6 votes

My [sub] strings are hiding!

05AB1E, 3 bytes όZ Try it online! -1 byte thanks to Emigna. Explanation: ...
Erik the Outgolfer's user avatar
6 votes

My [sub] strings are hiding!

Japt, 10 7 6 bytes á d!øV Try it online ...
Shaggy's user avatar
  • 42k
6 votes

My [sub] strings are hiding!

Python 2, 67 66 bytes Takes input as two strings, substring first. a=sorted lambda s,S:a(s)in[a(S[n:n+len(s)])for n in range(len(S))]
TFeld's user avatar
  • 19.8k
6 votes

The Spain license plates game

PHP, 111 bytes $y=array_map(str_split,preg_grep("#".chunk_split($_GET[1],1,".*")."#",$_GET[0]));sort($y);echo join($y[0]??[]); Try it online!
Jörg Hülsermann's user avatar
6 votes

The Spain license plates game

MATL, 30 29 bytes xtog!s2$S"1G!'.*'Yc!@gwXXn?@. Try it online! Explanation ...
Luis Mendo's user avatar
  • 105k
6 votes

Solving the water bucket riddle!

Python 3, 243 239 bytes -4 bytes thanks to @JonathanFrech! ...
Surculose Sputum's user avatar
6 votes

The shortest way to find one unique value when all other values are the same

Jelly, 3 bytes ḟÆṃ Explanation: (probably) removes all elements that are not the most common element (returned by ...
the default.'s user avatar
  • 8,415

Only top scored, non community-wiki answers of a minimum length are eligible