counting

Counting non-empty values in each column of a table

醉酒当歌 提交于 2019-12-08 12:41:20
问题 I am looking for missing data in a data migration project, and this report will help me immensely. Given a MySQL table, I would like to count all the empty (NULL or '') values in each row of that table. The output would be a list of column names and a count of empty or non-empty rows for each column. This data is something I would manually compare to the source tables - manually because I expect few counts to match up exactly and column names are completely different between the source and

Counting listView items error

…衆ロ難τιáo~ 提交于 2019-12-08 09:16:17
问题 I am trying to count listView items. Im using this code: int count=0; ListView listView = (ListView) findViewById(R.id.listView1); for(int i = 0; i <= listView.getLastVisiblePosition(); i++) { if(listView.getChildAt(i)!= null) { count++; } } Toast.makeText(getApplicationContext(), String.valueOf(count), Toast.LENGTH_SHORT).show(); Why the COUNT variable value is always 0, when listView display some records? 回答1: If you are looking for count of all ListView items, you can use this call (make

Get node descendants in a tree graph

霸气de小男生 提交于 2019-12-08 05:22:53
问题 I have a directed graph ( grafopri1fase1 ) the graph has no loops and it has a tree structure (not binary tree). I have an array of nodes ( meterdiretti ) that i have extracted from the graph ( grafopri1fase1 ) matching a condition. I would like to know starting from each node of Meterdiretti how many nodes are under each node of Meterdiretti . The result I would like to have is a Matrix with the following format first column------------ second column meterdiretti[1] -------- total amount of

Getting the number of cases in a switch-case in C

天大地大妈咪最大 提交于 2019-12-06 12:13:26
Is it possible to get the number of cases in a switch case in C without manually adding a counter variable which is incremented in each case? As I commented earlier, I think you want a dispatch table rather than a switch statement. Here's a little example. Say you got this: int find_the_case(); void do_something(); void do_something_different(); void do_something_completly_different(); void do_default(); int main(int argc, char *argv[]) { int c = find_the_case(); switch(c){ case 0: do_something(); break; case 1: do_something_different(); break; case 5: do_something_completly_different(); break

Finding all closed loops in a graph

徘徊边缘 提交于 2019-12-06 11:04:47
问题 I am trying to write a Python code which will identify all of the closed loops within an arbitrary graph. By a closed loop, I mean a loop which visits no vertex more than once, with the exception of the vertex the loop starts on (in the case of this picture, DGHD is an example, as is BCDB , or BCEFDB , or etc). I tried doing this with matrix multiplication, writing the graph as a matrix with 1s where 2 verticies are connected, and a 0 where they aren't, and putting them to the nth power,

Counting Overlaps of Integer Ranges

牧云@^-^@ 提交于 2019-12-06 05:44:04
问题 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 counts of the number of the ranges that fall in a particular span of ints. Each of these would have Start, End and Count values, producing something like this: (Start, End, Count) 0,1,1 (Only 1 range (A) falls between 0 and 1 inclusive) 2,3,2 (2 ranges (A

How can I find and count number of files matching a given string?

删除回忆录丶 提交于 2019-12-06 01:22:08
问题 I want to find and count all the files on my system that begin with some string, say "foo", using only one line in bash. I'm new to bash so I'd like to avoid scripting if possible - how can I do this using only simple bash commands and maybe piping in just one line? So far I've been using find / -name foo* . This returns the list of files, but I don't know what to add to actually count the files. 回答1: You can use find / -type f -name 'foo*' | wc -l Use the single-quotes to prevent the shell

Counting lattice points inside a triangle

不打扰是莪最后的温柔 提交于 2019-12-05 14:06:29
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 generating a list of points bounded by max, min of the triangle, and then checking if each point lies inside the triangle. I used the Barycentric coordinates method to do this. It works however my triangle is pretty huge and my program is basically a brute force across points. How do I improve on this algorithm? My code can be found here: https:/

Function to count hashtags

我的未来我决定 提交于 2019-12-05 09:02:16
问题 I'm trying to get a function that counts and shows hashtags of a list. Example input: ["Hey, im in the #pool", "beautiful #city", "#city is nice", "Have a nice #weekend", "#weekend <3", "Nice #"] Output: {"pool" : 1, "city" : 2, "weekend" : 2} But if there is only a # followed by no words, it should not count as a hashtag. Same with stuff before the hashtag, something like „%#“ is not allowed to count as a hashtag. Hashtags are defined (a-z,A-Z,0-9) every other char ends the hashtag My

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

淺唱寂寞╮ 提交于 2019-12-05 07:30:30
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 total 株式会社マイコ = 7 chars my only idea so far is to use: var wordArray=val.split(/\w+/); and then check each element to see if its contents are alphanumeric (so count as 1) or not (so take the array length). But I don't feel that's really very clever at all and the text