Hot answers tagged

19 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!
user avatar
  • 54.9k
15 votes

My [sub] strings are hiding!

Brachylog, 2 bytes sp Try it online! Explanation ...
user avatar
  • 36.5k
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!
user avatar
  • 11.8k
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 ...
user avatar
  • 207k
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. <...
user avatar
  • 28k
9 votes

Shortest simple regex matching a binary word

JavaScript (ES6), 488 341 bytes ...
user avatar
  • 146k
9 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() ...
user avatar
  • 169k
9 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: ...
user avatar
  • 11.2k
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. ...
user avatar
  • 48.5k
8 votes

Un-hash the Java Hash

C#, 1.052 × 1010 The idea is to do the hash function in reverse to get all possible un-hashed strings from the given number. Integer overflow of the 32-bit hash value is also emulated in reverse by ...
user avatar
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 ...
user avatar
  • 35.5k
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 ...
user avatar
  • 66.1k
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. ...
user avatar
  • 3,926
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! ...
user avatar
  • 99.7k
7 votes

Un-hash the Java Hash

Scala One "useful" characteristic of Java's String.hashCode method is that if you have a string z with ...
user avatar
  • 4,018
7 votes

Find X in a partially sorted Array

JavaScript (E6) 97.5 (39*5*0.5) (O(n), linear search, the array can be scrambled again and again) The function accepts (and ignores) a third parameter ...
user avatar
  • 31.8k
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 ...
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 ...
user avatar
  • 51.8k
7 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 ...
user avatar
  • 64.4k
7 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 (...
user avatar
  • 54.9k
6 votes
Accepted

Un-hash the Java Hash

C, 3.2 × 1010 preimages ...
user avatar
  • 207k
6 votes

Reverse odd runs

APL, 21 20 bytes {∊⌽¨⍵⊂⍨e⍲¯1↓0,e←2|⍵} Try it || All test cases Explanation: ...
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.
user avatar
  • 66.1k
6 votes

My [sub] strings are hiding!

05AB1E, 3 bytes όZ Try it online! -1 byte thanks to Emigna. Explanation: ...
user avatar
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))]
user avatar
  • 19.7k
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!
user avatar
6 votes

The Spain license plates game

MATL, 30 29 bytes xtog!s2$S"1G!'.*'Yc!@gwXXn?@. Try it online! Explanation ...
user avatar
  • 99.7k
6 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-...
6 votes

Solving the water bucket riddle!

Python 3, 243 239 bytes -4 bytes thanks to @JonathanFrech! ...
user avatar

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