Skip to content
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

Mock 4a help #608

Open
morksen123 opened this issue Apr 27, 2022 · 13 comments
Open

Mock 4a help #608

morksen123 opened this issue Apr 27, 2022 · 13 comments

Comments

@morksen123
Copy link

ik I'm supposed to do something like consumer.accept(t) but how do iterate through every number from generate?
Does anyone mind showing their code? thanks

@GraceYongXM
Copy link

can have a for loop in forEach!

@shotnothing
Copy link

can also do forEach() in the stream

@morksen123
Copy link
Author

can have a for loop in forEach!

something like the 'sample' answer?

@calvinseptyanto
Copy link

Can use for loop!
for (int i = 0; i < n; i++){
consumer.accept(...);
}

@aldrichwilliams23
Copy link

@calvinseptyanto Issue with that implementation is how to combine them into one line?

@shotnothing
Copy link

@calvinseptyanto Issue with that implementation is how to combine them into one line?

why need one line?

@shotnothing
Copy link

can have a for loop in forEach!

something like the 'sample' answer?

sample answer?

@morksen123
Copy link
Author

can have a for loop in forEach!

something like the 'sample' answer?

sample answer?

Like the answer written by the random guy in the file downloaded

@shotnothing
Copy link

shotnothing commented Apr 27, 2022

can have a for loop in forEach!

something like the 'sample' answer?

sample answer?

Like the answer written by the random guy in the file downloaded

err no all the answers were super whack haha

i just iterated a dummy variable thru N times, and had a .forEach() at the end to run the consumer accept get for said N times

@aldrichwilliams23
Copy link

@shotnothing Oh, my understanding from the paper is, since it's written as 2 0 6 9 5, your output need to be one line

But the code above, where you for loop and in each for loop you have consumer.accept(..) would produce

2
0
6
9
5

@morksen123
Copy link
Author

morksen123 commented Apr 27, 2022

@shotnothing Oh, my understanding from the paper is, since it's written as 2 0 6 9 5, your output need to be one line

But the code above, where you for loop and in each for loop you have consumer.accept(..) would produce

2 0 6 9 5

Hey, its System.out.print not System.out.println. so a loop construct will work too

@aldrichwilliams23
Copy link

@morksen123 Woops, thanks for pointing that out!

@shotnothing
Copy link

@shotnothing Oh, my understanding from the paper is, since it's written as 2 0 6 9 5, your output need to be one line

But the code above, where you for loop and in each for loop you have consumer.accept(..) would produce

2 0 6 9 5

Yeah I mean even with println, you could always just reduce it to a single string and print that once right at the end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants