#Need help understanding a question

1 messages · Page 1 of 1 (latest)

tight vortex
#

Hey all, I have a question from a homework assignment and I don't really understand what the question is fundamentally asking

hazy merlinBOT
#

This post has been reserved for your question.

Hey @tight vortex! Please use /close or the Close Post button 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.

tight vortex
#

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

quick crescent
#

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

tight vortex
#

right

quick crescent
#

you do understand the code itself, right?

tight vortex
#

yes

#

i believe so

quick crescent
#

try going through step-by-step then

tight vortex
#

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

quick crescent
#

yeah

#

wait no

tight vortex
#

?

#

because wouldn't you

quick crescent
#

i brainfarted too 💀

tight vortex
#

holup

quick crescent
#

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||

tight vortex
#

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

quick crescent
#

yeah it'd be 9

#

the table format is a bit confusing to transform into an array

tight vortex
#

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?

quick crescent
#

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

tight vortex
#

ok

#

i see that makes more sense

#

thank you again

hazy merlinBOT
# tight vortex thank you again

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.

quick crescent
tight vortex
#

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

quick crescent
#

it would be that yeah

#

be a bit more confident lol

tight vortex
#

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

quick crescent
#

have you ever heard of "let the units guide you" in physics

tight vortex
#

no, sorry

#

oh wait i think my teacher has a similar saying though

quick crescent
#

like if you remember all the units then it's not too bad to derive the equation

tight vortex
#

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

quick crescent
#

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:

hazy merlinBOT
#

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).

tight vortex
#

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?

quick crescent
#

no, anything with = is wrong

tight vortex
#

oh

#

then 3, right?

quick crescent
#

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

tight vortex
#

i see

#

okay i understand

#

thanks so much man

hazy merlinBOT
# tight vortex thanks so much man

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.

tight vortex
#

i was struggling fr

#

@quick crescent really appreciate the help, im gonna close this thread now 🤞