Most voted "algorithm" questions
An algorithm is a sequence of well-defined steps that defines an abstract solution to a problem. Use this tag when the problem is related to the design of an algorithm. Always use specific algorithm tags when the question is more directed to a specific type of algorithm.
Learn more…723 questions
Sort by count of
-
1
votes1
answer87
viewsAlgorithm for certain letter combination
I have the following problem, I want to know the combinations of certain letter in the string, example: AAbA Viraria AAbA, AAb, Ab, bA, b I arrived at the following code, but does not contemplate…
-
1
votes1
answer257
viewsVector and strcpy problems in C language
I’m trying to make a vector with 23 names, which should draw 11 salts, 6 sweets and 6 drinks without repetition, the draw should be done in numbers 1 to 3 and when it is drawn should be assigned a…
-
1
votes1
answer177
viewsRepeat an algorithm if the answer is wrong in guessing game without losing the drawn number
I made an algorithm in Python with the proposal to guess a number as the user type, ie the guessing game. But I would like to make a condition that makes him type again, in case he does not choose…
-
1
votes2
answers99
viewsWhy doesn’t my variable change the value?
I have several variables and one of them is menor, when checking her out (output) I realized that the same always remains at zero, because this is occurring? int z, menor = 0, maior = 0; for (int i…
-
1
votes3
answers76
viewsI can’t get the algorithm to ask for a certain range of values
Guys, in this algorithm, he asks to be typed 4 notes that are between 0 and 10, disregard the lowest and make the average of the left, adding and dividing by 4. I can do the average, but I couldn’t…
-
1
votes2
answers608
viewsAlgorithm that performs the combination of elements of a vector in VBA?
I need to take a vector in vba with any N elements and perform the combination of such elements. The idea is to have a function that takes 2 arguments. The vector with the elements to be combined…
-
1
votes2
answers3082
viewsPython data entry with multiple lines
I would like to understand how to input several data (int, float, str...) per line but repeatedly (i.e., in several lines) so that I can save each given input. I understand that I will have to use a…
-
1
votes2
answers834
viewsFind the highest vector value
A program that asks to find the largest number of an array, typing the amount of elements and until which element it will verify. However, in this program that I did it is not considering the first…
-
1
votes1
answer78
viewsCalculator is not capturing the second number
I have a code that I wrote, it takes two numbers and sums, subtracts, multiplies and divides. However, when incrementing the questions in the code and then running it reads only the number of the…
-
1
votes0
answers270
viewsCommand while in code in Visualg
Good evening guys. I have this code made and I need to do what the exercise is asking, but I don’t understand and I don’t know how to do it. The only hint I have is that you should use the command…
-
1
votes4
answers491
viewsPrint values of a vector without line break
Hello, I’m performing a C# exercise that asks for the following: The output with even numbers should be presented without line break, but I do not understand how I can do this. My code is like this:…
-
1
votes0
answers54
viewsHessian update in BFGS method
I’m developing the nonlinear optimization method BFGS (Broyden-Fletcher-Goldfarb-Shanno) and I’m having a hard time updating the value of Hessian to minimize function. The input variables for…
-
1
votes1
answer89
viewsFilter files by their extension(xml, rar, docx....)
Good Afternoon, I have an algorithm that takes all the files of an x directory, and reads them, but these files have to be XML, and sometimes RAR files appear, then at the time of reading give error…
-
1
votes2
answers91
viewsHow to generate a 2d matrix with one of the positions chosen separately having a different value?
I want to generate a 10x10 matrix, where all elements will be "B", except one of the positions, which should be chosen randomly and have the value "8". var m = []; for(i=0; i < 10; i++){ m[i] =…
-
1
votes1
answer73
viewsI can’t get the None result out of this code
I’m trying to pull this one out None, I’ve already put else, I’ve already put add2 and then I defined add = add2 but I haven’t been able to get it out. How does it look: Which fruit do you want to…
-
1
votes1
answer78
viewsThe program hangs when it arrives at the while
I made a basic program about calculating potentiation, but when it comes to while crash, and until the terminal I have to restart. So I can’t continue the program. I even tried to change the way the…
-
1
votes2
answers53
viewsHow can I associate typed and stored values in an array to a menu option?
How can I associate a range of values from 1 to 6 to each of the options in the OS menu that I have in the list? My idea is that when I type three times the number 1 for example, this counts as…
-
1
votes3
answers5809
viewsHow to fix "Valueerror: invalid literal for int() with base 10: '' - Python?
Summary of my program/ problem: I need to draw at an ATM between 10 and 600 reais. When running the program, any value above 100 it prints correctly, but if I put any value below 100 it presents the…
-
1
votes2
answers326
viewsProblems with pi approximation algorithm in C
Good evening, I’m having the following problem, I’m developing an algorithm to calculate a pi approximation. #include <stdlib.h> #include <stdio.h> #include <math.h> #include…
-
1
votes1
answer182
viewsAlgorithm for transiting in the Cartesian plane
I’m trying to codify the solution to the classic problem of walking around the Cartesian plane, starting from the origin, based on a user-given input string. Being: And: anti-clockwise rotation of…
-
1
votes0
answers42
viewsIs there any difference from Binary search to ordered Binary search on a list?
I’m studying algorithms for Searching and wanted to better understand the difference between Binary search for ordered Binary search. I understood that for both algorithms to work, the list needs to…
-
1
votes1
answer37
viewsMy algorithm generates a SHA512 Hash displays an unexpected result
I have the following string:…
-
1
votes1
answer104
viewsURI 1259 - Increasing and Decreasing Odd Pairs
I’m solving that URI Online Judge challenge. But my code has had the answer "Time limit exceeded", and I don’t understand exactly why. Follows code below: using System; using System.Linq; namespace…
-
1
votes0
answers31
viewsHow to define Custom Loss Function?
Hello, I am trying to make a custom Loss Function through the Keras Functional API and I am having problems with this implementation since I have never done anything like. I want to make a Loss…
-
1
votes1
answer125
viewsGreeting Functions "Good morning, Good afternoon and Good evening"
Today I came across a very interesting topic, which are the greetings "Good morning, Good afternoon and Good night" in Javascript (and among other languages..) Where in failed attempt to create a…
-
0
votes1
answer405
viewsProgramming logic for mounting trinary network
I can’t get the trinary network down: The logic is as follows: I register in the system and a referral link is generated; Occupies the 1st, 2nd and 3rd position (can be registered through my…
-
0
votes2
answers183
viewsMake two items in a Listview change position
I’m creating a button called Up, to make an item in the listview go up, while the one above. But I’ve tried everything and it won’t, I don’t know if I’m wrong about logic. But I’ve tried it in two…
-
0
votes1
answer891
viewsOperation with Factorials from thehuxley.com website
Input format: An integer x corresponding to the X of the equation and an integer n indicating a number of series terms, input ends when x = 0 and n = 0. Output format: A floating point number…
-
0
votes1
answer1004
viewsHow to check winner in the game of old
I’m playing an old-fashioned game on C, I want to know how to check which player won by checking the lines horizontally and vertically and on the diagonals. Here’s my program done so far: #define…
-
0
votes0
answers378
viewsCall Procedure sql server via JDBC which returns cursor
I am unable to call a Procedure SQL Server in java that returns a cursor. That’s possible, someone has some example ? Through Oracle, through the example:…
-
0
votes0
answers89
viewsHow do I check if a particular number is from a mobile phone?
Expensive, After reading the comments ON THIS TOPIC, dated 2014, I ask: currently, to check if a number is a mobile phone, just read the string backwards, checking if the eighth character is a…
algorithmasked 9 years, 7 months ago silvioprog 191 -
0
votes1
answer1098
viewsProgramming Resta-Um using Monte Carlo Method
I have little experience in Java and I’m trying to apply the Monte Carlo Method in Combinatorial Game Theory. I’m trying to demonstrate the Leftover Game Method where it needs to be solved using…
-
0
votes1
answer176
viewsIt is better to use common division or Shift and Soma operations on 8bit microcontrollers
Considering programming for 8bit microcontrollers, we know that even for this microcontroller, the compilers have reached a unique level of optimization that allows us to program focused only on the…
-
0
votes1
answer175
viewsJava algorithm, age increase;
I wanted to know how to make an algorithm in which I inserted a year, and the value increased with age, as year 2016=1, year 2017 = 2, in a method. Something like that: int fazAniversidade(int ano)…
-
0
votes2
answers277
viewsDisplay the first 5 divisional numbers by 3, discarding the number 0
I’m not able to display the first 5 divisibles by 3, I put a counter variable, but it returns another number. #include <stdio.h> #include <stdlib.h> int main() { int n = 20; for(int i=1;…
-
0
votes1
answer211
viewsSum of numbers smaller than n that are multiples of 3 or 5
I need to write a program that receives an n number and prints the sum of all numbers smaller than n and that are multiples of 3 or 5. For this, I must use only the while repeating structure and no…
algorithmasked 8 years, 8 months ago Guilherme Santana De Souza 743 -
0
votes1
answer65
viewsVirtual page - Frame allocation algorithm
Guys, can someone explain me this algorithm of Frame allocation? I’ve broken my head trying to understand what each function does but I can’t make sense of it. Code tutorial link below:…
-
0
votes2
answers226
viewsWhy does the following code print 'None' instead of the list?
The program must receive values, in a quantity specified by the user. I need a list to be created with these values. Why does this code not work? quantidade = int(raw_input()) inicio = 0 lista1 =…
-
0
votes1
answer1432
viewsHow to transform a while structure into for? And vice versa?
I am in need of an explanation on how to turn a structure into while to for and vice versa. I thank anyone who can help!
-
0
votes2
answers4871
viewsSum of Useful Days
Is there any way to add useful days to a date that doesn’t use repeat loops (like while and for)? I currently use this code var novaData = new Date(dataBase.valueOf()); var diasUteisRemanescente;…
-
0
votes1
answer795
viewsReverse letter box size - VISUALG
I’m having a problem with programming visualG algorithms. need to invert an array with values assigned to it. // opcao 18 funcao menu_18():caractere var inicio escreval (" A ORDEM INVERSA É: ") para…
-
0
votes1
answer818
viewsI need to know the size of a file even before it is created
I’m on a college job and it’s hard to solve... it’s like those wordlists that hackers use, but it’s for didactic study. QT: Generates a file with all possible groupings using the concept of simple…
-
0
votes0
answers42
viewsAutomatic clock update in Matlab
Does anyone know how to update the clock in the Matlab? I can only update after pressing a button, but I want you to update automatically.
-
0
votes1
answer68
viewsLargest palindrome product - Ruby
How to make this code faster? It works, but not fast enough. #!/bin/ruby def isPalin(mul) if mul.to_s == mul.to_s.reverse then return true else return false end end def lp(n) arr = [] for a1 in…
-
0
votes1
answer76
viewsDoubt with algorithm and vector
help me solve the following algorithm. In this case, it is a vector of 20 positions. My doubt is what values would be stored in vector A? for (i=1, A[0]=1; i< A.lenght; i++) A[i] = A[i-1]*2;…
-
0
votes2
answers15349
viewsFactorial algorithm in Portugol Studio
I have this algorithm: programa { inteiro numero, fatorial, resultado=1 funcao inicio() { escreva ("Insira um número a ser fatorado: ") leia (numero) para (fatorial = 1; fatorial <= numero;…
-
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
votes1
answer706
viewsHelp with "n" primes algorithm in an Arraylist
Please I need urgent help, how to fix my code? every time I call the right error method,I am beginner and am locked in an exercise that requires primes based on a number n(in this case this.n),for…
-
0
votes1
answer3114
viewsHow do one character variable receive another in a conditional structure in Visualg?
I’m making an algorithm to show the highest grade and on this highest grade, At first it seems all ok, but it’s not working. Where is the error? algoritmo "melhor aluno" var…
-
0
votes1
answer1036
viewsGenerating unique identifier using time()
I created an algorithm to generate an identifier, which consists of a random value with 24 non-sequential characters. The goal is basically to capture the current time using time() and concatenate…