g | x | w | all
Bytes Lang Time Link
028Juby250503T020951ZJordan
004Vyxal231016T013629Zlyxal
007Uiua231013T232944Zchunes
005Thunno 2 L230714T085713ZThe Thon
007Pyt230211T173012ZKip the
031Arturo230210T034652Zchunes
005Vyxal221020T170811Zpacman25
006Gaia190330T165658ZGiuseppe
008APL Dyalog Unicode190224T183352ZAdá
071C gcc190322T214628Zatt
018APLNARS190322T055413Zuser5898
005Husk190322T021430ZUnrelate
005Japt x190227T225246ZOliver
039PHP190226T101141ZTitus
007Brachylog190226T084136ZUnrelate
041Haskell190226T071925Zproud ha
005Stax190226T015532Zrecursiv
041Haskell190226T013825Zxnor
067JavaScript Node.js190225T235043ZKamil Na
035Perl 5 ap190225T230420ZXcali
008k190225T215114ZJ. Sendr
006Pyth190225T191727Zuser4854
042Factor190225T191710ZGalen Iv
040C# Visual C# Interactive Compiler190224T190305ZGymhgy
007APL Dyalog Extended190225T072056ZAdá
006Japt190224T230010ZQuintec
112PHP 112 Bytes190225T100413Zrexkogit
008Pyth190225T101758ZSok
005MATL190225T093942ZLuis Men
033PowerShell190225T091454Zmazzy
073Java 8190224T213744ZKevin Cr
009J190224T193022ZGalen Iv
063Python 3190225T060557Zpizzapan
010Pyth190225T045516ZJPeroute
126Rust190225T050207Zdon brig
095C clang190225T000927ZCollin P
034Wolfram Language190224T233921ZDavidC
054Clean190224T221549ZΟurous
019Retina 0.8.2190224T223515ZNeil
042Haskell190224T221637ZLaikoni
093JavaScript Node.js190224T221517ZKamil Na
015Perl 6190224T215842ZJo King
040Element190224T220010ZPhiNotPi
004Jelly190224T213742ZJonathan
038Python 3190224T200758ZKirill L
00405AB1E190224T194316ZEmigna
034Ruby190224T194817ZKirill L
040JavaScript ES6190224T193841ZArnauld
047Haskell190224T192855ZWheat Wi
018Bash + coreutils190224T191913ZDigital
020R190224T183402ZMickyT

J-uby, 28 bytes

:tally|:values|:count+(:<&1)

Attempt This Online!

Vyxal, 4 bytes

Ċċ∑t

Try it Online!

Just another 4 byter

Explained

Ċċ∑t­⁡​‎‎⁡⁠⁡‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁢‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁣‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁤‏‏​⁡⁠⁡‌­
Ċ     # ‎⁡[[item, count(item)] for item in input]
 ċ    # ‎⁢Each item != 1?
  ∑   # ‎⁣Summate. Because this is implemented as reduce by addition, it vectorises element-wise when folding.
   t  # ‎⁤Get the last item of that (the number of counts that != 1)
💎

Created with the help of Luminespire.

Uiua, 7 bytes

/+>1⍘⊚⊛

Try it!

/+>1⍘⊚⊛
      ⊛  # classify (i.e. map integers -> naturals)
    ⍘⊚   # inverse where (occurrences)
  >1     # where are they greater than one?
/+       # sum

Thunno 2 L, 5 bytes

Uæc1Q

Try it online!

Explanation

Uæc1Q  # Implicit input
U      # Uniquify the input
 æ     # Filter it by:
  c    #  Count in the input
   1Q  #  Is not equal to 1
       # Push the length
       # Implicit output

Pyt, 7 bytes

ĐỤ⇹ɔ⁻žŁ

Try it online!

Đ             implicit input; Đuplicate on the stack
 Ụ            get Ụnique elements
  ⇹ɔ          ɔount occurrences of each in original list
    ⁻žŁ       decrement; remove žeros; get Łength; implicit print
 

Arturo, 49 31 bytes

$=>[tally&|enumerate[k,v]->v>1]

Try it

-18 bytes due to Arturo 0.9.83 providing tally and enumerate.

