Skip to main content
9 votes

Sorting with a deque

K (ngn/k), 17 bytes {&/(x=|\x)|x=&\x} Every element must be the minimal (or the maximal) element of its prefix. Try it online! APL(Dyalog Unicode), 13 10 ...
akamayu's user avatar
  • 673
7 votes

Sorting with a deque

R, 30 bytes \(x,`!`=cummin)any(x-!x&x+!-x) Attempt This Online! Port of @Unrelated String's first Jelly answer. Outputs swapped ...
pajonk's user avatar
  • 17.2k
7 votes

Wait, ASCII was 128 characters all along?

Jelly, 7 bytes bØ⁷ỌḟØṖ Try It Online! ...
hyper-neutrino's user avatar
  • 42.5k
7 votes

Wait, ASCII was 128 characters all along?

JavaScript (ES6), 30 bytes Very similar to Jitse's answer. Returns 0 for printable or true for non-printable. f=n=>-~n%128<33||(n>>=7)&&f(n) ...
Arnauld's user avatar
  • 194k
7 votes

Reorder for smallest largest prefix sum

Vyxal, 6 bytes Ṗ≬¦ȧG∵ Try it Online! ...
emanresu A's user avatar
  • 39.2k
6 votes

Reorder for smallest largest prefix sum

Python 3, 93 bytes lambda a:min(permutations(a),key=lambda a:max(map(abs,accumulate(a)))) from itertools import* Try it online! -45 bytes thanks to Jonathan Allan ...
Jitse's user avatar
  • 7,484
5 votes

Sorting with a deque

Haskell + hgl, 23 bytes no uq<f'[gj,mx,mn]<<pxn Attempt This Online! Explanation For each prefix determine the maximum, minimum and last elements. If any ...
Wheat Wizard's user avatar
  • 99k
5 votes

Wait, ASCII was 128 characters all along?

Python 3, 36 bytes f=lambda n:-~n%128<33or f(n>>7)*n>>7 Try it online! Outputs with truthy and falsey swapped -2 bytes thanks to Themoonisacheese -...
Jitse's user avatar
  • 7,484
5 votes

Reorder for smallest largest prefix sum

R, 124 108 104 bytes Edit: -13 bytes thanks to Giuseppe. Edit2: -4 bytes thanks to pajonk ...
Dominic van Essen's user avatar
5 votes

Plot the ground path of a satellite

Ruby, Golfed version 313 bytes ...
Level River St's user avatar
4 votes

Sorting with a deque

JavaScript (ES6), 39 bytes Returns a Boolean value. a=>a.every(m=v=>(v>a?v:a=v)<m?a==v:m=v) Try it online! Commented ...
Arnauld's user avatar
  • 194k
4 votes

Sorting with a deque

