#Need help understanding a question
1 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @tight vortex! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
I understand arrays and everything I just don't get how this would look if I were to write the code and execute it, for example
Or how to approach an answer if that makes sense
from the question, you'd basically have int[][] m = ...; the the code that it states, all in the main method of an arbitrary main class
you're supposed to basically run the code manually though
like, in your head
right
you do understand the code itself, right?
try going through step-by-step then
okay lemme think this through
im definitely not 100% on my java right now though lmao
so then
would your answer be 10
or am i buggin
i brainfarted too 💀
holup
i think you made the same mistake as me lol
spoilered in case you want to retry yourself
||the first indexing is rows, not columns||
yeah lemme
try again
no i got 10 again
maybe im missing something
ohhhhhhhhhhhhhhh
okay
so then
nah i still don't get it
@quick crescent so
if the first indexing is rows would it be 9
or am i still tripping
im not super great at the mental coding stuff
that was like 30% a guess tbh
okay i got like 2 more i think i can work through them on my own these are a bit easier but im still kinda confused
would you mind helping me?
but if you were to translate that into code you'd get
int[][] m = {
{ 1, 1, 1, 1 },
{ 1, 2, 3, 4 },
{ 2, 2, 2, 2 },
{ 2, 4, 6, 8 }
};
so doing [1] on the second indexing gets the second column rather than the second row
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
yeah go ahead
okay this one i don't get because
the swaps and stuff
i think it would be "5 4" but i really don't know
hahahahah
i should lmao
i understand magic squares and i understand the code but i don't really know how they would relate in terms of the missing code
have you ever heard of "let the units guide you" in physics
like if you remember all the units then it's not too bad to derive the equation
okay yeah my teacher says "follow the units" when we do stuff like that in physics
especially w thermo which is what we r doing now
force is in Newtons, which is kg m/s^2
and from that it's obvious what the equation could be
mass is in kg
acceleration is m/s^2
F = ma
so yeah you can use something similar here with the types
also, consider:
A single equal sign is used for assignments. int value = 5;. For comparing primitves you use two equal signs if (value == 5) and for Objects .equals() if (string.equals(otherString).
right
ohhh shit
i think
would that mean its option 2?
because
the sums and the square would be the same?
like the sums of the rows/columns/diagonals would be the sum of the magic square?
no, anything with = is wrong
about the types thing
consider the return types and params of the methods
figure out how they fit together
you have a int[][] square to start and you want a boolean output
yep
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.