John Luxbrand

Greenhorn
+ Follow
since Sep 12, 2020
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by John Luxbrand




So to precise on the issue, I got it to properly check if the queue is empty and display the proper amount of items in the queue, however, the issue arises when i get to the test part where it removes last/first and writes it back out.
1 month ago

John Luxbrand wrote:

Paul Clapham wrote:Okay. So the stack trace says the error is at line 120 in your code. It's hard to tell what line that is here, because you've chopped off the first few lines of your class. So which line is line 120?



So to precise on the issue, I got it to properly check if the queue is empty and display the proper amount of items in the queue, however, the issue arises when i get to the test part where it removes last/first and writes it back out.
1 month ago

Paul Clapham wrote:Okay. So the stack trace says the error is at line 120 in your code. It's hard to tell what line that is here, because you've chopped off the first few lines of your class. So which line is line 120?


1 month ago

Paul Clapham wrote:Your input assumed that the program would take the first two parameters from the command line and use them for something. But there's no code in the program which uses parameters from the command line. Instead there is code which assumes that a sequence of numbers will be typed into stdin, as in your "expected output" picture. Since you typed no numbers at all into stdin, the output was based on summing that (empty) set, which returns zero.


Oh you're right lol im dumb but thank you! Is there a quick way to type these 1-100 in sequence in the terminal? or do i just manually add them 1 at a time?
1 month ago

Paul Clapham wrote:

John Luxbrand wrote:I am not sure what I am doing wrong.



What makes you think you are doing something wrong?



the error message in the attached photo
1 month ago
So the expected out put from my test case (1 100) is supposed to be 5050 0 5050 but instead i get 0 0 0. I assume it has to do something with the queuesize
1 month ago
I am not sure what I am doing wrong. I am assuming the issue is coming from the removeLast method
1 month ago
yeah, i tried just row * sizeOfGrid + col but it still does not seem like it changes anything
2 months ago

Paul Clapham wrote:Hi John, welcome to the Ranch!

It looks like the numbers you're working with, which look they come from somewhere outside the program, range from 1 to N. Am I right? I see some code which looks like it maps the range (1 ... N) to range (0 ... N-1), which is what you want to do to deal with Java's annoying zero-origin policy for arrays. But I see flaws in that mapping, for example line 30 shouldn't allow row 0. There may be others; perhaps you're doing the mapping twice in some cases? There's a lot of code and I haven't scanned it carefully.

Perhaps it would be better to have a class which encapsulates the Grid array and manages the mapping between the external 1-origin numbers and the internal 0-origin numbers? Otherwise you're going to find the mapping scattered all over the code, where you might forget to do it occasionally or you might do it twice accidentally.



Thank you for the welcome! Indeed the numbers are coming from a text file that companies it. The one i used for the picture is attached below(oh i cant attach text files). Unfortunately, due to my assignment, I'm not to create any extra classes and have to adhear to the methods and classes already given. Below is the weightedquickunion class that I am to use (i'm not to change it at all)

2 months ago

Carey Brown wrote:Just a guess but it seems to me that you are not comparing to either the beginning (0) or the end (sizeOfGrid-1) correctly. You might try these changes.


I tried your suggestion, it did not change anything, except that it now always recognizes the grid as percolating. THe actual opening of each space has not changed.
2 months ago
Hello, this is my first post on here so forgive any mistakes in post etiquette.
I'm trying to complete my percolation class using weightedquickfinds and such, however, when I run it I realize I'm missing the first row and first column as seen in picture *see attached* (first is what it's supposed to look like and the second is mine). I assume it is my encode method that is wrong since row=0 and row=1 would have same result. However if i change it so it is always (row - 1) * sizeOfGrid + col, i start getting index out of bound errors since -1*sizeOfGrid is a negative.


2 months ago