Skip to main content

New answers tagged

0 votes

Sum the array times n, except the last

vemf, 7 bytes ├¡╤1«╓ë Function that takes A as a left argument, and N as a right argument. the mixed-radix Decode ë needs for ...
taswelll's user avatar
  • 161
0 votes

Sum the array times n, except the last

Pxem, 0 + 95 = 95 bytes Filename .w.t.m.+._.c.a.s.m.-._.!.m.+.n Try it online! Usage Each item in A, end with 0, then N How it ...
鳴神裁四点一号's user avatar
0 votes

Sum the array times n, except the last

Uiua, 23 bytes, 12 characters /+⊂⊙×↙1:↘1.⇌ Try it on Uiua Pad!
Joonas's user avatar
  • 21
0 votes

Find ranges of True values in a list

Perl 5 + -M5.10.0 -n, 26 bytes say"@- ","@+"-1while/1+/gc Try it online!
Dom Hastings's user avatar
  • 23.9k
3 votes

Generate a subgroup of a free group

Haskell + hgl, 79 bytes f w=nn>~(m(rF(#)[]<fo)<mM(p$ap[id,rv<m(*(-1))]w)<ef 0) a#(h:t)| -h==a=t a#b=a:b Attempt This Online! Takes positive and ...
corvus_192's user avatar
  • 5,572
2 votes

Diamondize a Matrix

R, 102 94 bytes \(L,N=length(L),`>`=rep)apply(t(mapply(\(j,n)c(0>n-1,j,0>N-n),L,1:N)),2,\(a)list(rev(a[0<a]))) Attempt This Online! Outputs a list of ...
int 21h Glory to Ukraine's user avatar
2 votes

Is my Matrix Arrowhead?

R, 50 49 bytes -1 byte thanks to pajonk function(x,n=1:dim(x)-1)all((!n%o%n*!diag(n))-!x) Try it online! This solution is similar to the other existing 2 answers ...
2 votes

Just another traffic jam!

Japt -P, 6 bytes ËòÀÃÕc Try it
Shaggy's user avatar
  • 42.1k
3 votes

Generate a subgroup of a free group

Jelly, 18 17 bytes UN;ƊL⁹ḃịƲF;Ṗ+Ṫ¥?/ Try it online! -1 thanks to Jonathan Allan Takes the words as positive and negative integers on the left, and a 1-index on the ...
Unrelated String's user avatar
0 votes

Just another traffic jam!

Python 3.8 (pre-release), 59 bytes f=lambda a,b:a+b and a[:a.rfind(s:=a.lstrip(a[:1]))]+f(b,s) Try it online!
Jitse's user avatar
  • 7,324
1 vote

Zip uneven lists

Go, 80 bytes func f(a,b[]int)(o[]int){if len(a)<1{return} return append(a[:1],f(b,a[1:])...)} Attempt This Online! Straight-forward solution directly ...
bigyihsuan's user avatar
  • 9,786
2 votes

Generate a subgroup of a free group

Charcoal, 54 bytes ⊞υωWS«⊞υι⊞υ⭆⮌ι⎇№ακ↧κ↥κ»≔⍘NυθWΦE⪫υω⁺κ⎇№ακ↧κ↥κ№θκ≔⁻θ⌊ιθθ Try it online! Link is to verbose version of code. Takes a newline-terminated list of ...
Neil's user avatar
  • 172k
3 votes

Just another traffic jam!

R, 155 bytes ...
int 21h Glory to Ukraine's user avatar
3 votes

Generate a subgroup of a free group

Pyth, 25 bytes #jmu?s>2K+GHKPGsdYy=+m__M Try it online! Words are lists of non-zero integers where inversing is done by negation. Generates output infinitely ...
CursorCoercer's user avatar
5 votes

Generate a subgroup of a free group

Jelly,  24  23 bytes FµŻSƝaSƝTị UN;ƊṗⱮẎÇÐL€ḣ A dyadic Link that accepts the list of words on the left, and a non-negative integer, \$n\$, on the right and yields a ...
Jonathan Allan's user avatar
1 vote

Collect the elements of an array

jq, 51 bytes reduce.[]as$i([[]];.[-1]+=[0+$i]?//.+=[$i,[]])-[[]] Try it online! ...
GammaFunction's user avatar
1 vote

Collect the elements of an array

Jelly, 9 bytes ŒḊ€»ƝÄŻFƙ Try it online! Explanation Something of a Frankenstein's monster combination of the Jelly answers by lynn and Jonathan Allan, but with the ...
DLosc's user avatar
  • 39.7k
0 votes

Complex permutation

Uiua, 38 bytes ▽⊸≡(/×≡/≠◫2)∧(☇1⊞⍜⊙↻⊂¤⊙(⇡+1⊡1△.))⊙[[]] Try it in the pad! You can optionally add ◴ deduplicate to generate the ...
Joao-3's user avatar
  • 1,183
1 vote

Generate recursive "arrays" up to a certain depth

Jsonnet, 43 local f(l)=if l>0then[f(l-1),f(l-1)]else[]; Defines a jsonnet function - the nesting level is passed as a parameter. Online Jsonnet validator
Digital Trauma's user avatar
0 votes

I'm Lazy*: Top-left align my text

Perl 5 -lF, 55 bytes $i=0;map{$;[$i++].=$_ x!/ /}@F}{say map{s/.//;$&}@;for@ Try it online!
Xcali's user avatar
  • 15.3k
1 vote

Apply gravity to this matrix

K (ngn/k), 12 bytes Solution: {+{x@<x}'+x} Try it online! Explanation: ...
mkst's user avatar
  • 5,185
3 votes

I'm Lazy*: Top-left align my text

Uiua 0.11.0, 12 bytes ⍥(≡⊕⊂=@ .⍉)2 Try it out! Explanation ...
RomanPro100's user avatar
1 vote

Apply gravity to this matrix

Uiua SBCS, 8 bytes ⍜⍉≡(⊏⍏.) Try it!
chunes's user avatar
  • 24.7k
1 vote

Apply gravity to this matrix

Perl 5 -lF, 69 bytes $a=0;map$r[$a++]+=$_,@F}{say@$_ for reverse map[map$_-->0|0,@r],1..$. Try it online!
Xcali's user avatar
  • 15.3k
4 votes

Apply gravity to this matrix

Minecraft, 0 bytes This is a bit cheaty, but the question does state you can take input in "all reasonable forms" and a grid of Minecraft blocks seems reasonable enough. Input is given as a ...
LostXOR's user avatar
  • 887
2 votes

I'm Lazy*: Top-left align my text

Nibbles, 10 nibbles (5 bytes) `'.`';@|$$ Attempt This Online! Explanation It turns out that Nibbles' builtins are a very good fit for this challenge. ...
DLosc's user avatar
  • 39.7k
1 vote

Apply gravity to this matrix

Arturo, 59 bytes $=>[f:$->m->map size m\0'i->map m'r->r\[i-1]f map f&=>sort] Try it!
chunes's user avatar
  • 24.7k
0 votes

Quickly regrouping lists

Arturo, 50 bytes $->a[0while->¬one? a[a:chunk a=>[&]|map=>size+1]] Try it! Explanation ...
chunes's user avatar
  • 24.7k

Top 50 recent answers are included