Count repetitions of an arrayTips for golfing in CNon Unique ElementsLisp Extraction MissionOrdering words to...

What is a good reason for every spaceship to carry gun on board?

What can I do to encourage my players to use their consumables?

Equivalent of "illegal" for violating civil law

I have trouble understanding this fallacy: "If A, then B. Therefore if not-B, then not-A."

How to completely remove a package in Ubuntu (like it never existed)

What is the draw frequency for 3 consecutive games (same players; amateur level)?

Converting very wide logos to square formats

Other than edits for international editions, did Harry Potter and the Philosopher's Stone receive errata?

What are some ways of extending a description of a scenery?

What does an unprocessed RAW file look like?

How can I give a Ranger advantage on a check due to Favored Enemy without spoiling the story for the player?

Modern Algebraic Geometry and Analytic Number Theory

Is there any danger of my neighbor having my wife's signature?

What kind of places would goblins live in a fantasy setting with strong states?

How to write cases in LaTeX?

Coworker asking me to not bring cakes due to self control issue. What should I do?

Case protection with emphasis in biblatex

How bad is a Computer Science course that doesn't teach Design Patterns?

"Starve to death" Vs. "Starve to the point of death"

How to fly a direct entry holding pattern when approaching from an awkward angle?

Prevent Nautilus / Nemo from creating .Trash-1000 folder in mounted devices

Critique vs nitpicking

Buying a "Used" Router

Website seeing my Facebook data?



Count repetitions of an array


Tips for golfing in CNon Unique ElementsLisp Extraction MissionOrdering words to fit in a given stringReverse Deltas of an ArraySort and Re-apply Deltas of an ArrayInterleave numbers from 1 to n, with the same numbers reversedTurn an integer n into a list containing it n timesStretch an arrayFind the Missing Numbers in the Fibonacci Sequence Mod KRebuild a rectangular array from a cornerMost Common Multiple













13












$begingroup$


You will receive an array and must return the number of integers that occur more than once.



[234, 2, 12, 234, 5, 10, 1000, 2, 99, 234]


This will return 2, since each of 234 and 2 appear more than once.



[234, 2, 12, 234]
[2, 12, 234, 5, 10, 1000, 2]


The list will never be more than 100k integers long, and the integers inside the list will always be in between -100k and 100k.



Integers should be counted if they occur more than once, so if an integer occurs 3 times then it will still only count as one repeated integer.



Test cases



[1, 10, 16, 4, 8, 10, 9, 19, 2, 15, 18, 19, 10, 9, 17, 15, 19, 5, 13, 20]  = 4
[11, 8, 6, 15, 9, 19, 2, 2, 4, 19, 14, 19, 13, 12, 16, 13, 0, 5, 0, 8] = 5
[9, 7, 8, 16, 3, 9, 20, 19, 15, 6, 8, 4, 18, 14, 19, 12, 12, 16, 11, 19] = 5
[10, 17, 17, 7, 2, 18, 7, 13, 3, 10, 1, 5, 15, 4, 6, 0, 19, 4, 17, 0] = 5
[12, 7, 17, 13, 5, 3, 4, 15, 20, 15, 5, 18, 18, 18, 4, 8, 15, 13, 11, 13] = 5
[0, 3, 6, 1, 5, 2, 16, 1, 6, 3, 12, 1, 16, 5, 4, 5, 6, 17, 4, 8] = 6
[11, 19, 2, 3, 11, 15, 19, 8, 2, 12, 12, 20, 13, 18, 1, 11, 19, 7, 11, 2] = 4
[6, 4, 11, 14, 17, 3, 17, 11, 2, 16, 14, 1, 2, 1, 15, 15, 12, 10, 11, 13] = 6
[0, 19, 2, 0, 10, 10, 16, 9, 19, 9, 15, 0, 10, 18, 0, 17, 18, 18, 0, 9] = 5
[1, 19, 17, 17, 0, 2, 14, 10, 10, 12, 5, 14, 16, 7, 15, 15, 18, 11, 17, 7] = 5









share|improve this question









New contributor




jayko03 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$












  • $begingroup$
    What do you mean by Once it counts the repetition, don't count again? Also, since we want to find the repetition of a specific integer, how would we know which integer to search for if we are not given it? Lastly, the test cases are a bit confusing; which are output and which are input?
    $endgroup$
    – Embodiment of Ignorance
    20 hours ago








  • 4




    $begingroup$
    I've edited this to try to make it a bit clearer. Is this what you intended? Also, please put answers in for those test cases.
    $endgroup$
    – Riker
    20 hours ago






  • 1




    $begingroup$
    I have added some answers to the test cases, sorry if I go them wrong
    $endgroup$
    – MickyT
    19 hours ago






  • 1




    $begingroup$
    I've voted to close this question until you confirm this is what you intended.
    $endgroup$
    – Riker
    17 hours ago






  • 4




    $begingroup$
    Related (output the non-unique items, instead of the amount of non-unique items).
    $endgroup$
    – Kevin Cruijssen
    17 hours ago


















13












$begingroup$


You will receive an array and must return the number of integers that occur more than once.



[234, 2, 12, 234, 5, 10, 1000, 2, 99, 234]


This will return 2, since each of 234 and 2 appear more than once.



[234, 2, 12, 234]
[2, 12, 234, 5, 10, 1000, 2]


The list will never be more than 100k integers long, and the integers inside the list will always be in between -100k and 100k.



Integers should be counted if they occur more than once, so if an integer occurs 3 times then it will still only count as one repeated integer.



Test cases



[1, 10, 16, 4, 8, 10, 9, 19, 2, 15, 18, 19, 10, 9, 17, 15, 19, 5, 13, 20]  = 4
[11, 8, 6, 15, 9, 19, 2, 2, 4, 19, 14, 19, 13, 12, 16, 13, 0, 5, 0, 8] = 5
[9, 7, 8, 16, 3, 9, 20, 19, 15, 6, 8, 4, 18, 14, 19, 12, 12, 16, 11, 19] = 5
[10, 17, 17, 7, 2, 18, 7, 13, 3, 10, 1, 5, 15, 4, 6, 0, 19, 4, 17, 0] = 5
[12, 7, 17, 13, 5, 3, 4, 15, 20, 15, 5, 18, 18, 18, 4, 8, 15, 13, 11, 13] = 5
[0, 3, 6, 1, 5, 2, 16, 1, 6, 3, 12, 1, 16, 5, 4, 5, 6, 17, 4, 8] = 6
[11, 19, 2, 3, 11, 15, 19, 8, 2, 12, 12, 20, 13, 18, 1, 11, 19, 7, 11, 2] = 4
[6, 4, 11, 14, 17, 3, 17, 11, 2, 16, 14, 1, 2, 1, 15, 15, 12, 10, 11, 13] = 6
[0, 19, 2, 0, 10, 10, 16, 9, 19, 9, 15, 0, 10, 18, 0, 17, 18, 18, 0, 9] = 5
[1, 19, 17, 17, 0, 2, 14, 10, 10, 12, 5, 14, 16, 7, 15, 15, 18, 11, 17, 7] = 5









share|improve this question









New contributor




jayko03 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$












  • $begingroup$
    What do you mean by Once it counts the repetition, don't count again? Also, since we want to find the repetition of a specific integer, how would we know which integer to search for if we are not given it? Lastly, the test cases are a bit confusing; which are output and which are input?
    $endgroup$
    – Embodiment of Ignorance
    20 hours ago








  • 4




    $begingroup$
    I've edited this to try to make it a bit clearer. Is this what you intended? Also, please put answers in for those test cases.
    $endgroup$
    – Riker
    20 hours ago






  • 1




    $begingroup$
    I have added some answers to the test cases, sorry if I go them wrong
    $endgroup$
    – MickyT
    19 hours ago






  • 1




    $begingroup$
    I've voted to close this question until you confirm this is what you intended.
    $endgroup$
    – Riker
    17 hours ago






  • 4




    $begingroup$
    Related (output the non-unique items, instead of the amount of non-unique items).
    $endgroup$
    – Kevin Cruijssen
    17 hours ago
















13












13








13





$begingroup$


You will receive an array and must return the number of integers that occur more than once.



[234, 2, 12, 234, 5, 10, 1000, 2, 99, 234]


This will return 2, since each of 234 and 2 appear more than once.



[234, 2, 12, 234]
[2, 12, 234, 5, 10, 1000, 2]


The list will never be more than 100k integers long, and the integers inside the list will always be in between -100k and 100k.



Integers should be counted if they occur more than once, so if an integer occurs 3 times then it will still only count as one repeated integer.



Test cases



[1, 10, 16, 4, 8, 10, 9, 19, 2, 15, 18, 19, 10, 9, 17, 15, 19, 5, 13, 20]  = 4
[11, 8, 6, 15, 9, 19, 2, 2, 4, 19, 14, 19, 13, 12, 16, 13, 0, 5, 0, 8] = 5
[9, 7, 8, 16, 3, 9, 20, 19, 15, 6, 8, 4, 18, 14, 19, 12, 12, 16, 11, 19] = 5
[10, 17, 17, 7, 2, 18, 7, 13, 3, 10, 1, 5, 15, 4, 6, 0, 19, 4, 17, 0] = 5
[12, 7, 17, 13, 5, 3, 4, 15, 20, 15, 5, 18, 18, 18, 4, 8, 15, 13, 11, 13] = 5
[0, 3, 6, 1, 5, 2, 16, 1, 6, 3, 12, 1, 16, 5, 4, 5, 6, 17, 4, 8] = 6
[11, 19, 2, 3, 11, 15, 19, 8, 2, 12, 12, 20, 13, 18, 1, 11, 19, 7, 11, 2] = 4
[6, 4, 11, 14, 17, 3, 17, 11, 2, 16, 14, 1, 2, 1, 15, 15, 12, 10, 11, 13] = 6
[0, 19, 2, 0, 10, 10, 16, 9, 19, 9, 15, 0, 10, 18, 0, 17, 18, 18, 0, 9] = 5
[1, 19, 17, 17, 0, 2, 14, 10, 10, 12, 5, 14, 16, 7, 15, 15, 18, 11, 17, 7] = 5









share|improve this question









New contributor




jayko03 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




You will receive an array and must return the number of integers that occur more than once.



[234, 2, 12, 234, 5, 10, 1000, 2, 99, 234]


This will return 2, since each of 234 and 2 appear more than once.



[234, 2, 12, 234]
[2, 12, 234, 5, 10, 1000, 2]


The list will never be more than 100k integers long, and the integers inside the list will always be in between -100k and 100k.



Integers should be counted if they occur more than once, so if an integer occurs 3 times then it will still only count as one repeated integer.



Test cases



[1, 10, 16, 4, 8, 10, 9, 19, 2, 15, 18, 19, 10, 9, 17, 15, 19, 5, 13, 20]  = 4
[11, 8, 6, 15, 9, 19, 2, 2, 4, 19, 14, 19, 13, 12, 16, 13, 0, 5, 0, 8] = 5
[9, 7, 8, 16, 3, 9, 20, 19, 15, 6, 8, 4, 18, 14, 19, 12, 12, 16, 11, 19] = 5
[10, 17, 17, 7, 2, 18, 7, 13, 3, 10, 1, 5, 15, 4, 6, 0, 19, 4, 17, 0] = 5
[12, 7, 17, 13, 5, 3, 4, 15, 20, 15, 5, 18, 18, 18, 4, 8, 15, 13, 11, 13] = 5
[0, 3, 6, 1, 5, 2, 16, 1, 6, 3, 12, 1, 16, 5, 4, 5, 6, 17, 4, 8] = 6
[11, 19, 2, 3, 11, 15, 19, 8, 2, 12, 12, 20, 13, 18, 1, 11, 19, 7, 11, 2] = 4
[6, 4, 11, 14, 17, 3, 17, 11, 2, 16, 14, 1, 2, 1, 15, 15, 12, 10, 11, 13] = 6
[0, 19, 2, 0, 10, 10, 16, 9, 19, 9, 15, 0, 10, 18, 0, 17, 18, 18, 0, 9] = 5
[1, 19, 17, 17, 0, 2, 14, 10, 10, 12, 5, 14, 16, 7, 15, 15, 18, 11, 17, 7] = 5






