logic

Boolean Expression

How can you express X of Y are true, in boolean logic? a rule like 2 of the following must be true (A, B, C, D, E, F) is it a form of multiplcation or set operations? the end result is all the permutations like AB OR AC OR AD, if you said 3 of following it is like ABC, ABD, ABE, etc.. so it is like (A,B,C)^2? thanks! ...

ASP.NET logic / connection pooling and error handing

Hi I just uploaded my first ASP.NET (as part of my learning of vb.net) and got into awful mess with the connection pooling (funny things happen when there are more than 1 user of your web site) all sorted now by better use of the try catch statements (well the idea was to learn) BUT I was wondering if this is the best / final method, no...

Best way to learn First Order Logic

Hi, I'm going back to Uni to do an MSc and for one of my target courses I need to know first order logic, inlcuding semantic tableaux and resolution inside out. I don't have an academic background in the subject, so what's a good book, or online course, or online resource to learn this subject? I need clear explanations with lots of que...

Algorithm to determine the "usual" cash payment amounts for a given price

You walk into a store, select several products, then go to the counter to pay your bill. The total is some amount (A). You reach into your wallet, purse, or pocket and put down some cash (P), where P >= A, and the cashier gives you change. Given the set of coins and bills that are in circulation, what are the most likely values for P? ...

Pagination Problem [PHP]

So I'm doing this in PHP but it is a logic issue so I'll try to write it as generically as possible. To start here's how this pagination script works: for (draw first three pages links) if (draw ellipsis (...) if there are pages between #1's pages and #3's pages) for (draw current page and two pages on each side of it links) if (draw ...

Why is this a "so close yet so far" if statement?

I am working on an If statement and I want to satisfy two conditions to ignore the loop. This seemed easy at first, but now... I don't know. this is my dilemma... if((radButton1.checked == false)&&(radButton2.checked == false)) { txtTitle.Text = "go to work"; } The dilemma is "go to work" is not executed if radButton1 is false a...

Solving "Who owns the Zebra" programmatically?

Edit: this puzzle is also known as "Einstein's Riddle" The Who owns the Zebra is an example of a classic set of puzzles and I bet that most people on Stack Overflow can solve it with pen and paper. But what would a programmatic solution look like? Based on the clues listed below... There are five houses. Each house has its own unique...

What is the best way to specify execution time of recurring jobs or tasks?

I am looking for a way of efficiently specifying a recurring job execution time without having to write an explicit execution time to a datastore. In other words, rather than saying 'job x next runs at 13.00pm on 11.12.08' and then having to update the execution time for the following week once the job has run, I want to be able to say '...

What is domain logic?

What is domain logic? The Wikipedia page for domain logic redirects to business logic. Are they the same thing, and, if not, how do they differ? ...

Web crawler links/page logic in PHP

I'm writing a basic crawler that simply caches pages with PHP. All it does is use get_file_contents to get contents of a webpage and regex to get all the links out <a href="URL">DESCRIPTION</a> - at the moment it returns: Array { [url] => URL [desc] => DESCRIPTION } The problem I'm having is figuring out the logic behind determining wh...

What is fuzzy logic?

I'm working with a couple of AI algorithms at school and I find people use the words Fuzzy Logic to explain any situation that they can solve with a couple of cases. When I go back to the books I just read about how instead of a state going from On to Off it's a diagonal line and something can be in both states but in different "levels"....

Using API/Function calls or going for the Cron Job approach - An inquiry into dealing with transactions - How would you handle it?

Hey Everyone, I wanted to run something by you guys. I am starting a new project which is roughly the following: Important information: I am using PHP and MySQL Every minute I get a list of to-do transactions from an API from different users. Example: user1 send $1 to user2 userx send $2 to usera userw send $0.50 to user2 etc.. ...

How do you get the logical xor of two variables in Python?

How do you get the logical xor of two variables in Python? For example, I have two variables that I expect to be strings. I want to test that only one of them contains a True value (is not None or the empty string): str1 = raw_input("Enter string one:") str2 = raw_input("Enter string two:") if logical_xor(str1, str2): print "ok" el...

PHP/RegEx - Logic for prepending table names

So I'm trying to build a script that automagically prepends valid column names with its appropriate table prefix (e.g. "t." or "r.") $t_columns = array('id', 'name', 'label'); $r_columns = array('related_value'); INPUT: id > 1 AND (name = 'Hello' OR label IN ('World', 'Planet name AND label')) AND (related_value > 1 AND related_value...

Logical Operators: is AND better than OR?

Sorry if this is a comp-sci 101 question. I'm just unsure if I'm missing something obvious. So let's say some user input throws an error, and I want to catch it and return some feedback. The error will be a number, 0 - 8. 0 means "No Error". I want to give the user very specific feedback if the error is 3 (No numbers allowed, let's say)...

How do you help people learn logic?

People who are not IT, more specifically programmers, do not have a good way of solving problems. They simply do not think like us, programmers, who have a good logic. I have been asked too many times what I would recommend them to improve their logic which would eventually help with day-to-day professional problems. Things that come up ...

How would you implement this digital logic in Verilog or VHDL?

I posted an answer to another stackoverflow question which requires some digital logic to be implemented in Verilog or VHDL so that it can be programmed into an FPGA. How would you implement the following logic diagram in Verilog, VHDL, or any other hardware description language? The numbered boxes represent bits in a field. Each field...

Misunderstanding MixColumns step

I'm having an issue understanding the MixColumns step described here. I know about diffusion and it all makes sense up the the point where it states that each column is treated as a polynomial and multiplied modulo over GF(2^8). BUT..multiplying in GF(2^8). Although the domain is still the same, it is not reversible due to mod.... and ...

Please help me shorten this t-sql query...

I need to shorten this query and while I'm pretty good at SQL, I'm still learning. SELECT 'doejoh', DATETIME, [Recipient-Address], [Message-Subject], [Sender-Address] FROM dbo.Logs WHERE LEFT([Recipient-Address], 6) IN ('doejoh') UNION ALL SELECT 'doejoh', DATET...

NoElementException but I print the element and get the expected result

What I am trying to do is save a Move objects into a Vector called topMoves. There will be many Move objects which is why I create the object within the loop. The pastPriceMap stores prices for stocks at some past time (in this case one minute ago). The currPriceMap stores price for stocks some time within the last second. I get the fo...