Questions tagged [logic]

Logic refers to the ultimate flow of your code and how you arrive your desired solution. Questions should relate to finding a coding solution (or improving existing coding logic) to a given problem. Please use with an appropriate language tag, a thorough description of your logic, and the relevant code you're working on. General logic questions are off-topic. If you simply need a code review, consider https://codereview.stackexchange.com

Filter by
Sorted by
Tagged with
0 votes
0 answers
37 views

Why is my C++ if statement executing even when the condition is false? [closed]

In the following cpp code snippet. Where I have used gsl library for integration purposes. j_n2 is called by J; it is a double integral process. They can throw an exception if a certain condition is ...
0 votes
1 answer
31 views

Read a file and print the first letter of each word

I need to read a file and then print the first letter of each word in lowercase and their position in the file. I made this code but it's not working and i don't know why. #include <stdio.h> #...
  • 7
1 vote
0 answers
17 views

JavaScript reduce instance thoughts and ideas

after using a reduce to find the instance of the amount of times a year appears. how would I return that object so that on the year with the most occurrences return. Also any recommendation as to ...
  • 11
-4 votes
0 answers
15 views

The event handler for the OnClick event of an ASP.NET button is not executing [closed]

The button's OnClick event is not producing any output or result button response on submitting
0 votes
1 answer
7 views

What would be the gate design for a 2 bit multiplier for signed binary?

I understand how a normal 2 bit multiplier works but it only works for positive numbers, so how would it work with signed binary. i tried using nand gates, half adders, and a xor gate
  • 1
0 votes
1 answer
26 views

PowerShell - Populate my listbox with a selection made in drop down list

I am trying to make an Application Deployment tool on PowerShell ISE by pipelining the data through Active Directory for admins. Since Active Directory doesn't have a feature of fuzzy search, I ...
0 votes
0 answers
22 views

Getting number of people assigned to a role and preventing setting a lower number

I am developing a database where we manage jobs and freelancers having skills we need for individual jobs, and then assigning them to those jobs. For example the jobs database with examples of one-day ...
-9 votes
0 answers
51 views

Dont understand this recursion logic [closed]

I have a simple recursive function: When I call the function; these are the following returns: sum ([1,2,3], 3); // returns "6" sum ([1,2,3], 2); // returns "3" sum ([1,2,3], 1); /...
  • 596
0 votes
1 answer
24 views

Z3 fails to check reasoning in predicate logic for an example from SYMBOLIC LOGIC By Lewis Carroll

