1,930 questions
4
votes
2
answers
115
views
How to reduce multivariate boolean expressions
I need to model a system of several boolean expressions in 512 variables. Due to the number of variables, I found the expressions are way too large to handle normally, which is why I need a way to ...
1
vote
1
answer
123
views
How to set a boolean flag True after entry and back to False after exit using Pandas (vectorized)?
I'm working with a Pandas DataFrame where I need to track a boolean flag (in_position)
that becomes True after an entry_signal and resets to False only after an exit_signal.
This must be done ...
5
votes
2
answers
189
views
How does the `(…) and (…) or (…)` idiom mimic a ternary operator in Lua?
This statement mimics a ternary operator in the Lua programing language:
local result = condition and true_value or false_value
But how does it work? Why does it give true_value if the condition is ...
1
vote
2
answers
107
views
truthy values == false return true
So I am a beginner at javascript and learnt that there are only a limited falsy values: false, 0, -0, BigInt 0n, “”, null, undefined, NaN
Yet when I use the == operator with truthy values, this ...
4
votes
2
answers
492
views
Check if all values of Polars DataFrame are True
How can I check if all values of a polars DataFrame, containing only boolean columns, are True?
Example df:
df = pl.DataFrame({"a": [True, True, None],
"b": [...
0
votes
1
answer
57
views
Combining multiple OR conditions with AND in Excel formula
I am trying to combine OR conditions with AND over multiple columns in my Excel datasheet and would like advice on how to do this. A sample table is shown below.
The formula does not calculate the two ...
0
votes
1
answer
44
views
Troubleshooting of Boolean combination of AND and OR conditions in Excel Formula [duplicate]
I am trying to set up an Excel conditional formula with both AND and OR criteria.
However, the last 2 criteria OR(Table1[Col5]=$J$4,Table1[Col5]=$K$4) and OR(Table1[Col6]=Pivot!$J$5,Table1[Col6]=Pivot!...
1
vote
0
answers
46
views
Draw a border(s) around a hand-drawn SVG path with fabric.js
I'm using fabric JS free drawing mode to generate a bunch of hand-drawn SVGs. I then composite these onto a canvas. I convert them to a bitmap Image for rendering so that I can easily union all of the ...
0
votes
0
answers
58
views
Logical condition equivalent with restrictions
I am developing an Azure DevOps custom task. Part of the setting of the inputs is a VisibleRule which can contain a condition which will determine if the input will be visible, if the condition is ...
0
votes
0
answers
89
views
Using 2x4 active decoder and a NOR gate design a XOR gate
I am trying to create a a XOR gate. only from 2x4 and NOR Gates. however I am stuck. Please draw the diagram or give image of this.
9
votes
0
answers
321
views
Limiting the depth of Boolean expressions
I am given a Boolean expression of arbitrary depth, like (A or (B and (C or (~D and E) or F) or (G and H))). There can be any number of terms at each level.
I want to limit the depth of the ...
-2
votes
1
answer
160
views
c++: Is (a || b) || c; equivalent to if (!a && !b) { c; }
I'm updating somebody else's code.
They did the following :
bool a();
bool b();
a() || b() || std::clog << "whine about something" << std::endl;
I'm replacing the std::clog bit ...
0
votes
1
answer
66
views
How do i make an onTap toggle Icon to switch between two 'username' and 'Anonymous on Flutter?
I am making a Charity App project, and I am struggling to figure out how to have an anonymous button before someone submits their donation. I want the anonymous option to display before someone ...
0
votes
1
answer
58
views
How do I construct a boolean circuit from a boolean function when I cancelled our one of the variables?
I was given a truth table of four variables, let's call them A,B,C,D. I found every instance where the truth table was true and turned it into a function:
F = (-A^-B^-C^-D) v (-A^-B^-C^ D) v (-A^-B^ C^...
0
votes
6
answers
184
views
How to return false if only one specific condition is true and no others? [closed]
In the following (paraphrased) code, I am checking various conditions, updating them, and scheduling a single notification regardless of the number of changed conditions. If none of the conditions are ...
-1
votes
1
answer
645
views
Write the Boolean Function F(A,B,C,D) using no more than 2 Nor Gates
I am working on a problem where I have to draw a logic circuit using no more than 2 Nor gates. The function F(A, B, C, D) = Σ(2,4,10,12,14) with don't care conditions Σ(0,1,5,8). After drawing the k-...
1
vote
1
answer
159
views
Idiomatic alternative for operator logical-and-equals?
C++ has 'accumulator' operations for arithmetic (+,-,*,/) , and for bitwise operations AND and OR - but not for logical operations.
Now, in our code, we sometimes need to conjunct many boolean values -...
-2
votes
1
answer
145
views
Counter in custom sequence using JK flip-flops
I need a counter that displays a custom number sequence instead of counting up or down.
I know I'm gonna need 3 JKs, meaning 2 ICs with 2 flip-flops. a few logic gates, but I don't really get how I ...
1
vote
2
answers
285
views
Simplify a boolean expression with 4 variables to 3 variables
I'm doing some simplifications for a circuit and I ended up getting the following expression:
A.C'.D' + A.B'.C' + B.C.D' + B'.C.D + A'.B'.D'
which translates to the truth table where 0, 2, 3, 6, 8, 9, ...
5
votes
4
answers
386
views
How to evaluate nested boolean/logical expressions in Python?
I'm working on a complex rule parser that has the following properties:
A space character separates rules
A "+" character indicates an "AND" operator
A "," character ...
-1
votes
1
answer
95
views
Is there any better way to write this piece of code? [duplicate]
I am a beginner in this, I was curious if i can write the below code
more efficiently.
I can't use loops or conditional statements, just logical operators.
double a = Double.parseDouble(args[0]...
1
vote
0
answers
57
views
Unity project: I'm having error regarding a code
I'm currently working in a Unity project where I need to create an AR project. Also I need to give guidance to the user. In my case, the working of multimeter is working.. but when I try to implement ...
1
vote
1
answer
152
views
Generate as short as possible boolean formula from a given truth table [closed]
Given a truth table, maybe 3-vars, 5-vars or even 10-vars, i can write its formula in DNF or CNF, and simplify it using K-Map or Quine-McCluskey algorithm. But it is based on {NOT, AND, OR}. Now the ...
0
votes
1
answer
64
views
Compare 3 CASE expressions for an overall value
I have a Postgres database with a table named servers containing these columns:
compliance status
operating system version
reference ID - if a server is not compliant or the os is not the latest ...
0
votes
1
answer
49
views
Invalid Qualifier - For two sets of Boolean Conditions
Hi I'm new to Excel VBA trying to tell the VBA to autocalculate should my autocalculate checkbox be selected.
And if the autocalculate checkbox is selected, to check if the RectanglePerp checkbox is ...
0
votes
1
answer
164
views
Is there an algorithm trick to solve bracket placement permutations in boolean expressions?
The problem (original found here) is to be given a random string of t's and f's (standing for boolean true/false) separated by one of & | ^ e.g. "T&F|F^T&T^F" and write a ...
0
votes
1
answer
104
views
How to simplify these clauses into implications for an implication graph?
For a uni project I have to create an implication graph from clauses.
For example, from the clause (a or b), I can determine these implication :
¬a -> b
¬b -> a
but I really can't find the ...
1
vote
2
answers
320
views
OR-Tools CP-SAT conditional constraint
In the problem I am trying to solve, I have a list of length n of boolean variables called x. Given an integer m where m < n, I need to define these two constraints:
if LinearExpr.Sum(x[m:]) > ...
0
votes
0
answers
127
views
LC-3 Assembly OR operation
Displays a newline followed by "Enter First Number (4 binary digits): " as a prompt for the user to input a four-digit binary number.
Accepts user input for the first number, echoing each ...
0
votes
0
answers
61
views
How the logical operators works in java? [duplicate]
I executed the below java code in IDE. the first sysout prints false. where as second sysout prints true. Some websites says because of operator precedence this occurs.
System.out.println(false &&...
0
votes
0
answers
60
views
My TempArray always has the wrong values and therefore doesnt evaluate properly and I am confused why
I am writing a program to evaluate a boolean algebra equation such as A'B + C'
Ive tried changing how the temparray is read or created and im not sure what im missing
Im relativey new to this so it ...
1
vote
2
answers
114
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.
#
#...
0
votes
1
answer
48
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. ...
-1
votes
1
answer
42
views
How to make an alert show up when the page won't load AND it's been 7 seconds
How to make an alert show up when the page won't load AND it's been 7 seconds.
This is the expected behavior and I would like the alert to explain to the user why this is happening. I see this code ...
0
votes
0
answers
85
views
Derive conditions for each variable assignment from pseudocode
I have some pseudocode that is in the form:
patch a:
if b == "foo1"
then
a = "No"
if c == "foo2"
then
if d == "foo3" || d == "foo4&...
0
votes
0
answers
117
views
Problems with Drag and Drop system in Unity
I'm a beginner to C# code and having trouble figuring out how to get a certain game feature to work.
I want the player to be able to drag images into slots, press a button to check, and receive ...
1
vote
1
answer
320
views
How to output a 5 bit number from a ripple-carry adder/subtractor into a 5 bit decoder to account for overflow in Verilog?
I am working on a project that will take two 4-bit numbers between 0-9 and add/subtract them to be displayed in a seven segment display. Here is a big picture idea of what I am trying to create
My ...
0
votes
1
answer
834
views
Most optimal way of running intensive math calculations on a GPU
I am doing some academic/educational research (topic is related to boolean logic and it's extensions), and there is a mathematical algorithm that I would like to verify over some large set of numbers, ...
-3
votes
1
answer
53
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
...
-2
votes
1
answer
203
views
Simplification of a logical expression for logic (laws of logic algebra)
I am currently trying to learn how to simplify logical expressions. But I'm stuck on this problem where I have to simplify this expression using the laws of logic (Boolean algebra).I would like some ...
0
votes
0
answers
80
views
PySpark filter works incorrectly with one True built using lambda funtion
I was debugging a function and I have encountered a misterious thing:
Given a PySpark dataframe with one column (name_id) I build another (is_number) one using a lambda function to see if name_id is a ...
0
votes
1
answer
44
views
Changing boolean value from another servlet to stop the loop
I have a for loop which runs based on value of boolean variable.
public class LoopClass{
..
private boolean[] toInterrupt = new boolean[];
public boolean getValue() {
return ...
0
votes
1
answer
425
views
Multisim - AND Gate Always Giving An Output
I recently downloaded Multisim to give it a try. I used it many years ago and recently have a need to design some circuits so it was my first go-to. However, I am run into issues where the ...
0
votes
1
answer
443
views
Boolean Logic - Two Input Boolean Functions - Truth Table function's output clarification
I do not understand the truth table (Figure 1.2) function's output (the four right columns)
The function input variables (x and y) have bold numbers to the right of them, that I am not sure how to use,...
2
votes
1
answer
106
views
Application of Monads
The code below provides for testing the satisfiability of a 2-SAT boolean formula (a formula containing just clauses of the form X v Y). Although other algorithms exist (strongly connected components ...
0
votes
1
answer
96
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 ...
-2
votes
2
answers
63
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 ...
1
vote
1
answer
134
views
PHP : false OR false OR true == false? [duplicate]
I don't understand what's going on here in PHP.
I've spent hours on this until I understood that it doen't work normally, or that I dont understand something.
Here the few lines :
$test = false OR ...
2
votes
1
answer
321
views
logic gates to control 2 swiches and 2 lights
I have 2 switches that correspond to 2 lights and I would like to control them with logic gates. My problem starts when a switch is ON and the second one goes into ON as well.
In this condition, I ...
1
vote
0
answers
38
views
Having trouble getting code to draw kmap based on user input, and grouping them based on SOP and POS then writing them in simplified and original
Can you fix this code for me?
#include
#include
#include
#include
#include
using namespace std;
// Function to print the Karnaugh Map
void printKMap(const vector<vector>& kMap, const ...