logic

Computing GoogleShare of N Terms

I need guidance in how I should compute the GoogleShare of several terms. For example, take the following base terms: "Tom Cruise" = 12,000,000 pages "John Travolta" = 4,900,000 pages Now if we add a second term: "Tom Cruise" + "Scientology" = 784,000 pages "John Travolta" + "Scientology" = 331,000 pages So the GoogleShare for T...

Simplifying an inequality for an SQL query.

For reference, this question was boggled, so thanks to everyone who helped unboggle it. I'm trying to locate potential collisions of events in a booking program where events have varying lengths. (a ≤ x && e ≥ y) || (a ≥ x && e ≤ y) || (a ≤ x && e ≤ y) || (a ≥ x && e ≥ y) I'm using DataMapper to accomplish this, but the query I had be...

Why does "x ^= true" produce false in this example?

Hi, Why does the statement z ^= true produce a false when the previous produces a true ? bool v = true; bool z = false; z ^= v; Console.WriteLine(z); z ^= true; Console.WriteLine(z); OUTPUT ====== True False ...

PHP test-scoring logic & improvement?

$arr = $results->row(); $score = 0; foreach ($arr as &$i) { switch($i){ case ($i <= 4 AND $i >= 1): $score += 1; break; case ($i < 8 AND $i > 4): $score += 3; break; case ($i >= 8): $score += .5; break; } } echo $score This is my...

Overlapping time in SQL server

I am having a table like this ColumnId Intime Outtime 1 01/02/2009 10.00.000 01/02/2009 20.00.0000 2 01/02/2009 2.00.000 01/02/2009 2.00.0000 3 01/02/2009 2.00.000 01/02/2009 5.00.0000 4 01/02/2009 3.3.0.000 01/02/2009 5.00.0000 5 01/02/2009 10.00.000 01/02/2009 22...

Parsing AND, OR query to formulate sql

I'm developping a mini search engine, and I want to implement the feature of searches based on logic operators AND OR... I'm having a difficulty on parsing a query containing AND, OR, NOT... especially when it comes to parentheses... (cat or dog) not (bike not mike) For simple AND, and OR queries, it's obviously too simple and I figure...

Dynamic JavaScript If Statement

In PHP I can do: // $post = 10; $logic = >; $value = 100 $valid = eval("return ($post $logic $value) ? true : false;"); So the statement above would return false. Can I do something similar in JavaScript? Thanks! Darren. ...

Rewrite max using two and statements.

Say I want to rewrite A <= MAX (B, 100) using only AND statements and substractions. <= means smaller or equal. A and B are variables. Is it possible? I can't seem to use OR's using the Microsoft Solver foundation in this contrived example, which is a simplification of a problem I have at work : Decision x = new Decision(Domain.Real, "...

C/C++ HTTP library, that handles only the logic?

I am looking for an HTTP library for C/C++, that handles only the protocol logic, instead of the actual transport mechanism. Libraries I've came across tend to incoperate the entire communication process, which is not what I need. However, I'm looking for something that's more than merely an HTTP parser. Ideally it would also take care ...

Best way to calculate accuracy and display meaningful results

My current method allows me to determine the most accurate array but I cannot figure out a good way to display informative results. Here’s my situation … I compare X amount of integer arrays to a static integer array. For each position in the array I calculate the position’s accuracy result by comparing to the equivalent position in th...

Combinational logic design question, what does it mean for input to be asserted

The question reads: consider a 4-input boolean function that is asserted whenever exactly two of its inputs are asserted, construct its truth table, and then other parts for the question. I don't want an answer i would like to solve this myself, i just want to know the meaning of assert and how to start with the truth table. Any help is...

[Logic question] sum of products for that using k-map

Hi, I have a logic question: If I have: f(A,B,C,D) = M(4,7,8,11).D(1,2,13,14) what would be the sum of products for that using k-map (please note that this is big-m and you have to find the answer in the sum of products) I drew the k-map, the problem is, I can't find a way to cover the zeros without having to state 4 terms each with ...

UI/logic separation - could anyone recommend a good source of knowledge

Hey! I am a newcomer in the area of user interfaces. I am working now on the design of a user interface for a piece of code I have in C++ language. I've decided to use QT for creating the UI. Now, what I am mostly concerned in is what is the proper way of separating the UI from the logic. I have some data layer, which should be acces...

Best Practices in Storing and Accessing WebApp User Privacy Settings?

If you allowed people to determine who could view their user information, what would be the best way in which to store and access that information? They would be setting their preferences in any of these ways: User Based (select specific users - ie. Block: "Munch", "Dummy") Checkbox Based (select one or many groups of users - ie. "My ...

Queries count for page in asp.net mvc

Hi! I want to calculate how much queries are executed when i request a page in asp.net mvc. Difficults in page logic: sum queries are executed in main controller action, but others - in widget controller actions, which are called by Html.ActionLink in master page. I wrote base class for all controllers in which i'm encapsulate query c...

Directional Logic PLC

How do you determine direction of inputs using ladder diagrams with a PLC? Meaning, how do you save the previous state? Previous state of inputs. I need to determine direction that photobeams were activated.. forward or reverse. If they are activated in reverse, perform one action. If they are activated forwards, perform a different act...

Implementing 5-variable function using multiplexers

If I have a 5-variable function (below) and I want to implement it using a multiplexer, how would I do that (using the minimum possible multiplexer): f(A,B,C,D,E) = A + C'D + BD' + B'D + B'CE This is homework, so don't provide a solution, just a guidance of how that works. Thanks! ...

Assembly mask logic question

This is very simple, but I haven't been able to figure it out yet. This question is regarding a assembly mmx, but it's pure logic. Imagine the following scenario: MM0: 04 03 02 01 04 03 02 01 <-- input MM1: 02 02 02 02 02 02 02 02 MM2: 04 03 02 01 04 03 02 01 <-- copy of input after pcmpgtw MM0, MM1 MM0: FF FF 00 00 FF FF 00 0...

Grid based puzzle board game block removal algorithm

I have a "samegame" grid represented by a 1D array of integers. 0 to 63 to represent an 8x8 grid. the rules are that same coloured blocks of two or more can be removed by clicking on them. blocks then slide down from above. if a column is empty columns other columns move in from the sides. when someone clicks on the green blocks in t...

How to do while loops with multiple conditions

Hi I have a while loop in python condition1=False condition1=False val = -1 while condition1==False and condition2==False and val==-1: val,something1,something2 = getstuff() if something1==10: condition1 = True if something2==20: condition2 = True ' ' I want to break out of the loop when all these cond...