342 Answered Questions for the topic logic

06/25/19

#### Why is ''>0 True in Python?

In Python 2.6.4: >> ''>0 True Why is that?

06/23/19

#### python build a dynamic growing truth table?

My question is simple: "how to build a dynamic growing truth table in python in an elegant way?" for n=3 for p in False, True: for q in False, True: for r in False, True: print '|{0} | {1} |... more

06/22/19

#### Check severeal boolean returns in same time?

I have several bool elements and I am checking it if returns me false. bool i = false; switch (idcount) { case 1: i = p1(); break; case 2: i = p1() & p2(); break; case 3: i = p1() &... more

06/21/19

#### Can we implement a doubly-linked list using a single pointer?

I want to use a structure like: struct node { char[10] tag; struct node *next; }; I want to use the above structure to create a doubly-linked list. Is that possible and if yes, then how I can... more
Logic Java C# Algorithm

06/19/19

#### Display 1,2,3,4,5,6,8,10,11 as 1-6,8,10-11?

> I have this sequence **1,2,3,4,5,6,8,10,11** > > Expected output is **1-6,8,10-11** This problem is about formatting the sequence in easy readable form I tried with c# and used many... more

06/19/19

#### How can I simplify this set of if statements? (Or, what's making it feel so awkward?)?

My colleague showed me this piece of code, and we both wondered why we couldn't seem to remove duplicated code. private List<Foo> parseResponse(Response<ByteString> response) { if... more

06/19/19

I'd like to get the sign of a float value as an int value of -1 or 1. Avoiding conditionals is always a good idea in reducing computational cost. For instance, one way I can think of would be... more

06/19/19

#### Why does 2 && 3 results in 3 (javascript)?

When I type in browser's console: console.log(2 && 3) it results always with second number (in this case 3): 3 Can someone explain me why?
Logic Java

06/19/19

#### A java practice problem?

I came across this problem in javabat(http://www.javabat.com/prob/p183562): > We want to make a row of bricks that > is goal inches long. We have a number > of small bricks (1 inch each)... more
Logic Php

06/19/19

#### What should be passed into if() to print 'Hello World'?

What should be passed into the if() to print the output as "Hello World"? [Note: It should execute the else block.] if(?){ } else { echo "World"; }

06/19/19

#### Fastest way of finding the middle value of a triple?

Given is an array of three numeric values and I'd like to know the middle value of the three. The question is, what is the <i>fastest</i> way of finding the middle of the three? My... more

06/19/19

06/19/19

#### Parsing Java Source Code?

I am asked to develop a software which should be able to create Flow chart/ Control Flow of the input Java source code. So I started researching on it and arrived at following solutions: To create... more
Logic Javascript

06/19/19

#### Can !a!=!!b^!!-!a||!+!a|!c return anything other than 1?

I was playing the Javascript game with somebody and we were having fun making ridiculous and absurd expressions to make our inputs get a particular output. This little charming one ... more

06/19/19

#### General rules for simplifying SQL statements?

I'm looking for some "inference rules" (similar to set operation rules or logic rules) which I can use to reduce a SQL query in complexity or size. Does there exist something like that? Any... more
Logic Java Algorithm

06/19/19

#### All possible words?

I want to create all possible 5 letter words using a-z.Please suggest any good and fast algorithms. I have tried creating one and it looks something like this... byte[] allchar=new byte[]... more
Logic Html Jquery

06/19/19

#### Find the number of lines in a div?

I want to show 'View All' kind of link, only when the lines in the div has reached 4 lines. **HTML** <div> 3PAS-Pub-IO-doubleclick.net-LI, ATOM_DFP_Pub_LI,... more
Logic

06/17/19

#### Let p and q represent the following simple statements. ​p: I study. ​q: I graduate. Write the following compound statement in symbolic form. Upper I do not study or Upper I graduate.

Let p and q represent the following simple statements.​p: I study.​q: I graduateWrite the following compound statement in symbolic form.I do not study or i graduatethe symbolic form is.
Logic Math

05/29/19

#### A bag of rivets weighs 1050g. 114 rivets weighs 10g. How many rivets in the bag?

I initially figured this as 10/114=0.088g per rivet. Meaning 1050g/0.88g=11,931.818181... rivets in the bag.But now I'm second guessing myself. I truncated the weight per rivet to 0.088g/rivet. It... more

05/29/19

#### How to parse a string of boolean logic in PHP?

I'm building a PHP class with a private member function that returns a string value such as: 'true && true || false' to a public member function. (This string is the result of some regex... more

05/24/19

#### 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... more

05/22/19

#### Is "I cannot imagine a mechanism for X to happen, so X can never happen" a named logical fallacy?

"I have encountered this reasoning quite frequently: Somebody posits the hypothesis that an event X can happpen. A recent example I encountered was ""vinegar and salt in the boiling water make... more
Logic

05/21/19

#### Logic: is ( A && !(B || C)) || ( B || C ) the same as ( A || B || C )?

I've encountered some obj-c code and I'm wondering if there's a way to simplify it: #if ( A && !(B || C)) || ( B || C ) is this the same as? #if ( A || B || C ) If not, is there... more
Logic C# Date .net

05/21/19

#### End of month calculations?

Just wondering if any know of an elegant solution for the following. If I have 30 June 2009 and I add a month I want it to go to 31 July 2009, not the 30 July 2009. This logic is based on the... more

## Still looking for help? Get the right answer, fast.

Get a free answer to a quick problem.
Most questions answered within 4 hours.

#### OR

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.