Most voted "logic" questions
Use this tag when the question primarily involves logical sense in the development or processing of an informationbased application that, related to each other, imply an objective within an established rule.
Learn more…376 questions
Sort by count of

41
votes8
answers3166
viewsFewer moves from a horse to a given house in Chess
On a chessboard in any house I have a Horse (represented in red) and I will have only one other piece (represented in green) that the horse must go to it: I must use the simplest path and take into…

35
votes8
answers4394
viewsHow to identify "Capicua" numbers that have 5 digits?
According to this definition of Priberam.pt, a Picua number is: Number also read from right to left or vice versa and to which good luck is attributed. Following this reasoning, Picua would be…

24
votes4
answers8801
viewsWhat is it and what is a "truth table" for?
Well, the question is just this, I want to know what it is and for what purpose a truth table. I don’t want to know all the details, just a basic definition and an example.

20
votes3
answers376
viewsNSA Challenge  "Thirteen men and a shipment"
Browsing the internet looking for challenges (to be solved with programming), I found the "Thirteen men and a shipment", where said it is part of the random challenges of the NSA (link). The…

20
votes1
answer1027
viewsGalton’s Board  Central Limit Theorem
The reason for the question is study/learning. Know/apply programming techniques and concepts, transforming something "material" into "application". I received a video on Whatsapp, where mixed…

19
votes1
answer13251
viewsWhat is it and what is Karnaugh’s map for?
The question is just this: What is and what is this map of Karnaugh? I do not want to know everything about it, a short definition and a small example is enough.

18
votes1
answer27783
viewsWhat’s the difference between Modus Ponens and Modus Tollens?
Again in the study of mathematical logic, how to differentiate a proposition modus Ponens of a modus Tollens?

17
votes1
answer412
viewsWhat is fuzzy logic?
Studying about artificial intelligence I observed a lot the term fuzzy logic, or Fuzzy Logic. What is this diffuse logic and what are its applications? I know it is different from Boolean logic, but…

15
votes4
answers426
viewsContest question: logic error and semantic error?
I participated in a contest and fell the following question: 33  Analyze the algorithm and check the correct option for this algorithm. Algorithm Calculo_media: Var N1, N2, MEDIA: Inteiro Início…

14
votes5
answers2700
viewsDrawing strings from a weight array
My question is the following, I have an array with all the cities of the country,+ 5000 cities, I have a function that draws one of these cities and prints the result on the screen. I wish that the…

8
votes4
answers7856
viewsCalculate Total Hours by identifying Equal Time Intervals
after a bit of a break in the head, I ask for help from you to assist in the following situation: I have a problem with SQL (Sql Server 2005) calculation of hours; Basically I have to calculate the…

8
votes1
answer69
viewsHow do serial numbers work in a system?
You know when you buy a game online and you get the CDKEY, and then you open an app and you record that CDKEY for you? Or else you bought your new Operating System and will register and insert a…

8
votes1
answer37813
viewsWhat is the difference between Tautology, Contradictions and Contingencies?
Anyone who studies Mathematics or develops algorithms should know that Mathematical Logic is essential for several areas of knowledge, eg: in computing (programming), so I would like to know, what…

8
votes2
answers5108
viewsWhat is the difference between Logical Implication and Logical Equivalence?
I am studying mathematical logic and programming logic, and I would like to know the difference between Logical Implication and Logical Equivalence?

8
votes2
answers772
viewsHow does XOR work for two binaries with more than one digit?
I learned that the XOR operator works as OR Exclusive, that is, the end result is only 1 when only one of the operators is equal to 1. The truth table illustrates this well: My question is: how the…

8
votes2
answers713
viewsDynamic grouping of JSON data
I have been trying for a few days to perform JSON data grouping dynamically, but without success, it is a matter of logic rather than programming itself. Given an array of objects(Users), group them…

7
votes1
answer752
viewsHow to make a sum in Lambda with recursive logic using successor and predecessor?
I’m trying to assemble a Soma with recursive logic using just successor and predecessor in Lambda. But they’re not succeeding... In the case: suc = λx.x+1 ant = λx.x1 I’ve done something like:…

