counting

Search Engines Inexact Counting (about xxx results)

When you search in Google (i'm almost sure that Altavista did the same thing) it says "Results 1-10 of about xxxx"... This has always amazed me... What does it mean "about"? How can they count roughly? I do understand why they can't come up with a precise figure in a reasonable time, but how do they even reach this "approximate" one? I...

Reference Counting in C++

Hello. I'm implementing a math library in C++. The library will be compiled to a DLL so those who use it will only need the header files the classes' definitions. The users of my classes will be people who are new to the language. However, there are some objects that might be referenced in several parts of their programs. Since I don't ...

Counting the number of occurrences of words in a textfile

How could I go about keeping track of the number of times a word appears in a textfile? I would like to do this for every word. For example, if the input is something like: "the man said hi to the boy." Each of "man said hi to boy" would have an occurrence of 1. "the" would have an occurence of 2. I was thinking of keeping a diction...

Fastest way to count number of bit transitions in an unsigned int

I'm looking for the fastest way of counting the number of bit transitions in an unsigned int. If the int contains: 0b00000000000000000000000000001010 The number of transitions are: 4 If the int contains: 0b00000000000000000000000000001001 The number of transitions are: 3 Language is C ...

Basic Pixel/Cell Counting Algorithm

Good night :) I am currently playing with the DevIL library that allows me to load in image and check RGB values per pixel. Just as a personal learning project, I'm trying to write a very basic OCR system for a couple of images I made myself in Photoshop. I am successfully able to remove all the distortions in the image and I'm left wi...

Algorithm for Counting Sorted Strings (Homebrew "uniq -c")

Hi all, I have the following already sorted data: AAA AAA TCG TTT TTT TTT I want to count the occurrence of each string yielding AAA 2 TCG 1 TTT 3 I know I can do that with "uniq -c", but here I need to do extra processing on the overall C++ code I have. I am stuck with this construct (modified according to 'pgras' suggestion) #...

Index of x Recurring Character

The following code is supposed to show in a message box the index of the third a in the string checkme, but when I run the program it doesn't give me the right answer (should be 12, instead I get 9). What am I doing wrong and how would I go about making it work? Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System....

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, B}, {A, B, B}} and therefore |K| = 6. Another example would be if S = {A, A, B, B}, the...

How do I count the characters, words, and lines in a file, using Perl?

What is a good/best way to count the number of characters, words, and lines of a text file using Perl (without using wc)? ...

item frequency count in python

Hi, I'm a python newbie, so maybe my question is very noob. Assume I have a list of words, and I want to find the number of times each word appears in that list. Obvious way to do this is: words = "apple banana apple strawberry banana lemon" uniques = set(words.split()) freqs = [(item, words.split.count(item)) for item in uniques] print...

RegExp Counting System

I'm trying to create a system where I can convert RegEx values to integers and vice versa. where zero would be the most basic regex ( probably "/./" ), and any subsequent numbers would be more complex regex's My best approach so far was to stick all the possible values that could be contained within a regex into an array: values = [ "...

Code Golf 4th of July Edition: Counting Top Ten Occurring Words

Given the following list of presidents do a top ten word count in the smallest program possible: INPUT FILE Washington Washington Adams Jefferson Jefferson Madison Madison Monroe Monroe John Quincy Adams Jackson Jackson Van Buren Harrison DIES Tyler Polk Taylor ...

Time-Delayed MySQL "Update" for More Realistic Tally of Online Video Views

I'm creating a video embed page for a real estate site, where a user can go to watch a video tour of a given home. There is no other reason to visit that particular page, so I figured that I could use a simple MySQL Update to a "video view tally" column for that homes's row, which will update views=views+1 each time the page is loaded. ...

AppleScript Word Count Service

Hi folks, I am trying to create a service in OSX leopard that counts the number of words of selected text. I have automator set to run an applescript, with the following put in it: on run {input, parameters} count words of input display alert "Words: " & input return input end run When I compile the script, it...

Counting all the keys pressed and what they are (python)

I'd like to create a map of the number of presses for every key for a project I'm working on. I'd like to do this with a Python module. Is it possible to do this in any way? ...

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 custom assembly language implementations for all our platforms, but I'd like move all the...

Counting solutions to linear inequalities

I am trying to solve a problem which I have reduced down to counting the number of integer solutions to a number of linear inequalities. I need to be able to count the number of solutions for any number of variables c_1, ..., c_n, but for n=3 the equations could be written as: Now, I know the values of n and r in advance and wish to f...

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

Hello, 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 each Alphanumeric WORD as 1; a few examples: 株式会社myCompany = 4 chars + 1 word = 5...

Counting problem C#

Hello, I've a bit of a problem. I'm adding numbers to ArrayList like 156, 340 (when it is TransferIn or Buy) etc and then i remove them doing it like 156, 340 (when it's TransferOut, Sell). Following solution works for that without a problem. The problem I have is that for some old data employees were entering sum's like 1500 instead o...

Getting the most frequent items without counting every item

Hi. I was wondering if there was an algorithm for counting "most frequent items" without having to keep a count of each item? For example, let's say I was a search engine and wanted to keep track of the 10 most popular searches. What I don't want to do is keep a counter of every query since there could be too many queries for me to count...