Skip to main content

New answers tagged

0 votes

Say What You See

Uiua, 13 bytes ⍥(♭≡◇⊂°⋕°▽) Try it! ...
nyxbird's user avatar
  • 1,019
0 votes

Determine the depth of an array

Uiua, 11 bytes -2⧻{⍥⊸/◇⊂∞} Try it! Repeatedly reduce with conjoin (/◇⊂) until a fixed point (...
nyxbird's user avatar
  • 1,019
2 votes

Display number of occurrences for every character in an input string

Red 0.6.5, 71 bytes m: #[]foreach c input[m/:c: 1 + any[m/:c 0]]foreach[k v]m[print[k":"v]] Note: The 71-bytes version works in Red 0.6.5. The Red ...
Galen Ivanov's user avatar
  • 21.2k
2 votes

Display number of occurrences for every character in an input string

Ruby, 42 bytes ->s{s.chars.tally.map{puts _1+" : #{_2}"}} Attempt This Online! If the output format wasn't so strict you could go way shorter Ruby, 20 ...
Joon Yorigami's user avatar
3 votes

Count /[^a-z]/ig with /[a-z]/ig

Jelly, score 0, 366 68 bytes LdLYYTYYJSpppppJLdLdLdLdLdLNCNCNCNCSSSSRUFNMHpOIFACHHNCHNCNCRTLrLLCN Try it online! Uses a New and Exciting™️ construction for ...
Unrelated String's user avatar
1 vote

Count up forever

BrainChild, 108 bytes include *;while(int a~-1|int b~-1|int c~-1|int d~-1){if(!++a)if(!++b)if(!++c)d++printf("$0$1$2$3 ",d,c,b,a)} Brainchild doesn't ...
ATaco's user avatar
  • 11.2k
1 vote

Count up forever

punchcode, 6 bytes [RS][ESC][VT][GS][CR][LF] uncompiled: -START | ---OOOO-| ---OO-OO| ----O-OO| ---OOO-O| ----OO-O|
madeforlosers's user avatar
1 vote

Count /[^a-z]/ig with /[a-z]/ig

AWK -F "", 13 score, 24 bytes $0=NF-gsub(/[A-Za-z]/,x) ...
xrs's user avatar
  • 579
1 vote

Count the fish in a school

Haskell + hgl, 36 bytes ca"1"<<tx<m(gkY$rX">{1_<>|<><{1_|.") Attempt This Online! Explanation ...
Wheat Wizard's user avatar
  • 100k
0 votes

Count the fish in a school

APL+WIN, 70 bytes Prompts for school as a 2 dimension array. m←((i←(⍴i)÷3),3)⍴i←(n←v≠' ')/v←,j←⎕⋄+⌿(⍴j)⍴n\,(m[;1]='>'),0,m[;,3]='<' Try it online! Thanks to ...
Graham's user avatar
  • 6,846
1 vote

Count the fish in a school

Pip -r, 22 bytes $+^gR`\S`*3{'<Q@a?Rhh} Takes input from stdin; requires it to be padded to a rectangle with spaces. Attempt ...
DLosc's user avatar
  • 39.2k
1 vote

Count the fish in a school

Uiua, 30 bytes +@0/+⬚0⊜(=-:@>◿3+2\+≠@ .)⊸≠@\n Try it online!, inspired by ovs's K solution Explanation: ...
ErikDaParrot's user avatar
1 vote

Count the fish in a school

C# (.NET Core), 189 bytes ...
Pepik's user avatar
  • 111
2 votes

Count the fish in a school

C++ (clang), 191 124 bytes ...
ioveri's user avatar
  • 141
1 vote

Count the fish in a school

05AB1E, 12 bytes ðÊ€ηOIÇ+3ÖøO Similar as a bunch of other answers. Takes the input as a list of lists of characters, including trailing spaces to make all lines ...
Kevin Cruijssen's user avatar
3 votes

Count the fish in a school

R, 95 94 bytes -1 thanks to pajonk ...
Eonema's user avatar
  • 301
3 votes

Count the fish in a school

Ruby, 83 79 bytes ->s{a=[c=x=0]*w=s=~/\n/ s.bytes{|i|c+=i/60 i>10?a[(i-62+x+=1)%w]+=c%3/2:x=0} a} Try it online! Function that takes a newline separated ...
Level River St's user avatar
4 votes

Count the fish in a school

Python + NumPy, 79 bytes lambda s:sum((cumsum((X:=c_[s].view("i4")%-8)<0,1)+X)%3>1,0) from numpy import* Attempt This Online! Takes a list of rows ...
Albert.Lang's user avatar
  • 4,574
3 votes

Count the fish in a school

Scala 3, 178 161 bytes Saved 17 bytes thanks to @corvus_192 Golfed version. Attempt This Online! ...
138 Aspen's user avatar
  • 6,617
13 votes
Accepted

Count the fish in a school

Vyxal, 8 bytes C<v¦+3Ḋ∑ Try it Online! I/O as a matrix of charcodes. Inspired by ovs's K answer (and then backported to that to save two bytes) ...
emanresu A's user avatar
  • 44.2k
8 votes

Count the fish in a school

K (ngn/k), 18 bytes +/{x=62-3!2+\~^x}' Try it online! ...
ovs's user avatar
  • 60.6k
3 votes

Count the fish in a school

JavaScript (ES6), 69 bytes -2 thanks to @l4m2 Expects an array of arrays of characters (which may be of different lengths). Returns an array of integers. ...
Arnauld's user avatar
  • 198k
5 votes

Count the fish in a school

Perl 5 -F, 57 50 bytes s/(>)<>|<></$1?100:aa1/ge;s/./$;[pos]+=$&/ge}{say@ Try it online!
Xcali's user avatar
  • 16.2k
1 vote

Count the fish in a school

Python, 142 126 122 bytes lambda s:[*map([m.start()+2*(m[0]<'>')for r in s for m in re.finditer(r'\S..',r)].count,range(max(map(len,s))))] import re Attempt ...
movatica's user avatar
  • 1,383
4 votes

Count the fish in a school

Japt, 24 21 16 bytes Takes input as a 2D array of codepoints. Ëí+DËgHÃå+ÃÕËxv3 Try it ...
Shaggy's user avatar
  • 43.5k
2 votes

Count the fish in a school

Ruby, 92 bytes Takes an array of lines as input. ...
Jordan's user avatar
  • 11.3k
6 votes

Count the fish in a school

Jelly, 14 bytes >⁶Ä3ḍk⁸Ġ€F=2)S A monadic Link that accepts a list of lists of < > characters and yields a list of the ...
Jonathan Allan's user avatar
2 votes

Count the fish in a school

Charcoal, 40 35 28 26 bytes WSP⭆ι⁺¬﹪⁺℅κL⁻…ι⊕λ ³Σ⊟KD⊕λ→ Try it online! Link is to verbose version of code. Takes input as a list of newline-terminated strings. ...
Neil's user avatar
  • 177k
3 votes

Count the fish in a school

Retina, 97 bytes N$^` $.& (\S)(\S)\1 $2 < 1 > 1 +`(?<=^(.)*)(.)((.*¶)+(?<-1>.)*)1(?(1)^) $.(_$2*)$3 0 0G` Try it ...
Neil's user avatar
  • 177k

Top 50 recent answers are included