Skip to main content

Questions tagged [boolean-expression]

A boolean expression is an expression in a programming language that produces a boolean value when evaluated, i.e. one of true or false.

boolean-expression
Filter by
Sorted by
Tagged with
1 vote
0 answers
46 views

Python: How to slice a 2d array to specified range of x and y values? Also how to improve this code?

I have a meshgrid given by X and Y of unequal length and a 2d array of values vx2. I want to create a sub-2d array Z from a certain xlim and ylim. I want to create a contour plot but since matplotlib ...
Pundarikaksha Kavipurapu's user avatar
0 votes
2 answers
24 views

Google Sheets - formula for multiple values from different columns are fulfilled

I need to find a formula that can tell me if certain conditions are met in multiple columns. I have Column A "Day of Week" and Column B "24 Hr Clock" In column C I would like to ...
Ron B's user avatar
  • 1
2 votes
3 answers
212 views

Checking for False when variable can also be None or True

Update: please see my discussion if you want to delve further into this topic! Thank you everyone for your feedback on this! I have a boolean(ish) flag that can be True or False, with None as an ...
AutumnKome's user avatar
0 votes
1 answer
27 views

implement a function to group cells when simplifying Boolean expression using K-map

In order to implement simplification of a 5-variable Boolean expression using Karnaugh map, I write a JavaScript function to group cells (which input is a list of integers specifying minterms): ...
Duy Duy's user avatar
  • 581
1 vote
0 answers
25 views

QueryDSL BooleanExpression exclude data if the field is null

