PieCot
  • Member for 6 years
  • Last seen this week
Find the largest and the smallest number in an array
0 votes

Python 3, 54 bytes Another Python solution: the mandatory solution using lambda was missing :) lambda y:[f(e for e in y if e*0==0)for f in (min,max)] Try it online! -10 bytes thanks to aeh5040

View answer
Fastest yes in the west
2 votes

Rust, 49 48 bytes \$\times\,\frac{32186368}{744521728}\approx2.075\$ Plain Rust, compiled with -C target-cpu=native -C opt-level=3. Clearly not the winner, only for reference; not bad, btw :) fn ...

View answer
"DDoouubbllee ssppeeaakk!!"
2 votes

Octave, 32 25 bytes @(x)char(kron(x+0,[1,1])) Try it online! -7 bytes thanks to Giuseppe

View answer
"DDoouubbllee ssppeeaakk!!"
2 votes

Matlab >= r2015a, 16 bytes @(x)repelem(x,2) Credits to Giuseppe Note: I haven't found an online interpreter for MATLAB; this answer correctly works with MATLAB r2015a. Matlab <= r2014b, 23 ...

View answer
Roll the carpet
0 votes

Python 3, 112 bytes r=lambda t,h=[[]]:len(h)>len(t)and h[:-1]+[h[-1]+list(t)]or r(t[len(h):],list(zip(*h[::-1]))+[list(t)[:len(h)]]) In this case, the output is the value of the function. Try it ...

View answer
Roll the carpet
0 votes