; All rabbits, that are not greedy, are black ; No old rabbits are free from greediness ; Therefore: Some black rabbits are not old (declare-sort U) (declare-fun g (U) Bool) (declare-fun b (U) Bool) (...
0 votes
0 answers
17 views

I am having a logic error in my facial expression recognising program

The code doesnt have any syntax error and the model accuracy is 95% but when I feed it image to predict emotion, It usually just predicts one of the emotion at random for all inputs. Here is my code(I ...
0 votes
1 answer
41 views

Powershell Scripting - How to use less IF / IF-ELSE statements

I mainly code with PowerShell and 85% of my scripts are built with it. The more I go on and code, the more I realize that I always use IF statements, which to be fair are sometimes needed, but since I ...
  • 11
0 votes
1 answer
20 views

Is it possible to do Equivalence logic simplification with SymPy from discrete variable domains?

I've been using SymPy to do logic simplification (using their sympy logic module and it's working well with boolean expressions. I'm now trying to tackle a trickier problem, but I'm having troubles ...
0 votes
0 answers
18 views

how to write shorthand logic of echoing condition

{{$activePage === 'training-program' || $activePage === 'farmer-scientist' || $activePage === 'exposure' || $activePage === 'beneficiaries' ? '' : 'collapsed'}} how to write this shorthand logic in ...
1 vote
1 answer
33 views

Proving n + S n = S (n + n) without n + S m = S (n + m)

Is it possible to prove forall n, n + S n = S (n + n) (with or without induction) without using forall n m, n + S m = S (n + m)? Looking at the proof, if I start by using induction on n, we end up in ...
0 votes
1 answer
40 views

java swing with functional/declarative programming logic error

I'm trying to make a login function in java swing with functional programming style, below is my code String username = txtUsername.getText(); String passwordStr = String.valueOf(txtPassword....
  • 11
-1 votes
0 answers
19 views

Find Unique paths in a Grid with Obstacles in js?

Given a grid of size m * n, let us assume you are starting at (1, 1) and your goal is to reach (m, n). At any instance, if you are on (x, y), you can either go to (x, y + 1) or (x + 1, y).thats the ...
-1 votes
0 answers
11 views

How to find geo-location of a point on earth's surface knowing geo-location of another point nearby?

I am trying to write a program in which I want to find a point's geo-location. Consider two points a and b on surface of earth. Assume that I know the distance between both points and geo-location (...
0 votes
0 answers
18 views

Can't figure out this decision tree bug

I'm making a top trump type card game - but I'm stumbling on one of the controls. Been banging my head against the wall on this one - which is weird cause it seems like the simplest one to solve It's ...
0 votes
0 answers
13 views

Quine–McCluskey to cnf

I have trouble understanding how to get the cnf through the mccluskey algorithm. This is apparently the correct solution (below part) Solution At the top it's done via a kv map and that one makes ...
0 votes
1 answer
57 views

A function that determines if the empty list is part of a clause set

Theoretically my function should be able to return True or False if a set of clauses has the empty list ([]), I actually defined the next data type: data Literal = V String | NotV String deriving Eq ...
0 votes
0 answers
36 views

Is there API for Mail Flow Alerts that can be used in Logic Apps? [closed]

I've been trying to create a Logic Application that can pull alerts from Mail Flow (it's in Exchange Admin Center or Email & collaboration alerts in MS 365 Defender site). Have anyone tried it ...
  • 1
0 votes
0 answers
11 views

Logic App - Obtain SharePoint list and then loop over XML REST API Response to check against the SP List

I am looking for advice in being able to create a Logic App that first makes an API request to SharePoint to obtain items in a list every 5 minutes. Then using a REST API Get request to retrieve an ...
  • 1
0 votes
0 answers
47 views

Why is Math.round() for Java not working for 16.275? [duplicate]

I am trying to round 16.275 to 2 decimal places in Java using Math.round(). It should be 16.28, but it keeps printing 16.27. double x = 16.275; x = Math.round(x*100.0)/100.0; System.out.println(x); ...
  • 11
0 votes
0 answers
17 views

Three js GLTFLoader.js error with a flie source

I'm having Three js GLTFLoader.js error with a flie source. The error is reffered to Uncaught TypeError: Failed to resolve module specifier "three". Relative references must start with ...
0 votes
1 answer
21 views

Oracle fast formula condition to compare only the timestamp part

I am creating an Oracle fast formula, I need to check the time between 06:00 AM and 12:00 AM i.e. when the PAY_TIME > 06:00 AM and less than 12:00 AM. I am using the following - ...
2 votes
1 answer
60 views

MongoDB Query building is not working as expected in Node.js?

I am trying to build a MongoDB query based on OR and AND but having difficulties in making query logic, for every OR word between keywords, the keywords need to go in the Should block, and for AND ...
0 votes
0 answers
4 views

Electric current in the logic gate

sir, there is something I don't understand about the electric current that is passed as in the picture if the transistor is input (true) it will be channeled Electric current starts from the ...
  • 43
0 votes
0 answers
10 views

Django group_send messages are not sent instant

i am trying to build a lobby system for a game. I want the lobby to be startable and once started there should happen a countdown that is sent to each connected client. The problem is now that all ...
  • 97
0 votes
3 answers
25 views

find the total distance of point on x axis in js?

I am creating a program in JavaScript that will detect the line is in parallel to x or Y axis so here I want to distance of 5+3-2=6 for total distance but here I get the distance of 5+3=8 and 5-2=3 so ...
0 votes
0 answers
45 views

2 class html on 1 execution in jquery

Hello im having problem in carousel, i can execute 2 of them in jquery but the slide wont move, can anyone help me? and in mobile view it work for slide. also can i use array for jquery selector id? ...
  • 1
0 votes
2 answers
38 views

nested for loop bubble-sort logic (python)

(first time poster, already scared to post lol, apologies in advance, not too sure how to word my question properly but i'll give it a go!) I don't fully understand the logic itself behind the for ...
-1 votes
0 answers
17 views

My rewind and fast forward functions arent working properly with pygame music mixer [duplicate]

For some reason my rewind and fast forward functions arent working properly with pygame music mixer, the fast forward functions works fine and increments by 10 seconds as its supposed to at first but ...
0 votes
0 answers
12 views

Gödel didn’t prove the incompleteness?

Gödel’s proof considers an arbitrary system K containing natural number. The proof defines a relation Q(x,y) then considers ∀x(Q(x,p)) where p is a particular natural number. The proof shows that the ...
0 votes
3 answers
35 views

Formula to use to convert the hours entered to 1/4th hour

I am creating a Oracle fast formula where I am trying to round the time entered by employee to the nearest 1/4 hour. 15-22 minutes = 0.25 hours 23- 37 minutes = 0.50 hours 38-52 minutes = 0.75 hours ...
0 votes
1 answer
65 views

String of binary, determine even or odd, then do mathematical operation

You are given a string S of length N which encodes a non-negative number V in a binary form. Two types of operations may be performed on it to modify its value : if V is odd, subtract 1 from it if V ...
  • 25
0 votes
1 answer
46 views

Bottom Sheet not automatically getting dismissed when navigating to another view in SwfitUI

I am using bottom sheets in SwiftUI and when I navigate to another screen the bottom sheet is not getting dismissed. Does anyone know if this is supposed to be the default behaviour for bottom sheets. ...
0 votes
0 answers
20 views

Change clock's hour by selected option value

How can I change clock's hour hand when I select the option value in a select tag. For example by default I need the time to be actual, and if I choose +2UTC timezone I get the actual hour time + 2 ...
2 votes
2 answers
66 views

Why is this the truth table for AND,OR with NULL?

In the following truth table for AND and OR using a NULL value (taken from a MySQL query): I am guessing that NULL AND NULL|NULL OR NULL will never short-circuit so return the final NULL. But how do ...
  • 107k
0 votes
1 answer
29 views

Player Movements in RPG Java Game - Simultaneous key pressing

In my java RPG game, a KeyHandler checks which of the WASD key is pressed during playstate: `if (gp.gameState == gp.playState) { if (code == KeyEvent.VK_W){ upPressed = true; } ...
0 votes
0 answers
41 views

Encode any String to fixed length which can Decoded back

Encode a string containing alphabet's , number's and special character's to a specified length I found a answer which allows to do this for numbers only : Answer Can this be done for a string ...
-3 votes
3 answers
50 views

Python pop function starts over indexing

I'm trying to remove all instances from a list, for example 9. I have an ordered list: num = [1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 10, 11, 12, 13] arg = 9 I use bisect_left(num, 9), this returns 8 (...
-1 votes
0 answers
9 views

having a problem for simplify this statement that a'b'c+abc'

this is the statement: A'B'C + ABC' so, when I put this in chat gpt it shows c(A'B') + C(AB') like this, so, I need fair reason for how this second step came. i tried check every note that i have to ...
0 votes
0 answers
20 views

How to Implement Dual Input Methods for User Interaction

I'm currently working on a project that requires the user to provide input using either a text-based method or a voice-based method. I'm struggling to figure out how to simultaneously run two ...
-2 votes
1 answer
79 views

Why can't all existential binders be replaced by unique constants during skolemization?

When using skolemization to replace existentially quantified variables in an expression, any existential bound at the top level can be replaced by a new globally unique constant, however if the ...
-1 votes
0 answers
7 views

Only Having a Pop-up After All Questions Are Answered

I have three Y/N questions in my REDCap survey and I'm trying to make it so that if they say no to any of the three questions, a pop-up shows after they fill out all of the three questions. Is there ...
  • 1
0 votes
1 answer
58 views

Logic App HTTP GET request : I put 2 app id & secret but i got output for one app . Can someone help me out

Can someone help me out ......!
1 vote
1 answer
68 views

Are nested ifs equals to and logic?

I wonder whether these two Python codes are always the same or not. if condition_1: if condition_2: some_process and if condition_1 and condition_2: some_process I searched but did ...
0 votes
0 answers
12 views

Incorrect valid coins value. Error in code logic

I am assigned with the task of giving coins to the user on successful delivery of an order. The coins come with an expiration date of 45 days. I am using MongoDB and have 2 collections: User and ...
1 vote
2 answers
31 views

Check if an integer from a tuple is between the values of another tuple

def are_values_crossed(tuple_1, tuple_2): if tuple_2[0] <= tuple_1[0] <= tuple_2[1]: return True if tuple_2[0] <= tuple_1[1] <= tuple_2[1]: return True if tuple_1[0] <= ...
  • 835
-1 votes
0 answers
25 views

how to order a forEach?

after doing the first fetch I get an array with values, I do a forEach and then I do another fetch to translate the values ​​and use them as options in a select, what is happening is that in the first ...

1
2 3 4 5
185