I have a problem when try to use a filter in a query that have a null field. if (StringUtils.isNotBlank(query)){ expression = expression.and(qAdopt.name.containsIgnoreCase(query) ...
Michael Navarrete Cartes's user avatar
0 votes
2 answers
61 views

Evaluating logical expressions recognized by ANTLR using the System.Linq.Expressions namespace

I've defined a grammar, which I have to parse in C# and evaluate the resulted "constraints" on a list of dictionaries. The grammar is mainly boolean algebra. Here you can check it: grammar ...
vencelbajnok's user avatar
-2 votes
1 answer
44 views

What is the most elegant way of checking if multiple objects exist, in Node.js? [duplicate]

Suppose I have several environment variables, going by the hypothetical names OBJECT_A, OBJECT_B, OBJECT_C, etc. I must implement a function doTheyExist() that must return a boolean. I want to know ...
Pedro Falcão's user avatar
2 votes
2 answers
111 views

How is this (xy)' + (yz) simplified into this (x’+y’)+z in boolean algebra?

I not understand how the first Boolean expression on the question can be simplified into the last. Please help me. My attempt: 1. (xy)' + (yz) 2. (x' + y') + (yz) # Using de Morgan's law. 3. x' + (y' +...
Alix Blaine's user avatar
0 votes
1 answer
35 views

Octave: Boolean AND returns wrong number

I am trying for several hours to calculate a boolean AND operation in Octave. It return a wrong number. I want to calculate following numbers: result = 4037 & 63 result should be 5 but i get 1. I ...
user19471767's user avatar
1 vote
2 answers
80 views

How do I get this code to accommodate any given number by only using boolean logic (no conditionals/ functions)

Here is the problem: number = 1101 #You may modify the lines of code above, but don't move them! #When you Submit your code, we'll change these lines to #assign different values to the variables. # #...
XYZ's user avatar
  • 19
0 votes
0 answers
36 views

Retrieve data based on boolean logic

I'll get right to my question. I have an API that gives me a number of items based on a category I input. I can only request one category per API call. Now I want to retrieve a number of items using a ...
stuckonhere's user avatar
0 votes
1 answer
102 views

Can reification predicates from CLP(FD) be used to check equality of logic expressions?

According to the documentation (section A.9.12), CLP(FD) constraints such as #>, #=, #/\ etc. can be reified. Constraint #<==>/2 is supposed to be True iff P and Q are equivalent according ...
Yui Rio's user avatar
0 votes
1 answer
36 views

Trouble with boolean logic in if (else) statements

I am trying to create a function that returns a different greeting depending on two variables: the country and time provided. If time is greater than or equal to 0 but less than 12 it will be morning. ...
Umar Hussain's user avatar
0 votes
1 answer
54 views

designing a circuit with 3 3-bit inputs and 4 1-bit outputs

The inputs are A[2:0], B[2:0] and C[2:0] respectively. The outputs are E,RA,RB,RC. If at least at one of the inputs (A,B,C) none of the bits are equal to 1 or if at least at one input the bits that ...
Bhuhu's user avatar
  • 1
0 votes
1 answer
57 views

Yacc : Boolean and Arithmetic expression grammars conflict

I'm implementing a compiler as part of a class, for a language which is supposed to support both arithmetic and boolean expression. Unfortunately, I'm having some trouble implementing rules for both ...
ice-wind's user avatar
  • 828
-1 votes
1 answer
69 views

Confusion with Boolean Expressions in C / < and > are reversed? [closed]

I am a bit confused. < means that the right side of the number is bigger, no? So natually, the while condition while (height > 0 && height < 9); in #include <cs50.h> #include &...
Deni's user avatar
  • 1
0 votes
2 answers
49 views

What is a good way to verify if arguments of a function are numbers

I have a function which takes in 3 arguments and I want to make sure those three arguments are numbers. As of right now, I've made this after a bit of experimenting and it seems to work but I'm not ...
Chargou's user avatar
2 votes
1 answer
86 views

Reduce if/else-if on a bunch of partially overlapping conditions

I was trying to solve a coding problem which ended up with these conditionals: x_A2 <= x_B1 OR x_A1 >= X_B2 --> 0 x_A1 <= x_B1 <= x_A2 --> x_A2 - X_B1 x_B1 <= x_A1 <= x_B2 --...
user3621272's user avatar
-3 votes
1 answer
52 views

Booleans Values

Which of the following will be fully evaluated that first option will be checked inclusive the second option, if the following variables represent the following boolean values a = True b = False ...
Kondwani Paul Kufeyani's user avatar
-2 votes
1 answer
98 views

How is boolean xx = (43.3L == 3.333f) syntactically correct

I'm have a problem with understanding this question about syntax it says the answer is boolean xx = (43.3L == 3.333f); but i don't understand how it is Which of the following Java statements are NOT ...
Edward lucas's user avatar
0 votes
1 answer
85 views

Why is '(x in list_1) == True' is True but 'x in list_1 == True' is False? [duplicate]

I know this is can be a very basic question, but I found something curious on Python. I will try to explain this with the following example: l = [1,2,3,4,5] n1 = 1 We know the following: print( n1 in ...
Sebastián Silva's user avatar
1 vote
2 answers
53 views

Subsetting a Boolean variable in Python

When a DataFrame ("Given_DF") has a Boolean variable (such as B below),how can one subset the DataFrame to keep only rows of Variable B with True value?. Given_DF ID A B 0 123 ...
sonicpoem's user avatar
-1 votes
1 answer
43 views

PHP - false == 0 but false != "00" [duplicate]

I had a problem with checking falsy conditions and don't understand how 'false' works. I tested the code above, echo (0 == false); //->true echo ("0" == false); //->true echo ("0&...
Nicolas Henry's user avatar
1 vote
1 answer
49 views

check to see whether an object exists in dict

a = {1 : 4} print(4 in a) # case 1: False a = {1 : 's'} print('s' in a) # case 2: False a = {1 : None} print(None in a) # case 3: False a = {1: True} print(True in a) # case 4: True so my ...
cardinal2000's user avatar
1 vote
2 answers
270 views

How to solve " Controlling expression is not an 'essentially Boolean' expression " in MISRA code?

I have a simple macro function which will check the condition and return an Boolean value. Below is the snippet of code assume: #define boolean bool Test.h file #define CHECK_STATE(X) (...
user2986042's user avatar
  • 1,156
0 votes
1 answer
83 views

Bool in C# works something unclear for me

Here goes an example of C# code. I did not get why in first case we will have 1 instead of 0. Why does it return 1 instead? static void Main(string[] args) { int firstNumber = 0; bool ...
DeepBlue's user avatar
-2 votes
2 answers
49 views

Boolean Logic and For Loops

I was wondering if those familiar with codingbat's problems might be able to help me with understanding the differences between these two solutions and why one doesn't work. The problem: Given a ...
AzureBoredom's user avatar
0 votes
0 answers
120 views

Essential Prime Implicant with "don't care"

How to count Prime Implicant/ate and Essential Prime Implicant/ate when I have don't care in my K-map? For xample, for the following K-map, how many PI and EPI do I have?: enter image description here ...
cucucucu's user avatar
-2 votes
1 answer
100 views

How exactly does the "and not" operation in python works [duplicate]

i am trying to learn python and for that i am watching a course, in which the core concepts of the language are being taught. I wrote the following code, in which a secret word has to be guessed: I ...
mdot's user avatar
  • 1
2 votes
1 answer
111 views

Resolve Java Interface ambiguity in method parameters

I have a tree of boolean operations from a boolean expression that I have to run in Java. The tree would be something like this: And I would need to run it in Java iteratively so that it returns me a ...
simondx's user avatar
  • 73
-1 votes
2 answers
136 views

How do I identify the Boolean Expression of this logic circuit?

As the title says, what can be the possible boolean expression of the logic circuit given? The Truth table is also included.Logic Circuit I have tried to solve my own Boolean Expression and coded it ...
Ragna Alt's user avatar
1 vote
1 answer
57 views

Can I use a boolean mask to find if a DateTime value falls between two other DateTime values in a different dataframe

I want to filter the datapoints I have, until I only have the datapoints were the participant was asleep left. I have my dataframe with DateTime values and the values I am researching, and a different ...
Marloes's user avatar
  • 13
0 votes
0 answers
182 views

SOP Boolean expression of state variable and output of a Moore FSM

Disclaimer: I'm studying for an exam, but I don't have to hand in anything. I have the state transition diagram of the FSM and its states encoding: I want to find the Sum-Of-Products Boolean ...
sansarc's user avatar
  • 65
0 votes
1 answer
47 views

Python: real order of execution for equalities/inequalities in expressions? [duplicate]

Imagine this "sneaky" python code: >>> 1 == 2 < 3 False According to Python documentation all of the operators in, not in, is, is not, <, <=, >, >=, !=, == have the ...
oBrstisf8o's user avatar
-1 votes
1 answer
54 views

Boolean operator 'and', expect False answer if one expression is False?

I´m a 1 week self taught python3 guy, and i´m into the comparison and boolean operators and learn this: True and True True True and False False False and True False False and False ...
Jaime Cordoba's user avatar
0 votes
0 answers
220 views

How to Convert string to boolean with function CASE WHEN in PostgreSQL

Full Query: SELECT '' as [id], a.OrganizationId as [organization_id], a.AdmissionNo as [admission_no], a.AdmissionDate as [admission_date], p.MrNo as [mr_no], ...
My August's user avatar
0 votes
1 answer
38 views

Why does IF statement fail?

I have a horrible feeling that the answer to this question is going to be obvious, but... I am reading data from a small file in MicroPython. The value of the line I read determines whether a bool ...
PhilTilson's user avatar
0 votes
1 answer
176 views

Generalized product-of-sums Boolean expression with n true variables out of m total variables

Problem How do you write a "product-of-sums" Boolean expression, in m Boolean variables, which enforces at least n of those variables being 1/true? Attempt Starting in the "sum-of-...
Lazy Titanic's user avatar
0 votes
3 answers
698 views

Why can't I use a boolean expression in a SQL CASE expression inside a WHERE clause?

I want to write a query with the following logic: If @fundKey is greater than 0, look for funds with a key matching @fundKey. Otherwise, look for funds with a key less than 1000000. If I were to ...
Peter Olson's user avatar
3 votes
1 answer
289 views

Converting SHA256 into a SAT instance / Boolean expression using Lisp

I recently came across a discussion discussing conversion of SHA256 into a SAT instance by modifying the lisp implementation of SHA256 from Ironclad - sha-256 as a boolean function There is some ...
gautam's user avatar
  • 43
0 votes
1 answer
53 views

I keep getting an FileNotFoundException error, but I declared it thrown in the method and included a try/catch block [duplicate]

I can make this code work if I modify the main method class, but I am supposed to make it work WITHOUT modifying it at all. I'm confused as to what is causing the error. Here is the method I have ...
ConfusedFetus's user avatar
0 votes
1 answer
342 views

getting syntax error when checking boolean value with 'If' statement

I'm trying to detect 3 specific EMA crosses, assign them to boolean variable, plot them and set alerts when their conditions are true. I have no problem detecting and plotting the 3 crosses when they ...
andyt6886's user avatar
0 votes
1 answer
593 views

Karnaugh map & Quine McCluskey

I would like to know if the same answer should be obtained when simplifying an expression using a karnaugh map and the mccluskey method. I guess that it does but I would prefer to get a confirmation.
bestgamer14's user avatar
0 votes
2 answers
72 views

Python Sympy - Check if a variable is present in the monomials of the ANF of a Boolean expression

I have a Boolean expression that is transformed to its Algebraic Normal Form (ANF), with the logic module of Sympy. We don't know in advance what is the degree of the monomials of the ANF: it could be ...
Aster's user avatar
  • 61
1 vote
1 answer
100 views

Python Sympy - Select monomials from the ANF of a Boolean expression

I have some truth table in GF(2) and I compute the corresponding Algebraic Normal Form (ANF) or Zhegalkin polynomial. Below a dummy example with two variables. from sympy.logic.boolalg import ANFform ...
Aster's user avatar
  • 61
-2 votes
1 answer
81 views

I have trouble with changing the process of that code in Java [closed]

I have trouble with changing my code. I want to do that with a boolean and I have no clue how to do that. It is just confusing me. This is my task: Tyrepressure-test It is to check whether the ...
Tomas Bernatonis's user avatar
-4 votes
1 answer
141 views

Comparing an int initialization with a boolean operator for an if statement parameter

I've declared ints skyB and day, and written this line: if (skyB == true || (day=1) != true) { System.out.print("example text"); } Am I correct in assuming that the code will properly ...
Carson Turner's user avatar
2 votes
1 answer
292 views

Check if all rows are equal by group ID and return boolean value

I have a data frame where a unique ID is given to each unique instance where there is a string in either title.1 or title.2. Each ID is coded with one or more names. See below: title.1 title.2 name ...
bvecc's user avatar
  • 197
0 votes
1 answer
189 views

React - Conditional Rendering with Switch and boolean case

I would like to clarify a doubt on React Conditional Rendering with Switch Case I have an implementation with conditions. ie I have to set a string value based on boolean case For example let str = &...
Manushi's user avatar
  • 759
0 votes
0 answers
427 views

Kotlin elvis operator vs "... == true" boolean expression check preformance

Assume we have nullable val a: Boolean?. In code we want to assign value of a to another non-nullable variable val b: Boolean. If a is true then we want b also to be true If a is false or null the we ...
Dmitriy Fialkovskiy's user avatar

1
2 3 4 5
22