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
8
votes
2 answers

count the number of binary string of length n that is repeatable

The problem is to find the number of repeatable binary strings of length n.A binary string is repeatable if it can be obtained by any sub string of the binary string that repeats itself to form the original binary string. Example "1010" is a…
Prashant Bhanarkar
  • 930
  • 3
  • 14
  • 32
8
votes
1 answer

C++ Biological Cell Counting with OpenCV

I'm relatively new to OpenCV and I do not have a strong image processing background. Currently I am working on a project to write a program to count all the biological cells from microscope in an image. I have tried various method from Internet…
Woody
  • 612
  • 9
  • 21
8
votes
5 answers

Counting occurrences of integers in an array

I'm writing a program that counts the occurrences of integers entered into an array, eg if you entered 1 1 1 1 2 1 3 5 2 3, the program would print out the distinct numbers followed by their occurrences, like this: 1 occurs 5 times, 2 occurs 2…
Len
  • 133
  • 2
  • 7
8
votes
1 answer

Python : counting module imports?

I am a mid end python developer at an animation studio, and have been presented with a unique diagnostics request ; To assess what code gets used and what doesn't. Within the sprawling disorganized structure of Python modules importing modules : I…
jorxster
  • 217
  • 2
  • 11
8
votes
3 answers

using javascript, how can I count a mix of asian characters and english words

I need to take a string of mixed Asian characters (for now, assume only Chinese kanji or Japanese kanji/hiragana/katakana) and "Alphanumeric" (i.e., Enlgish, French), and count it in the following way: 1) count each Asian CHARACTER as 1; 2) count…
user224513
  • 81
  • 1
  • 2
7
votes
7 answers

Counting digits using while loop

I was recently making a program which needed to check the number of digits in a number inputted by the user. As a result I made the following code: int x; cout << "Enter a number: "; cin >> x; x /= 10; while(x > 0) { count++; x =…
E.O.
  • 794
  • 6
  • 16
  • 24
7
votes
2 answers

How can I count the number of cases in recursive functions?

def calcPath(trace_map, x, y): n = len(trace_map) count = 0 if x > n - 1 or y > n - 1: pass elif x < n and y < n: if x + trace_map[x][y] == (n - 1) and y == (n - 1): count += 1 elif x == (n - 1)…
7
votes
4 answers

Count common sets of items between different customers

I have data on customers and the different products they have purchased: Customer Product 1 A 1 B 1 C 2 D 2 E 2 F 3 A 3 B 3 D …
Mooks
  • 593
  • 4
  • 12
7
votes
4 answers

Count occurrences of value in a map

I have a map of the following type: private HashMap> entireMap; The keys go from 1 - n. The subMap inside the entireMap is of the following type: HashMap subMap = new HashMap
sHarivaRi
  • 83
  • 1
  • 1
  • 9
7
votes
2 answers

C++ Counting Map

Recently I was dealing with what I am sure is a very common problem, which essentially boils down into the following: Given a long text, calculate the frequency of each word occurring in the text. I was able to solve this problem using…
Tomasz Kaminski
  • 900
  • 7
  • 14
7
votes
1 answer

How to detect and count a spiral's turns

I need to detect a spiral shaped spring and count its coil turns. I have tried as follows: Image ProcessImage(Image img) { Image imgClone = new Image( img.Width, img.Height); imgClone =…
Rick2047
  • 1,565
  • 7
  • 24
  • 35
6
votes
2 answers

Python algorithm of counting occurrence of specific word in csv

I've just started to learn python. I'm curious about what are the efficient ways to count the occurrence of a specific word in a CSV file, other than simply use for loop to go through line by line and read. To be more specific, let's say I have a…
laotanzhurou
  • 65
  • 1
  • 1
  • 5
6
votes
1 answer

Faster way of counting total number of columns in a cassandra row with hector

I want to count the total number of columns for a Cassandra row using Hector client. Currently I am doing this with a CountQuery, but it seems really slow to me. Also for a row, with just 60k columns it's taking nearly 2 seconds. My code currently…
disco crazy
  • 31,313
  • 12
  • 80
  • 83
6
votes
3 answers

Counting merge sort with three permutations of 1, 2, ..., n, working in O(n log n)

I am looking for an algorithm running in O(n log n), based probably on merge sort with counting. Which will give the number of such pairs in 3 strings(being permutations of the string 1, 2, 3, ..., n) that one number of the pair follows the other…
Leon
  • 63
  • 4
6
votes
2 answers

How do you calculate the total number of all possible unique subsets from a set with repeats?

Given a set** S containing duplicate elements, how can one determine the total number all the possible subsets of S, where each subset is unique. For example, say S = {A, B, B} and let K be the set of all subsets, then K = {{}, {A}, {B}, {A, B}, {B,…
Nixuz
  • 3,439
  • 4
  • 39
  • 44