g | x | w | all
Bytes Lang Time Link
088Tcl181219T195032Zdavid
102Tcl180605T231303Zsergiol
066Zsh230124T010729Zroblogic
7125Vyxal s230723T120128Zlyxal
010Thunno 2230722T164447ZThe Thon
056Arturo230121T123255Zchunes
185Scala230417T070447Z138 Aspe
009Husk230121T145926ZRazetime
044Wolfram Language Mathematica230210T041009Zatt
081PowerShell230210T023834ZJulian
030Raku230209T054724ZSean
082JavaScript230125T155938ZEzioMerc
106Elm230122T203301ZKirill L
105Nim230124T211834Zxigoi
009Nibbles230124T205641Zxigoi
117C GCC230123T195604ZPeter
089Julia230123T202239ZAshlin H
014Pip p230123T172118ZDLosc
013Vyxal230121T165933Zlesobrod
nan230121T123959ZThe Thon
084Desmos220522T200349ZnaffetS
058Factor + pairrocket220520T174804Zchunes
108C# Visual C# Interactive Compiler181219T181200Zdana
059Ruby181219T141628ZKirill L

Tcl, 98 88 bytes

thx to sergiol

proc A {l 1\ 0 2\ 0} {lmap a\ b\ c $l {incr [llength [lsort -u "$a $b $c"]]}
list $1 $2}

Try it online!

Tcl, 102 bytes

proc S {L 1\ 0 2\ 0} {lmap {x y z} $L {incr [expr $x-$y|$y-$z?$x==$y|$y==$z|$x==$z?2:0:1]}
list $1 $2}

Try it online!

Zsh, 66 bytes