7
votes2
answers585
viewsListing error in paginated search system
When I do the query I get the following result [imagem1] By clicking to go to page 2, I get the following result [imagem2] That is, on page "1" everything working with the total results displayed…

7
votes2
answers65
viewsWhat to do when a model has N responsibilities
My system exists a class that is currently a common class for several situations, below some of the other models to exemplify public class Servico { public int Id {get;set;} public string Nome…

7
votes2
answers99
viewsWhy split this operation into two cause result changes?
I made a simple algorithm that solved Fibonacci in 2 logical operations within the loop. I decided to look for a better way and found a version that makes in only 1 calculation inside the loop. It…

7
votes1
answer2353
viewsAnalyze whether a number is even or odd
The program must do: Digite um Número: 12345 1 e ímpar 2 e par 3 e ímpar 4 e pra 5 e ímpar So far I’ve made the following code: void parImpar (int num) { int resto; while (num > 0) { resto =…

6
votes6
answers2305
viewsTransform results combination function into a dynamic function
I have a function that generates all possible combinations of numbers from 1 to 10. The combinations are 4 numbers, that is, each combination has 4 different numbers. Ex: [1,2,3,4], [1,2,3,5],…

6
votes3
answers212
viewsWhat is the reason for this IF/ELSE assignment?
Because in this code the value 0 is assigned to the IF and the value 1 is assigned to the ELSE? <?php $flipCount = 0; do { $flip = rand(0,1); $flipCount++; if ($flip){ echo "<div…

6
votes2
answers1002
viewsBogosort  what is this?
What exactly does the bogosort sorting algorithm? Because many say he’s inefficient?

6
votes1
answer117
viewsThe if parole is not obeying the rules
I have a problem here in my gallery, when I enter the menu and choose which image category I will choose. Ex: Praise Group (yes it is a religious site), it has to go in my controller and pick up the…

6
votes1
answer67
viewsHow to apply Pathfinding in a structure of nodes?
I have a node structure that represents my pages and their links, for example, from page A I can go to page B or page C. In addition I can have page A pointing to page B pointing to C pointing again…
logicasked 7 years, 6 months ago Marcus Becker 724 
6
votes1
answer183
viewsWhy is there no "Logical XOR" in C++?
I was thinking and I came up with this question: Why is there "Bitwise OR", "Bitwise AND" and "Bitwise XOR", if in Boolean logic there is only "Logical OR" and "Logical AND". There should be the…

6
votes2
answers549
viewsWhat is the difference between Fuzzy logic and boolean logic?
Was reading regarding Fuzzy logic and I realized that it has relations with boolean logic. However, I was very confused at the point that defines the relation of the logic of Fuzzy with the boolean,…

6
votes1
answer96
viewsWhat is the logic for discovering all possible numbers that add up to the requested number?
But note that the number on the left is always higher than the number on the right. I’ve tried several ways, but I don’t think I understand the logic to create an algorithm that does this so I…

6
votes2
answers312
viewsWho is who in the use of functions?
I have searched a lot, and has a lot of good content here, which covers this topic, however I still can not understand the functioning. The characters I’m referring to are: Function Parameters…

6
votes0
answers145
viewsAlgorithm by Christofides  TSP, Problem in transforming the AGM into a graph with all vertices with even degree
I am carrying out the implementation of the algorithm of Christofides and input I receive the data from TSPLIB. Christofides' Algorithm has the following steps: Find the minimum generating tree Find…

6
votes5
answers4944
viewsFunction to check palindrome
I have the challenge of writing a code to check if a text is a palindrome or not. I haven’t finished the code, at the moment, it’s like this: function checkPalindrome(str) { var direita = [];…

6
votes4
answers653
viewsCross values in array
I have a value X and I have a array with various values. I would like to search all the same values and smaller, which would enter into a combination that their sum would give the value X. Example:…

5
votes3
answers185
viewsProblem with program that prints three numbers increasingly
I’m having trouble creating the decision structures in a program that reads three numbers and prints them increasingly. My code that’s going wrong is this:: #include <stdio.h> int main (void)…

5
votes2
answers303
viewsLogic ports in SQL
Is there a command that represents the logic gate XNOR or NOR in SQL? Something that for example denies XOR output

5
votes2
answers1688
viewsJoin a number of people without repeating the combination with the stipulated maximum
I have N pessoas to form as many meetings as possible. These N pessoas cannot speak to those who have already spoken at other meetings. Each meeting has at most N pessoas. Based on this information…

5
votes1
answer605
viewsClose loop when typing specific character
Hello! I need to resolve the following question, but I’m not getting it. Write an algorithm that calculates the average arithmetic of the students' 3 grades (number undetermined of pupils) of a…

5
votes1
answer3351
viewsMACRO in Excel  printing with sequential numbers
I have a macro from a few years ago that still works, when I click to print the production orders of my company, I put the start and end number, and the macro prints the Ops with the numbers in…

5
votes1
answer106
viewsI don’t understand the order to execute a code
public class Rope { static String result = ""; {result += "c";} static {result += "u";} {result += "r";} public static void main(String[] args) { System.out.print(Rope.result + " ");…

5
votes6
answers12886
viewsDoubt about logical operators && e  in Java
I have the following code in my app: if (aquaName != null && !aquaName.getText().toString().isEmpty()){ values.put(NAME_COLUMN, aquaName.getText().toString().trim()); } else {…

5
votes1
answer1734
viewsCode for calculating 2nd degree equation returns "Nan" as roots
I tried to create a program that calculates the two roots of a seconddegree equation. When I run my code, it asks for the values of a, b and c correctly, but when showing the result, it always…

5
votes1
answer215
viewsComparison of value within data frame
Hello, I have a database, with about 50000 remarks, as follows, only figurative values: nome<c("joão","pedro", "joãoo") identificador<c(123456,124578,123456) valor<c(2145,350,23)…

5
votes8
answers3758
viewsExercise taking the position of the array
I’m doing an exercise but I can’t go through all the necessary validations. Write the function "medalText(number)", which takes a number as a parameter, using only an "if". You have to return the…

4
votes1
answer413
viewsHow to know if an intersection contains another intersection?
If I and J are two sets formed by intersections, how to know if I contains J, knowing that: I = i1 i2 ... in J = j1 j2 ... jn nor I nor J are empty, therefore nox or jx the saint I know the answer…
logicasked 9 years, 4 months ago Miguel Angelo 28,526 
4
votes1
answer563
viewsAlgorithm to find common word sequence
I’m looking for a logic where I can find in an exorbitant amount of data, phrases that are common. Phrase in this context is word sequence. For example in these prayers: I’m traveling to South…

4
votes2
answers1045
viewsCalculation to determine whether triangle is rectangle gives no expected result
The program I created takes three integer values, calculates within the if these values and if the condition is correct it should show on the screen the YES (the triangle is rectangle), and if the…

4
votes2
answers122
viewsDoubt  Logic of numbers changing places
I’m trying to put together a C algorithm to find integer numbers that change places by multiplying by another. I haven’t found problems like this on the Internet, I don’t even know if there’s a way…

4
votes1
answer801
viewsHow to group items in a list with a proper condition?
I have a list with a property called tamanho which may contain two values: "M" or "I". I need this list to be random, but with a grouping condition. "M" would be half page and "I" full. That is, I…

4
votes3
answers216
viewsWhy is there an asterisk left?
I want the number of rows and columns to be equal to input data. Why is this last *? Code: #include<stdio.h> #include<math.h> int row = 0; char column = 0; int n; int main ( void ) {…

4
votes2
answers333
viewsCalculate minimum number of permutations to sort
I received this question in a test, and I would like to know which ways to go. I have an array of distinct n integers, A = [A0, a1, ..., an1]. I can swap any two elements of the array any number of…