niczky12
  • Member for 3 years, 10 months
  • Last seen more than a month ago
Unique is Cheap
3 votes

Julia 0.6, 45 bytes, Score: 77 Inspired by the MATL solution: f(w)=sum(UpperTriangular([z==j for z=w,j=w])) Try it online! A less pretty solution, using counts: Julia 0.6, score: 82 F(w)=sum(l-&...

View answer
Duck, duck, goose!
3 votes

Julia 0.6, 33 bytes print("duck\n"^rand(1:9),"goose") This will print duck up to 9 times before goose! Try it online!

View answer
Increment The Time
2 votes

Julia 1.0, 66 bytes using Dates;f="HH:MM";g(s)=Dates.format(DateTime(s,f)+Minute(1),f) Try it online! Using libraries because why not and it's still shorter than Python.

View answer
Implement the Thanos sorting algorithm
2 votes

Julia 1.0, 30 bytes -x=x>sort(x) ? -x[1:2:end] : x Try it online! Takes every second element of the array if not sorted.

View answer
Seidel Triangle
2 votes

Julia 0.6, 85 bytes r(l,n=cumsum(l))=[n...,n[end]] w=reverse f(n)=n<2?[1]:n%2<1?r(f(n-1)):w(r(w(f(n-1)))) Try it online! This is a recursive solution in Julia. Note that it has 1-based ...

View answer
Minimize Least Used Binary Bits in Fractions
2 votes

Julia 0.6, Score = 7702 g(x,b=[bin(x)...])=min(sum(b.=='0'),sum(b.=='1')) f(a,b)=((r,i)=findmin(map(i->max(g(a*i),g(b*i)),1:10^5));[r,a*i,b*i]) Try it online! A naive and slow solution. Output ...

View answer
Sort odd numbers first
1 votes

Julia 1.0, 27 bytes f(l)=l[sortperm(l.%2 .==0)] Try it online! This works too and is a lot more elegant: f(l)=sort(l,lt=(a,b)->b%2==0) But it's a few bytes longer :(

View answer
Generate a password
1 votes

Julia 1.0, 158 bytes ¬t=(c=Dict();C=Dict();for i=eachmatch(r"\w",t);l=i.match;k=lowercase(l);c[k]=get(c,k,0)+1;C[k]=l;end;*(["$v$(C[k])" for (v,k)=sort([(v,k) for (k,v)=c])]...)) Original ungolfed ...

View answer
Outputting ordinal numbers (1st, 2nd, 3rd)
1 votes

Julia 0.6, 68 bytes f(x,m=x%10,p=x%100-m)="$x$(["th","st","nd","rd"][m>3||p==10?1:m+1])" Try it online! Straightforward remainder rules in Julia.

View answer
Alice and Bob have a fight
1 votes

Julia 0.6, 175 bytes p=println() f(l="AB",h=[10,10],a=1)=(while min(h...)>0;d=3-a;p(l[a]," a ",l[d]);r=rand(1:6);h[d]-=r;p(l[a]," r ",r);p(l[d]," h ",max(h[d],0));a=d;end;p(l[findmax(h)[2]]," w")) ...

View answer
Does the start equal the end?
1 votes

Julia 0.6, 29 bytes f(x)=x==""?false:x[1]==x[end] Try it online!

View answer
How old is it roughly?
1 votes

Julia 0.6, 161 bytes f(n,d=cumprod([1,60,60,24,7,31/7,365/31]),r=div.(n,d),i=findlast(r.>=1),l=Int(r[i]))="$l $(split("second minute hour day week month year",' ')[i])$("s"^(l>1*1))" Try it ...

View answer
Sequentially Divisible
1 votes

Julia 0.6, 79 bytes f(s,l=length(s),n=s[])=(while !all(mod.(collect(0:l-1).+n,s).==0);n+=s[];end;n) Try it online! Inputs without valid solutiosn will cause infinite looping... :)

View answer
The next colour
1 votes

Julia 0.6, 76 bytes f(s)=match(Regex("$s(.[a-z]*)"),"RedOrangeYellowGreenBlueIndigoViolet"^2)[1] Try it online! This handles the Violet->Red by recycling the string with the power ^ operator. Here'...

View answer
Which Card is it?
1 votes

Julia 0.6, 156 bytes f(n)=print(split(" of ,hearts,diamonds,spades,clubs,two,three,four,five,six,seven,eight,nine,ten,jack,queen,king,ace",',')[[(n-1)%13+6,1,div(n-1,13)+2]]...) Try it online! -2 ...

View answer
Vertically collapse text
0 votes

Julia 0.6, 141 bytes l=length g(z,i)=(n=z[i];m=z[i+1];(N,M)=l.([n,m]);z[i:i+1]=[n[1:min(N,M)],m*n[M+1:N]]) f(s,w=split(s),d=1:l(w)-1)=(g.([w],[d d]);join(w,"\n")) Try it online! Broadcasting with g....

View answer
The world ends in ed
0 votes

Julia 0.6, 46 bytes f(s)=string(matchall(r"[a-z](?![a-z])"i,s)...) Try it online! Simple Julia with Standard regex. The r"" constructor creates a Regex class. Notice how the i letter after the last ...

View answer
How old is it roughly?
0 votes

R, 246 bytes f=function(x,r=as.integer(strsplit(strftime(as.POSIXlt(x,"","1970-01-01"),"%Y %m %V %d %H %M %S")," ")[[1]])-c(1970,1,1,1,1,0,0),i=which.max(r>0)){cat(r[i],paste0(c("year","month","...

View answer