$ => [               ; a function
    tally &          ; create a dictionary of elements and their occurrences from the input
    |                ; then...
    enumerate[k,v]-> ; count the number of key-value pairs where...
    v>1              ; the value (occurrences) is greater than one
]                    ; end function

Vyxal, 5 bytes

UÞ⊍UL

Try it Online!

Typical symmetric difference with the unique values in the list, take the length of the unique values in that list.

Gaia, 6 bytes

e:uDul

Try it online!

e	| eval as a list
 :	| duplicate
  u	| uniquify
   D	| multiset difference; keep only repeated elements
    u	| uniquify
     l	| find length

APL (Dyalog Unicode), 9 8 bytesSBCS

-1 thanks to ngn

Anonymous tacit prefix function.

+/1<⊢∘≢⌸

Try it online!

+/ sum of

1< whether 1 is less than

 for each unique element:

⊢∘ ignoring the actual unique element,

 the count of its occurrences

C (gcc), 71 bytes

f(r,l,t)int*r;{int n[7<<15]={};for(t=0;l;t+=!~n[r[--l]+100000]--);r=t;}

Try it online!

Naive approach. 7<<15=229376.

APL(NARS), 9 chars, 18 bytes

{≢∪⍵∼⍦∪⍵}

test:

  f←{≢∪⍵∼⍦∪⍵}
  f 1 2 2 3 1 1 1 1 1 1
2
  f 234, 2, 12, 234, 5, 10, 1000, 2, 99, 234
2
  f 1, 10, 16, 4, 8, 10, 9, 19, 2, 15, 18, 19, 10, 9, 17, 15, 19, 5, 13, 20
4
  f 11, 8, 6, 15, 9, 19, 2, 2, 4, 19, 14, 19, 13, 12, 16, 13, 0, 5, 0, 8
5

Husk, 5 bytes

LuṠ-u

Try it online!

L        The number of
 u       unique elements of
  Ṡ-u    the input with every unique element removed once.

Japt -x, 5 bytes

ü ®¦q

Run it online

PHP, 39 bytes

a nice occasion to use variable variables:

foreach($argv as$v)$r+=++$$v==2;echo$r;

takes input from command line arguments. Run with -nr or try it online.


$argv[0] is - and that appears only once in the arguments, so it does not affect the result.

Brachylog, 7 bytes

ọzt;1xl

Try it online!

Explanation:

ọ          For every unique element E of the input, [E, how many times E occurs]
 zt        The last elements of the previous value.
   ;1x     With every 1 removed,
      l    how many there are.

Haskell, 41 bytes

f[]=0
f(a:s)=sum[1|filter(==a)s==[a]]+f s

This solution basically counts how many elements of the list have the same element appear exactly once later in the list.

Stax, 5 bytes

ëB♀╡╙

Run and debug it

Haskell, 41 bytes

f(h:t)=sum[1|filter(==h)t==[h]]+f t
f _=0

Try it online!

Count suffixes where the first element h appears exactly once in the part t that comes after.


Haskell, 40 bytes

import Data.List
f l=length$nub$l\\nub l

Try it online!

Stealing the method from other answers.

JavaScript (Node.js), 67 bytes

a=>[...new Set(a.filter(e=>a.indexOf(e)!=a.lastIndexOf(e)))].length

Try it online!

Perl 5 -ap, 35 bytes

map$k{$_}++,@F;$_=grep$_>1,values%k

Try it online!

k, 8 bytes

+/1<#:'=

reads as: sum (length each group) > 1

+/ is sum (plus over)

#:' is length each