for i ({1..$#..3})T+=${#${(u)@[i,i+2]}}
<<<${#T//[^1]},${#T//[^2]}

Try it online! 65b(bugged) 67b(pure) 67b(utils) 72b 78b 83b 102b 116b 128b

Vyxal s, 57 bitsv1, 7.125 bytes

3ẇƛUL12f=

Try it Online!

Explained

3ẇƛUL12f=­⁡​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁣‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏‏​⁡⁠⁡‌⁢⁡​‎‏​⁢⁠⁡‌­
3ẇ         # ‎⁡Wrap into chunks of 3
  ƛ        # ‎⁢to each chunk
   UL      # ‎⁣  take the length of the chunk uniquified
     12f=  # ‎⁤  and push whether 1 and 2 is in that length list
# ‎⁢⁡the s flag reduces the list by addition, which is performed element-wise vectorised
💎

Created with the help of Luminespire.

Thunno 2, 10 bytes

3ẇıUl;12dc

Try it online!

Explanation

3ẇıUl;12dc  # Implicit input
3ẇ          # Split into threes
  ı  ;      # Map over the list:
   Ul       #  Length of uniquified list
      12dc  # Count 1s and 2s
            # Implicit output

Arturo, 61 57 56 bytes

$->a[b:[x,y,z]map[1,2]'n->enumerate a b->n=size tally@b]

Try it

Scala, 185 bytes

Golfed version. Try it online!

val f:Array[Int]=>Array[Int]=l=> {var r=Array(0,0,0);var i=0;var a,b,c=0;while(i<l.length){b=l(i);c=l(i+1);a=l(i+2);r(if(a==b){if(b==c)0 else 1} else if(b==c||a==c)1 else 2)+=1;i+=3};r}

Ungolfed version. Try it online!

import java.util.Arrays
import java.util.function.Function

object Main {
  def main(args: Array[String]): Unit = {
    val f: Array[Int] => Array[Int] = l => {
      var r = Array(0, 0, 0)
      var i = 0
      var a, b, c = 0
      while (i < l.length) {
        b = l(i)
        c = l(i + 1)
        a = l(i + 2)
        r(if (a == b) {
          if (b == c) 0 else 1
        } else if (b == c || a == c) 1 else 2) += 1
        i += 3
      }
      r
    }
    val tests = Array(
      Array(2, 4, 2, 5, 5, 5, 4, 2, 1, 3, 3, 1),
      Array(3, 5, 6, 5, 5, 7, 6, 6, 8, 7, 7, 7, 3, 4, 2, 4, 4, 3),
      Array(3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 5, 4, 3),
      Array(3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1)
    )
    for (test <- tests) {
      val result = f.apply(test)
      printf("%s: %s%n", Arrays.toString(test), Arrays.toString(result))
    }
  }
}

Husk, 9 bytes

hmLkoLuC3

Try it online!

Wolfram Language (Mathematica), 44 bytes

0&@@@c@BlockMap[Max@*c,#,3]/@{3,2}&
c=Counts

Try it online!

            BlockMap[Max@*Counts,#,3]           #equal in each block of 3            
     Counts@                         /@{3,2}    count 3 equal, 2 equal
0&@@@                                           coerce Missing[...] to 0

PowerShell, 81 bytes

for($r=@{};$i-$args.Count;$i++){$r[($args[$i++..++$i]|sort|gu).Count]++}
$r[1..2]

Try it online!

Explanations

Look at the array by taking sub arrays of three successive elements $args[$i..($i+2)]

We count the number of items in the sub array after sorting and removing duplicates (gu)

Then we increment the count in the result object $r

From $r, we then show only the entries with a single or two numbers

Raku, 30 bytes

(+«*.rotor(3)».Set).Bag{1,2}

Try it online!

JavaScript, 82 bytes

Without recursion

a=>(b=[,0,0],a.map(d=>([x,y,z,...a]=a,x&&++b[new Set([x,y,z]).size])),[b[1],b[2]])

Try it:

f=a=>(b=[,0,0],a.map(d=>([x,y,z,...a]=a,x&&++b[new Set([x,y,z]).size])),[b[1],b[2]])

console.log(f([3,5,6,5,5,7,6,6,8,7,7,7,3,4,2,4,4,3])); // [1, 3]
console.log(f([3,3,3,4,4,4,5,5,5,6,6,6,5,4,3])); // [4, 0]
console.log(f([3,4,5,6,7,8,9,8,7,6,5,4,3,2,1])); // [0, 0]

Elm, 108 106 bytes

import List.Extra as E
m=List.map
f x=m(\j->E.count((==)j)<|m(List.length<<E.unique)<|E.groupsOf 3 x)[1,2]

Try it on Ellie

Nim, 105 bytes

import sequtils
proc e[S](s:S):S=[1,2].mapIt s.distribute(s.len div 3).mapIt(it.deduplicate.len).count it

Attempt This Online!

Nibbles, 9 bytes

.,2,`?.`/3@,`$$@

Attempt This Online!

Explanation

.    Map
,2    [1,2]
,     length of
`?     find indices in
.       map
`/ 3     split into chunks of 3
@         input
,        length of
`$        deduplicate
$          the chunk
@       of the number (1 or 2)

C (GCC), 135 128 117 bytes

-7 bytes thanks to @ceilingcat

-11 more, again thanks to @ceilingcat

This is basically @ceilingcat's answer now, since he's improved it by more than 13 percent.

#define E(k)v[k-~i]==v[i
a;b;i;f(v,l)int*v;{for(a=b=i=0;i<l;i+=3)E()]&E(1)]?++a:E()]|E(1)]|E(1)+1]&&++b;*v=a;v[1]=b;}

Try It Online!

Unfortunately, I'm too lazy to write a new explanation for the most recent answer, but it's quite similar to the previous 128-byte one:

#define E(j,k)v[j+i]==v[k-~i]
a;b;i;f(v,l)int*v;{for(a=b=i=0;i<l;i+=3)E(,)&&E(,1)&&++a||(E(,)||E(,1)||E(1,1))&&++b;*v=a;v[1]=b;}

Try It Online!

f takes a vector (v) and its length (l) as arguments, and return its values in the first two elements of that vector. Explanation:

#define E(j,k)v[j+i]==v[k-~i] // k-~i == k-(-i-1) == k+i+1. an empty first argument equals +i, and an empty second argument equals -~i == i+1
a;b;i;
f(v,l)int*v;
{
    for(a=b=i=0;i<l;i+=3)
        E(,)&&E(,1)&&++a // if element i, i+1 and i+2 are all equal, increment a
        ||(E(,)||E(,1)||E(1,1))&&++b; // otherwise, if any two elements are equal, increment b
    *v=a; // set the first element in v to a
    v[1]=b; // set the second one to b
}

Julia, 89 bytes

!x=(~=sum;a=length(x);b=[x[i:i+2] for i=1:3:a];c=~allequal.(b);[c,a÷3-c-~allunique.(b)])

Attempt This Online!

Julia has allequal and allunique built in. To find the number of triplets containing exactly 2 matching values (all remaining cases), I subtract these two amounts from the total. Replacing ÷ with / saves one byte, but the value becomes a float.

Pip -p, 14 bytes

_N#*UQ*g<>3M12

Takes the numbers as command-line arguments. Attempt This Online!

Explanation

_N#*UQ*g<>3M12
       g        ; List of command-line args
        <>3     ; Group into 3-element sublists
    UQ*         ; Uniquify each
  #*            ; Get length of each
_N              ; Lambda expression: how many times does the argument appear in ^
           M12  ; Map that lambda to the arguments 1 and 2

This returns a list containing the number of length-1 uniquified sublists and the number of length-2 uniquified sublists.

Vyxal 14 13 bytes

3ẇƛ∪L;:1O$2Ox

Try it online!

Explanation:

3ẇ             # 3-partition
  ƛ            # Open lambda map
   ∪L          # Length of sublist union
     ;         # Close lambda map
      :        # Duplicate for next operation
       1O      # Count 1
         $     # Swap
          2O   # Count 2
            x  # Print stack as list

Thunno, \$ 12 \log_{256}(96) \approx \$ 9.88 bytes

3ApeZULE12dc

Attempt This Online!

Port of Emigna's 05AB1E answer.

Explanation

3ApeZULE12dc  # Implicit input
3Ap           # Split into sublists of length 3
   e   E      # For each sublist:
    ZU        #   Remove duplicates
      L       #   And get the length
        12dc  # Count the number of 1s and 2s in this list
              # Implicit output

Desmos, 84 bytes

l(r)=r.length
b=[l(k[3x-2...3x].unique)forx=[1...l(k)/3]]
f(k)=[l(b[b=1]),l(b[b=2])]

Try it on Desmos!

Factor + pair-rocket, 58 bytes

[ 3 group 1 => 2 [ '[ cardinality _ = ] count ] with map ]

Try it online!

C# (Visual C# Interactive Compiler), 108 bytes

x=>new[]{1,2}.Select(n=>x.Select((v,i)=>(v,g:i/3)).GroupBy(y=>y.g,y=>y.v).Count(y=>y.Distinct().Count()==n))

Try it online!

Less golfed...

// x is the input list of ints
x=>x
  // 1 distinct number means 3/3 are the same
  // 2 distinct number means 2/3 are the same
  new[]{1,2}
  // iterate over the outer array to get an index
  .Select(n=>x
    // iterate over the whole list with an index
    // and break into groups of size 3
    .Select((v,i)=>v,g:i/3))
    .GroupBy(y=>y.g,y=>y.v)
     // count the distinct values in each group
     // and get the result based on outer array value
    .Count(y=>y.Distinct().Count()==n))

Ruby, 59 bytes

->a{[1,2].map{|x|a.each_slice(3).count{|y|x==y.uniq.size}}}

Try it online!