25 Replies
the task is: there is race where it is recorded in the first line the number of race he ran
H array is the places he got
P array is the minutes it needed to finish
and Mp array is the seconds
i had to get the fastest race first and last index
so max and min
but the catch is the place must be at least 3 or 2 or 1
this input file
and it should write 4 and 5
but mine is 4 and 9
can you explain a bit more about the "catch" and the "fastest race first and last index" parts?
also, wouldnt it be easier to represent each race as an object instead of an array of each metric?
oh okay I get it now. Yeah this would be a lot easier if you modelled it as an object, like a
record
no because no struct or class
sry
wdym?
are you not allowed to use structs or classes for this particular homework?
i am lazy to do in specification
?
specification -> structogram -> code
silly for a thing like this
but to answer your question... this is not good code
it can easily be done while reading from the file, as opposed to reading all the values into weird arrays first, or even better and readable with using an object to hold the values
sir
but the code is good semantically?
no
so it doesn't do what it has to?
I mean you just said that yourself.
broooo
they are giving me a headache
probably the output file is bad
your expected value is wrong, yes
look at race 5
3 1 39
vs race 9
3 1 5
race 9 is the fastest top 3 race at 65 total seconds
race 4 is the slowest top 3 race, at 290 secondsPlease use proper naming for your variable names :oh:
How is anybody supposed to read this
What is H? What is P? What is Mp??
I understand you mentioned this in the text below but it should be in the variable name in general
like, look at your code, and compare it to this
I think mine is a lot easier to read and understand
Race
is my custom struct that holds the placement, minutes and seconds from the file, and also adds a TotalSeconds
propertyI didn't choose the variable names
I had to name it like that
Um actually 🤓
We musn't use linq because "We didn't learn it"
??????????????????????????
Your teacher sucks
Not the teacher
The system
I don't understand what you mean
Who forces you to use abysmal naming conventions?
She teaches what she is being told to do
Its my language brah
Single letter variable is not tied to a language
You should honestly just learn to use proper naming, even if you are shown not to. It is a nice learning excercise since you don't directly copy over code that way
Surely you can see that your code is practically unreadable yourself?
H
P
Mp
are not language, just bad variable names
temp
is also terribleThat said, I really can't help you because I can't even read the code myself
These things are made trivial with LINQ, but in the very least you should probably look into creating methods for some common tasks like getting the smallest number and such if you can'tuse those.
Your code now is just a big wall of code that does something but it's very hard to figure out when so many things happen with so little info in the naming
this is what i told to call them
don't judge me