code-golf array-manipulation






share|improve this question









New contributor




jayko03 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




jayko03 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 17 hours ago









Jonathan Allan

52.3k535170




52.3k535170






New contributor




jayko03 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 20 hours ago









jayko03jayko03

1664




1664




New contributor




jayko03 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





jayko03 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






jayko03 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • $begingroup$
    What do you mean by Once it counts the repetition, don't count again? Also, since we want to find the repetition of a specific integer, how would we know which integer to search for if we are not given it? Lastly, the test cases are a bit confusing; which are output and which are input?
    $endgroup$
    – Embodiment of Ignorance
    20 hours ago








  • 4




    $begingroup$
    I've edited this to try to make it a bit clearer. Is this what you intended? Also, please put answers in for those test cases.
    $endgroup$
    – Riker
    20 hours ago






  • 1




    $begingroup$
    I have added some answers to the test cases, sorry if I go them wrong
    $endgroup$
    – MickyT
    19 hours ago






  • 1




    $begingroup$
    I've voted to close this question until you confirm this is what you intended.
    $endgroup$
    – Riker
    17 hours ago






  • 4




    $begingroup$
    Related (output the non-unique items, instead of the amount of non-unique items).
    $endgroup$
    – Kevin Cruijssen
    17 hours ago




















  • $begingroup$
    What do you mean by Once it counts the repetition, don't count again? Also, since we want to find the repetition of a specific integer, how would we know which integer to search for if we are not given it? Lastly, the test cases are a bit confusing; which are output and which are input?
    $endgroup$
    – Embodiment of Ignorance
    20 hours ago








  • 4




    $begingroup$
    I've edited this to try to make it a bit clearer. Is this what you intended? Also, please put answers in for those test cases.
    $endgroup$
    – Riker
    20 hours ago






  • 1




    $begingroup$
    I have added some answers to the test cases, sorry if I go them wrong
    $endgroup$
    – MickyT
    19 hours ago






  • 1




    $begingroup$
    I've voted to close this question until you confirm this is what you intended.
    $endgroup$
    – Riker
    17 hours ago






  • 4




    $begingroup$
    Related (output the non-unique items, instead of the amount of non-unique items).
    $endgroup$
    – Kevin Cruijssen
    17 hours ago


















$begingroup$
What do you mean by Once it counts the repetition, don't count again? Also, since we want to find the repetition of a specific integer, how would we know which integer to search for if we are not given it? Lastly, the test cases are a bit confusing; which are output and which are input?
$endgroup$
– Embodiment of Ignorance
20 hours ago






$begingroup$
What do you mean by Once it counts the repetition, don't count again? Also, since we want to find the repetition of a specific integer, how would we know which integer to search for if we are not given it? Lastly, the test cases are a bit confusing; which are output and which are input?
$endgroup$
– Embodiment of Ignorance
20 hours ago






4




4




$begingroup$
I've edited this to try to make it a bit clearer. Is this what you intended? Also, please put answers in for those test cases.
$endgroup$
– Riker
20 hours ago




$begingroup$
I've edited this to try to make it a bit clearer. Is this what you intended? Also, please put answers in for those test cases.
$endgroup$
– Riker
20 hours ago




1




1




$begingroup$
I have added some answers to the test cases, sorry if I go them wrong
$endgroup$
– MickyT
19 hours ago




$begingroup$
I have added some answers to the test cases, sorry if I go them wrong
$endgroup$
– MickyT
19 hours ago




1




1




$begingroup$
I've voted to close this question until you confirm this is what you intended.
$endgroup$
– Riker
17 hours ago




$begingroup$
I've voted to close this question until you confirm this is what you intended.
$endgroup$
– Riker
17 hours ago




4




4




$begingroup$
Related (output the non-unique items, instead of the amount of non-unique items).
$endgroup$
– Kevin Cruijssen
17 hours ago






$begingroup$
Related (output the non-unique items, instead of the amount of non-unique items).
$endgroup$
– Kevin Cruijssen
17 hours ago












31 Answers
31






active

oldest

votes













1 2
next












10












$begingroup$


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!






share|improve this answer









