New answers tagged

0 votes

Smallest Bit Rotation

Charcoal, 18 bytes ≔⍘N²θI⍘⌊Eθ⭆θ§θ⁺κμ² Try it online! Link is to verbose version of code. Explanation: ≔⍘N²θ Convert the input ...
  • 153k
0 votes

Smallest Bit Rotation

Retina 0.8.2, 55 bytes .+ $* +r`\1(1+) 0$1 10 1 . $&$'$`¶ 1 10 +`01 110 O` \G1 Try it online! Explanation: .+ $* Convert ...
  • 153k
1 vote

Output a random value from the last 16 values outputted

Java 8, 145 bytes ...
  • 101
0 votes

Smallest Bit Rotation

Python 2, 76 bytes i,o=bin(input())[2:],[] for x in i:i=i[-1]+i[:-1];o+=[int(i,2)] print min(o) Try it online! Python2 because it accepts integers directly as ...
  • 6,207
1 vote

Smallest Bit Rotation

R, 62 bytes \(n,j=2^(0:(i=log2(n))))min(j%*%matrix(n%/%j%%2,i+2,i+2)[-1,]) Attempt This Online! Instead of iteratively rotating bits, we use them to fill a matrix ...
1 vote

Output a random value from the last 16 values outputted

Zsh, 117 bytes seq 16|tee a;argv=(`shuf a`) while :;{shift;16=`shuf -n1 a`;<<<$16 s=(${(n)@});((s[1]<s[16]))||exit;tr \ \\n<<<$@>a} Try it ...
  • 1,708
0 votes

Smallest Bit Rotation

C (gcc), 76 bytes s;l;r;f(n){for(s=l=r=n;l/=2;s=s<r?s:r)r=r%2<<(31-__builtin_clz(n))|r/2;l=s;} Try it online!
  • 19.3k
1 vote

Yakko's New World Order

Vyxal, 140 bytes »÷¤xŻλjb↑+k2x₴O₍‟ḂṀṫ. ɖ`‟z¦¼ẇeRʁ>j:t{*0 Nq;*₅1z⟑-¶±↓`ṡF²k•-ṡ⁼₌]L₇ḊṪṗ₃h¦SεĠT$₴∴∇ǎ)¾ŀ⟇ḟṡ₄↲ḣ×£↳ǎrq°ʁ₀∇ẋ≠↑⁽5₍↑¯₈¤⌈←±e«∷¦jẇʁ»⁺9(n›ḋ÷$)_WṘ(n~i⅛⟇)¾ ...
  • 826
1 vote

Smallest Bit Rotation

R, 80 78 75 71 bytes f=\(n,b=2^(0:log2(n)),x=n%/%b%%2)if(n)min(x%*%b,f(n-1,b,c(x[-1],x[1]))) Attempt This Online! Recursive function that in every iteration ...
  • 13.3k
2 votes

Yakko's New World Order

05AB1E, 121 bytes •Caиβ”œ`äÔÚ×3ιØ>ãA8Cγ“Ø₄XмK £#_¯½%˜‚-Z†b}g3EqÄúé…¹ζzŒWmRç°¶вåΔBв„6J0й%∍¬üë¯β±B[λ9fΩÙ„¶g¹`Hk¹ʒJ.≠|”ΩoK"Âc9„Ƶι–+@ÌèÊ$§₅•.I I/O as a list. ...
2 votes

Smallest Bit Rotation

Excel, 81 80 71 69 bytes =LET(a,DEC2BIN(A1),b,LEN(a),c,SEQUENCE(b),MIN(BIN2DEC(MID(a&a,c,b)))) Input n With many thanks to @KevinCruijssen for the great ...
0 votes

Smallest Bit Rotation

