Questions tagged [logic]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
80 views

Storing Sort Order in Database: match the business logic or the application logic? [closed]

Take a profile page for a job applicant with a list of names in a form with typical CRUD: Resume Name: Altenrate Name 1: Alternate Name 2: Alternate Name 3: Assuming we have some sort of Names table ...
user avatar
  • 1,339
-2 votes
1 answer
72 views

Is there a name for this kind of state machine?

I'm thinking of a GUI architecture that works like a finite-state machine where there is a set of possible states and a set of possible inputs--or events. The thing is, some states transition to the ...
user avatar
  • 162
4 votes
3 answers
236 views

Is it possible to store N bits of unique combinations, in N-1 bits? If not; why does MD5 get reprimanded for collissions?

Regarding cryptography and the issue of collisions, I posed a question as to whether it was ever possible to store every single possible combination of a bit array of a particular size, in a bit array ...
user avatar
  • 3,319
1 vote
0 answers
46 views

Best way to integrate google signin in existing user registration system with PHP/MYSQL [Logic]

I want to integrate google signin, in our existing user registration system. But not sure which approach will be good in terms of data security + user experience (UX) + speed. Even if its a good idea ...
user avatar
  • 111
1 vote
1 answer
146 views

How does the classic proof for the halting problem work?

I've looked up a lot proofs for the halting problem (that are basic enough that I can understand what they are trying say ^^) but for all of them I don't get their last step right before they pull the ...
user avatar
  • 129
-2 votes
2 answers
76 views

Nassi Shneiderman diagram: Which player has its turn?

I am trying to program a little game and for that I need to determine which's players turn. I am solving it firstly with a Nassi-Schneiderman diagram with a variable turn whic can be 1 or 2, but my ...
user avatar
  • 23
1 vote
2 answers
248 views

Logic App next number

I have a need to generate a next number for each file type my Logic Apps is generating. My Logic App is doing some translations between an WMS and a customer's ERP. The issue is the customer is ...
user avatar
3 votes
2 answers
3k views

Understanding LSB and MSB

In reference to one interface control document, I found difficulty in understanding this concept. There is one parameter having LSB of 0.0625 and MSB of 2048 that should be transmitted from one piece ...
user avatar
1 vote
1 answer
545 views

Why are next-state function and output functions of an FSM combinational functions?

From my understanding, combinational logic is dependent solely on input, and sequential logic involves state--memory. When explaining a finite state machine (FSM), however, it is said that an FSM ...
user avatar
  • 162
0 votes
2 answers
85 views

Divergent Bodies of Truth, Relationships of Concepts

A recent endeavor of mine requires asking users how related two concepts are. Example: Kiwi and Fruit. Identical? Fairly Similar? Rather different? Unrelated? It occurs to me that for certain ...
user avatar
  • 1,432
0 votes
1 answer
160 views

Algorithm to identify differences between two sorted data sets

PROBLEM STATEMENT: Print the items that differ between the following two left and right sorted data sets: A A B C C D D E G F H EOF EOF The proposed solution ...
user avatar
1 vote
1 answer
48 views

Eliminate areas of binary space and increment through result efficiently

The goal is to take a binary space, say 64 bits, and make certain parts of it "valid" and certain parts "invalid", then increment, starting at 0, through that space, avoiding the invalid areas. Space ...
user avatar
1 vote
3 answers
304 views

For which built-in C++ type is the law of excluded middle violated?

Apparently, for some built-in type of C++, the following does not hold: a==b || a!=b Which type/value is it? The question is originally from this video: https://www.youtube.com/watch?v=etZgaSjzqlU&...
user avatar
  • 41
0 votes
1 answer
190 views

load more and Search Logic

Firstly i hope im in the right place to ask this question. I am building a web page that allows the user to select one image from a set of a 100+. i want to display them 6 at a time and the user ...
user avatar
2 votes
2 answers
1k views

Confusion about strengthening/weakening preconditions/postconditions

I've recently become incredibly confused about the notion of "strengthening/weakening a precondition/postcondition". I think my confusion lies in my interpretation of the words "precondition" and "...
user avatar
4 votes
4 answers
217 views

Generation of logic tables from if conditions

