341 Answered Questions for the topic logic

03/19/19

Median of 5 sorted arrays?

I am trying to find the solution for median of 5 sorted arrays. This was an interview questions. The solution I could think of was merge the 5 arrays and then find the median [O(l+m+n+o+p)]. I... more
Logic C++

03/19/19

C++ interview preparation?

I have a Phone interview coming up next with with a company which works in financial software industry. The interview is mainly going to be in C++ and problem solving and logic. Please tell me the... more

Interpret Bayesian probability as frequentist probability?

It is usually said that the Bayesian probability is a subjective concept, quantifying one's degree of belief in something, while the frequentist probability is the the fraction of certain outcomes... more

03/19/19

Universal and Existential Quantifiers of First-Order Logic?

I am taking a Scala programming course. At one point the instructor said: > Functions *blah* and *bladdy* are the universal and existential > quantifiers of first-order logic. Could someone... more
Logic Javascript

03/19/19

ReferenceError: Invalid left-hand side in assignment?

my code for a rock paper scissors game (called toss) is as follows: var toss = function (one,two) { if(one = "rock" && two = "rock") { console.log("Tie! Try again!"); } // more... more
Logic Philosophy

03/19/19

What is the difference between "necessary" and "sufficient"?

What is the logical difference between something being necessary in order for something else to be true; as opposed to something being sufficient to make something else true. i.e. Fuel is... more
Logic Sql Php Mysql

03/19/19

Showing Featured Item From the Database?

I have database table as below. id, bungalow_name, type, address, featured A bungalow can be featured in the home page. If a bungalow is featured, `featured` column has the value `1`. I have 50... more

03/19/19

Does a negative claimant have a burden of proof?

I have often heard it said that the burden of proof is on the positive claimant but not on the one making a negative claim. A person claiming, "God exists" has a burden of proof but not a person... more
Logic Sql Oracle

03/18/19

Swapping column values in Oracle?

I was solving one of the puzzles and came across swapping column values using DML queries: SELECT * FROM TEMP_TABLE; ID1, ID2 -------- 20, 15 20, 15 20, 15 Solution is mathematical... more

03/18/19

What is modal logic for?

I understand "pure" logic as a structural description of what a valid proof is but I have never understood the reasons for using modal logic. What's an example typical of how modal logic is used?

03/18/19

When to use conjunction and when to use implication? (First Order Logic)?

I'm learning First Order Logic at the moment. I'm looking at this example: Some dogs bark ∃x (dog(X) Λ bark(x)) All dogs have four legs ∀x (dog(x) -> have_four_legs(x)) My question is: is it... more

03/18/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 parseResponse(Response response) { if (response.status().code() !=... more
Logic Sql Oracle

03/18/19

oracle sql date not later than today?

I need to display some data if it's a - new data - updated data let's say, I will be basing these data from a publishdate column and updated column where publishdate and updateddate are both... more

03/18/19

Why does this if statement, with an assignment and equality check, evaluate to false?

How does a Java *if statement* work when it has an assignment and an equality check `OR`-d together?? public static void test() { boolean test1 = true; if (test1 = false || test1 == false) { ... more

03/18/19

What happens when you logical not a float?

I assume this just returns an int. Is there anything else going on I should be aware of? C/C++ differences? float a = 2.5; !a; // What does this return? Int? Float?
Logic Swift Ios Xcode6

03/18/19

Swift good coding practice: If statement with optional type Bool?

So I've been developing an app in Swift, and today I spent nearly an hour debugging a problem that turned out to be completely unexpected. It all resulted from the code below. if (hero.isAI) {... more

03/18/19

Any way to toggle between two strings using one piece of JavaScript?

I want to do something like if(something.val() == 'string1') { something.val('string2'); } else if(something.val() == 'string2') { something.val('string1') } But in one line of code. I... more

03/18/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 fastest way of finding the middle of the three? My approach is this kind... more

03/18/19

Determine if two strings are similar in Javascript?

Let's say I have two strings, is there any way to check if they are at least 90% similar? var string1 = "theBoardmeetstoday,tomorrow51"; var string2 = "Board meets today, tomorrow"; Thanks, Tegan more

What fallacy in Pascal's Wager allows replacing God with the devil?

I wanted to know the name of the fallacy or fallacies the Pascal's Wager in the sense that it can be applied to motivate one's belief in many things. A similar argument to the original Wager can be... more

03/18/19

Java method to find the rectangle that is the intersection of two rectangles using only left bottom point, width and height?

I have found the solution but wanted to ensure my logic is the most efficient. I feel that there is a better way. I have the (x,y) coordinate of the bottom left corner, height and width of 2... more

03/18/19

How to get started with philosophy without getting overwhelmed quickly?

I’ve spent a lot of time trying to find how to get started with philosophy but I can’t. It seems that getting started with computer programming is nothing in comparison - with computer programming... more

03/18/19

Does Pascal's Wager contain any logical flaws or fallacies?

Blaise Pascal's famous wager was that even if the existence of God cannot be determined through reason, a rational person should wager as though God exists, because living life accordingly has... more

03/14/19

How to create a method to return 1 or 0 without using conditions?

I was asked a question in an interview to return 1 if provided 0 and return 0 if provided 1 without using conditions i.e if, ternary etc Just to give you and idea below code without if's: public... more

What is the difference between a statement and a proposition?

I'm doing a MOOC on mathematical philosophy and the lecturer drew a distinction between a proposition and a statement. This is very puzzling to me. My background is in math and I regard those two... more

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

Ask a question for free

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

OR

Find an Online Tutor Now

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