How to count number of distinct days from one table using two dates (for range) from another table for each row?

So I have one datatable with three columns: userid, mindate, maxdate. I have another datatable that contains all the login logs for each user.

I need to make a query so that I can sum all the distinct login days from one datatable between the mindate and maxdate from another datatable for each user.

The code I can write until:

SELECT a.*, b.logins FROM ‘usertable’ as a
LEFT JOIN (SELECT user_id, COUNT(DISTINCT(loginday)) from ‘logintable
GROUP BY user_id) as b
on a.userid = b.user_id;

I just need help adding a ‘where’ statement that can query from b like:
WHERE loginday between a.mindate and a.maxdate.

Thank you!

Finding the number of distinct strings in regular expression

Given the regular expression $$(1 + \varepsilon + 0 )(1 + \varepsilon + 0 )(1 + \varepsilon + 0 )(1 + \varepsilon + 0 )$$, how many distinct strings are in the language? How do you determine this from looking at the regular expression? Do I have to generate a table of all possible combinations or is there a more straightforward way?

Combinations and Permutations of M sets of distinct items?

I’m wokring on this problem for a while. I want to know:

1. The correct name of this problem, so I can look it up in textbooks\online.

Here is the problem descirption:

The (un-ordered) combinations to be generated are:

• of 1 item size: {a1}, {a2} …. {c4}
• of 2 items size: {a1, b1}, {a1, b2} … {b2, c4}
• of 3 items size: {a1, b1, c1}, … {a3, b2, c4}

The question is: Given any number of sets M where each set has distinc number of items, How many (un-ordered) combinations are there of size 1, 2, …, up to M? And how to generate those combinations?

Fast way to count distinct pairs of integers

I have a association list, S, whose size is about 5*10^4. I also have a function F which takes in ordered pairs of elements from S, and spits out ordered pairs of integers. There is some amount of repetition among these outputs of F.

I’d like to compute the exact cardinality of the image of F, if that’s possible.

How do attackers hit a website with thousands of similar but distinct IP addresses?

I have a website that is being hit with invalid URL requests by thousands of distinct IP addresses, never the same one used twice. Most of them are in a few ranges of IP addresses and often just go up sequentially.

Could this be a zombie botnet of compromised devices, or is it possible the attacker is spoofing these addresses?

The clustering of IP addresses into a handful of ranges seems inconsistent with what I would expect from random devices across the world being compromised and part of a botnet.

User agents are all legitimate and quite varied, but I know that is simple to spoof.

It doesn’t feel like a DDOS attack as it is “just” a few thousand per hour. If they really wanted to DDOS it seems like they would crank the volume up more. Once I adjusted some exception handling I was able to get my server to resume being responsive to legitimate use.

I suspect it is a malicious (poorly constructed) crawler/spider.

Is IP address spoofing easily done and common now in these scenarios?

Distinct Binary Heaps

I have $$n$$ elements out of $$n-1$$ are distinct. The repeated element is either minimum or maximum element. I need to figure out how many distinct max heaps can be made from it.

My analysis : I started with $$n$$ distinct elements. Since root is fixed( maximum element) we can choose $$l$$(found using deducting total elements from elements in penultimate level) from remaining $$n-1$$ elements and recursively choose for Left Sub-tree and Right Sub-tree.

Recurrence Relation :

$$T(n)={n-1 \choose l} * T(l) * T(r)$$

Now for $$n-1$$ distinct elements(given), for root we have $$2$$ options i.e. maximum elements and we can recurse as above for left and right sub-tree. But since the repeated element is also there I am not able to figure out exact way to do so.

Eg: $$A=[2,6,6] =>$$ There are 2 distinct max heaps $$=> [6,2,6] , [6,6,2]$$

I am unable to think of the way to find out the number of max heaps in this case. Can someone think of algorithm/recurrence relation to find so ?

SQL server Suma mas Distinct

Necesito sumar el campo (CantidadIngresa) para cada producto diferente, la suma se realiza correctamente, por ejemplo en el producto “GAZ” si sumo (4+5+2) = 11, esto es correcto, sin embargo necesito que me muestre cada producto una sola vez, pero a pesar de que uso la instrucción Distinct para que me muestre solo una linea por cada producto, me sigue mostrando los productos tantas veces como se repita. En el caso del ejemplo del GAZ, debería mostrarse solo 1 vez. Que es lo que estoy haciendo mal?

Instrucción SQL:

PowerApps How to get Distinct values of a SharePoint list which is a datasource of dropdown

I am building an app in SharePoint online using PowerApp, I have a dropdown which its data source is from a SharePoint list, it has duplicate data, so I need to get distinct values for the dropdown.

I check PowerApps documentation it has a formula like bellow

Distinct(Employees, Department) 

It works if your data connection is from Excel, but if your data connection is from a SharePoint list, I could not figure it out, any help is appreciated

Number of distinct BFS, DFS trees in a complete graph

What is the number of distinct BFS, DFS in a complete graph?

My approach is like this–>

For DFS take a node, we have (n-1) possible tree edges, next we have all possible (n-2) tree edges,…….finally 1 possible tree edge. and we can choos any of n nodes as rooot node. hence no of distinct DFS trees= n*(n-1)(n-2)….1= n!

For BFS tree if we take a node as root, we have to explore all its neighbors , so the number distinct of BFS trees =no of nodes we can choose as root ie. n .

Is this approach correct?

Magneto 1.x multiple and distinct messages on same page

Is it possible in Magento 1.x to have two distinct messages on a page. For my use case I want a main full width message at the top of the page and a smaller message in div lower down on the page.

At the moment when I set, for example, an error message I see the message rendered twice, but ideally I want to target one of the messages only.

This will happen on my checkout page, so at the moment I am using:

Mage::getSingleton('checkout/session')->addError('Please enter all required information'); 

I was thinking that perhaps I could make use of the customer session:

Mage::getSingleton('customer/session')->addError('Please enter all required information'); `

Would this enable me to have two distinct messages? I know the use case isn’t ideal but I am adding this to an existing project so the user journey cannot be fixed form the bottom up!