Posts by Leonardo Santos • 536 points
13 posts
-
1
votes1
answer41
viewsA: How to serialize a Hash object from Hashlib for Socket submission?
You can use the function hash.Digest() to get the bytes of the hash and pass to conn.sendall, without needing the pickle. hashed_Message = hashlib.sha256(message.encode('utf-8'))…
-
0
votes2
answers40
viewsA: Returned value is being the same as the entered value
You need to convert the value you received into the input to Number. This can be done using parseInt() or Number(). Would look like this: var decimal =…
-
2
votes2
answers85
viewsA: Randomly generated numbers with arrays are repeated
As I commented, you can fill the array with the loop index (nums5[i] = i + 1) and then shuffle the array using this algorithm: https://stackoverflow.com/a/110570/5775775. This will generate an array…
c#answered Leonardo Santos 536 -
2
votes1
answer128
viewsA: Syntax error in Python 3.7
The mistake is in the print "%s %s" % (parte1, parte2). In Python 3 you need to put the arguments of print in brackets (, ), like any other function call. In case it would look like this: print("%s…
python-3.xanswered Leonardo Santos 536 -
5
votes5
answers10820
viewsA: How to Reverse a String?
When the language does not provide a method to do this, I usually use the following algorithm: public String reverse(String str) { char[] chars = str.toCharArray(); int numChars = chars.length - 1;…
-
1
votes1
answer1216
viewsA: Reading of Java XML
First, the method of SAXReader.read(String) that you’re using on getDocumento expects a URL or a file name (https://dom4j.github.io/javadoc/2.0.1/org/dom4j/io/SAXReader.html#read-java.lang.String-),…
-
6
votes2
answers933
viewsA: Take the index of a value in an array
You can use a loop to scroll through the array items until you find the desired one. For example: char[] letras = new char[]{'a','b','c','d'}; int indice = -1; // Percorre todas as letras for (int i…
-
4
votes2
answers2531
viewsA: Inaccessible folder on github
This happens because there is another "repository" . git inside the folder www. What you can do is run: git rm --cached www Go in the directory www and delete the folder .git, go back to previous…
-
4
votes1
answer166
viewsA: Wrong result when calculating BMI
The problem was that you were using the format %f instead of %lf, which is the right one to use with the double. Just change to %lf in both printf and scanf. In the printf is optional but is…
canswered Leonardo Santos 536 -
2
votes2
answers508
viewsA: How to check if a String is null and add in an array?
You can use a for + list. Bundle extra = getIntent().getExtras(); List<String> textos = new ArrayList<>(); int numeroDeTextos = 8; for (int i = 0; i < numeroDeTextos; i++) { String…
-
0
votes1
answer37
viewsA: Can’t find file directory
This happens because the file corresponding to STOREDPATH does not exist. You need to create the file before using it in Fileoutputstream. Would look like this: File storedFile = new…
-
0
votes1
answer301
viewsA: Gulp task - Error
You need to add the package gulp-uglify. If you already specified this package in the package.json of your project, just use npm install to install the dependencies, otherwise use the command npm…
-
5
votes3
answers175
viewsA: Why is my Array item not changed in foreach?
You are modifying the value of the local variable 'course', just that, so it is not working. You would have to modify the array value. Kind of for ( int i = 0; i < cursos.length; i++ ) { if (…
javaanswered Leonardo Santos 536