Posts by Jefferson Quesado • 22,370 points
421 posts
-
9
votes2
answers2071
viewsQ: When to use static methods mock?
@Fernandoschelb recently asked the question about how to mock static methods. It raised my doubts: If we can do it, when we should do it? What are the cases where static method mock is beneficial?…
-
36
votes2
answers2114
viewsA: What is an asymptote?
A Greek tale The asymptote of Achilles is the tortoise Corollary of Paradox of Zeno One day, Achilles the Hero and a turtle fought. The turtle stated to Achilles that if she started ahead, she would…
-
11
votes2
answers750
viewsA: How to improve the performance of my code with "for"?
Deepening the response of @Maniero, in the matter of complexity. Asymptotic complexity is a lot, but that’s not all. Asymptotic complexity depends on variables, it is annotated according to the…
-
5
votes2
answers1175
viewsA: How to get the representation of a positive integer in binary, using recursion?
For positive numbers, what we can do is successive divisions by two and write module 2 (or num & 1 to make explicit that you want the bit) in the appropriate position for this. An interesting…
-
5
votes2
answers552
viewsA: How best to craft AI for a simple game
All the examples cited by @Victorstafusa in their response are complex games. Let’s look at the block Breaker, since he was the example of the question? To define a smart agent, you must determine…
-
2
votes3
answers4086
viewsA: Warning: control Reaches end of non-void Function - c++
The other answer already talks about the mistake. Maniero gives a viable solution, but perhaps not the desired one. I will unlock here where it is missing and what is covered. Under the conditions,…
-
3
votes1
answer129
viewsA: How to place a domino piece to the left of 6|6 in C?
Before addressing the question, I will point out some problems in your code: its modular calculation is problematic 5 is equivalent to 0 mod 5, not 1 5 is only equivalent to 1 mod 4 or mod 2 at…
canswered Jefferson Quesado 22,370 -
5
votes4
answers3505
viewsA: How to generate random characters or string?
I will address the specific case of your question. Among the many possible ways to generate random information chains, I found these to be the most significant. But first, a little concept. It’s all…
-
8
votes1
answer460
viewsA: What are the differences between the computational power of deterministic and non-deterministic stack automata?
Yeah, there’s a difference between the two. And she’s brutal. Nondeterministic stack automata can solve much more context-free languages than deterministic ones. I would point out that this goes…
-
1
votes2
answers97
viewsA: How to make a method that compares values from two objects?
Yes, it is possible. How do you want to do it? What is your modeling? I can run a list of people and get the highest BMI. This does not belong to an object of the person class, but maybe it can…
javaanswered Jefferson Quesado 22,370 -
0
votes2
answers71
viewsA: This code is leading me to an infinite cycle and I can’t figure out why
You are ordering using the bubble strategy, with right to a flag to mark whether there have been exchanges or not. Mathematically, you need to do the most o( (n^2 - n)/2 ) operations. By rotating…
-
2
votes3
answers400
viewsA: How to return 2 vectors of different types in C++
From what I’m seeing here, your problem is representation of knowledge, more specifically on the composition of molecules and ions. Reverse semantics My first point of attention was the name of the…
-
18
votes2
answers5427
viewsA: What is an automaton?
Don’t want to know what they [automata] eat or how they reproduce? Maniero Junior, Antonio, 2017 Automata eat letters/discrete tokens, living in mathematical spaces. A priori, if mathematics does…
-
8
votes1
answer702
viewsQ: How to draw a straight using turtle geometry?
I’m trying to supplement my answer to a question about intersections of circles. In this answer, at a given time, I get an equation of the line in through the coefficients a,b,c: r: a*x + b*y + c =…
-
8
votes1
answer5112
viewsA: How to detect what are the common points between two circles?
The problem here is classic Analytical Geometry, where you find a way to deal with geometry without using compasses or rulers. It differs greatly from classical geometry because you represent…
-
3
votes3
answers158
viewsA: Doubt about sql query
Deriving from the idea of @Josédiz, you could make a junction to the left of the table with itself, putting in the junction clause the same clinic identifier and T2 be with T2.ativo = 'FALSE'. Made…
-
3
votes1
answer6172
viewsA: IF CONDITIONS STRUCTURE AND IF WITHIN ANOTHER
You gave 2 cases of 4 possible. Then we have the diagram below: sensor 1 0 | 1 +-------+-------+ s | | | e 0 | ???1 | ligar | n | | garra | s ---+-------+-------+ o | | | r 1 | desli | ???2 | | gar…
ifanswered Jefferson Quesado 22,370 -
2
votes2
answers354
viewsA: Two strings starting from one, in C
Failed to declare function return extraiSobrenome. That in the case would be a character pointer, or char*. Note that you need to change the variable nome original, otherwise you will not succeed in…
-
9
votes1
answer158
viewsQ: How to compare relative run time of fast algorithms?
The @Sorack asked the following questions about performance: What’s the most performative way to convert an int into the sum of its digits? What’s the most performative way to convert int[] to int?…
-
5
votes1
answer240
viewsA: What is the most performative way to convert int[] to int?
As I do commented, I believe that to get a general sense of how their sum is going to be performative or not, you would need to analyze the bytecodes that will be called and the general weight that…
-
11
votes2
answers10671
viewsA: What’s the difference between Union and Union All?
An alternative way of seeing UNION and UNION ALL comes directly from mathematics: UNION is an operation of collections of elements that results in a third ensemble; UNION ALL is an operation of…
-
10
votes1
answer187
viewsQ: How to identify an invalid graph for operator allocation problem per machine?
Recently I was answering a question (Machine Scheduling - Graph Theory), but there was an open problem that I could not solve: Given any graph, identify if it is valid for the operator allocation…
-
3
votes1
answer279
viewsA: Machine Scheduling - Graph Theory
I will owe the pictures, but I will respond as best I can verbatim You are working with an optimization problem. In the specific case, you want to minimize the number of operators. Obviously an…
-
2
votes2
answers222
viewsA: File In C language
I just came here to show you a lot of possibilities reply from @Isac, using resources from scanf to remove this formatting. To begin with, I found it strange to read the value of a character in a…
canswered Jefferson Quesado 22,370 -
2
votes2
answers405
viewsA: How do you force git to keep a directory but ignore all the files inside it?
There are some points I disagree with Reply from @Wallacemaxters, as well as the reply from @egomesbrandao also did not please me as a whole. I will give a quick explanation of how the folder and…
gitanswered Jefferson Quesado 22,370 -
0
votes2
answers95
viewsA: Difficulty to rescue information from AFFILIATE given a PRODUCT, many relationship to many
Product binds with stock that binds with branch. At least that’s what the columns name indicates, mnemonically. To accept products that are not in stock, always remember the sql Join chart, see that…
-
7
votes1
answer5602
viewsQ: What is the meaning of the acronyms SISD, SIMD, MISD, MIMD? What is your relationship with programming?
In some answers and questions I see quotations to these acronyms. They usually fit in the following table: | Single data | Multiple data Single instruction | SISD | SIMD Multiple instruction | MISD…
-
4
votes2
answers156
viewsA: Execution of programs in pararelo WITHOUT use of Threads
Roughly speaking, if you want something MIMD, you need to use separate processing heads. The traditional modes of this are: Threads Lawsuits Distributed program In Unix environments, you create new…
-
2
votes1
answer655
viewsA: Conditional upon Bhaskara’s calculation
A grade function n can be written as a product of three factors: a constant a nonzero a first-degree function (x - r_n) a grade function n-1 Taking this recursively, we come to the conclusion that…
pythonanswered Jefferson Quesado 22,370 -
7
votes2
answers648
viewsA: Hyperfactor in C by recursion
About your solution, you are not rescuing the value of the function in a variable. It seems that you have an implicit idea in your code that the value of the variable resultado is being changed on…
-
0
votes3
answers178
viewsA: Program in C : A certain doubt
A practical solution is to always insert ordered values. The idea here is the same idea as insertion sort: i keep an orderly part, then add an element at the end and reorder the set based on the new…
-
0
votes1
answer65
viewsA: Questions about storing values in a variable
In c, a variable of type char is an integer of only a single byte. Whether it will be interpreted graphically or numerically will depend on the context. In case, when calling getchar, you are asking…
-
5
votes1
answer509
viewsA: Arraylist<Obj> java listing
I will talk here about the advantages of each of the strategies individually. There are situations where one is better than the other and vice versa. But first, talk a little about the foreach. In…
javaanswered Jefferson Quesado 22,370 -
1
votes1
answer326
viewsA: "[Error] expected Expression before 'creature'" in function
The function call is wrong. You did: exibe(criatura tabuleiro); Should have done: exibe(tabuleiro); C already knows it is a creature. In this case, you confused the compiler by passing a type and a…
canswered Jefferson Quesado 22,370 -
0
votes1
answer32
viewsA: Program stops responding when I try to fill the list
You are not initiating the value of elemento->proximo in function insere. Put elemento->proximo = NULL shortly after the malloc already solves your problem. Another alternative would be using…
-
3
votes2
answers2266
viewsA: How to find the name of the key in a dictionary by the value contained in it?
Usually, what you’re doing is the opposite of a traditional mapping. Now, you can turn your multimapa into another multimapa, this time with reversed keys/values. Here I describe a little better a…
pythonanswered Jefferson Quesado 22,370 -
1
votes2
answers1480
viewsA: Comparison of elements from a JAVA list
We have some strategies to analyze here: keep the whole list and select the 2 largest ones keep the whole list and sort it at the end by selecting the 2 largest ones after ordering keep only 2…
-
2
votes1
answer790
viewsA: What is the best way to work with java queues?
As stated by @RHERWOLF at your answer, queue is a data structure. What is the difference of a data structure and an algorithm? Well, an algorithm is a finite set of steps to make a computation. A…
-
11
votes1
answer655
viewsQ: git fetch: "inflate: data stream error" and "SHA1 COLLISION FOUND WITH"
I have on my machine a copy of the repository for work, another for maintenance and a third just to resolve conflicts of merge request. The external repository is in the https://gitlab.com In the…
gitasked Jefferson Quesado 22,370 -
4
votes1
answer178
viewsQ: Error deploying application in Glassfish: org.objectweb.asm.ClassReader. <init> -> java.lang.Arrayindexoutofboundsexception
Questions Why Glassfish 3.1.2.2 runs ASM and this ASM fails to load the classes of my dependency? How do I get my application up? Why doesn’t it happen on other servers than with Glassfish 3.1.2?…
glassfishasked Jefferson Quesado 22,370 -
3
votes1
answer952
viewsA: Validate user typed only number - C
There are several points that need attention: Attribution vs Comparison The first one was identified by the compiler. You put only one = within the if, so you’re doing an assignment, not a…
-
2
votes1
answer298
viewsA: Reading file in C
For starters, how are you not touching the stdin, you don’t need to give a fflush in it. Another thing: use fgets will cause the file reading pointer to be moved forward. Use fscanf soon after will…
-
6
votes2
answers191
viewsA: What is the best way to sort lists in Java?
Okay, the best best shape will depend on many factors, including the conjunction of the astral projection of the Sun in relation to Venus and where its shadow projects in the house of the Lunar…
javaanswered Jefferson Quesado 22,370 -
3
votes2
answers454
viewsA: Jenkins slave build with JDK not previously installed
I am still struggling to try to solve in a more elegant way. I considered the reply from @nunks.lol elegant, putting the service and everything else, but as the server is Windows I just could not do…
jenkinsanswered Jefferson Quesado 22,370 -
5
votes2
answers439
viewsA: Java financial math equation
I’m using the trapezoid method to solve this equation. This method also refers to the name "secant method". The trapezoid method is very close to that of the Newton-Raphson algorithm, but instead of…
javaanswered Jefferson Quesado 22,370 -
2
votes1
answer238
viewsA: Doubt in a matter of C pointers
build a function that returns 0 if it is possible to do the operation, -1 otherwise Here you did well, only it is not possible to make the split when the denominator is 0. To make this comparison,…
-
3
votes2
answers797
viewsA: Why can you pass a char vector to the scanf as the direct address or variable?
There are conceptual errors in my answer. I only noticed after the reply by @Maniero. But I couldn’t remove it, it was already marked as accepted. So while I am not correcting/removing this…
-
7
votes1
answer1282
viewsA: Loops based on a flowchart
That flow, tell me this: Perform task A Compare B; If it comes true, get out of the loop Perform the task C Go back to step 1 Note that the flow in step 4 is an unconditional deviation returning to…
-
2
votes1
answer486
viewsA: "Workspace is in use or cannot be created" after Eclipse closes unexpectedly
The mistake was caused by something similar to what the @acklay went through with Git: Error: Unable to create 'C:/Myproject/. git/index.lock': File exists In this case, Eclipse created inside the…
eclipseanswered Jefferson Quesado 22,370 -
1
votes1
answer486
viewsQ: "Workspace is in use or cannot be created" after Eclipse closes unexpectedly
My Eclipse closed unexpectedly. When trying to open again, it shows the following message: With the words: The default Workspace [...] is in use or cannot be created. Please Choose a Different one.…
eclipseasked Jefferson Quesado 22,370