Questions tagged [counting]

Counting is the action of finding the number of elements of a finite set of objects.

Counting is the action of finding the number of elements of a finite set of objects. The traditional way of counting consists of continually increasing a (mental or spoken) counter by a unit for every element of the set, in some order, while marking (or displacing) those elements to avoid visiting the same element more than once, until no unmarked elements are left; if the counter was set to one after the first object, the value after visiting the final object gives the desired number of elements. The related term enumeration refers to uniquely identifying the elements of a finite (combinatorial) set or infinite set by assigning a number to each element.

Counting using tally marks at Hanakapiai Beach Counting sometimes involves numbers other than one; for example, when counting money, counting out change, "counting by twos" (2, 4, 6, 8, 10, 12, ...), or "counting by fives" (5, 10, 15, 20, 25, ...). There is archeological evidence suggesting that humans have been counting for at least 50,000 years. Counting was primarily used by ancient cultures to keep track of social and economic data such as number of group members, prey animals, property, or debts (i.e., accountancy). The development of counting led to the development of mathematical notation, numeral systems, and writing.

1837 questions
5
votes
2 answers

Most efficient way to count occurrences?

I've got an array of bytes (primitive), they can have random values. I'm trying to count occurrences of them in the array in the most efficient/fastest way. Currently I'm using: HashMap dataCount = new HashMap<>(); for (byte b : data)…
user_4685247
  • 2,878
  • 2
  • 17
  • 43
5
votes
2 answers

grouping, comparing, and counting rows in r

I have a data frame that looks as the following: system Id initial final 665 9 16001 6070 6071 683 10 16001 6100 6101 696 11 16001 6101 6113 712 10 16971 6150 6151 715 11 16971 6151 6163 4966 …
5
votes
2 answers

Counting lattice points inside a triangle

I've points for a big triangle lets call it a, b, c. (a = (x, y) and so on). Now I want to count the number of integral points inside the area enclosed by this triangle, so I first looked at Pick's theorem. The second approach that I considered was…
5
votes
3 answers

Counting Overlaps of Integer Ranges

I've been stumped on this algorithm for quite a bit. Say there are four ranges of integers. Each range has a Start and an End value. Range A: 0,5 Range B: 4,12 Range C: 2,10 Range D: 8,14 From these values I would like to get a new set which…
Sam Washburn
  • 1,817
  • 3
  • 25
  • 43
5
votes
3 answers

Alternatives to GCC's new atomic integer operations

GCC's recent support for atomic operations (as described here) is great, and is 90% of what we need. Unfortunately, some of our products still need to run on Windows and so we need atomic integer operations for Windows as well. In the past, we had…
dicroce
  • 45,396
  • 28
  • 101
  • 140
5
votes
2 answers

Difference bloom filters and FM-sketches

What is the difference between bloom filters and hash sketches (also FM-sketches) and what is their use?
navige
  • 2,447
  • 3
  • 27
  • 53
5
votes
2 answers

How do I count characters in a string, excluding certain types?

I need to determine the total number of characters in a textbox and display the value in a label, but all whitespace need to be excluded. Here is the code: var sLength : string; i : integer; begin sLength := edtTheText.Text; slength:=…
user1291092
  • 105
  • 4
  • 9
5
votes
1 answer

Count in base 2, 3, 4 etc in Java and output all permutations

I want to write a function in Java that takes as input an integer and outputs every possible permutation of numbers up to that integer. For example: f(1) 0 f(2) should output: 00 01 10 11 f(3) should…
tree-hacker
  • 5,351
  • 9
  • 38
  • 39
4
votes
0 answers

How to count number of words spoken using any method (SR or otherwise)

I am having some trouble getting pointers to how to perform what appears to be a deceptively easy task: Given an audio stream, how do you count the number of words that have been spoken, in real-time? I don't need to recognize what the words are,…
Alex Sirota
  • 83
  • 1
  • 6
4
votes
0 answers

Counting characters in a string with SSE Intrinsics

I am trying to implement a character-frequency function in C. This task is very simple of course, simply loop over the string and increment like this: for(cycle = 0; cycle < length; cycle++){ integer = line[cycle]; bins[ integer*length+cycle…
Mark
  • 41
  • 2
4
votes
5 answers

Count elements in a multidimensional array

Ive got this code: loadData : function(jsonArray) { var id = $(this).attr("id"); for(var i in jsonArray) { $("#"+id+" tbody").append(''); var header = { 1:…
Brad Morris
  • 43
  • 1
  • 1
  • 3
4
votes
1 answer

Counting sticks that touch red lines in Julia

I want to randomly "scatter" sticks of length 1 like shown in the diagram. I also want to count the sticks that touched the red lines. My approach was to create normalized vectors that are oriented randomly in space. The problem is that they are…
4
votes
3 answers

counting colums in csv file with python

I want to count email accounts of male and female separately the code I wrote is not working properly so can anyone help me with this, please here is my code thank you in advance import csv mailAcc = {} femailAcc = {} with open('1000…
imhamza3333
  • 174
  • 8
4
votes
3 answers

Counting digit occurrences

This problem is really confusing me; we're given two integers A, B, we want to count occurrences of digits in the range [A, B]. I though that if we could count the number of digit occurrences in the range [0, A] and [0, B], then the rest is trivial.…
Chris
  • 26,544
  • 5
  • 58
  • 71
4
votes
1 answer

Binning Pandas value_counts

I have a Pandas Series produced by df.column.value_counts().sort_index(). | N Months | Count | |------|------| | 0 | 15 | | 1 | 9 | | 2 | 78 | | 3 | 151 | | 4 | 412 | | 5 | 181 | | 6 | 543 | | 7 | 175 | | 8 | …
Axle Max
  • 785
  • 1
  • 14
  • 23