Suppose I have a large, multi-line case statement, which checks several variables before returning a final value. case when (foo='bar' OR foo='foo') AND (bar='foo') then 200 when (foo='jar') AND (...
user avatar
  • 69
0 votes
1 answer
746 views

How to run 2-layer perceptron to solve XOR

XOR is not solvable by using a single perceptron with standard scalar product and unit step function. This article suggests using 3 perceptron to make a network: http://toritris.weebly.com/perceptron-...
user avatar
  • 103
0 votes
2 answers
149 views

Combine if blocks with repetitive code

I have this piece of code if (!expr1) { codeblock1; } elseif (expr2) { codeblock2; codeblock1; } It is pissing the hell out of me because I am trying to refactor it in such a way that ...
user avatar
  • 2,148
0 votes
1 answer
60 views

Separate context-dependent information from the core logic code

Say, I have a code file where all the core logic is located. In addition, I have some custom logic that is defined by some flags, like if (a && b && c) {} if (!e && f) {} ...
user avatar
0 votes
1 answer
68 views

sql - How do I add child of child when dependent on parent

I'm building a wpf application which interacts with a sql database. I'm confused about adding children of children in my window. For example.. I just created a fishing trip so my fishing trip doesnt ...
user avatar
1 vote
3 answers
493 views

Storing Business Logic in Tables rather than Stored Procedure or Application

The requirement is that once the product has been delivered, user can update the logic as he wants. An example of logic I have is follows- An institute teaches English has following requirements - ...
user avatar
  • 111
2 votes
2 answers
141 views

From a set of rules, derive the implications? [closed]

I've only just become interested in this domain, so sorry if I'm not using the correct terminologies. What I want is the following: Say I have a set of rules (or constraints), I want to derive some ...
user avatar
0 votes
1 answer
82 views

Possibility of retrieving X value after Bitwise OR operator

Z = X ∨ Y (where X, Y, Z are 96bits binary numbers) If I have "Z" value and "Y" value. Are there any possibilities to retrieve "X" value from "Z"? What I know ...
user avatar
0 votes
2 answers
425 views

in trouble making a card game with pygame

I am designing a card game playable against the computer. The rule is very simple Both player and CPU gets 10 cards of 1 to 10. Player and CPU plays a single card at the same time, every round. The ...
user avatar
-4 votes
2 answers
2k views

How can I Identify which condition satisfied the if statement? [closed]

Suppose, I am using a if statement as such: if(A || B || C || D) { echo "Hurrah! if is satisfied!"; echo "But! How can I know which was true of the 4 (A,B,C,D)"; } Is there any way I can ...
user avatar
0 votes
1 answer
765 views

Creating algorithms [closed]

I am a relatively new programmer. I can pick up languages and learn syntax at a speed that I consider good, but I can't figure out how to solve problems logically using algorithms very well. I know ...
user avatar
2 votes
1 answer
770 views

What algorithm can be used to determine order given incomplete information?

Given a series of statements such as: a<c a<b b<c (Read as "a is before b", "a is before c", etc.) What is the order of the elements? In this example, the answer is a<b<c. A less ...
user avatar
  • 143
8 votes
2 answers
401 views

Is it common practice to transform requirement specifications into predicate logic for functional programming?

I've recently been assigned to work on a small project which is being implemented in Haskell. Coming from an OO/imperative background, I'm used to converting requirements/user-stories into use-cases ...
user avatar
  • 2,517
3 votes
3 answers
2k views

Logic behind an 'undo' for painting on a canvas

I'm working on a module that allows users a basic paint function. I want to support undoing any modifications done to the painting surface. Assuming that we have one layer (for the sake of simplicity),...
user avatar
  • 356
0 votes
0 answers
55 views

Logic to find the number of requests which can be open at any point of time

I am trying to build an application which tries to find out if a system is suffering from backlog (# of requests which are open are more than what the team can handle) I have the below parameters ...
user avatar
  • 109
2 votes
1 answer
308 views

Data model for persisting queries to database

I have been asked to build what is essentially a query builder for a reporting application. The variety of objects to query, potential modifiers, number of conditions, and so forth to be reported on ...
user avatar
110 votes
8 answers
25k views

Why is polling accepted in web programming?

I am currently working on a Ruby on Rails project which shows a list of images. A must-have for this project is that it shows new posts in realtime without the need of refreshing the web page. After ...
user avatar
  • 1,169
0 votes
1 answer
473 views

Understanding bitmap logic

I was going though this blog and it says You can represent a list of distinct integers no larger than N using exactly N bits: if the integer i appears in your list, you set the i th bit to true. ...
user avatar
8 votes
5 answers
556 views

In retrospect, has it been a good idea to use three-valued logic for SQL NULL comparisons?

In SQL, NULL means "unknown value". Thus, every comparison with NULL yields NULL (unknown) rather than TRUE or FALSE. From a conceptional point of view, this three-valued logic makes sense. From a ...
user avatar
  • 9,210
1 vote
3 answers
435 views

Is "code that generates code" really all that great?

I was looking through CodePen's "popular pens" and I noticed this cool little spiral animation somebody made with a seemingly ridiculously small amount of code. This is quite impressive until you ...
user avatar
  • 123
0 votes
1 answer
194 views

Calculating WPM given a variable stream of input

I'm creating an application that sits in the background and records all key presses (currently this is done and working; an event is fired every keydown/keyup). I want to offer a feature for the user ...
user avatar
  • 123
1 vote
2 answers
937 views

C# Logic - gaps & Islands

I am looking for help designing the display of available times for appointments (for example a hairdresser's appointment book). Currently I have a query that returns a collection of periods that are ...
user avatar
  • 11
4 votes
2 answers
2k views

Logic design question for SQL query

Was wondering if you could help me on a SQL problem I’m having. I have a set of records of events where each event has a start time and end time. No event has the same start time, and the end time ...
user avatar
1 vote
1 answer
2k views

Finding possible positions for rectangle in a 2-d array

Well, the title is not very appropriate, please read on (I couldn't get a better one). Note: Using Python 2.7, but an algorithm will help too. I'm making a side scroller game, in which I am ...
user avatar
  • 255
-1 votes
2 answers
1k views

How to remove data redundancy in a table? [closed]

F1 F2 F3 C1 C2 C3 ------------------------------------------------ A B C 1 D E F 2 A B C 3 D E F 4 A B C 5 D E F 6 ...
user avatar
3 votes
1 answer
155 views

Tests for emptiness vs tests for nothingness

Is there any consensus between languages how tests for emptiness are distinct from tests for noneness? In python the following expression is false: {} is {} However this expression evaluates to True ...
user avatar
16 votes
3 answers
13k views

How to unit test method that returns a collection while avoiding logic in the test

I am test-driving a method that is to generate a collection of data objects. I want to verify that the properties of the objects are being set correctly. Some of the properties will be set to the same ...
user avatar
  • 1,810
4 votes
4 answers
456 views

In which order should I do comparisons? [duplicate]

I'm a strong proponent of writing if statements like this: variable == constant Because to me it just makes sense, it is more readable than the inverted: constant == variable Which seems to be ...
user avatar
1 vote
2 answers
553 views

How Do Computers Process Conditional/Input/ Event Based Code? [duplicate]

I understand that computers are basically a complex system of electrical signatures that can calculate based on logic boards, and some sort of gate mechanism, but how do computers process something ...
user avatar
5 votes
3 answers
1k views

Matching up articles with similar ones

I am creating a site where people can write on a niche topic. It is almost like a blog, however the area as I mentioned is a small niche with (hopefully) passionate users. I want a functionality ...
user avatar
2 votes
1 answer
8k views

Mobile number validation

I am trying to find best way to validate a mobile number with in a country. Currently my understanding is: User can enter whatever format they want in mobile numbers and its a waste of time and ...
user avatar
0 votes
4 answers
158 views

Identifier for the “completed” stage of a process: 0, 99, something else? [closed]

Say, that you are handling a multi-step process (like a complex registration form, with a number of steps the user has go through in order). You need to be able to save the current state of the ...
user avatar
  • 351
9 votes
5 answers
4k views

Why is there both a short-circuit OR as well as unshort-circuited variation of that operator in C#?

Periodically, I wonder about this: The short-circuit OR would always return the same value that the unshort-circuited OR operator would? I expect that the short-circuit OR would always evaluate ...
user avatar
  • 1,938
21 votes
8 answers
67k views

Techniques to increase logic at programming [closed]

I am into programming since last 3 years. But I seems to be lost in it. I am not able to get good at it even though I code everyday. suppose I solve one problem, I will wander from solution to ...
user avatar
  • 646