-
-
Notifications
You must be signed in to change notification settings - Fork 686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Starting to reformat loops into a unified concept #2773
base: main
Are you sure you want to change the base?
Conversation
Adding reference resolution Making small updates to instructions Adding blueprint to give to students
…itespace to config.json
I'm aiming to review this early next week, FYI 😉 |
|
||
## Out of scope | ||
|
||
- Specific iteration over a `Map` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this listed here? When I think about loops I don't necessarily think of maps.
Things that are related and seem to be out of scope of this exercise:
- Breaking out of loops using the
break
keyword - Skipping iterations using the
continue
keyword
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding those to the out of scope I prefer mention them and maybe try to add exercise to cover those topics now that you say it, do you have in mind some other topics that could be out of scope? or I should remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be worried that also adding the control-flow statements to this exercise may make it a bit too big.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6 tasks in a not very complex concept for me seems acceptable
Co-authored-by: Sander Ploegsma <[email protected]>
Co-authored-by: Sander Ploegsma <[email protected]>
Co-authored-by: Sander Ploegsma <[email protected]>
Co-authored-by: Sander Ploegsma <[email protected]>
…pics were introduced Adding links to the corresponding headings topics
Adding a different introduction instead of copying the about.md Adding continue and break statements explanation and exercises
concepts/loops/introduction.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoa, I know I said to trim down the contents of the introduction but I think we need to give at least some information 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤣 What do you suggest to add then ? hahaha
"arrays", | ||
"for-loops", | ||
"foreach-loops" | ||
"arrays" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, I don't know to be honest. That would mean that the exercise is limited to just array creation and array indexing?
I'd like to have a good plan going forward, discussions like these become a bit too big for code reviews tbh.
|
||
## Out of scope | ||
|
||
- Specific iteration over a `Map` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be worried that also adding the control-flow statements to this exercise may make it a bit too big.
static int evaluateChallengingExam(List<Integer> studentScores) { | ||
int count = 0; | ||
|
||
for (int score : studentScores) { | ||
if (score <= 40) { | ||
break; | ||
} | ||
|
||
count++; | ||
} | ||
|
||
return count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually makes for a nice while
task:
class MakingTheGrade {
static int evaluateChallengingExam(List<Integer> studentScores) {
int index = 0;
while (studentScores.get(index) > 40) {
index++;
}
return index + 1;
}
}
😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you suggest to change this one for the one that is actually the while task? and make a new one for break ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Floating another idea for trying to keep this as a break
task, it might help to require them to something a bit more with the matching score. For example, if we require them to add the score to a second list (like keeping a list of the first failing score), the solution might look like this:
static void evaluateChallengingExam(List<Integer> studentScores, List<Integer> firstFailingScores) {
for (int score : studentScores) {
if (score <= 40) {
firstFailingScores.add(score);
break;
}
}
}
This way, we can even come up with tests for when the none of the scores pass.
exercises/concept/making-the-grade/src/test/java/MakingTheGradeTest.java
Show resolved
Hide resolved
exercises/concept/making-the-grade/src/test/java/MakingTheGradeTest.java
Show resolved
Hide resolved
Co-authored-by: Sander Ploegsma <[email protected]>
…l statements section Adding two tests for task 5 and 6 Updating design.md to remove out of scope and add new missing learning objective
…java into ReformatLoopsConcept
Hey @kahgoh Do you mind helping me review this PR? Sander is taking a break from exercism so I will like your opinions on this topics |
Hey @manumafe98, I'd be happy to help :) I hope to have a look at it within a day or two. |
Thanks! no rush |
|
||
for (int score : studentScores) { | ||
if (score % 2 == 0) { | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice the design says to have an essential comment if the student doesn't use continue
. I think another valid way to solve this one is to add only odd scores in an if
statements (i.e. no usage of continue
):
static int countOddScores(List<Integer> studentScores) {
int count = 0;
for (int score : studentScores) {
if (score % 2 != 0) {
count++;
}
}
}
We could try to make up a more complicated calculation (although, haven't thought how it could fit with the story yet). For example, we could try something like:
- Lets say we are trying to calculate a
value
. Thevalue
starts at 0. Then for each score ... - If the number is even, go to the next number (don't do anything to
value
). - Then, if the number is also greater than 20, add
5
tovalue
. - Then, if the number is also greater than 60, then double the
value
. - Then, if the number is also greater than 80, subtract 50 from
value
.
We could even add something like "stop adding to the value
if the number is greater than 90" to sneak in a possible break
.
while (count < numberOfStudents) { | ||
sum += studentScores.get(count); | ||
count++; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would also likely use the for
loop too (as per @sanderploegsma's comment). Giving them a list to go through "opens the door" for the for
loop. Perhaps we could try moving away from a list - we could try ask them to call a method that returns something until a condition is met.
One way that came to my mind is that we could extend the challenging exam scenario by saying we want to see how many attempts it takes for a student to pass on exam. Then we could give them an Attempt
object with a score()
method that returns different a value each time it is called.
static int evaluateChallengingExam(List<Integer> studentScores) { | ||
int count = 0; | ||
|
||
for (int score : studentScores) { | ||
if (score <= 40) { | ||
break; | ||
} | ||
|
||
count++; | ||
} | ||
|
||
return count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Floating another idea for trying to keep this as a break
task, it might help to require them to something a bit more with the matching score. For example, if we require them to add the score to a second list (like keeping a list of the first failing score), the solution might look like this:
static void evaluateChallengingExam(List<Integer> studentScores, List<Integer> firstFailingScores) {
for (int score : studentScores) {
if (score <= 40) {
firstFailingScores.add(score);
break;
}
}
}
This way, we can even come up with tests for when the none of the scores pass.
Co-authored-by: Kah Goh <[email protected]>
@manumafe98, @kahgoh, happy to work with you on this one, guys. |
pull request
This PR reworks our current loop structure (
for
andfor-each
) into one big single concept called loops and also introduceswhile
anddo-while
loopscloses #2625
Reviewer Resources:
Track Policies