MATLAB / Octave, 154 bytes Not the shortest one, but to golf in MATLAB/Octave is always fun :) function h=r(t,h);n=fliplr(h');s=size(n,2);q=numel(t);if s<=q h=r(t(max(s,1)+1:end),[n; t(1:max(s,1))...

View answer
To string or not to string
0 votes

MATLAB / Octave, 110 bytes Choose a random permutation of a subset of the input letters (with repetitions), whose random length is based on the probability of generating a word with that length. @(a)...

View answer
Write a function to decrypt Feynman Challenge Cipher #1
0 votes

Python 3.6, 48 bytes Recursion + f-Strings f=lambda a:a and f'{a[::-5]+f(a[:-1])}'[:len(a)] Try it online!

View answer
Nth subset of a set
2 votes

MATLAB/Octave, 31 29 27 bytes @(n)9-find(dec2bin(n,8)-48) reduced of 2 bytes thanks to alephalpha reduced of 2 bytes thanks to Giuseppe Try it online!

View answer
Nth subset of a set
0 votes

Python 3.6, 58 bytes f=lambda n:[8-v for v,i in enumerate(f'{n:08b}')if int(i)]

View answer
Where's Blackhat?
8 votes

Matlab, 87,5% function hat=is_blackhat_here2(filepath) img_hsv = rgb2hsv(imread(filepath)); img_v = img_hsv(:,:,3); bw = imdilate(imerode( ~im2bw(img_v), strel('disk', 4, 8)), strel('disk', 4, 8)); ...

View answer
Print invisible text
1 votes

Octave / Matlab, 25 23 bytes @(x)repmat(' ',size(x)) Saved 2 bytes thanks to Giuseppe Try it online!

View answer
Last digit large number
2 votes

Python 3, 55 bytes p=lambda l,i=-1:not l or f'{l[0]**int(p(l[1:],0))}'[i:] Older versions p=lambda l,i=-1:len(l)and f'{l[0]**int(p(l[1:],0))}'[i:]or 1 (60 bytes)

View answer
Find the nth decimal of pi
2 votes

Python 3, 338 bytes This implementation is based on the Chudnovsky algorithm, one of the fastest algorithms to estimate pi. For each iteration, roughly 14 digits are estimated (take a look here for ...

View answer
Calculate the sum of all odd digits of pi in range
3 votes

Python3, 346 bytes Based on a recursive implementation of the Chudnovsky algorithm, one of the fastest algorithms to estimate pi. For each iteration, roughly 14 digits are estimated (take a look here ...

View answer
Pleasanortmanteaus
3 votes

Python 3, 156 150 bytes I've considered y as a consonant. lambda a,b:{a[:i]+b[j:]for i in range(1,len(a))for j in range(1,len(b))if((a[i-1]in'aeiou')^(b[j]in'aeiou'))*0**(a in a[:i]+b[j:]or b in a[:...

View answer
How many bytes is it
2 votes

Python3, 90 bytes (76 70 bytes 3-most-significant-digits version) h=lambda v,u=0:v>999.4and h(v/1024,u+2)or"%.*f%sB"%(u and(v<10)+(v<100),v,"KiMiGi"[u-2:u]) Version whose outputs are ...

View answer
Integer Linear Programming
1 votes

Matlab, 226 bytes DISCLAIMER: Not an "original" implementation, only for fun. Simple solution taking advantage of the intlinprog function: function r=f(a);b=-1*a(1:end-1,end);p=a(end,1:end-1);c=a(1:...

View answer
Pair and sort from two integer lists
Accepted answer
3 votes

Python O(mn log mn) The best pairs can be found computing the distances of all the possible pairs, and iteratively choosing the best pair among those remaining after filtering out the already chosen ...

View answer
set intersection of two lists
1 votes

Python3, 51 bytes lambda a,b:[v for v in a if{n:1 for n in b}.get(v)] If the input lists can contain duplicates: Python3, 67 bytes lambda a,b:list({v:1 for v in a if {n:1 for n in b}.get(v)}.keys()...

View answer
Enklactify these strings
8 votes

Python3, 59 bytes lambda l:{len({*d}):''.join(d)for d in zip(*l)}.get(len(l)) Returns a string with the enklact, None otherwise

View answer
Print all alphanumeric characters plus underscore
0 votes

MATLAB, 30 bytes ['a':'z','A':'Z','0':'9','_'] Very simple :) Or, at the same cost: char(48+[49:74,17:42,0:9,47]) or char([97:122,65:90,48:57,95])

View answer
Solve for N from input string
0 votes

awk, 48 bytes awk -F'[ N]' '{printf("%.f",($6-$4)/($1?$1:1))}' Use cases: echo "N + 1 = 3" | awk -F'[ N]' '{printf("%.f",($6-$4)/($1?$1:1))}' echo "N - 1 = 5" | awk -F'[ N]' '{printf("%.f",($6-$4)/...

View answer
Additive Persistence
0 votes

Python 3, 82 bytes while 1:f=lambda n:n//10and 1+f(sum(map(int,str(n))));i=input();print(i,f(int(i)))

View answer
Generate programs that print n times their length
0 votes

MATLAB (63 bytes) a=@(n)['repmat(''a'',1,',num2str(n*(15+numel(num2str(n)))),')'] For example: >> a(5) ans = repmat('a',1,80) and: >> repmat('a',1,80) ans = ...

View answer
Ordered list of binary sequences of multiple dimensions
0 votes

MATLAB, 68 bytes d=@(n)dec2bin(sortrows([sum(dec2bin(0:2^n-1)');0:2^n-1]')*~eye(2,1))

View answer
This is my pillow
2 votes

MATLAB, 58 44 bytes Thanks to @Stewie Griffin for saving a bunch of bytes ;) [repmat(kron(['/\';'\/'],ones(4,5)),3,6),''] Old version: p=@()char(47+45*kron(ones(3,6),kron([0 1;1 0],ones(4,5))))

View answer
Add comments to a Python script and make it a bilingual Python/C++ “program”
5 votes

Score 136 Only for the records: #include <cstdio> #define def class a{public #define greet() #define print(a) };int main(){puts(a);} Another (less efficient) way to handle the colon.

View answer
Atbash Self Palindromes
1 votes

MATLAB, 61 bytes Not the shortest solution, but still interesting f=@(a)~any(changem(upper(a),90:-1:65,65:90)-fliplr(upper(a)))

View answer
Print a 10 by 10 grid of asterisks
16 votes

MATLAB, 14 bytes repmat('*',10)

View answer