Most voted "logic" questions
Use this tag when the question primarily involves logical sense in the development or processing of an information-based application that, related to each other, imply an objective within an established rule.
Learn more…376 questions
Sort by count of
-
1
votes1
answer2108
viewsFilter array whose elements are between two values
A virtual store allows its visitors to filter products by price. There is an array of product prices. A programmer has already created a function maisBaratosQue(valor, precos) that returns an array…
-
1
votes1
answer237
viewsError "Exception in thread "main" java.lang.Arithmeticexception: / by zero" in java
I’m trying to solve an exercise, but it keeps going wrong. I wonder if someone could help me? public class mod_IV_ex_1 { static int fatorial(int numero){ int fatorial = 0; if (numero == 0) {…
-
1
votes1
answer47
viewsArray sum returns only one value
Some time ago I had to execute a sum of arrays with javascript, Example: allData[0].likes = [5,10,15,20,25]; allData[1].likes = [10,2,3,17,15]; Using a solution I found on the Internet I used the…
-
1
votes1
answer48
viewsHow does access to strings in an array work?
Create a program that receives the date in numeral and then return it in full. I tried to do a few times, but I ended up merging my code with one I found from a forum and came out like this:…
-
1
votes1
answer241
viewsRuntime error in python 3.8 - URI
I’m practicing some examples in the URI Online Judge and I’ve come up with this example: And I tried the following solution: numeros = input().split(); N1, N2, N3, N4 = float(numeros[0]),…
-
1
votes1
answer337
viewsHow to fix Time limit exceeded error
I was trying to solve this issue in URI and I managed to reach the output required by URI. However I got the error Time limit exceeded, because the running time limit is 2s, and my code resulted in…
-
1
votes1
answer106
viewsDoubt about looping loops in C
I’m trying to solve this question: 3. The user enters two numbers x and y (with x < y): (b) The program returns the sum of the perfect numbers of the range [x, y]. However, he returns the number…
-
1
votes2
answers35
viewsConvert Two-dimensional String array Separated by comma
I need to convert this Array: Array ( [0] => Array ( [value] => pdf [label] => PDF ) [1] => Array ( [value] => csv [label] => CSV ) [2] => Array ( [value] => rtf [label]…
-
1
votes1
answer58
viewsReturning Multiple Values
The following code tells us to place a sequence of numbers in the following matrix and then assign a value to X and find out if the value of X is equal to some matrix value. But it is returning me…
-
0
votes1
answer1170
viewsHow to fetch a value between a past range
I have to find out if the value (5.55 for example) exists in a matrix and know in which range of that matrix this, and bring me the id of the range. I had taken a test and it seemed to be working…
-
0
votes2
answers1939
viewsPhp <= "value" and >= "value"?
I would like to know how to make PHP detect if a variable is with the value between one of the values passed. Explaining better I have a variable with a value, this value will make it include a file…
-
0
votes1
answer610
viewsFill FILL-IN with Browser data
I’m trying to create a kind of simple CRUD I got to this point but still have half failed my code, to using the window type Appbuilder I have a screen with "New" "Change" "Delete" "Save" but when I…
-
0
votes1
answer120
viewsHow to display only the variable value in Progress
to create a program and would like to display only the value of the variable in Display without the name, has how to do this ? DISPLAY "Nota Fiscal do dia" vDia "do mes"vMes "do ano de"vAno . there…
-
0
votes2
answers354
viewsMouse events (when passing an x element) Jquery
Well, I’m having trouble with mouseenter(). it only fires the event if I click, I need that when passing inside an element(div) it fires the event. Like I’m doing: $('#<?php echo…
-
0
votes2
answers73
viewsLogic optimization
I have the following logic that I need to optimize using PHP Parâmetros: máximo mínimo alerta Se ultrapassar o nível máximo enviar um alerta Se alerta já tiver sido enviado não enviar nada Se o…
-
0
votes0
answers200
viewsForeach inside foreach with parent elements, children and grandchildren
Good afternoon gentlemen, I’m trying to print a paragraph dynamically but I’m having some difficulty. I have the following html code: form {} label { display: block } span { display: block; float:…
-
0
votes2
answers171
viewsCheck the status of a service on Amazon
Well my doubt is not exactly about code but how to start a project. My doubt is the following, having a machine in Amazon, within it there are several services that are running...my problem is that…
-
0
votes0
answers40
views"change-making" algorithm - Smallest amount of currencies possible
Given the Change-Making algorithm: change(C1, C2, ...., Cr: valores de denominações de moedas, onde C1 > C2 > ... > Cr; n: inteiro positivo) for i := 1 para r di := 0 {di conta a…
-
0
votes1
answer159
viewsWhat is the explanation for the following question
This is a matter of the simulated java certification of the Whizlabs site. public class Whizlabs { public static void main(String[] args) { int[] testData = {1, 2, 3}; for(abc){ } } } The question…
-
0
votes3
answers1589
viewsHow to read file line . txt from index 0
I have the following excerpt of code that reads line by line from a text file, ending until the beginning of string. How should I change it, so that such action occurs in reverse? while (getline…
-
0
votes1
answer171
viewsWhat is the most performative way to group data from a PHP array?
I have an array that was generated by Database Query Builder of Laravel 5.1.x. array:96 [▼ 0 => {#1256 ▼ +"customer_id": 58 +"city": "Rio de Janeiro" +"program_id": 3 +"program": "PROGRAMA XPTO"…
-
0
votes1
answer143
viewsWhat is the difference of a static and dynamic Hazard?
As far as I know a Hazard is an undesirable effect caused by the deficiency in the system or by external influences. An Hazard in a logical system occurs when there is a modification in the input…
logicasked 7 years, 3 months ago Um Programador 1,491 -
0
votes0
answers50
viewsInvert Number
What logic could I employ to make a program where I insert a number and then be reversed. ex: 123 to 321 PS: has to be a function.
-
0
votes1
answer292
viewsItem composition from the same SQL table
Well, I started studying Mysql recently and found a question that I couldn’t solve: An ITEM table has the columns (PK)cd_item, nm_item, ds_item, cd_tipo_item, the problem in this case is that an…
-
0
votes1
answer688
viewsSwap value of two variables without using a third, using either sum or subtraction only
Using only two variables (A and B) and also using only (sum or subtraction), make the value of A turn the value of B and the value of B become the value of A.
-
0
votes0
answers503
viewsProblem with 2D character Sprite display in Unreal Engine 4
I was following a tutorial from the site of Unreal Engine 4 and in a certain video has an explanation of how to give movement to some character (WASD, jump, run and etc). In another video shows how…
-
0
votes1
answer481
viewsCombination of digits from A to Z (Crosse Join)
I’m running a four-digit algorithm from A to Z. I did it using vectors in Pascal like this: var i:integer; j:integer; k:integer; l:integer; vect1:array[1..26] of string; vect2:array[1..26] of…
-
0
votes1
answer42
viewsProduction in PHP hours
Talks personal, I’m developing a page, and arrived at the time I particularly do not understand much, calculation of hours in php, following: I have values that come from the database, which are:…
-
0
votes1
answer63
viewsCreate the code to fill the array - Javascript/Logic
I have a problem with an arrays exercise. The question is this:: Create the code to fill the array with the following values: 3 4 7 12 19 28 39 52 67 84 I’ve done the other exercises on that list,…
-
0
votes0
answers38
viewsLarge Inside Loop of Other
The challenge is to find x different ways to divide the object, for 3 people where each has to receive a value less than or equal to M, and the sum of the value that each won has to be equal to N,…
-
0
votes0
answers110
viewsHow do I check if a password is correct in an ATM project?
I have a college job where I need to create a kind of ATM in C#, where I have to create two textbox in which I have to enter a four-digit password in the first, and fix the same masked password in…
-
0
votes2
answers204
views -
0
votes1
answer30
viewsExecute a validation inserted in a string
I have a variable in PHP that mounts a logical string. $str = "(('TR1'=='TR' OR 'TR2=='TR' OR 'TR'=='TR') AND ('10,0'=='10,1' OR '9,0'=='9,0'))"; I’d like to find a way that validation is possible,…
-
0
votes2
answers114
viewsProgramming logic - Constant
If I create a variable int x = 10 and not alter it throughout the code it is considered a constant? or is only considered a constant if I use a reserved word of the language for example: final int x…
-
0
votes1
answer466
viewsobfuscate javascript code with php
I have a question about a javascript code obfuscator made in php.. https://damidev.000webhostapp.com someone can help me understand how this guy did to generate ?…
-
0
votes1
answer110
viewsPass a given sequence of times in Python 3
I have the following sequence: {1,4,12,28,45,22} I need a variable for example: seguinte = input(num('Insira um número: ')) According to the number given, he would pass the last item to the…
-
0
votes0
answers58
viewsHow do I make two references of a table in other 2 tables?
Well, I have 3 tables tbl_users tbl_article tbl_profile I need tbl_usuarios to be related to tbl_articles and tbl_perfil. How could it be done? Table tbl_usuarios:…
-
0
votes1
answer156
viewsPaging in Codeigniter with error Type: Error Message: Unsupported operand types
I have a function that takes all the values from the database and sends them to a view, then I’m making a pagination. Only when I put the $this->pagination->create_links() of the variable…
-
0
votes0
answers234
viewsCompare values in two tables with php and Mysqli
I have to compare if the numbers in table A exist in table B and if it exists it makes one instruction or another. I tried that and it didn’t work. Note: In table B there may not be codigo table A…
-
0
votes4
answers1889
viewsFill vector in C
I have an exercise that asks the teacher to type 5 notes, and display the typed notes, I wrote the code, but it’s not running the right way, someone can help? Follows code #include <stdio.h>…
-
0
votes0
answers24
viewsHelp with system change with less work
I have a product list: CREATE TABLE produtos ( idProduto int(2) unsigned NOT NULL AUTO_INCREMENT, tipo enum('m','p') NOT NULL, modelo varchar(100) NOT NULL DEFAULT '', bandejas enum('1','2') NOT…
-
0
votes1
answer326
viewsUnderscore JS, Group object array by more than 1 attribute contained in an object
Hello I currently have an object of arrays that contains the following structure { "ID_Local_leitura": "2134236478dysa743242579f", "idO": "11342s36478dysa743242579", "timeStamp":…
-
0
votes1
answer338
viewsJoin with various conditions
I have two tables and need to unite them bringing the result through the following conditions: The Numero_tel_origem and Numero_tel_dest table 1, has to be the same Numero_tel_origem Numero_tel_dest…
-
0
votes1
answer73
viewsJQUERY programming logic
Talk personal! I am not able to reason in a small problem that I am wanting to improve the code. I have several Ivs(Content1,Content2,Content3....), I have a Content check that Content is active on…
-
0
votes1
answer84
viewsProblem zeroing out a game score
Well, I read Bjarne’s book on programming and I’m learning programming there, I’m in chapter 5 which is about mistakes, at the end of the chapter there’s a list of exercises for me to do, I came…
-
0
votes1
answer58
viewsHow to use javascript to perform math operation
I have the following relationship How do I create a javascript code that counts decimals? For example... if I measure 5.7cm? The account that would be: subtract 110 from 145 and the result divided…
-
0
votes1
answer481
viewsReverse binary number scratch
The binary number is coming out reversed, someone knows how to solve the same?…
-
0
votes1
answer900
viewsresult: print JS variable value in <td>
I am developing a code in which the user inserts the value to be downloaded, in the result is presented the amount of ballots of each value that will be released in the operation. Well, the logic is…
-
0
votes1
answer64
viewsDoes programming logic change depending on the language?
Hello, will programming logic change if you change language or will it always be the same? like logic never changes?
logicasked 4 years, 1 month ago Samuel Henrique Cipriano 1 -
0
votes1
answer86
viewsGame of life, what’s wrong?
I’m training Python and recently I’ve been trying to recreate the famous "Game Of Life", I managed to avoid code flaws but it is still not behaving properly. The program was to behave this way:…