Nibbles, 13 nibbles (6.5 bytes) ?`*!`\$[`\@]: Attempt This Online! ...
Dominic van Essen's user avatar
4 votes

Sorting with a deque

K (ngn/k), 13 bytes &/|/=/&\'\-:\ Try it online! Returns a positive integer for truthy and 0 for falsy. I don't think I've seen any other code with such ...
Bubbler's user avatar
  • 77.5k
4 votes

Wait, ASCII was 128 characters all along?

R, 44 43 40 bytes Edit: -3 bytes thanks to pajonk f=\(x)(x+1)%%128>31&(!(y=x%/%128)||f(y)) Attempt This Online!
Dominic van Essen's user avatar
4 votes

Reorder for smallest largest prefix sum

Factor + math.combinatorics, 55 bytes [ <permutations> [ cum-sum vabs supremum ] infimum-by ] Try it online! ...
chunes's user avatar
  • 25.5k
4 votes

Reorder for smallest largest prefix sum

05AB1E, 8 bytes œΣηOÄà}н Try it online or verify all test cases or verify all possible outputs (by using an additional group-by after the sort). Explanation: <...
Kevin Cruijssen's user avatar
4 votes

Wait, ASCII was 128 characters all along?

Nibbles, 14 nibbles (7 bytes) Program bytes: d9 87 12 08 3a dd 3b Human-readable representation: ,|`@128$\ch$P Attempt This ...
Dominic van Essen's user avatar
4 votes

Check if two lists are permutations of each other

Haskell, 26 bytes (.g).(==).g g=sum.map(65^) Try it online! 27 bytes g=sum.map(65^) a%b=g a==g b Try it online! Converts the ...
xnor's user avatar
  • 146k
4 votes

Compute Dickman

Charcoal, 26 bytes ≧×⁸φF×Nφ⊞υ∨‹ιφ⁻⌊υ∕§υ±φιI⊟υ Try it online! Link is to verbose version of code. Note that the version shown is only within 0.1% for ...
Neil's user avatar
  • 173k
3 votes

Sorting with a deque

05AB1E, 11 10 bytes ηε{DyθÚÊ}P -1 byte porting @JonathanAllan's Jelly answer Outputs 1 if sortable; ...
Kevin Cruijssen's user avatar
3 votes

Calculate sum of self-exponentation

Forth (gforth),  103  100 bytes -3 bytes thanks to ovs : ^ 1 TUCK +DO OVER * LOOP * ; : s 0 SWAP DUP @ 0 DO DUP I 1+ CELLS + @ DUP ^ ROT + SWAP LOOP DROP ; Try it ...
david's user avatar
  • 539
3 votes

Visualize the greatest common divisor

Vyxal, 25 bytes ġ/ʀṘ*fDÞǔ‛.oİ‟Ẋ'?ġ+↔;h⁽ɾ¢ Try it Online! Input as pair of numbers, output as char list. ...
emanresu A's user avatar
  • 39.2k
3 votes

Wait, ASCII was 128 characters all along?

Go, 75 68 bytes func f(n int)bool{for k:=n;k>0;k>>=7{if -^k%128<33{n=0}} return n>0} Attempt This Online! Based on @Jitse's answer. Does not swap ...
bigyihsuan's user avatar
  • 10.2k
3 votes

Reorder for smallest largest prefix sum

Arturo, 58 bytes $=>[minimum permutate&'p->max map size p=>[abs∑take p&]] Try it! Explanation ...
chunes's user avatar
  • 25.5k
3 votes

Reorder for smallest largest prefix sum

R, 136 bytes \(x)(~x)[order(apply(~x,1,\(v)max(abs(cumsum(v)))))[1],] `~`=\(v)`if`(n<-sum(v|1),{X={};for(i in 1:n)X=rbind(X,cbind(v[i],~v[-i]));X},v) Attempt ...
pajonk's user avatar
  • 17.2k
3 votes

Reorder for smallest largest prefix sum

JavaScript (ES6), 99 bytes Naive method trying all possible permutations. ...
Arnauld's user avatar
  • 194k
3 votes

Draw a big slash X

Raku (Perl 6) (rakudo), 85 73 bytes {for $_ ->\y {say [~] .map({' \\/X'.comb[2*!(y+$_)+(y==$_)]})}}o{-$_..$_} Attempt This Online!
bb94's user avatar
  • 2,731
3 votes

Check if two lists are permutations of each other

JavaScript (ES6), 27 bytes Expects (a)(b) and returns a Boolean value. a=>b=>a.sort()+""==b.sort() Try it ...
Arnauld's user avatar
  • 194k
3 votes

Check if two lists are permutations of each other

Vyxal 3, 3 bytes ᵛS≈ Try it Online! I haven't golfed in forever. ...
Seggan's user avatar
  • 5,407
2 votes

Sorting with a deque

Charcoal, 16 bytes ⬤θ№⟦⌊…θ⊕κ⌈…θ⊕κ⟧ι Try it online! Link is to verbose version of code. Outputs a Charcoal boolean, i.e. - if ...
Neil's user avatar
  • 173k

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