= is group (ex. =1 2 1 6 7 2 generates 1 2 6 7!(0 2;1 5;,3;,4) (dictionary of unique value and its positions)

Use example (first test case)

+/1<#:'=1 10 16 4 8 10 9 19 2 15 18 19 10 9 17 15 19 5 13 20

writes 4

Pyth, 6 bytes

l{.-Q{

Try it here

Explanation

l{.-Q{
     {Q   Deduplicate the (implicit) input.
  .-Q     Remove the first instance of each from the input.
l{        Count unique.

Factor, 42 bytes

: d ( x -- ) duplicates members length . ;

Try it online!

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

n=>n.GroupBy(c=>c).Count(c=>c.Count()>1)

The first draft of the spec was unclear, and I thought it mean return all the elements that appear more than once. This is the updated version.

Somehow I didn't notice that my code returned the number of elements that appeared once. Thanks to Paul Karam for catching that!

Try it online!

APL (Dyalog Extended), 8 7 bytesSBCS

Anonymous tacit prefix function using Jonah's method.

+/1<∪⍧⊢

Try it online!

+/ the total number occurrences
  literally the sum of Truths

1< where one is less than

 the unique elements'

 count in

 the unmodified argument

Japt, 12 11 9 8 6 bytes

ü èÈÊÉ

With lots of help from @ASCII-Only, and suggestions from @Shaggy and @Luis felipe De jesus Munoz.

Try it online!

PHP (112 Bytes)

<?php $c=0;foreach(array_count_values(json_decode(file_get_contents('php://stdin'))) as $b)if($b>1)$c++;echo $c;

The assignment does not make it clear if the input is received via Stdin in exactly given format or as separate parameters in Argv, so here is a variant for argv, 91 Bytes:

<?php array_shift($argv);$c=0;foreach(array_count_values($argv) as $b)if($b>1)$c++;echo $c;

Pyth, 8 bytes

lfthTr8S

Try it online here, or verify all the test cases at once here.

MATL, 5 bytes

8#uqz

Try it online! Or verify all test cases.

Explanation

8#u   % Number of ocurrences of each unique value
q     % Subtract 1
z     % Number of nonzeros

PowerShell, 33 bytes

($args|group|?{$_.Count-1}).Count

Try it online!

Java 8, 74 73 bytes

L->L.stream().filter(i->L.indexOf(i)<L.lastIndexOf(i)).distinct().count()

Try it online.

Explanation:

L->                      // Method with ArrayList parameter and integer return-type
  L.stream()             //  Create a stream of the input-list
   .filter(i->           //  Filter it by:
     L.indexOf(i)        //   Where the first index of a value
     <L.lastIndexOf(i))  //   is smaller than the last index of a value
   .distinct()           //  Deduplicate this filtered list
   .count()              //  And return the count of the remaining values

J, 11 9 bytes

-2 bytes thanks to Jonah!

1#.1<1#.=

Try it online!

Original solution:

1#.(1<#)/.~

Try it online!

Explanation:

        /.~   group the list by itself
   (   )      for each group
    1<#       is the length greater than 1
1#.           sum by base-1 conversion

Python 3, 63 bytes

lambda l:len(C(l)-C({*l}))
from collections import Counter as C

Try it online!

Pyth, 10 bytes

lf<1/QT.{Q

Probably a way to golf it, I'm quite rusty with pyth...

Alternate 10 byte version...

lf>lT1.gSk

Try it online!

Rust, 126 bytes

let f=|v:Vec<i32>|{let mut u=v.clone();u.sort();u.dedup();u.iter().filter(|i|v.iter().filter(|n|**n==**i).count()>1).count()};

I give up. This is basically the same as Ruby. There is "another way" creating an array and indexing into it using the values in the input vector, +100000, however the type conversions (as usize / as i32) take up too much space.

C (clang) 175 117 95 bytes

c(*a,*b){return*a-*b;}r(*l,m){qsort(l,m,4,c);return((!m||l[1]-*l)&l[-1]==*l)+(m?r(l+1,m-1):0);}

Try it online!

This is the first time I've submitted one of these, so let me know if there are any issues with formatting or anything.

Updates from the comments:

original submission

Wolfram Language 34 bytes

 Length@DeleteCases[Gather@#,{x_}]&

Gather groups identical integers into lists. DeleteCases[...{x_}] eliminates lists containing a single number. Length returns the number of remaining lists (each containing two or more identical integers.

Clean, 59 54 bytes

import StdEnv,StdLib
$l=sum[1\\[_,_:_]<-group(sort l)]

Try it online!

Sorts the list, groups adjacent equal elements, and counts the number with more than 1 item.

Retina 0.8.2, 19 bytes

O`.+
m`^(.+)(¶\1)+$

Try it online! Link includes test suite which splits each line on commas. Explanation:

O`.+

Sort equal values together.

m`^(.+)(¶\1)+$

Count the number of runs of at least two values.

Haskell, 42 bytes

f s=sum[1|x<-[-9^6..9^6],filter(==x)s>[x]]

Try it online! Abuses the fact the the integers in the list are guaranteed to be within -100k and 100k.

JavaScript (Node.js), 93 bytes

a=>Object.values(a.reduce((a,c)=>Object.assign(a,{[c]:(a[c]|0)+1}),{})).filter(i=>i>1).length

Try it online!

Perl 6, 15 bytes

+*.repeated.Set

Try it online!

Pretty self explanatory. An anonymous code block that gets the count (+) of the Set of elements among the repeated elements of the input (*).

I've realised I've posted almost the exact same solution for a related question.

Element, 40 bytes

_(#'{"2:0+4:'~1+";~2=[''1+""]$2+'[(#]'}`

Try it online!

This requires input to be in a precise format like [234, 2, 1000, 2, 99, 234] (enclosed with [] with a comma and space between integers).

Explanation:

_                                        input
 (#                                      delete the [ at start of input
   '{"                               '}  WHILE the string is non-empty
   '{"2:                             '}    duplicate it
   '{"  0+                           '}    add 0 to coerce to integer (gets next number in array)
   '{"    4:                         '}    make 3 additional copies
   '{"      '                        '}    temporarily move 1 copy to control stack
   '{"       ~                       '}    fetch the current map value for given integer
   '{"        1+                     '}    increment map value
   '{"          "                    '}    retrieve temporary copy of integer (the key for the map)
   '{"           ;                   '}    store updated map value
   '{"            ~                  '}    fetch map value again (1 if 1st instance, 2 if 2nd, etc.)
   '{"             2=                '}    test for map value = 2, this is the first duplication
   '{"               [      ]        '}    IF
   '{"               [''    ]        '}      move stuff from main stack to control stack
   '{"               [  1+  ]        '}      increment the counter of duplicate (bottom of stack)
   '{"               [    ""]        '}      move stuff back to main stack
   '{"                       $       '}    take length of current integer
   '{"                        2+     '}    add 2 (for the comma and space)
   '{"                          '[  ]'}    FOR loop with that number
   '{"                          '[(#]'}      trim those many characters from front of input string
                                       ` output result

Jelly, 4 bytes

ĠITL

Try it online!

...Or ĠIƇL

How?

ĠITL - Link: list of integers   e.g. [234, 2, 12, 234, 5, 10, 1000, 2, 99, 234]
Ġ    - group indices by value        [[2,8],5,6,3,9,[1,4,10],7]
 I   - incremental differences       [[6],[],[],[],[],[3,6],[]]
  T  - truthy indices                [1,6]
   L - length                        2

would filter to keep only truthy results of I ([[6],[3,6]]) which also has the desired length.

Python 3, 38 bytes

lambda a:sum(a.count(x)>1for x in{*a})

Try it online!

05AB1E, 4 bytes

Ù¢≠O

Try it online! or as a Test Suite

Explanation

   O  # sum
  ≠   # the false values
 ¢    # in the count
Ù     # of each unique digit in input

Ruby, 34 bytes

->a{a.uniq.count{|x|a.count(x)>1}}

Try it online!

JavaScript (ES6), 40 bytes

a=>a.map(o=x=>n+=(o[x]=-~o[x])==2,n=0)|n

Try it online!

Haskell, 47 bytes

f[]=0
f(a:b)|x<-filter(/=a)b,x/=b=1+f x|1>0=f b

Try it online!

This is the naïve approach. There is likely something that could be done to improve this.

f[]=0

We return 0 for the empty list

f(a:b)

In the case of a non-empty list starting with a and then b.

|x<-filter(/=a)b,x/=b=1+f x

If filtering a out of b is different from b (that is a is in b) then we return 1 more than f applied to b with the as filtered out.

|1>0=f b

If filtering as doesn't change b then we just run f across the rest.

Here is another similar approach that has the same length:

f[]=0
f(a:b)|elem a b=1+f(filter(/=a)b)|1>0=f b

Try it online!

Bash + coreutils, 18

sort|uniq -d|wc -l

Try it online!

R, 20 bytes

Is this what you are after? Uses table to count the occurrences of each of the scan input values. Tests if count is > 1 and sums the trues.

sum(table(scan())>1)

Try it online!