Posts by Gomiero • 5,286 points
130 posts
-
1
votes1
answer36
viewsA: Pthread_join not working as it should to popular a C array
There are some problems in the program, but the main one that causes this behavior is the struct initialization and Thread_preenche inside the looping. Although the structure is declared within the…
-
4
votes1
answer41
viewsA: How to convert regex Pattern from C# to C++?
In the string of the regular expression, the character \d is recognized by the compiler so incorrect as a exhaust (escape sequence). In several languages, the backslash \ followed by a symbol, is…
-
2
votes2
answers81
viewsA: Multiplication of Matrices in Fortran
The Fortran language does not multiply multidimensional matrices directly, only vectors (one-dimensional). To multiply multidimensional matrices, use the function matmul (Fortran 90): program test…
-
1
votes1
answer40
viewsA: shellcode amended "Segmentation fault"
The binary shellcode code, declared in the variable shellcode[], is stored in memory on a data page, therefore without permission for code execution (read + write only). When the program calls the…
-
2
votes1
answer132
viewsA: How to use the sum in Julia?
A suggestion to solve complex equations is to "break them" into smaller parts, then go assembling and testing the program gradually, for each item you insert, and avoid arriving at the end and occur…
-
0
votes1
answer80
viewsA: How to connect a Electron Nodejs window to a proxy?
To enter a command line parameter within the code, you can use the command app.commandLine.appendSwitch, that reconfigures the application directly from the Javascript code. It is important that…
-
0
votes1
answer481
viewsA: Reverse binary number scratch
To reverse the order of the bits, simply change the operator adicione (0 ou 1) a lista (that will always add at the end of the list) inside the block if/or by the operator insira (0 ou 1) na posição…
-
0
votes1
answer329
viewsA: Compare a string in Assembly x86
On the line: cmp ecx, "f" The program is comparing the value stored in the register ecx with the letter f, however, after the system call sys_read, this register (still) contains the address of the…
-
1
votes2
answers402
viewsA: Changing lines of an array - Python Pandas
To perform this change, it is possible to indicate the desired order of the rows in a list (or tuple) directly in the array indexing: arr = arr[[1,0,2,3,4],:] After ordering: In [14]: arr Out[14]:…
-
4
votes1
answer147
viewsA: Create vectors of new types in Julia
To insert an element of type struct in the vector, you must use the macro push!: push!(v, j1) push!(v, j2) push!(v, j3) Or, if you prefer to insert the three items in a single command: push!(v, j1,…
-
3
votes1
answer111
viewsA: Rust difference between Std::ops for normal operators
TL;DR: No, there is no difference in performance (in the question example and other observation operators) when you compile with the option release. The arithmetic operations in std::ops are defined…
-
2
votes1
answer189
viewsA: How to convert an Object to integer in Pyton 3?
The problem in the substitution happens because, by default, the call df.str.replace considers the first argument to be a regular expression, therefore it is necessary to put a character escape…
python-3.xanswered Gomiero 5,286 -
5
votes1
answer1543
viewsA: Calculate pi with python and recursion
The main problem lies in its function sum, that is incorrectly calculating the sum value of the series. One possible way to assemble this function is to analyze the individual series terms and get…
-
1
votes1
answer43
viewsA: Error in calculating the average from Inmet data using a Fortran program
One of the problems is in charge read(10,*), for the * indicates that you are reading from directed to list (list-directed), and this kind of reading is not ideal for question data due to different…
-
4
votes2
answers144
viewsA: "Hello, world" with Wish TCL/TK, how to change the text of a widget?
You can change the text (or any other property) of widget, with the command configure, indicating the property that will be changed and the new value. Example: button .submit -text "Click Me"…
-
2
votes1
answer692
viewsA: Return difference between higher and lower array value in Assembly
There are 2 problems with the program: 1) How the array is formed by bytes, all data operations (load, comparisons, etc.) must be done with 8-bit registers and not 32. Example: _start: mov…
-
2
votes2
answers588
viewsA: How do I correctly access elements of a dynamic matrix via pointer?
There is nothing "wrong", only that in dynamic allocation, the data is stored differently (non-linear). In your example, instead of a block of size ROWS*COLUMNS, 4 pointers of the type are allocated…
-
1
votes1
answer96
views -
1
votes1
answer81
viewsA: Paint pixels in c++
According to the comments, the error was corrected after including the GDI32 lib (libgdi32.a), where the function is located SetPixel. The mistake: undefined reference to…
-
4
votes1
answer37
viewsA: I cannot print, in the main function, values from a vector created in another function received by a double pointer
In function main, the variable qq is declared as double pointer and when calling function fazVetor() with the operator &qq, generates a triple pointer. As the function fazVetor() receives a…
-
3
votes1
answer6918
viewsA: Separating a dataframe by some criteria - Python Pandas
Assuming the following data for this reply, saved in the file 'dados.csv': data,hora,numero 01/01/2018,10:30,0.1 01/01/2018,20:05,0.2 01/01/2018,07:00,0.3 02/01/2018,11:10,0.4 02/01/2018,22:35,0.5…
-
0
votes1
answer69
viewsA: Code Mandelbrot set
The code highlighted in the question traverses a space in the complex plane to verify whether or not each point belongs to the Mandelbrot set. Initially, the code defines a array to store the test…
-
1
votes1
answer565
viewsA: Problem with Geometry pack and grid (Tkinter)
Cannot use layout managers grid and pack together, in the same window master. One possibility to correct is, for example, to remove the command pack() at the end of the line, at the point where the…
-
0
votes1
answer873
viewsA: Read txt on Assembly i8086
To read the file without specifying the size, you need to read until you detect the end of the file. An example of how to change the program to read larger files without specifying the size: In the…
-
1
votes1
answer208
viewsA: How to declare a multidimensional array using new
The best way to declare the array multidimensional is to declare an array of pointers for each level and initialize the level within a looping. Example for ponteiro[30][100]: // Declara e cria o…
-
1
votes1
answer113
views -
2
votes1
answer31
viewsA: vector inside vector generates double values in the second dimension
The problem is because the method push_back() copies the element obj by executing a copy constructor. An example of this builder would be: // Construtor de cópia da classe classe(classe const…
-
2
votes1
answer95
viewsA: Problems with incorrect data in a dataset (using Pandas)
A safe way to test whether the line value is numerical (for the question data), is to define a function that attempts to perform the conversion to int and check if there was a mistake: def…
-
1
votes1
answer1784
viewsA: Pandas: Create multiple columns in Dataframe
The problem of repetition happens because, within the looping: for i in df.NUM_LEGISLACAO: df['NUM'] = i.split('/')[0] df['ANO'] = i.split('/')[1] every iteration, the columns NUM and ANO are filled…
-
5
votes2
answers6881
viewsA: How to find splitters of a number quickly
It is possible to optimize the looping to perform the calculation of dividers more efficiently: defining the counter c like 2, the beginning of the cycle as 2, the end for the square root of num…
-
1
votes1
answer1847
viewsA: How to save the obtained medias in a dataframe, in a new column containing the averages of this dataframe using pandas?
To put the average in the last column, it is necessary: Turn first row into header Calculate the mean on the vertical axis (axis=0) Indicate that you want the (average) calculation only with the…
-
1
votes1
answer7108
viewsA: Convert decimal to binary in Scratch
The best solution to generate binary digits is to use a list to store the digits and a looping to reduce the variable entradaUsuario at each iteration. With each iteration of looping, the algorithm…
-
1
votes1
answer198
views -
1
votes1
answer411
viewsA: importing data extension ". date"
The separator of the first 8 fields of the file is the space character and not TAB (\t). To read the file correctly, add the parameter delim_whitespace=True and change the parameter header to 0…
-
1
votes1
answer106
viewsA: I can’t get the input value "csrfmiddlewaretoken"
If you analyze the request reset in the variable soup (with the command print(repr(soup))) you will see that the site is returning the message: Access to this page has been denied because we Believe…
python-3.xanswered Gomiero 5,286 -
0
votes1
answer176
viewsA: Python Guessing game
There are 2 problems with the code. The first is a syntax error in the function FornecerPista(): def FornecerPista(): # AQUI: o nome correto da variável é estado1, não status1 if estado1 == 7: if…
-
1
votes1
answer61
viewsA: Javascript - drawRect is interfering with the background color
Before starting each drawing/path, it is necessary to call the method beginPath() to "empty" the path list, otherwise the command Fill will fill the canvas with the previous path (background). The…
-
4
votes1
answer5209
viewsA: How to normalize data? Any sklearn library?
The Standardscaler standardizes the data for a unit of variance (var=1) and not for a crease, so the results differ from expected. To standardize the data in the interval (-1, 1), use the…
-
2
votes1
answer150
viewsA: Problems with the Realloc
Probably the error that is occurring is lack of memory. As with every iteration of looping you allocate double memory, after 30 iterations the realloc will attempt to allocate more than 230 (>…
-
1
votes1
answer172
viewsA: How to access elements of a vector of a type defined by struct?
Segmentation failure error happens when trying to change vector data infomaterial without initializing it with elements (the vector is "empty"). The solution is to initialize the vector with a…
-
2
votes1
answer1067
viewsA: How to Calculate CRC Modbus RTU
The error is happening due to the LSB be after the shift of the CRC16 recorder. This check must occur before the shift operation, according to the modified code below: void CRC (unsigned char* msg,…
-
1
votes1
answer2356
viewsA: How to concatenate a variable to a string containing escape character
The problem is happening because the data is not a string but a sequence of bytes. To concatenate the variable h to this sequence, it is necessary to convert the hexadecimal string to the type byte…
python-3.xanswered Gomiero 5,286 -
1
votes1
answer395
viewsA: Calculate Factorial Array using Thread’s
Like each of the threads will change a different position of the vector, it can be declared as global, and the position for the factorial calculation, be informed as a parameter of the thread.…
-
3
votes1
answer641
viewsA: How to create dictionary from lists
One possibility is to use the class Dictreader module csv, that maps information to a guy Ordereddict (dictionary that maintains the input order). Example: import csv # Abre o arquivo with…
-
3
votes2
answers68
viewsA: Python: How to turn a method or a class into obsolete?
To send the obsolete function message, use the method warn or showwarning module warnings: Example: import warnings def funcao_obsoleta(): # Habilita avisos de "obsoleto", que, a princípio, são…
-
4
votes1
answer3590
viewsA: Sum all columns of an array using numpy. Is there a better way to do it?
You can calculate the sum of the columns directly with the function sum, informing the parameter: axis 0 ('Axis=0'): In [20]: mat.sum(axis=0) Out[20]: array([55, 60, 65, 70, 75]) Documentation: sum…
-
1
votes2
answers6485
viewsA: Python - Moving files to another folder
This problem occurs due to call os.listdir() in the condition test of while: while x <= (len(os.listdir(oldAdress))-1): With each loop iteration, the file list length is recalculated and stays…
python-3.xanswered Gomiero 5,286 -
0
votes1
answer22
viewsA: Program for when a structure statement occurs at different locations
The error is happening because the structure struct addrinfo tips needs to be initialized before being used by the function getaddrinfo(), and the members ai_addrlen, ai_canonname, ai_addr and…
-
0
votes1
answer2705
viewsA: I can’t close the Tkinter Window
To close the previous window, you can call the method destroy() of the instance self.Janela, however, it must be called before to create the new instance (principal = Tk()). The code of the function…
-
2
votes2
answers75
viewsA: How do I remove the thousandths of a value?
One possible solution is to create a rounding function using the Math.floor: function arredonda(num, numCasasDecimais) local mult = 10^(numCasasDecimais or 0) return math.floor(num * mult + 0.5) /…