APL (Dyalog Extended), 9 bytes Anonymous tacit prefix function. ⌊/⍳⊥⍤⌽¨⊤¨ Try it online! ⌊/ the smallest (lit. minimum-...
  • 29.2k
0 votes

Smallest Bit Rotation

><> (Fish), 91 bytes i0$1>:@$:@)?!v\ ;n\^@+1$*2@ <r $@:\?=@:$@:r-1/&~$?)@:&: 2+*2~v?:}:{%2:/.2b-%1:, 1$*2$/.38- Try it Instead of counting ...
  • 7,126
2 votes

Smallest Bit Rotation

JavaScript (Node.js), 63 bytes x=>'0b'+[...y=x.toString(2)].map(t=>y=y.slice(1)+t).sort()[0]-0 Try it online! t keeps ...
  • 16.2k
3 votes

Smallest Bit Rotation

Octave, 73 bytes It's not pretty, and it doesn't work on TIO. But it works in the program itself. ...
1 vote

Smallest Bit Rotation

Java 10, 118 bytes n->{var b=n.toString(n,2);for(int l=b.length(),i=l,t;i-->0;n=t<n?t:n)t=n.parseInt((b+b).substring(i,i+l),2);return n;} Input \$n\$; ...
3 votes

Smallest Bit Rotation

J, 16 bytes [:<./2#.i.|."{#: Try it online! #:: Convert \$n\$ to binary. i. ...
  • 8,711
3 votes

Smallest Bit Rotation

05AB1E, 6 bytes bā._Cß Input \$n\$; outputs the smallest bit rotation. Try it online or verify all test cases. Both the \$[1,n]\$ list with an input \$n\$ and ...
2 votes

Yakko's New World Order

MS-DOS .COM format (8086), 220 bytes Takes a CR-LF delimited list of countries from standard input. ...
  • 4,387
1 vote

Help me sell old donuts

J, 59 bytes 1 :'1#.]<.##&>@{.[:(a(#~u>:])@,1+}.)&.>/@|.\(<a=.100$0),;/' Try it online! Probably not the golfiest possible J approach but I ...
  • 30.9k
0 votes

Write a Rectangular Program that Outputs the Number of Times it was Rotated

TI-Basic, 2x2 = 4 03 12 This is the exact same as this answer, for the same reason. 3x3 = 9 2:3 ::: 1:0
  • 2,360
3 votes

Help me sell old donuts

Charcoal, 51 34 bytes ≔⟦⟧ζFη«F¹⁰⁰⊞ζθFιF¬¬ζ⊞υ⊟ζ≔⊖Φζκζ»ILυ Try it online! Link is to verbose version of code. Explanation: Now uses @Jonah's method. ...
  • 153k
0 votes

Derivative of a product

Arturo, 49 bytes $[s][join.with:"+"map 1..size s'i[insert s i"'"]] Try it
  • 14.9k
6 votes

Yakko's New World Order

Jelly, 121 bytes “wỴḅKṭḞ2Ṅðȧ¤[Ạ⁺©iṆȦẉ&ŒÐḷ<⁸Ṛ⁵Ƙ#A½Ƈ'¥ṚPċṢSḥSQUmṘẉL>²XɼNĠ¥ṆỊẋi¥@ȯ⁺CḲKSḌȮC²ß5LṂJṁȮr]zƬe§^YVœX<ḃç%ƝṪƬṣ$¹Ṗa?⁵ḤẠÐẈ}ƬỊhR=zḢɱ¿z’œ? Try it ...
3 votes

Yakko's New World Order

Charcoal, 208 bytes ...
  • 153k
0 votes

Help me sell old donuts

Python, 105 bytes f=lambda n,d,i=0,x="":d>[]and len((x:=str(i)*100+x)[:d[0]])+f(n,d[1:],i+1,(x+" ")[d[0]:x.find(str(i-n))]) I would be very ...
5 votes

Yakko's New World Order

JavaScript (Node.js), 205 bytes -2 thanks to @l4m2 This is based on a specific implementation of sort() but probably works with several engines. The source code ...
  • 177k
3 votes

Yakko's New World Order

JavaScript (Node.js), 253 bytes ...
  • 16.2k
0 votes

Get the date of the Nth day of week after the Xth day of week in a given year and month

C (gcc), 439 bytes Most of the code is parsing the input. ...
  • 4,387
1 vote

Shortest code to produce infinite output

Pip, 4 bytes W1P1 Prints the number 1 with a trailing newline over and over. Attempt This Online! This is a simple loop; in ...
  • 35.7k
2 votes

Help me sell old donuts

C (clang), 129 bytes ...
  • 949
0 votes

Am I an insignificant array?

Arturo, 36 bytes $[a][n:a\0every? a'x[2>abs n-x n:x]] Try it
  • 14.9k
0 votes

Output a random value from the last 16 values outputted

...
2 votes

Help me sell old donuts

Vyxal, 19 bytes ȧ₁?›(-½:ȧ~+^-Þr)_-∑ Try it Online! or verify all test cases
  • 826
1 vote

Am I an insignificant array?

Excel, 35 33 bytes =AND(ABS(DROP(ζ,1)-DROP(ζ,-1))<2) 2 bytes saved under the assumption that the input can be arbitrarily chosen so as to be a vertical vector.
2 votes

Help me sell old donuts

Go, 169 bytes ...
  • 5,403
1 vote

Help me sell day-old bagels

Go, 106 bytes func(a[]int)(s int){l,h:=0,100 for _,o:=range a{if h+l<o{s+=h+l}else{s+=o} if o<h{l=h-0}else{l=0}} return} Attempt This Online! Port of Olivier'...
  • 5,403
1 vote

Am I an insignificant array?

Thunno, \$ 7 \log_{256}(96) \approx \$ 5.76 bytes z[ZA2<P Attempt This Online! Outputs 0 for False and ...
  • 5,590
1 vote

Am I an insignificant array?

Julia, 23 bytes ~x=all(<(2),diff(x).^2) Attempt This Online! (Currently, the site doesn't seem evaluate any Julia code properly. Since ...
5 votes

Output a random value from the last 16 values outputted

Nibbles, 10 bytes (20 nibbles)* /`.,16>>:$=`#$16$:/ *Nibbles is a pure functional language and has no random number capability. So, this program uses the ...
0 votes

Reversed Iota's

Julia 1.0, 27 bytes ~n=map(i->[i:-1:1;],[1:n;]) Try it online!
2 votes

Create a bingo card generator

Jelly, 38 36 bytes 75s15Ẋ€ḣ€5Z“ƝM»€3¦€3¦“BINGO”ṭṚK€Y⁷Ṅ) Try it online! Most of the credit goes to @cairdcoinheringaahing and @UnrelatedString for helping me in ...
  • 5,590
1 vote

Am I an insignificant array?

Pip, 11 bytes 2>M:BAD_MPg Attempt This Online! Explanation ...
  • 35.7k
2 votes

Help me sell old donuts

JavaScript (ES6), 80 bytes Expects (days)(orders). ...
  • 177k
1 vote

Get the date of the Nth day of week after the Xth day of week in a given year and month

05AB1E, 204 (or 126?) bytes With strict I/O and outputting NA when the date goes beyond the given input month+year: 204 bytes: ...
0 votes

Reversed Iota's

Pip, -p 12 bytes Fl\,aO R\,lx How? ...
  • 1,033
2 votes

Get the date of the Nth day of week after the Xth day of week in a given year and month

JavaScript, 102 93 91 88 80 78 bytes Oof, this made my brain itch. Probably still some room for improvement. In the case of the last 2 NA test cases the dates wrap ...
  • 38.8k
1 vote

Modular multiplicative inverse

[Pyt], 1 byte ɯ Try it online! Takes inputs in the order b a (on separate lines). Outputs ...
0 votes

Bingo card generator

Vyxal, 11 bytes 75ɾ15ẇƛÞ℅5Ẏ Try it Online! ...
  • 33.6k
1 vote

Output a random value from the last 16 values outputted

Swift 5.6+, 107 bytes var a=[_](1...16),i=0 a.map{print($0)} while Set(a).count>1{a[i]=a.randomElement()! print(a[i]) i=(i+1)%16} Uses ...
  • 939

Top 50 recent answers are included