$endgroup$





















    6












    $begingroup$


    APL (Dyalog Unicode), 9 bytesSBCS





    Anonymous tacit prefix function.



    +/{1<≢⍵}⌸


    Try it online!



    +/ sum of



    {}⌸ for each unique element:



    1< whether 1 is less than



    ≢⍵ the count of occurrences






    share|improve this answer











    $endgroup$





















      6












      $begingroup$


      Bash + coreutils, 18





      sort|uniq -d|wc -l


      Try it online!






      share|improve this answer









      $endgroup$





















        4












        $begingroup$


        Python 3, 38 bytes





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


        Try it online!






        share|improve this answer









        $endgroup$





















          4












          $begingroup$


          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.






          share|improve this answer









          $endgroup$





















            4












            $begingroup$


            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:




            • -58 to 117 bytes from Jo King

            • -80 to 95 bytes from ASCII-only


            original submission






            share|improve this answer










            New contributor




            Collin Phillips is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.






            $endgroup$









            • 5




              $begingroup$
              Welcome, nice start. I'm not a C person but here's a link to a tips for golfing C page
              $endgroup$
              – MickyT
              14 hours ago






            • 2




              $begingroup$
              117 bytes => d,i;c(*a,*b){return*a-*b;}r(l[],m){qsort(l,m,4,c);for(i=d=0;++i<m;)d+=((l[i+1]-l[i]||i>m-2)&&l[i-1]==l[i]);return d;}. As @ASCII-only noted, the includes don't affect the compilation of your program
              $endgroup$
              – Jo King
              14 hours ago








            • 2




              $begingroup$
              @JoKing 100: d;c(*a,*b){return*a-*b;}r(*l,m){qsort(l,m,4,c);for(d=0;~m--;)d+=(!m||l[1]-*l)&l[-1]==*l++;return d;}
              $endgroup$
              – ASCII-only
              14 hours ago








            • 1




              $begingroup$
              @CollinPhillips yes. as you can see in the link i posted, it still compiles fine without the includes
              $endgroup$
              – ASCII-only
              14 hours ago






            • 2




              $begingroup$
              95: 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);}
              $endgroup$
              – ASCII-only
              13 hours ago



















            4












            $begingroup$


            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





            share|improve this answer











            $endgroup$













            • $begingroup$
              Hey Galen. 1#.1<1#.= for 9 bytes + good ol' self-classify fun.
              $endgroup$
              – Jonah
              15 hours ago






            • 1




              $begingroup$
              @Jonah Thanks! Honestly, I wasn't aware of this.
              $endgroup$
              – Galen Ivanov
              7 hours ago






            • 1




              $begingroup$
              @Jonah Nice!
              $endgroup$
              – Adám
              7 hours ago



















            3












            $begingroup$


            Ruby, 34 bytes





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


            Try it online!






            share|improve this answer









            $endgroup$





















              3












              $begingroup$


              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.






              share|improve this answer











              $endgroup$





















                3












                $begingroup$


                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.






                share|improve this answer











                $endgroup$





















                  3












                  $begingroup$


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





                  n=>n.GroupBy(c=>c).Count(c=>c.Count()<2)


                  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.



                  Try it online!






                  share|improve this answer











                  $endgroup$









                  • 1




                    $begingroup$
                    Your output is wrong, it needs to count the elements with 2 or more occurences. It should be n=>n.GroupBy(c=>c).Count(c=>c.Count()>=2). The OP says the answer of this list is 2. Your code returns 5. The change I gave you returns 2.
                    $endgroup$
                    – Paul Karam
                    8 hours ago






                  • 1




                    $begingroup$
                    Or just >1 to keep the 40 bytes count
                    $endgroup$
                    – Paul Karam
                    7 hours ago



















                  2












                  $begingroup$


                  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





                  share|improve this answer











                  $endgroup$













                  • $begingroup$
                    So all values that are not 1 are false?
                    $endgroup$
                    – Adám
                    18 hours ago










                  • $begingroup$
                    @Adám: Yes, that is correct.
                    $endgroup$
                    – Emigna
                    17 hours ago



















                  2












                  $begingroup$

                  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





                  share|improve this answer











                  $endgroup$





















                    2












                    $begingroup$


                    APL (Dyalog Extended), 8 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






                    share|improve this answer











                    $endgroup$





















                      2












                      $begingroup$


                      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!






                      share|improve this answer











                      $endgroup$













                      • $begingroup$
                        11
                        $endgroup$
                        – ASCII-only
                        15 hours ago










                      • $begingroup$
                        9 9 9?
                        $endgroup$
                        – ASCII-only
                        15 hours ago












                      • $begingroup$
                        8 8
                        $endgroup$
                        – ASCII-only
                        15 hours ago








                      • 2




                        $begingroup$
                        6
                        $endgroup$
                        – ASCII-only
                        15 hours ago






                      • 2




                        $begingroup$
                        6 6
                        $endgroup$
                        – ASCII-only
                        14 hours ago





















                      1












                      $begingroup$


                      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!






                      share|improve this answer









                      $endgroup$





















                        1












                        $begingroup$


                        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





                        share|improve this answer









                        $endgroup$





















                          1












                          $begingroup$


                          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.






                          share|improve this answer









                          $endgroup$





















                            1












                            $begingroup$


                            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.






                            share|improve this answer











                            $endgroup$





















                              1












                              $begingroup$

                              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.






                              share|improve this answer









                              $endgroup$





















                                0












                                $begingroup$

                                JavaScript (ES6), 40 bytes





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


                                Try it online!






                                share|improve this answer









                                $endgroup$





















                                  0












                                  $begingroup$


                                  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!






                                  share|improve this answer








                                  New contributor




                                  Kamil Naja is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                  Check out our Code of Conduct.






                                  $endgroup$





















                                    0












                                    $begingroup$

                                    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.






                                    share|improve this answer









                                    $endgroup$





















                                      0












                                      $begingroup$


                                      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!






                                      share|improve this answer











                                      $endgroup$





















                                        0












                                        $begingroup$


                                        Python 3, 63 bytes





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


                                        Try it online!






                                        share|improve this answer









                                        $endgroup$





















                                          0












                                          $begingroup$


                                          PowerShell, 33 bytes





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


                                          Try it online!






                                          share|improve this answer









                                          $endgroup$





















                                            0












                                            $begingroup$


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





                                            arr.GroupBy(x=>x).Where(y=>y.Count()>1).Select(y=>y.Key).Count()


                                            Try it online!






                                            share|improve this answer










                                            New contributor




                                            D T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                            Check out our Code of Conduct.






                                            $endgroup$













                                            • $begingroup$
                                              Hello, and welcome to PPCG! You've answered with a snippet, whereas we only accept functions and programs by default so please adjust to one of those formats. You can also golf your code further by removing the extra spaces (eg: > 1 becomes >1).
                                              $endgroup$
                                              – Οurous
                                              9 hours ago










                                            • $begingroup$
                                              Hey @Οurous, thank you for informing me. I have updated my answer. Would you mind checking it again...
                                              $endgroup$
                                              – D T
                                              7 hours ago










                                            • $begingroup$
                                              no, input can't be a predefined variable. Surely it wouldn't cost any bytes to turn it into an anonymous function?
                                              $endgroup$
                                              – Jo King
                                              7 hours ago



















                                            0












                                            $begingroup$


                                            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





                                            share|improve this answer











                                            $endgroup$





















                                              0












                                              $begingroup$

                                              Pyth, 8 bytes



                                              lfthTr8S


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






                                              share|improve this answer









                                              $endgroup$





















                                                0












                                                $begingroup$

                                                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;





                                                share|improve this answer











                                                $endgroup$













                                                • $begingroup$
                                                  Yes, you can take input via the command line arguments (as per standard IO formats). Though wouldn't there be problems if the filename was numerical?
                                                  $endgroup$
                                                  – Jo King
                                                  4 hours ago










                                                • $begingroup$
                                                  @JoKing Sure, I fixed it.
                                                  $endgroup$
                                                  – rexkogitans
                                                  4 hours ago















                                                1 2
                                                next



                                                Your Answer





                                                StackExchange.ifUsing("editor", function () {
                                                return StackExchange.using("mathjaxEditing", function () {
                                                StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
                                                StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
                                                });
                                                });
                                                }, "mathjax-editing");

                                                StackExchange.ifUsing("editor", function () {
                                                StackExchange.using("externalEditor", function () {
                                                StackExchange.using("snippets", function () {
                                                StackExchange.snippets.init();
                                                });
                                                });
                                                }, "code-snippets");

                                                StackExchange.ready(function() {
                                                var channelOptions = {
                                                tags: "".split(" "),
                                                id: "200"
                                                };
                                                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                                                StackExchange.using("externalEditor", function() {
                                                // Have to fire editor after snippets, if snippets enabled
                                                if (StackExchange.settings.snippets.snippetsEnabled) {
                                                StackExchange.using("snippets", function() {
                                                createEditor();
                                                });
                                                }
                                                else {
                                                createEditor();
                                                }
                                                });

                                                function createEditor() {
                                                StackExchange.prepareEditor({
                                                heartbeatType: 'answer',
                                                autoActivateHeartbeat: false,
                                                convertImagesToLinks: false,
                                                noModals: true,
                                                showLowRepImageUploadWarning: true,
                                                reputationToPostImages: null,
                                                bindNavPrevention: true,
                                                postfix: "",
                                                imageUploader: {
                                                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                                                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                                                allowUrls: true
                                                },
                                                onDemand: true,
                                                discardSelector: ".discard-answer"
                                                ,immediatelyShowMarkdownHelp:true
                                                });


                                                }
                                                });






                                                jayko03 is a new contributor. Be nice, and check out our Code of Conduct.










                                                draft saved

                                                draft discarded


















                                                StackExchange.ready(
                                                function () {
                                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f180302%2fcount-repetitions-of-an-array%23new-answer', 'question_page');
                                                }
                                                );

                                                Post as a guest















                                                Required, but never shown

























                                                31 Answers
                                                31






                                                active

                                                oldest

                                                votes








                                                31 Answers
                                                31






                                                active

                                                oldest

                                                votes









                                                active

                                                oldest

                                                votes






                                                active

                                                oldest

                                                votes








                                                1 2
                                                next










                                                10












                                                $begingroup$


                                                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!






                                                share|improve this answer









                                                $endgroup$


















                                                  10












                                                  $begingroup$


                                                  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!






                                                  share|improve this answer









                                                  $endgroup$
















                                                    10












                                                    10








                                                    10





                                                    $begingroup$


                                                    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!






                                                    share|improve this answer









                                                    $endgroup$




                                                    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!







                                                    share|improve this answer












                                                    share|improve this answer



                                                    share|improve this answer










                                                    answered 20 hours ago









                                                    MickyTMickyT

                                                    10.1k21637




                                                    10.1k21637























                                                        6












                                                        $begingroup$


                                                        APL (Dyalog Unicode), 9 bytesSBCS





                                                        Anonymous tacit prefix function.



                                                        +/{1<≢⍵}⌸


                                                        Try it online!



                                                        +/ sum of



                                                        {}⌸ for each unique element:



                                                        1< whether 1 is less than



                                                        ≢⍵ the count of occurrences






                                                        share|improve this answer











                                                        $endgroup$


















                                                          6












                                                          $begingroup$


                                                          APL (Dyalog Unicode), 9 bytesSBCS





                                                          Anonymous tacit prefix function.



                                                          +/{1<≢⍵}⌸


                                                          Try it online!



                                                          +/ sum of



                                                          {}⌸ for each unique element:



                                                          1< whether 1 is less than



                                                          ≢⍵ the count of occurrences






                                                          share|improve this answer











                                                          $endgroup$
















                                                            6












                                                            6








                                                            6





                                                            $begingroup$


                                                            APL (Dyalog Unicode), 9 bytesSBCS





                                                            Anonymous tacit prefix function.



                                                            +/{1<≢⍵}⌸


                                                            Try it online!



                                                            +/ sum of



                                                            {}⌸ for each unique element:



                                                            1< whether 1 is less than



                                                            ≢⍵ the count of occurrences






                                                            share|improve this answer











                                                            $endgroup$




                                                            APL (Dyalog Unicode), 9 bytesSBCS





                                                            Anonymous tacit prefix function.



                                                            +/{1<≢⍵}⌸


                                                            Try it online!



                                                            +/ sum of



                                                            {}⌸ for each unique element:



                                                            1< whether 1 is less than



                                                            ≢⍵ the count of occurrences







                                                            share|improve this answer














                                                            share|improve this answer



                                                            share|improve this answer








                                                            edited 20 hours ago

























                                                            answered 20 hours ago









                                                            AdámAdám

                                                            28.3k274201




                                                            28.3k274201























                                                                6












                                                                $begingroup$


                                                                Bash + coreutils, 18





                                                                sort|uniq -d|wc -l


                                                                Try it online!






                                                                share|improve this answer









                                                                $endgroup$


















                                                                  6












                                                                  $begingroup$


                                                                  Bash + coreutils, 18





                                                                  sort|uniq -d|wc -l


                                                                  Try it online!






                                                                  share|improve this answer









                                                                  $endgroup$
















                                                                    6












                                                                    6








                                                                    6





                                                                    $begingroup$


                                                                    Bash + coreutils, 18





                                                                    sort|uniq -d|wc -l


                                                                    Try it online!






                                                                    share|improve this answer









                                                                    $endgroup$




                                                                    Bash + coreutils, 18





                                                                    sort|uniq -d|wc -l


                                                                    Try it online!







                                                                    share|improve this answer












                                                                    share|improve this answer



                                                                    share|improve this answer










                                                                    answered 19 hours ago









                                                                    Digital TraumaDigital Trauma

                                                                    59.2k787224




                                                                    59.2k787224























                                                                        4












                                                                        $begingroup$


                                                                        Python 3, 38 bytes





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


                                                                        Try it online!






                                                                        share|improve this answer









                                                                        $endgroup$


















                                                                          4












                                                                          $begingroup$


                                                                          Python 3, 38 bytes





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


                                                                          Try it online!






                                                                          share|improve this answer









                                                                          $endgroup$
















                                                                            4












                                                                            4








                                                                            4





                                                                            $begingroup$


                                                                            Python 3, 38 bytes





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


                                                                            Try it online!






                                                                            share|improve this answer









                                                                            $endgroup$




                                                                            Python 3, 38 bytes





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


                                                                            Try it online!







                                                                            share|improve this answer












                                                                            share|improve this answer



                                                                            share|improve this answer










                                                                            answered 18 hours ago









                                                                            Kirill L.Kirill L.

                                                                            4,6051523




                                                                            4,6051523























                                                                                4












                                                                                $begingroup$


                                                                                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.






                                                                                share|improve this answer









                                                                                $endgroup$


















                                                                                  4












                                                                                  $begingroup$


                                                                                  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.






                                                                                  share|improve this answer









                                                                                  $endgroup$
















                                                                                    4












                                                                                    4








                                                                                    4





                                                                                    $begingroup$


                                                                                    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.






                                                                                    share|improve this answer









                                                                                    $endgroup$




                                                                                    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.







                                                                                    share|improve this answer












                                                                                    share|improve this answer



                                                                                    share|improve this answer










                                                                                    answered 16 hours ago









                                                                                    LaikoniLaikoni

                                                                                    19.9k436100




                                                                                    19.9k436100























                                                                                        4












                                                                                        $begingroup$


                                                                                        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:




                                                                                        • -58 to 117 bytes from Jo King

                                                                                        • -80 to 95 bytes from ASCII-only


                                                                                        original submission






                                                                                        share|improve this answer










                                                                                        New contributor




                                                                                        Collin Phillips is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                        Check out our Code of Conduct.






                                                                                        $endgroup$









                                                                                        • 5




                                                                                          $begingroup$
                                                                                          Welcome, nice start. I'm not a C person but here's a link to a tips for golfing C page
                                                                                          $endgroup$
                                                                                          – MickyT
                                                                                          14 hours ago






                                                                                        • 2




                                                                                          $begingroup$
                                                                                          117 bytes => d,i;c(*a,*b){return*a-*b;}r(l[],m){qsort(l,m,4,c);for(i=d=0;++i<m;)d+=((l[i+1]-l[i]||i>m-2)&&l[i-1]==l[i]);return d;}. As @ASCII-only noted, the includes don't affect the compilation of your program
                                                                                          $endgroup$
                                                                                          – Jo King
                                                                                          14 hours ago








                                                                                        • 2




                                                                                          $begingroup$
                                                                                          @JoKing 100: d;c(*a,*b){return*a-*b;}r(*l,m){qsort(l,m,4,c);for(d=0;~m--;)d+=(!m||l[1]-*l)&l[-1]==*l++;return d;}
                                                                                          $endgroup$
                                                                                          – ASCII-only
                                                                                          14 hours ago








                                                                                        • 1




                                                                                          $begingroup$
                                                                                          @CollinPhillips yes. as you can see in the link i posted, it still compiles fine without the includes
                                                                                          $endgroup$
                                                                                          – ASCII-only
                                                                                          14 hours ago






                                                                                        • 2




                                                                                          $begingroup$
                                                                                          95: 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);}
                                                                                          $endgroup$
                                                                                          – ASCII-only
                                                                                          13 hours ago
















                                                                                        4












                                                                                        $begingroup$


                                                                                        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:




                                                                                        • -58 to 117 bytes from Jo King

                                                                                        • -80 to 95 bytes from ASCII-only


                                                                                        original submission






                                                                                        share|improve this answer










                                                                                        New contributor




                                                                                        Collin Phillips is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                        Check out our Code of Conduct.






                                                                                        $endgroup$









                                                                                        • 5




                                                                                          $begingroup$
                                                                                          Welcome, nice start. I'm not a C person but here's a link to a tips for golfing C page
                                                                                          $endgroup$
                                                                                          – MickyT
                                                                                          14 hours ago






                                                                                        • 2




                                                                                          $begingroup$
                                                                                          117 bytes => d,i;c(*a,*b){return*a-*b;}r(l[],m){qsort(l,m,4,c);for(i=d=0;++i<m;)d+=((l[i+1]-l[i]||i>m-2)&&l[i-1]==l[i]);return d;}. As @ASCII-only noted, the includes don't affect the compilation of your program
                                                                                          $endgroup$
                                                                                          – Jo King
                                                                                          14 hours ago








                                                                                        • 2




                                                                                          $begingroup$
                                                                                          @JoKing 100: d;c(*a,*b){return*a-*b;}r(*l,m){qsort(l,m,4,c);for(d=0;~m--;)d+=(!m||l[1]-*l)&l[-1]==*l++;return d;}
                                                                                          $endgroup$
                                                                                          – ASCII-only
                                                                                          14 hours ago








                                                                                        • 1




                                                                                          $begingroup$
                                                                                          @CollinPhillips yes. as you can see in the link i posted, it still compiles fine without the includes
                                                                                          $endgroup$
                                                                                          – ASCII-only
                                                                                          14 hours ago






                                                                                        • 2




                                                                                          $begingroup$
                                                                                          95: 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);}
                                                                                          $endgroup$
                                                                                          – ASCII-only
                                                                                          13 hours ago














                                                                                        4












                                                                                        4








                                                                                        4





                                                                                        $begingroup$


                                                                                        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:




                                                                                        • -58 to 117 bytes from Jo King

                                                                                        • -80 to 95 bytes from ASCII-only


                                                                                        original submission






                                                                                        share|improve this answer










                                                                                        New contributor




                                                                                        Collin Phillips is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                        Check out our Code of Conduct.






                                                                                        $endgroup$




                                                                                        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:




                                                                                        • -58 to 117 bytes from Jo King

                                                                                        • -80 to 95 bytes from ASCII-only


                                                                                        original submission







                                                                                        share|improve this answer










                                                                                        New contributor




                                                                                        Collin Phillips is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                        Check out our Code of Conduct.









                                                                                        share|improve this answer



                                                                                        share|improve this answer








                                                                                        edited 13 hours ago





















                                                                                        New contributor




                                                                                        Collin Phillips is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                        Check out our Code of Conduct.









                                                                                        answered 14 hours ago









                                                                                        Collin PhillipsCollin Phillips

                                                                                        412




                                                                                        412




                                                                                        New contributor




                                                                                        Collin Phillips is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                        Check out our Code of Conduct.





                                                                                        New contributor





                                                                                        Collin Phillips is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                        Check out our Code of Conduct.






                                                                                        Collin Phillips is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                        Check out our Code of Conduct.








                                                                                        • 5




                                                                                          $begingroup$
                                                                                          Welcome, nice start. I'm not a C person but here's a link to a tips for golfing C page
                                                                                          $endgroup$
                                                                                          – MickyT
                                                                                          14 hours ago






                                                                                        • 2




                                                                                          $begingroup$
                                                                                          117 bytes => d,i;c(*a,*b){return*a-*b;}r(l[],m){qsort(l,m,4,c);for(i=d=0;++i<m;)d+=((l[i+1]-l[i]||i>m-2)&&l[i-1]==l[i]);return d;}. As @ASCII-only noted, the includes don't affect the compilation of your program
                                                                                          $endgroup$
                                                                                          – Jo King
                                                                                          14 hours ago








                                                                                        • 2




                                                                                          $begingroup$
                                                                                          @JoKing 100: d;c(*a,*b){return*a-*b;}r(*l,m){qsort(l,m,4,c);for(d=0;~m--;)d+=(!m||l[1]-*l)&l[-1]==*l++;return d;}
                                                                                          $endgroup$
                                                                                          – ASCII-only
                                                                                          14 hours ago








                                                                                        • 1




                                                                                          $begingroup$
                                                                                          @CollinPhillips yes. as you can see in the link i posted, it still compiles fine without the includes
                                                                                          $endgroup$
                                                                                          – ASCII-only
                                                                                          14 hours ago






                                                                                        • 2




                                                                                          $begingroup$
                                                                                          95: 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);}
                                                                                          $endgroup$
                                                                                          – ASCII-only
                                                                                          13 hours ago














                                                                                        • 5




                                                                                          $begingroup$
                                                                                          Welcome, nice start. I'm not a C person but here's a link to a tips for golfing C page
                                                                                          $endgroup$
                                                                                          – MickyT
                                                                                          14 hours ago






                                                                                        • 2




                                                                                          $begingroup$
                                                                                          117 bytes => d,i;c(*a,*b){return*a-*b;}r(l[],m){qsort(l,m,4,c);for(i=d=0;++i<m;)d+=((l[i+1]-l[i]||i>m-2)&&l[i-1]==l[i]);return d;}. As @ASCII-only noted, the includes don't affect the compilation of your program
                                                                                          $endgroup$
                                                                                          – Jo King
                                                                                          14 hours ago








                                                                                        • 2




                                                                                          $begingroup$
                                                                                          @JoKing 100: d;c(*a,*b){return*a-*b;}r(*l,m){qsort(l,m,4,c);for(d=0;~m--;)d+=(!m||l[1]-*l)&l[-1]==*l++;return d;}
                                                                                          $endgroup$
                                                                                          – ASCII-only
                                                                                          14 hours ago








                                                                                        • 1




                                                                                          $begingroup$
                                                                                          @CollinPhillips yes. as you can see in the link i posted, it still compiles fine without the includes
                                                                                          $endgroup$
                                                                                          – ASCII-only
                                                                                          14 hours ago






                                                                                        • 2




                                                                                          $begingroup$
                                                                                          95: 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);}
                                                                                          $endgroup$
                                                                                          – ASCII-only
                                                                                          13 hours ago








                                                                                        5




                                                                                        5




                                                                                        $begingroup$
                                                                                        Welcome, nice start. I'm not a C person but here's a link to a tips for golfing C page
                                                                                        $endgroup$
                                                                                        – MickyT
                                                                                        14 hours ago




                                                                                        $begingroup$
                                                                                        Welcome, nice start. I'm not a C person but here's a link to a tips for golfing C page
                                                                                        $endgroup$
                                                                                        – MickyT
                                                                                        14 hours ago




                                                                                        2




                                                                                        2




                                                                                        $begingroup$
                                                                                        117 bytes => d,i;c(*a,*b){return*a-*b;}r(l[],m){qsort(l,m,4,c);for(i=d=0;++i<m;)d+=((l[i+1]-l[i]||i>m-2)&&l[i-1]==l[i]);return d;}. As @ASCII-only noted, the includes don't affect the compilation of your program
                                                                                        $endgroup$
                                                                                        – Jo King
                                                                                        14 hours ago






                                                                                        $begingroup$
                                                                                        117 bytes => d,i;c(*a,*b){return*a-*b;}r(l[],m){qsort(l,m,4,c);for(i=d=0;++i<m;)d+=((l[i+1]-l[i]||i>m-2)&&l[i-1]==l[i]);return d;}. As @ASCII-only noted, the includes don't affect the compilation of your program
                                                                                        $endgroup$
                                                                                        – Jo King
                                                                                        14 hours ago






                                                                                        2




                                                                                        2




                                                                                        $begingroup$
                                                                                        @JoKing 100: d;c(*a,*b){return*a-*b;}r(*l,m){qsort(l,m,4,c);for(d=0;~m--;)d+=(!m||l[1]-*l)&l[-1]==*l++;return d;}
                                                                                        $endgroup$
                                                                                        – ASCII-only
                                                                                        14 hours ago






                                                                                        $begingroup$
                                                                                        @JoKing 100: d;c(*a,*b){return*a-*b;}r(*l,m){qsort(l,m,4,c);for(d=0;~m--;)d+=(!m||l[1]-*l)&l[-1]==*l++;return d;}
                                                                                        $endgroup$
                                                                                        – ASCII-only
                                                                                        14 hours ago






                                                                                        1




                                                                                        1




                                                                                        $begingroup$
                                                                                        @CollinPhillips yes. as you can see in the link i posted, it still compiles fine without the includes
                                                                                        $endgroup$
                                                                                        – ASCII-only
                                                                                        14 hours ago




                                                                                        $begingroup$
                                                                                        @CollinPhillips yes. as you can see in the link i posted, it still compiles fine without the includes
                                                                                        $endgroup$
                                                                                        – ASCII-only
                                                                                        14 hours ago




                                                                                        2




                                                                                        2




                                                                                        $begingroup$
                                                                                        95: 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);}
                                                                                        $endgroup$
                                                                                        – ASCII-only
                                                                                        13 hours ago




                                                                                        $begingroup$
                                                                                        95: 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);}
                                                                                        $endgroup$
                                                                                        – ASCII-only
                                                                                        13 hours ago











                                                                                        4












                                                                                        $begingroup$


                                                                                        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





                                                                                        share|improve this answer











                                                                                        $endgroup$













                                                                                        • $begingroup$
                                                                                          Hey Galen. 1#.1<1#.= for 9 bytes + good ol' self-classify fun.
                                                                                          $endgroup$
                                                                                          – Jonah
                                                                                          15 hours ago






                                                                                        • 1




                                                                                          $begingroup$
                                                                                          @Jonah Thanks! Honestly, I wasn't aware of this.
                                                                                          $endgroup$
                                                                                          – Galen Ivanov
                                                                                          7 hours ago






                                                                                        • 1




                                                                                          $begingroup$
                                                                                          @Jonah Nice!
                                                                                          $endgroup$
                                                                                          – Adám
                                                                                          7 hours ago
















                                                                                        4












                                                                                        $begingroup$


                                                                                        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





                                                                                        share|improve this answer











                                                                                        $endgroup$













                                                                                        • $begingroup$
                                                                                          Hey Galen. 1#.1<1#.= for 9 bytes + good ol' self-classify fun.
                                                                                          $endgroup$
                                                                                          – Jonah
                                                                                          15 hours ago






                                                                                        • 1




                                                                                          $begingroup$
                                                                                          @Jonah Thanks! Honestly, I wasn't aware of this.
                                                                                          $endgroup$
                                                                                          – Galen Ivanov
                                                                                          7 hours ago






                                                                                        • 1




                                                                                          $begingroup$
                                                                                          @Jonah Nice!
                                                                                          $endgroup$
                                                                                          – Adám
                                                                                          7 hours ago














                                                                                        4












                                                                                        4








                                                                                        4





                                                                                        $begingroup$


                                                                                        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





                                                                                        share|improve this answer











                                                                                        $endgroup$




                                                                                        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






                                                                                        share|improve this answer














                                                                                        share|improve this answer



                                                                                        share|improve this answer








                                                                                        edited 7 hours ago

























                                                                                        answered 19 hours ago









                                                                                        Galen IvanovGalen Ivanov

                                                                                        6,84711034




                                                                                        6,84711034












                                                                                        • $begingroup$
                                                                                          Hey Galen. 1#.1<1#.= for 9 bytes + good ol' self-classify fun.
                                                                                          $endgroup$
                                                                                          – Jonah
                                                                                          15 hours ago






                                                                                        • 1




                                                                                          $begingroup$
                                                                                          @Jonah Thanks! Honestly, I wasn't aware of this.
                                                                                          $endgroup$
                                                                                          – Galen Ivanov
                                                                                          7 hours ago






                                                                                        • 1




                                                                                          $begingroup$
                                                                                          @Jonah Nice!
                                                                                          $endgroup$
                                                                                          – Adám
                                                                                          7 hours ago


















                                                                                        • $begingroup$
                                                                                          Hey Galen. 1#.1<1#.= for 9 bytes + good ol' self-classify fun.
                                                                                          $endgroup$
                                                                                          – Jonah
                                                                                          15 hours ago






                                                                                        • 1




                                                                                          $begingroup$
                                                                                          @Jonah Thanks! Honestly, I wasn't aware of this.
                                                                                          $endgroup$
                                                                                          – Galen Ivanov
                                                                                          7 hours ago






                                                                                        • 1




                                                                                          $begingroup$
                                                                                          @Jonah Nice!
                                                                                          $endgroup$
                                                                                          – Adám
                                                                                          7 hours ago
















                                                                                        $begingroup$
                                                                                        Hey Galen. 1#.1<1#.= for 9 bytes + good ol' self-classify fun.
                                                                                        $endgroup$
                                                                                        – Jonah
                                                                                        15 hours ago




                                                                                        $begingroup$
                                                                                        Hey Galen. 1#.1<1#.= for 9 bytes + good ol' self-classify fun.
                                                                                        $endgroup$
                                                                                        – Jonah
                                                                                        15 hours ago




                                                                                        1




                                                                                        1




                                                                                        $begingroup$
                                                                                        @Jonah Thanks! Honestly, I wasn't aware of this.
                                                                                        $endgroup$
                                                                                        – Galen Ivanov
                                                                                        7 hours ago




                                                                                        $begingroup$
                                                                                        @Jonah Thanks! Honestly, I wasn't aware of this.
                                                                                        $endgroup$
                                                                                        – Galen Ivanov
                                                                                        7 hours ago




                                                                                        1




                                                                                        1




                                                                                        $begingroup$
                                                                                        @Jonah Nice!
                                                                                        $endgroup$
                                                                                        – Adám
                                                                                        7 hours ago




                                                                                        $begingroup$
                                                                                        @Jonah Nice!
                                                                                        $endgroup$
                                                                                        – Adám
                                                                                        7 hours ago











                                                                                        3












                                                                                        $begingroup$


                                                                                        Ruby, 34 bytes





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


                                                                                        Try it online!






                                                                                        share|improve this answer









                                                                                        $endgroup$


















                                                                                          3












                                                                                          $begingroup$


                                                                                          Ruby, 34 bytes





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


                                                                                          Try it online!






                                                                                          share|improve this answer









                                                                                          $endgroup$
















                                                                                            3












                                                                                            3








                                                                                            3





                                                                                            $begingroup$


                                                                                            Ruby, 34 bytes





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


                                                                                            Try it online!






                                                                                            share|improve this answer









                                                                                            $endgroup$




                                                                                            Ruby, 34 bytes





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


                                                                                            Try it online!







                                                                                            share|improve this answer












                                                                                            share|improve this answer



                                                                                            share|improve this answer










                                                                                            answered 19 hours ago









                                                                                            Kirill L.Kirill L.

                                                                                            4,6051523




                                                                                            4,6051523























                                                                                                3












                                                                                                $begingroup$


                                                                                                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.






                                                                                                share|improve this answer











                                                                                                $endgroup$


















                                                                                                  3












                                                                                                  $begingroup$


                                                                                                  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.






                                                                                                  share|improve this answer











                                                                                                  $endgroup$
















                                                                                                    3












                                                                                                    3








                                                                                                    3





                                                                                                    $begingroup$


                                                                                                    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.






                                                                                                    share|improve this answer











                                                                                                    $endgroup$




                                                                                                    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.







                                                                                                    share|improve this answer














                                                                                                    share|improve this answer



                                                                                                    share|improve this answer








                                                                                                    edited 16 hours ago

























                                                                                                    answered 17 hours ago









                                                                                                    Jonathan AllanJonathan Allan

                                                                                                    52.3k535170




                                                                                                    52.3k535170























                                                                                                        3












                                                                                                        $begingroup$


                                                                                                        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.






                                                                                                        share|improve this answer











                                                                                                        $endgroup$


















                                                                                                          3












                                                                                                          $begingroup$


                                                                                                          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.






                                                                                                          share|improve this answer











                                                                                                          $endgroup$
















                                                                                                            3












                                                                                                            3








                                                                                                            3





                                                                                                            $begingroup$


                                                                                                            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.






                                                                                                            share|improve this answer











                                                                                                            $endgroup$




                                                                                                            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.







                                                                                                            share|improve this answer














                                                                                                            share|improve this answer



                                                                                                            share|improve this answer








                                                                                                            edited 16 hours ago

























                                                                                                            answered 16 hours ago









                                                                                                            Jo KingJo King

                                                                                                            23.4k255123




                                                                                                            23.4k255123























                                                                                                                3












                                                                                                                $begingroup$


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





                                                                                                                n=>n.GroupBy(c=>c).Count(c=>c.Count()<2)


                                                                                                                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.



                                                                                                                Try it online!






                                                                                                                share|improve this answer











                                                                                                                $endgroup$









                                                                                                                • 1




                                                                                                                  $begingroup$
                                                                                                                  Your output is wrong, it needs to count the elements with 2 or more occurences. It should be n=>n.GroupBy(c=>c).Count(c=>c.Count()>=2). The OP says the answer of this list is 2. Your code returns 5. The change I gave you returns 2.
                                                                                                                  $endgroup$
                                                                                                                  – Paul Karam
                                                                                                                  8 hours ago






                                                                                                                • 1




                                                                                                                  $begingroup$
                                                                                                                  Or just >1 to keep the 40 bytes count
                                                                                                                  $endgroup$
                                                                                                                  – Paul Karam
                                                                                                                  7 hours ago
















                                                                                                                3












                                                                                                                $begingroup$


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





                                                                                                                n=>n.GroupBy(c=>c).Count(c=>c.Count()<2)


                                                                                                                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.



                                                                                                                Try it online!






                                                                                                                share|improve this answer











                                                                                                                $endgroup$









                                                                                                                • 1




                                                                                                                  $begingroup$
                                                                                                                  Your output is wrong, it needs to count the elements with 2 or more occurences. It should be n=>n.GroupBy(c=>c).Count(c=>c.Count()>=2). The OP says the answer of this list is 2. Your code returns 5. The change I gave you returns 2.
                                                                                                                  $endgroup$
                                                                                                                  – Paul Karam
                                                                                                                  8 hours ago






                                                                                                                • 1




                                                                                                                  $begingroup$
                                                                                                                  Or just >1 to keep the 40 bytes count
                                                                                                                  $endgroup$
                                                                                                                  – Paul Karam
                                                                                                                  7 hours ago














                                                                                                                3












                                                                                                                3








                                                                                                                3





                                                                                                                $begingroup$


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





                                                                                                                n=>n.GroupBy(c=>c).Count(c=>c.Count()<2)


                                                                                                                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.



                                                                                                                Try it online!






                                                                                                                share|improve this answer











                                                                                                                $endgroup$




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





                                                                                                                n=>n.GroupBy(c=>c).Count(c=>c.Count()<2)


                                                                                                                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.



                                                                                                                Try it online!







                                                                                                                share|improve this answer














                                                                                                                share|improve this answer



                                                                                                                share|improve this answer








                                                                                                                edited 10 hours ago

























                                                                                                                answered 19 hours ago









                                                                                                                Embodiment of IgnoranceEmbodiment of Ignorance

                                                                                                                1,140119




                                                                                                                1,140119








                                                                                                                • 1




                                                                                                                  $begingroup$
                                                                                                                  Your output is wrong, it needs to count the elements with 2 or more occurences. It should be n=>n.GroupBy(c=>c).Count(c=>c.Count()>=2). The OP says the answer of this list is 2. Your code returns 5. The change I gave you returns 2.
                                                                                                                  $endgroup$
                                                                                                                  – Paul Karam
                                                                                                                  8 hours ago






                                                                                                                • 1




                                                                                                                  $begingroup$
                                                                                                                  Or just >1 to keep the 40 bytes count
                                                                                                                  $endgroup$
                                                                                                                  – Paul Karam
                                                                                                                  7 hours ago














                                                                                                                • 1




                                                                                                                  $begingroup$
                                                                                                                  Your output is wrong, it needs to count the elements with 2 or more occurences. It should be n=>n.GroupBy(c=>c).Count(c=>c.Count()>=2). The OP says the answer of this list is 2. Your code returns 5. The change I gave you returns 2.
                                                                                                                  $endgroup$
                                                                                                                  – Paul Karam
                                                                                                                  8 hours ago






                                                                                                                • 1




                                                                                                                  $begingroup$
                                                                                                                  Or just >1 to keep the 40 bytes count
                                                                                                                  $endgroup$
                                                                                                                  – Paul Karam
                                                                                                                  7 hours ago








                                                                                                                1




                                                                                                                1




                                                                                                                $begingroup$
                                                                                                                Your output is wrong, it needs to count the elements with 2 or more occurences. It should be n=>n.GroupBy(c=>c).Count(c=>c.Count()>=2). The OP says the answer of this list is 2. Your code returns 5. The change I gave you returns 2.
                                                                                                                $endgroup$
                                                                                                                – Paul Karam
                                                                                                                8 hours ago




                                                                                                                $begingroup$
                                                                                                                Your output is wrong, it needs to count the elements with 2 or more occurences. It should be n=>n.GroupBy(c=>c).Count(c=>c.Count()>=2). The OP says the answer of this list is 2. Your code returns 5. The change I gave you returns 2.
                                                                                                                $endgroup$
                                                                                                                – Paul Karam
                                                                                                                8 hours ago




                                                                                                                1




                                                                                                                1




                                                                                                                $begingroup$
                                                                                                                Or just >1 to keep the 40 bytes count
                                                                                                                $endgroup$
                                                                                                                – Paul Karam
                                                                                                                7 hours ago




                                                                                                                $begingroup$
                                                                                                                Or just >1 to keep the 40 bytes count
                                                                                                                $endgroup$
                                                                                                                – Paul Karam
                                                                                                                7 hours ago











                                                                                                                2












                                                                                                                $begingroup$


                                                                                                                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





                                                                                                                share|improve this answer











                                                                                                                $endgroup$













                                                                                                                • $begingroup$
                                                                                                                  So all values that are not 1 are false?
                                                                                                                  $endgroup$
                                                                                                                  – Adám
                                                                                                                  18 hours ago










                                                                                                                • $begingroup$
                                                                                                                  @Adám: Yes, that is correct.
                                                                                                                  $endgroup$
                                                                                                                  – Emigna
                                                                                                                  17 hours ago
















                                                                                                                2












                                                                                                                $begingroup$


                                                                                                                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





                                                                                                                share|improve this answer











                                                                                                                $endgroup$













                                                                                                                • $begingroup$
                                                                                                                  So all values that are not 1 are false?
                                                                                                                  $endgroup$
                                                                                                                  – Adám
                                                                                                                  18 hours ago










                                                                                                                • $begingroup$
                                                                                                                  @Adám: Yes, that is correct.
                                                                                                                  $endgroup$
                                                                                                                  – Emigna
                                                                                                                  17 hours ago














                                                                                                                2












                                                                                                                2








                                                                                                                2





                                                                                                                $begingroup$


                                                                                                                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





                                                                                                                share|improve this answer











                                                                                                                $endgroup$




                                                                                                                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






                                                                                                                share|improve this answer














                                                                                                                share|improve this answer



                                                                                                                share|improve this answer








                                                                                                                edited 19 hours ago

























                                                                                                                answered 19 hours ago









                                                                                                                EmignaEmigna

                                                                                                                46.6k432142




                                                                                                                46.6k432142












                                                                                                                • $begingroup$
                                                                                                                  So all values that are not 1 are false?
                                                                                                                  $endgroup$
                                                                                                                  – Adám
                                                                                                                  18 hours ago










                                                                                                                • $begingroup$
                                                                                                                  @Adám: Yes, that is correct.
                                                                                                                  $endgroup$
                                                                                                                  – Emigna
                                                                                                                  17 hours ago


















                                                                                                                • $begingroup$
                                                                                                                  So all values that are not 1 are false?
                                                                                                                  $endgroup$
                                                                                                                  – Adám
                                                                                                                  18 hours ago










                                                                                                                • $begingroup$
                                                                                                                  @Adám: Yes, that is correct.
                                                                                                                  $endgroup$
                                                                                                                  – Emigna
                                                                                                                  17 hours ago
















                                                                                                                $begingroup$
                                                                                                                So all values that are not 1 are false?
                                                                                                                $endgroup$
                                                                                                                – Adám
                                                                                                                18 hours ago




                                                                                                                $begingroup$
                                                                                                                So all values that are not 1 are false?
                                                                                                                $endgroup$
                                                                                                                – Adám
                                                                                                                18 hours ago












                                                                                                                $begingroup$
                                                                                                                @Adám: Yes, that is correct.
                                                                                                                $endgroup$
                                                                                                                – Emigna
                                                                                                                17 hours ago




                                                                                                                $begingroup$
                                                                                                                @Adám: Yes, that is correct.
                                                                                                                $endgroup$
                                                                                                                – Emigna
                                                                                                                17 hours ago











                                                                                                                2












                                                                                                                $begingroup$

                                                                                                                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





                                                                                                                share|improve this answer











                                                                                                                $endgroup$


















                                                                                                                  2












                                                                                                                  $begingroup$

                                                                                                                  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





                                                                                                                  share|improve this answer











                                                                                                                  $endgroup$
















                                                                                                                    2












                                                                                                                    2








                                                                                                                    2





                                                                                                                    $begingroup$

                                                                                                                    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





                                                                                                                    share|improve this answer











                                                                                                                    $endgroup$



                                                                                                                    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






                                                                                                                    share|improve this answer














                                                                                                                    share|improve this answer



                                                                                                                    share|improve this answer








                                                                                                                    edited 6 hours ago

























                                                                                                                    answered 17 hours ago









                                                                                                                    Kevin CruijssenKevin Cruijssen

                                                                                                                    38.6k557200




                                                                                                                    38.6k557200























                                                                                                                        2












                                                                                                                        $begingroup$


                                                                                                                        APL (Dyalog Extended), 8 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






                                                                                                                        share|improve this answer











                                                                                                                        $endgroup$


















                                                                                                                          2












                                                                                                                          $begingroup$


                                                                                                                          APL (Dyalog Extended), 8 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






                                                                                                                          share|improve this answer











                                                                                                                          $endgroup$
















                                                                                                                            2












                                                                                                                            2








                                                                                                                            2





                                                                                                                            $begingroup$


                                                                                                                            APL (Dyalog Extended), 8 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






                                                                                                                            share|improve this answer











                                                                                                                            $endgroup$




                                                                                                                            APL (Dyalog Extended), 8 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







                                                                                                                            share|improve this answer














                                                                                                                            share|improve this answer



                                                                                                                            share|improve this answer








                                                                                                                            edited 2 hours ago

























                                                                                                                            answered 7 hours ago









                                                                                                                            AdámAdám

                                                                                                                            28.3k274201




                                                                                                                            28.3k274201























                                                                                                                                2












                                                                                                                                $begingroup$


                                                                                                                                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!






                                                                                                                                share|improve this answer











                                                                                                                                $endgroup$













                                                                                                                                • $begingroup$
                                                                                                                                  11
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  15 hours ago










                                                                                                                                • $begingroup$
                                                                                                                                  9 9 9?
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  15 hours ago












                                                                                                                                • $begingroup$
                                                                                                                                  8 8
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  15 hours ago








                                                                                                                                • 2




                                                                                                                                  $begingroup$
                                                                                                                                  6
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  15 hours ago






                                                                                                                                • 2




                                                                                                                                  $begingroup$
                                                                                                                                  6 6
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  14 hours ago


















                                                                                                                                2












                                                                                                                                $begingroup$


                                                                                                                                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!






                                                                                                                                share|improve this answer











                                                                                                                                $endgroup$













                                                                                                                                • $begingroup$
                                                                                                                                  11
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  15 hours ago










                                                                                                                                • $begingroup$
                                                                                                                                  9 9 9?
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  15 hours ago












                                                                                                                                • $begingroup$
                                                                                                                                  8 8
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  15 hours ago








                                                                                                                                • 2




                                                                                                                                  $begingroup$
                                                                                                                                  6
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  15 hours ago






                                                                                                                                • 2




                                                                                                                                  $begingroup$
                                                                                                                                  6 6
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  14 hours ago
















                                                                                                                                2












                                                                                                                                2








                                                                                                                                2





                                                                                                                                $begingroup$


                                                                                                                                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!






                                                                                                                                share|improve this answer











                                                                                                                                $endgroup$




                                                                                                                                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!







                                                                                                                                share|improve this answer














                                                                                                                                share|improve this answer



                                                                                                                                share|improve this answer








                                                                                                                                edited 1 hour ago

























                                                                                                                                answered 15 hours ago









                                                                                                                                QuintecQuintec

                                                                                                                                1,5581723




                                                                                                                                1,5581723












                                                                                                                                • $begingroup$
                                                                                                                                  11
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  15 hours ago










                                                                                                                                • $begingroup$
                                                                                                                                  9 9 9?
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  15 hours ago












                                                                                                                                • $begingroup$
                                                                                                                                  8 8
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  15 hours ago








                                                                                                                                • 2




                                                                                                                                  $begingroup$
                                                                                                                                  6
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  15 hours ago






                                                                                                                                • 2




                                                                                                                                  $begingroup$
                                                                                                                                  6 6
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  14 hours ago




















                                                                                                                                • $begingroup$
                                                                                                                                  11
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  15 hours ago










                                                                                                                                • $begingroup$
                                                                                                                                  9 9 9?
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  15 hours ago












                                                                                                                                • $begingroup$
                                                                                                                                  8 8
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  15 hours ago








                                                                                                                                • 2




                                                                                                                                  $begingroup$
                                                                                                                                  6
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  15 hours ago






                                                                                                                                • 2




                                                                                                                                  $begingroup$
                                                                                                                                  6 6
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  14 hours ago


















                                                                                                                                $begingroup$
                                                                                                                                11
                                                                                                                                $endgroup$
                                                                                                                                – ASCII-only
                                                                                                                                15 hours ago




                                                                                                                                $begingroup$
                                                                                                                                11
                                                                                                                                $endgroup$
                                                                                                                                – ASCII-only
                                                                                                                                15 hours ago












                                                                                                                                $begingroup$
                                                                                                                                9 9 9?
                                                                                                                                $endgroup$
                                                                                                                                – ASCII-only
                                                                                                                                15 hours ago






                                                                                                                                $begingroup$
                                                                                                                                9 9 9?
                                                                                                                                $endgroup$
                                                                                                                                – ASCII-only
                                                                                                                                15 hours ago














                                                                                                                                $begingroup$
                                                                                                                                8 8
                                                                                                                                $endgroup$
                                                                                                                                – ASCII-only
                                                                                                                                15 hours ago






                                                                                                                                $begingroup$
                                                                                                                                8 8
                                                                                                                                $endgroup$
                                                                                                                                – ASCII-only
                                                                                                                                15 hours ago






                                                                                                                                2




                                                                                                                                2




                                                                                                                                $begingroup$
                                                                                                                                6
                                                                                                                                $endgroup$
                                                                                                                                – ASCII-only
                                                                                                                                15 hours ago




                                                                                                                                $begingroup$
                                                                                                                                6
                                                                                                                                $endgroup$
                                                                                                                                – ASCII-only
                                                                                                                                15 hours ago




                                                                                                                                2




                                                                                                                                2




                                                                                                                                $begingroup$
                                                                                                                                6 6
                                                                                                                                $endgroup$
                                                                                                                                – ASCII-only
                                                                                                                                14 hours ago






                                                                                                                                $begingroup$
                                                                                                                                6 6
                                                                                                                                $endgroup$
                                                                                                                                – ASCII-only
                                                                                                                                14 hours ago













                                                                                                                                1












                                                                                                                                $begingroup$


                                                                                                                                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!






                                                                                                                                share|improve this answer









                                                                                                                                $endgroup$


















                                                                                                                                  1












                                                                                                                                  $begingroup$


                                                                                                                                  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!






                                                                                                                                  share|improve this answer









                                                                                                                                  $endgroup$
















                                                                                                                                    1












                                                                                                                                    1








                                                                                                                                    1





                                                                                                                                    $begingroup$


                                                                                                                                    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!






                                                                                                                                    share|improve this answer









                                                                                                                                    $endgroup$




                                                                                                                                    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!







                                                                                                                                    share|improve this answer












                                                                                                                                    share|improve this answer



                                                                                                                                    share|improve this answer










                                                                                                                                    answered 19 hours ago









                                                                                                                                    Sriotchilism O'ZaicSriotchilism O'Zaic

                                                                                                                                    35.1k10159369




                                                                                                                                    35.1k10159369























                                                                                                                                        1












                                                                                                                                        $begingroup$


                                                                                                                                        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





                                                                                                                                        share|improve this answer









                                                                                                                                        $endgroup$


















                                                                                                                                          1












                                                                                                                                          $begingroup$


                                                                                                                                          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





                                                                                                                                          share|improve this answer









                                                                                                                                          $endgroup$
















                                                                                                                                            1












                                                                                                                                            1








                                                                                                                                            1





                                                                                                                                            $begingroup$


                                                                                                                                            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





                                                                                                                                            share|improve this answer









                                                                                                                                            $endgroup$




                                                                                                                                            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






                                                                                                                                            share|improve this answer












                                                                                                                                            share|improve this answer



                                                                                                                                            share|improve this answer










                                                                                                                                            answered 16 hours ago









                                                                                                                                            PhiNotPiPhiNotPi

                                                                                                                                            19.6k967149




                                                                                                                                            19.6k967149























                                                                                                                                                1












                                                                                                                                                $begingroup$


                                                                                                                                                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.






                                                                                                                                                share|improve this answer









                                                                                                                                                $endgroup$


















                                                                                                                                                  1












                                                                                                                                                  $begingroup$


                                                                                                                                                  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.






                                                                                                                                                  share|improve this answer









                                                                                                                                                  $endgroup$
















                                                                                                                                                    1












                                                                                                                                                    1








                                                                                                                                                    1





                                                                                                                                                    $begingroup$


                                                                                                                                                    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.






                                                                                                                                                    share|improve this answer









                                                                                                                                                    $endgroup$




                                                                                                                                                    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.







                                                                                                                                                    share|improve this answer












                                                                                                                                                    share|improve this answer



                                                                                                                                                    share|improve this answer










                                                                                                                                                    answered 16 hours ago









                                                                                                                                                    NeilNeil

                                                                                                                                                    81k744178




                                                                                                                                                    81k744178























                                                                                                                                                        1












                                                                                                                                                        $begingroup$


                                                                                                                                                        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.






                                                                                                                                                        share|improve this answer











                                                                                                                                                        $endgroup$


















                                                                                                                                                          1












                                                                                                                                                          $begingroup$


                                                                                                                                                          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.






                                                                                                                                                          share|improve this answer











                                                                                                                                                          $endgroup$
















                                                                                                                                                            1












                                                                                                                                                            1








                                                                                                                                                            1





                                                                                                                                                            $begingroup$


                                                                                                                                                            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.






                                                                                                                                                            share|improve this answer











                                                                                                                                                            $endgroup$




                                                                                                                                                            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.







                                                                                                                                                            share|improve this answer














                                                                                                                                                            share|improve this answer



                                                                                                                                                            share|improve this answer








                                                                                                                                                            edited 15 hours ago

























                                                                                                                                                            answered 16 hours ago









                                                                                                                                                            ΟurousΟurous

                                                                                                                                                            7,20111035




                                                                                                                                                            7,20111035























                                                                                                                                                                1












                                                                                                                                                                $begingroup$

                                                                                                                                                                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.






                                                                                                                                                                share|improve this answer









                                                                                                                                                                $endgroup$


















                                                                                                                                                                  1












                                                                                                                                                                  $begingroup$

                                                                                                                                                                  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.






                                                                                                                                                                  share|improve this answer









                                                                                                                                                                  $endgroup$
















                                                                                                                                                                    1












                                                                                                                                                                    1








                                                                                                                                                                    1





                                                                                                                                                                    $begingroup$

                                                                                                                                                                    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.






                                                                                                                                                                    share|improve this answer









                                                                                                                                                                    $endgroup$



                                                                                                                                                                    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.







                                                                                                                                                                    share|improve this answer












                                                                                                                                                                    share|improve this answer



                                                                                                                                                                    share|improve this answer










                                                                                                                                                                    answered 15 hours ago









                                                                                                                                                                    DavidCDavidC

                                                                                                                                                                    24k244102




                                                                                                                                                                    24k244102























                                                                                                                                                                        0












                                                                                                                                                                        $begingroup$

                                                                                                                                                                        JavaScript (ES6), 40 bytes





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


                                                                                                                                                                        Try it online!






                                                                                                                                                                        share|improve this answer









                                                                                                                                                                        $endgroup$


















                                                                                                                                                                          0












                                                                                                                                                                          $begingroup$

                                                                                                                                                                          JavaScript (ES6), 40 bytes





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


                                                                                                                                                                          Try it online!






                                                                                                                                                                          share|improve this answer









                                                                                                                                                                          $endgroup$
















                                                                                                                                                                            0












                                                                                                                                                                            0








                                                                                                                                                                            0





                                                                                                                                                                            $begingroup$

                                                                                                                                                                            JavaScript (ES6), 40 bytes





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


                                                                                                                                                                            Try it online!






                                                                                                                                                                            share|improve this answer









                                                                                                                                                                            $endgroup$



                                                                                                                                                                            JavaScript (ES6), 40 bytes





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


                                                                                                                                                                            Try it online!







                                                                                                                                                                            share|improve this answer












                                                                                                                                                                            share|improve this answer



                                                                                                                                                                            share|improve this answer










                                                                                                                                                                            answered 19 hours ago









                                                                                                                                                                            ArnauldArnauld

                                                                                                                                                                            76.7k693322




                                                                                                                                                                            76.7k693322























                                                                                                                                                                                0












                                                                                                                                                                                $begingroup$


                                                                                                                                                                                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!






                                                                                                                                                                                share|improve this answer








                                                                                                                                                                                New contributor




                                                                                                                                                                                Kamil Naja is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                Check out our Code of Conduct.






                                                                                                                                                                                $endgroup$


















                                                                                                                                                                                  0












                                                                                                                                                                                  $begingroup$


                                                                                                                                                                                  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!






                                                                                                                                                                                  share|improve this answer








                                                                                                                                                                                  New contributor




                                                                                                                                                                                  Kamil Naja is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                  Check out our Code of Conduct.






                                                                                                                                                                                  $endgroup$
















                                                                                                                                                                                    0












                                                                                                                                                                                    0








                                                                                                                                                                                    0





                                                                                                                                                                                    $begingroup$


                                                                                                                                                                                    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!






                                                                                                                                                                                    share|improve this answer








                                                                                                                                                                                    New contributor




                                                                                                                                                                                    Kamil Naja is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                    Check out our Code of Conduct.






                                                                                                                                                                                    $endgroup$




                                                                                                                                                                                    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!







                                                                                                                                                                                    share|improve this answer








                                                                                                                                                                                    New contributor




                                                                                                                                                                                    Kamil Naja is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                    Check out our Code of Conduct.









                                                                                                                                                                                    share|improve this answer



                                                                                                                                                                                    share|improve this answer






                                                                                                                                                                                    New contributor




                                                                                                                                                                                    Kamil Naja is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                    Check out our Code of Conduct.









                                                                                                                                                                                    answered 16 hours ago









                                                                                                                                                                                    Kamil NajaKamil Naja

                                                                                                                                                                                    1013




                                                                                                                                                                                    1013




                                                                                                                                                                                    New contributor




                                                                                                                                                                                    Kamil Naja is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                    Check out our Code of Conduct.





                                                                                                                                                                                    New contributor





                                                                                                                                                                                    Kamil Naja is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                    Check out our Code of Conduct.






                                                                                                                                                                                    Kamil Naja is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                    Check out our Code of Conduct.























                                                                                                                                                                                        0












                                                                                                                                                                                        $begingroup$

                                                                                                                                                                                        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.






                                                                                                                                                                                        share|improve this answer









                                                                                                                                                                                        $endgroup$


















                                                                                                                                                                                          0












                                                                                                                                                                                          $begingroup$

                                                                                                                                                                                          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.






                                                                                                                                                                                          share|improve this answer









                                                                                                                                                                                          $endgroup$
















                                                                                                                                                                                            0












                                                                                                                                                                                            0








                                                                                                                                                                                            0





                                                                                                                                                                                            $begingroup$

                                                                                                                                                                                            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.






                                                                                                                                                                                            share|improve this answer









                                                                                                                                                                                            $endgroup$



                                                                                                                                                                                            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.







                                                                                                                                                                                            share|improve this answer












                                                                                                                                                                                            share|improve this answer



                                                                                                                                                                                            share|improve this answer










                                                                                                                                                                                            answered 9 hours ago









                                                                                                                                                                                            don brightdon bright

                                                                                                                                                                                            516410




                                                                                                                                                                                            516410























                                                                                                                                                                                                0












                                                                                                                                                                                                $begingroup$


                                                                                                                                                                                                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!






                                                                                                                                                                                                share|improve this answer











                                                                                                                                                                                                $endgroup$


















                                                                                                                                                                                                  0












                                                                                                                                                                                                  $begingroup$


                                                                                                                                                                                                  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!






                                                                                                                                                                                                  share|improve this answer











                                                                                                                                                                                                  $endgroup$
















                                                                                                                                                                                                    0












                                                                                                                                                                                                    0








                                                                                                                                                                                                    0





                                                                                                                                                                                                    $begingroup$


                                                                                                                                                                                                    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!






                                                                                                                                                                                                    share|improve this answer











                                                                                                                                                                                                    $endgroup$




                                                                                                                                                                                                    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!







                                                                                                                                                                                                    share|improve this answer














                                                                                                                                                                                                    share|improve this answer



                                                                                                                                                                                                    share|improve this answer








                                                                                                                                                                                                    edited 9 hours ago

























                                                                                                                                                                                                    answered 9 hours ago









                                                                                                                                                                                                    JPeroutekJPeroutek

                                                                                                                                                                                                    28017




                                                                                                                                                                                                    28017























                                                                                                                                                                                                        0












                                                                                                                                                                                                        $begingroup$


                                                                                                                                                                                                        Python 3, 63 bytes





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


                                                                                                                                                                                                        Try it online!






                                                                                                                                                                                                        share|improve this answer









                                                                                                                                                                                                        $endgroup$


















                                                                                                                                                                                                          0












                                                                                                                                                                                                          $begingroup$


                                                                                                                                                                                                          Python 3, 63 bytes





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


                                                                                                                                                                                                          Try it online!






                                                                                                                                                                                                          share|improve this answer









                                                                                                                                                                                                          $endgroup$
















                                                                                                                                                                                                            0












                                                                                                                                                                                                            0








                                                                                                                                                                                                            0





                                                                                                                                                                                                            $begingroup$


                                                                                                                                                                                                            Python 3, 63 bytes





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


                                                                                                                                                                                                            Try it online!






                                                                                                                                                                                                            share|improve this answer









                                                                                                                                                                                                            $endgroup$




                                                                                                                                                                                                            Python 3, 63 bytes





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


                                                                                                                                                                                                            Try it online!







                                                                                                                                                                                                            share|improve this answer












                                                                                                                                                                                                            share|improve this answer



                                                                                                                                                                                                            share|improve this answer










                                                                                                                                                                                                            answered 8 hours ago









                                                                                                                                                                                                            pizzapants184pizzapants184

                                                                                                                                                                                                            2,684716




                                                                                                                                                                                                            2,684716























                                                                                                                                                                                                                0












                                                                                                                                                                                                                $begingroup$


                                                                                                                                                                                                                PowerShell, 33 bytes





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


                                                                                                                                                                                                                Try it online!






                                                                                                                                                                                                                share|improve this answer









                                                                                                                                                                                                                $endgroup$


















                                                                                                                                                                                                                  0












                                                                                                                                                                                                                  $begingroup$


                                                                                                                                                                                                                  PowerShell, 33 bytes





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


                                                                                                                                                                                                                  Try it online!






                                                                                                                                                                                                                  share|improve this answer









                                                                                                                                                                                                                  $endgroup$
















                                                                                                                                                                                                                    0












                                                                                                                                                                                                                    0








                                                                                                                                                                                                                    0





                                                                                                                                                                                                                    $begingroup$


                                                                                                                                                                                                                    PowerShell, 33 bytes





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


                                                                                                                                                                                                                    Try it online!






                                                                                                                                                                                                                    share|improve this answer









                                                                                                                                                                                                                    $endgroup$




                                                                                                                                                                                                                    PowerShell, 33 bytes





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


                                                                                                                                                                                                                    Try it online!







                                                                                                                                                                                                                    share|improve this answer












                                                                                                                                                                                                                    share|improve this answer



                                                                                                                                                                                                                    share|improve this answer










                                                                                                                                                                                                                    answered 5 hours ago









                                                                                                                                                                                                                    mazzymazzy

                                                                                                                                                                                                                    2,5251316




                                                                                                                                                                                                                    2,5251316























                                                                                                                                                                                                                        0












                                                                                                                                                                                                                        $begingroup$


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





                                                                                                                                                                                                                        arr.GroupBy(x=>x).Where(y=>y.Count()>1).Select(y=>y.Key).Count()


                                                                                                                                                                                                                        Try it online!






                                                                                                                                                                                                                        share|improve this answer










                                                                                                                                                                                                                        New contributor




                                                                                                                                                                                                                        D T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                                                        Check out our Code of Conduct.






                                                                                                                                                                                                                        $endgroup$













                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                          Hello, and welcome to PPCG! You've answered with a snippet, whereas we only accept functions and programs by default so please adjust to one of those formats. You can also golf your code further by removing the extra spaces (eg: > 1 becomes >1).
                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                          – Οurous
                                                                                                                                                                                                                          9 hours ago










                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                          Hey @Οurous, thank you for informing me. I have updated my answer. Would you mind checking it again...
                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                          – D T
                                                                                                                                                                                                                          7 hours ago










                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                          no, input can't be a predefined variable. Surely it wouldn't cost any bytes to turn it into an anonymous function?
                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                          – Jo King
                                                                                                                                                                                                                          7 hours ago
















                                                                                                                                                                                                                        0












                                                                                                                                                                                                                        $begingroup$


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





                                                                                                                                                                                                                        arr.GroupBy(x=>x).Where(y=>y.Count()>1).Select(y=>y.Key).Count()


                                                                                                                                                                                                                        Try it online!






                                                                                                                                                                                                                        share|improve this answer










                                                                                                                                                                                                                        New contributor




                                                                                                                                                                                                                        D T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                                                        Check out our Code of Conduct.






                                                                                                                                                                                                                        $endgroup$













                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                          Hello, and welcome to PPCG! You've answered with a snippet, whereas we only accept functions and programs by default so please adjust to one of those formats. You can also golf your code further by removing the extra spaces (eg: > 1 becomes >1).
                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                          – Οurous
                                                                                                                                                                                                                          9 hours ago










                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                          Hey @Οurous, thank you for informing me. I have updated my answer. Would you mind checking it again...
                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                          – D T
                                                                                                                                                                                                                          7 hours ago










                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                          no, input can't be a predefined variable. Surely it wouldn't cost any bytes to turn it into an anonymous function?
                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                          – Jo King
                                                                                                                                                                                                                          7 hours ago














                                                                                                                                                                                                                        0












                                                                                                                                                                                                                        0








                                                                                                                                                                                                                        0





                                                                                                                                                                                                                        $begingroup$


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





                                                                                                                                                                                                                        arr.GroupBy(x=>x).Where(y=>y.Count()>1).Select(y=>y.Key).Count()


                                                                                                                                                                                                                        Try it online!






                                                                                                                                                                                                                        share|improve this answer










                                                                                                                                                                                                                        New contributor




                                                                                                                                                                                                                        D T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                                                        Check out our Code of Conduct.






                                                                                                                                                                                                                        $endgroup$




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





                                                                                                                                                                                                                        arr.GroupBy(x=>x).Where(y=>y.Count()>1).Select(y=>y.Key).Count()


                                                                                                                                                                                                                        Try it online!







                                                                                                                                                                                                                        share|improve this answer










                                                                                                                                                                                                                        New contributor




                                                                                                                                                                                                                        D T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                                                        Check out our Code of Conduct.









                                                                                                                                                                                                                        share|improve this answer



                                                                                                                                                                                                                        share|improve this answer








                                                                                                                                                                                                                        edited 5 hours ago





















                                                                                                                                                                                                                        New contributor




                                                                                                                                                                                                                        D T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                                                        Check out our Code of Conduct.









                                                                                                                                                                                                                        answered 9 hours ago









                                                                                                                                                                                                                        D TD T

                                                                                                                                                                                                                        1014




                                                                                                                                                                                                                        1014




                                                                                                                                                                                                                        New contributor




                                                                                                                                                                                                                        D T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                                                        Check out our Code of Conduct.





                                                                                                                                                                                                                        New contributor





                                                                                                                                                                                                                        D T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                                                        Check out our Code of Conduct.






                                                                                                                                                                                                                        D T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                                                        Check out our Code of Conduct.












                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                          Hello, and welcome to PPCG! You've answered with a snippet, whereas we only accept functions and programs by default so please adjust to one of those formats. You can also golf your code further by removing the extra spaces (eg: > 1 becomes >1).
                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                          – Οurous
                                                                                                                                                                                                                          9 hours ago










                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                          Hey @Οurous, thank you for informing me. I have updated my answer. Would you mind checking it again...
                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                          – D T
                                                                                                                                                                                                                          7 hours ago










                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                          no, input can't be a predefined variable. Surely it wouldn't cost any bytes to turn it into an anonymous function?
                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                          – Jo King
                                                                                                                                                                                                                          7 hours ago


















                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                          Hello, and welcome to PPCG! You've answered with a snippet, whereas we only accept functions and programs by default so please adjust to one of those formats. You can also golf your code further by removing the extra spaces (eg: > 1 becomes >1).
                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                          – Οurous
                                                                                                                                                                                                                          9 hours ago










                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                          Hey @Οurous, thank you for informing me. I have updated my answer. Would you mind checking it again...
                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                          – D T
                                                                                                                                                                                                                          7 hours ago










                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                          no, input can't be a predefined variable. Surely it wouldn't cost any bytes to turn it into an anonymous function?
                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                          – Jo King
                                                                                                                                                                                                                          7 hours ago
















                                                                                                                                                                                                                        $begingroup$
                                                                                                                                                                                                                        Hello, and welcome to PPCG! You've answered with a snippet, whereas we only accept functions and programs by default so please adjust to one of those formats. You can also golf your code further by removing the extra spaces (eg: > 1 becomes >1).
                                                                                                                                                                                                                        $endgroup$
                                                                                                                                                                                                                        – Οurous
                                                                                                                                                                                                                        9 hours ago




                                                                                                                                                                                                                        $begingroup$
                                                                                                                                                                                                                        Hello, and welcome to PPCG! You've answered with a snippet, whereas we only accept functions and programs by default so please adjust to one of those formats. You can also golf your code further by removing the extra spaces (eg: > 1 becomes >1).
                                                                                                                                                                                                                        $endgroup$
                                                                                                                                                                                                                        – Οurous
                                                                                                                                                                                                                        9 hours ago












                                                                                                                                                                                                                        $begingroup$
                                                                                                                                                                                                                        Hey @Οurous, thank you for informing me. I have updated my answer. Would you mind checking it again...
                                                                                                                                                                                                                        $endgroup$
                                                                                                                                                                                                                        – D T
                                                                                                                                                                                                                        7 hours ago




                                                                                                                                                                                                                        $begingroup$
                                                                                                                                                                                                                        Hey @Οurous, thank you for informing me. I have updated my answer. Would you mind checking it again...
                                                                                                                                                                                                                        $endgroup$
                                                                                                                                                                                                                        – D T
                                                                                                                                                                                                                        7 hours ago












                                                                                                                                                                                                                        $begingroup$
                                                                                                                                                                                                                        no, input can't be a predefined variable. Surely it wouldn't cost any bytes to turn it into an anonymous function?
                                                                                                                                                                                                                        $endgroup$
                                                                                                                                                                                                                        – Jo King
                                                                                                                                                                                                                        7 hours ago




                                                                                                                                                                                                                        $begingroup$
                                                                                                                                                                                                                        no, input can't be a predefined variable. Surely it wouldn't cost any bytes to turn it into an anonymous function?
                                                                                                                                                                                                                        $endgroup$
                                                                                                                                                                                                                        – Jo King
                                                                                                                                                                                                                        7 hours ago











                                                                                                                                                                                                                        0












                                                                                                                                                                                                                        $begingroup$


                                                                                                                                                                                                                        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





                                                                                                                                                                                                                        share|improve this answer











                                                                                                                                                                                                                        $endgroup$


















                                                                                                                                                                                                                          0












                                                                                                                                                                                                                          $begingroup$


                                                                                                                                                                                                                          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





                                                                                                                                                                                                                          share|improve this answer











                                                                                                                                                                                                                          $endgroup$
















                                                                                                                                                                                                                            0












                                                                                                                                                                                                                            0








                                                                                                                                                                                                                            0





                                                                                                                                                                                                                            $begingroup$


                                                                                                                                                                                                                            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





                                                                                                                                                                                                                            share|improve this answer











                                                                                                                                                                                                                            $endgroup$




                                                                                                                                                                                                                            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






                                                                                                                                                                                                                            share|improve this answer














                                                                                                                                                                                                                            share|improve this answer



                                                                                                                                                                                                                            share|improve this answer








                                                                                                                                                                                                                            edited 4 hours ago

























                                                                                                                                                                                                                            answered 5 hours ago









                                                                                                                                                                                                                            Luis MendoLuis Mendo

                                                                                                                                                                                                                            74.5k888291




                                                                                                                                                                                                                            74.5k888291























                                                                                                                                                                                                                                0












                                                                                                                                                                                                                                $begingroup$

                                                                                                                                                                                                                                Pyth, 8 bytes



                                                                                                                                                                                                                                lfthTr8S


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






                                                                                                                                                                                                                                share|improve this answer









                                                                                                                                                                                                                                $endgroup$


















                                                                                                                                                                                                                                  0












                                                                                                                                                                                                                                  $begingroup$

                                                                                                                                                                                                                                  Pyth, 8 bytes



                                                                                                                                                                                                                                  lfthTr8S


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






                                                                                                                                                                                                                                  share|improve this answer









                                                                                                                                                                                                                                  $endgroup$
















                                                                                                                                                                                                                                    0












                                                                                                                                                                                                                                    0








                                                                                                                                                                                                                                    0





                                                                                                                                                                                                                                    $begingroup$

                                                                                                                                                                                                                                    Pyth, 8 bytes



                                                                                                                                                                                                                                    lfthTr8S


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






                                                                                                                                                                                                                                    share|improve this answer









                                                                                                                                                                                                                                    $endgroup$



                                                                                                                                                                                                                                    Pyth, 8 bytes



                                                                                                                                                                                                                                    lfthTr8S


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







                                                                                                                                                                                                                                    share|improve this answer












                                                                                                                                                                                                                                    share|improve this answer



                                                                                                                                                                                                                                    share|improve this answer










                                                                                                                                                                                                                                    answered 4 hours ago









                                                                                                                                                                                                                                    SokSok

                                                                                                                                                                                                                                    4,007925




                                                                                                                                                                                                                                    4,007925























                                                                                                                                                                                                                                        0












                                                                                                                                                                                                                                        $begingroup$

                                                                                                                                                                                                                                        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;





                                                                                                                                                                                                                                        share|improve this answer











                                                                                                                                                                                                                                        $endgroup$













                                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                                          Yes, you can take input via the command line arguments (as per standard IO formats). Though wouldn't there be problems if the filename was numerical?
                                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                                          – Jo King
                                                                                                                                                                                                                                          4 hours ago










                                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                                          @JoKing Sure, I fixed it.
                                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                                          – rexkogitans
                                                                                                                                                                                                                                          4 hours ago
















                                                                                                                                                                                                                                        0












                                                                                                                                                                                                                                        $begingroup$

                                                                                                                                                                                                                                        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;





                                                                                                                                                                                                                                        share|improve this answer











                                                                                                                                                                                                                                        $endgroup$













                                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                                          Yes, you can take input via the command line arguments (as per standard IO formats). Though wouldn't there be problems if the filename was numerical?
                                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                                          – Jo King
                                                                                                                                                                                                                                          4 hours ago










                                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                                          @JoKing Sure, I fixed it.
                                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                                          – rexkogitans
                                                                                                                                                                                                                                          4 hours ago














                                                                                                                                                                                                                                        0












                                                                                                                                                                                                                                        0








                                                                                                                                                                                                                                        0





                                                                                                                                                                                                                                        $begingroup$

                                                                                                                                                                                                                                        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;





                                                                                                                                                                                                                                        share|improve this answer











                                                                                                                                                                                                                                        $endgroup$



                                                                                                                                                                                                                                        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;






                                                                                                                                                                                                                                        share|improve this answer














                                                                                                                                                                                                                                        share|improve this answer



                                                                                                                                                                                                                                        share|improve this answer








                                                                                                                                                                                                                                        edited 4 hours ago

























                                                                                                                                                                                                                                        answered 4 hours ago









                                                                                                                                                                                                                                        rexkogitansrexkogitans

                                                                                                                                                                                                                                        57928




                                                                                                                                                                                                                                        57928












                                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                                          Yes, you can take input via the command line arguments (as per standard IO formats). Though wouldn't there be problems if the filename was numerical?
                                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                                          – Jo King
                                                                                                                                                                                                                                          4 hours ago










                                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                                          @JoKing Sure, I fixed it.
                                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                                          – rexkogitans
                                                                                                                                                                                                                                          4 hours ago


















                                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                                          Yes, you can take input via the command line arguments (as per standard IO formats). Though wouldn't there be problems if the filename was numerical?
                                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                                          – Jo King
                                                                                                                                                                                                                                          4 hours ago










                                                                                                                                                                                                                                        • $begingroup$
                                                                                                                                                                                                                                          @JoKing Sure, I fixed it.
                                                                                                                                                                                                                                          $endgroup$
                                                                                                                                                                                                                                          – rexkogitans
                                                                                                                                                                                                                                          4 hours ago
















                                                                                                                                                                                                                                        $begingroup$
                                                                                                                                                                                                                                        Yes, you can take input via the command line arguments (as per standard IO formats). Though wouldn't there be problems if the filename was numerical?
                                                                                                                                                                                                                                        $endgroup$
                                                                                                                                                                                                                                        – Jo King
                                                                                                                                                                                                                                        4 hours ago




                                                                                                                                                                                                                                        $begingroup$
                                                                                                                                                                                                                                        Yes, you can take input via the command line arguments (as per standard IO formats). Though wouldn't there be problems if the filename was numerical?
                                                                                                                                                                                                                                        $endgroup$
                                                                                                                                                                                                                                        – Jo King
                                                                                                                                                                                                                                        4 hours ago












                                                                                                                                                                                                                                        $begingroup$
                                                                                                                                                                                                                                        @JoKing Sure, I fixed it.
                                                                                                                                                                                                                                        $endgroup$
                                                                                                                                                                                                                                        – rexkogitans
                                                                                                                                                                                                                                        4 hours ago




                                                                                                                                                                                                                                        $begingroup$
                                                                                                                                                                                                                                        @JoKing Sure, I fixed it.
                                                                                                                                                                                                                                        $endgroup$
                                                                                                                                                                                                                                        – rexkogitans
                                                                                                                                                                                                                                        4 hours ago










                                                                                                                                                                                                                                        1 2
                                                                                                                                                                                                                                        next









                                                                                                                                                                                                                                        jayko03 is a new contributor. Be nice, and check out our Code of Conduct.










                                                                                                                                                                                                                                        draft saved

                                                                                                                                                                                                                                        draft discarded


















                                                                                                                                                                                                                                        jayko03 is a new contributor. Be nice, and check out our Code of Conduct.













                                                                                                                                                                                                                                        jayko03 is a new contributor. Be nice, and check out our Code of Conduct.












                                                                                                                                                                                                                                        jayko03 is a new contributor. Be nice, and check out our Code of Conduct.
















                                                                                                                                                                                                                                        If this is an answer to a challenge…




                                                                                                                                                                                                                                        • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                                                                                                                                                                                                        • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                                                                                                                                                                                          Explanations of your answer make it more interesting to read and are very much encouraged.


                                                                                                                                                                                                                                        • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                                                                                                                                                                                                                        More generally…




                                                                                                                                                                                                                                        • …Please make sure to answer the question and provide sufficient detail.


                                                                                                                                                                                                                                        • …Avoid asking for help, clarification or responding to other answers (use comments instead).





                                                                                                                                                                                                                                        draft saved


                                                                                                                                                                                                                                        draft discarded














                                                                                                                                                                                                                                        StackExchange.ready(
                                                                                                                                                                                                                                        function () {
                                                                                                                                                                                                                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f180302%2fcount-repetitions-of-an-array%23new-answer', 'question_page');
                                                                                                                                                                                                                                        }
                                                                                                                                                                                                                                        );

                                                                                                                                                                                                                                        Post as a guest















                                                                                                                                                                                                                                        Required, but never shown





















































                                                                                                                                                                                                                                        Required, but never shown














                                                                                                                                                                                                                                        Required, but never shown












                                                                                                                                                                                                                                        Required, but never shown







                                                                                                                                                                                                                                        Required, but never shown

































                                                                                                                                                                                                                                        Required, but never shown














                                                                                                                                                                                                                                        Required, but never shown












                                                                                                                                                                                                                                        Required, but never shown







                                                                                                                                                                                                                                        Required, but never shown







                                                                                                                                                                                                                                        Popular posts from this blog

                                                                                                                                                                                                                                        Why do type traits not work with types in namespace scope?What are POD types in C++?Why can templates only be...

                                                                                                                                                                                                                                        Will tsunami waves travel forever if there was no land?Why do tsunami waves begin with the water flowing away...

                                                                                                                                                                                                                                        Simple Scan not detecting my scanner (Brother DCP-7055W)Brother MFC-L2700DW printer can print, can't...