Posts by Pirategull • 659 points
34 posts
-
0
votes0
answers34
viewsQ: How to delete an element of a vector in C++, permanently
I don’t know much about the "pass-by-value" of C/C++, and I don’t know when to pointer or not to a function argument. Next is the code I have: Struct Customer { .... } int get_nearest (int n,…
c++asked Pirategull 659 -
0
votes0
answers19
viewsQ: TO_DATE method in Oracle SQL is generating an unintentional Timestamp, how to remove it?
I have a column called 'periodo_filter' with date of type (data1 A data2), example: (01/1/2000 A 19/1/2020). With the following code I am removing the first date from this column and creating a new…
-
0
votes0
answers8
viewsQ: How do I select the JSON elements I receive as Answer from a fetch API?
In the following image this represented the answer that I receive when calling an API of the Solr server, I would like to take item by item and make available to the user a thumbnail with the video…
javascriptasked Pirategull 659 -
2
votes2
answers44
viewsQ: How to take the value typed in an input and then add it to a Javascript URL?
I’m creating a search bar on my localhost. The intention is that when the user enters what he would like to search for, the value is added to the value of q in, for example: const solr =…
-
0
votes0
answers7
viewsQ: What is the Difference between Solr Core and Solr Collection?
I saw a topic on that question in the global stackoverflow, but I don’t understand when they refer to "Logical" or "Physical" in the answers. What is a Solrcore? What is a Solrcollection? If I have…
solrasked Pirategull 659 -
1
votes1
answer65
viewsQ: Creating a quiz game, how do I avoid code duplication in javascript?
I am creating a simple game of selecting the correct answer, the basic structure is working, but I would like to improve my code, and learn to factor better. Follows the passage that define the…
javascriptasked Pirategull 659 -
1
votes2
answers64
viewsQ: How to copy a string in C?
The following method I found on the internet, serves to create a string copy.: char* bin_copy_string(const char* begin, const char* end) { char* result; result = malloc(end - begin); if (result) {…
-
0
votes1
answer72
viewsQ: How do I create a Dynamic Array in C?
I’m starting programming in C, after learning the basics in Python. At first I’m trying to write a simple program, which reads input arguments and prints them in reverse, for example, "hello world"…
casked Pirategull 659 -
-2
votes1
answer31
viewsQ: How do I create a Java class that is like: Minhaclasse<T extends Comparable<T>?
I am trying to start a class that is a Bubble Sort that extends a class called Comparable. My code is like this: public final class BubbleSortPassPerItem<T extends Comparable<T>>…
javaasked Pirategull 659 -
2
votes2
answers116
viewsQ: In Java, what is the purpose of calling interface methods on objects from other classes?
Follow the code I’m studying: public interface Node { public abstract int eval (); } public abstract class Unary implements Node { private final Node child; public Unary(final Node child) {…
-
-1
votes1
answer89
viewsQ: Should I use Thread.Sleep() for my program not to occupy the processor?
I have a small group of classes that implement a game of Snake with two players, the game is working as expected. But I’m using one while infinity that is operating at the maximum speed that the JVM…
javaasked Pirategull 659 -
2
votes2
answers571
viewsQ: How to handle multiple conditionals (if and if if followed) in Java and how to compress them?
Currently I have a small group of classes that implement a game of Snake with two players. I am implementing the movements as the keystrokes, currently the code is like this: // #----- Classe…
-
0
votes1
answer94
viewsQ: How to use the Scanner class to read two inputs separated by a Java space, and by two different variables?
I am trying to do something simple, I would like that, given two arguments separated by a space, read through stdin, each be stored in a different variable, for example: Scanner s1 = new…
javaasked Pirategull 659 -
1
votes1
answer101
viewsQ: How to stop reading from sys.stdin in Python 3 after reaching a bounded number of lines?
I am trying to receive command from sys.stdin until it reaches a limit n lines, and then finish the execution automatically. My code is as follows: import sys A = [] n = int(input("number of nodes:…
-
2
votes1
answer72
viewsQ: Dual recursion in a function, how does it work?
I understand what happens in recursion when there is only one recursive call, I understand well how to write an output condition for recursions. But I have difficulty understanding when there are…
-
0
votes1
answer149
viewsQ: How to Decrease Complexity of a Function with Two Loops in Python
This function returns the number of pairs in which A[i] > A[j] for 1 < i < j < n def calc(A): cont = i = j = 0 while i < len(A): j = i + 1 while j < len(A): if A[i] > A[j]: cont…
pythonasked Pirategull 659 -
6
votes1
answer177
viewsQ: How to reduce the number of loops to calculate the smallest difference between all the numbers in a list?
The program below returns the smallest possible difference between all the elements of a list: def calculo(A): r = float("inf") n = len(A) for i in range(0, n-1): for j in range(1, n): if abs(A[i] -…
-
3
votes0
answers39
viewsQ: Notion Big O and small O, Big Omega and Small Omega, applied to very similar exponential functions
In the academic book we use, asks us to relate what a function A is of a function B (ex: A = O(B)) You have a relationship that I can’t understand the resolution of the answer To = (1,21)^n B =…
asked Pirategull 659 -
3
votes1
answer77
viewsQ: Copy and split a List in Python3, Merge Sort
I was trying to write the merge sort in python on my own, but returned a list nothing to do with several repeated numbers. When checking the solution code online, I was left with doubts about how to…
-
6
votes2
answers409
viewsQ: Python algorithm complexity with two loops
This algorithm is used to return the element that repeats most in a list: def algorithm_x(a): x = 0 y = 0 for i in range(0, len(a)): k = 1 for j in range(i+1, len(a)): if a[i] == a[j]: k = k + 1 if…
pythonasked Pirategull 659 -
0
votes2
answers187
viewsA: How to turn a set into a Python 3.x list
n2 = set(input().split()) m2 = set(input().split()) m_diff = m2.difference(n2) n_diff = n2.difference(m2) # poderia resolver o exercício iterando diretamente no set e…
pythonanswered Pirategull 659 -
-1
votes2
answers187
viewsQ: How to turn a set into a Python 3.x list
I’m doing an exercise that asks to, given two sets, print in ascending order (line by line) the symmetric difference between them, my code: n = set(input().split()) m = set(input().split()) m_diff =…
pythonasked Pirategull 659 -
1
votes2
answers40
viewsA: Using Intunaryoperator Java Interface to return n functions
I was able to get what I wanted, if it’s useful to anyone in the future: public static IntUnaryOperator compose(IntUnaryOperator... functions) { IntUnaryOperator toReturn = x -> x; for…
-
1
votes2
answers40
viewsQ: Using Intunaryoperator Java Interface to return n functions
I am reading the documentation of this bookstore that is in the title. I want to implement a method that returns a composition of functions, if I not by arguments must return the identity function,…
-
4
votes1
answer101
viewsQ: Generics <? super T> and <? extends T>
In the coding below, because the Box<? extends T> extends and the EqualityComparator<? super T> super T? uses so as to make part of the code println true return? public boolean…
javaasked Pirategull 659 -
1
votes2
answers47
viewsQ: How to make a text be edited only once in Javascript/Html
function saveImg() { let out = []; const imgData = canvas.toDataURL(); const fav = document.getElementById("favourites"); out.push(`<div>`); out.push(`<img src= ${imgData} height = "200"…
-
2
votes2
answers487
viewsQ: Can anyone explain to me the meaning of the $ dollar symbol in Javascript?
The codes in question are as follows:: var $item = $(this).parent().parent().find('input'); what use is this $ in the first code, if I remove it what difference will make? function…
javascriptasked Pirategull 659 -
4
votes1
answer68
viewsQ: In Assumptions on Timing - I don’t understand this concept of a book
Cited in the book that a critical region has 4 key points: Progress: Ensures that all threads are entering and leaving the critical region, avoiding deadlocks. Mutually Exclusive: Only one thread…
-
1
votes1
answer81
viewsQ: Java competition, simple example, multi-threaded hash map not secure
I’m using a hash map to assign the voto at the id of a voter. But the class has several threads operating on top of the method addVote(...) and getVoteCount(...) , and the result returned is always…
-
0
votes1
answer171
viewsQ: How to return a specific element within an array?
I’m trying to return the largest among 4 numbers, for this I’m using the function qsort() available on <stdlib.h>. Follows the code: int comparison (const void *a, const void *b){ if (*(int*)a…
-
3
votes1
answer297
viewsQ: Regular Expression for a binary string that accepts even number of zeros
As stated in the title, follows the DFA that accepts the proposed language: My question is about the regular expression of that DFA which is as follows:(1*01*01*)*. Conforms to regular expression,…
regexasked Pirategull 659 -
-1
votes1
answer138
viewsQ: Node.js First steps, don’t know how to start
I’ve been dedicating myself to Javascript for some time, looking for various ways to learn, recently I came across the callback functions, usually used when using javascript on a server instead of…
-
3
votes3
answers1087
viewsQ: Function to return letter frequencies in an array
I was trying to do the function that is in the title, but I did not succeed, looking at the solution code for such function, I could not understand, follow the code: function letter_frequency(s) {…
-
0
votes2
answers48
viewsQ: Javascript, Function that groups strings according to parameter value
I’m trying to solve the exercise that is in the image, the language and' javascript: this is the code I created, but it only works for some cases and not for the example given (pp) for example,…
javascriptasked Pirategull 659