-
Notifications
You must be signed in to change notification settings - Fork 2
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
1920 Special Semester Q7 #399
Comments
there's a pattern in which the different circle's centre coordinates are created. if it's getCircles(10) --> (1,10) , (2,9) ...... (9,2), (10,1) since you can't use for loops or helper class, u can use streams! (Hint: IntStream) Hope this helps! |
you can try using intStream.mapToObj(x -> new Circle(..........)) |
i did this |
Actually, was wondering, is there a difference between using IntStream and Stream? not really right, like since we know that our stream will be all ints? |
all the same so long as u can produce the right output |
I know using map only will be wrong but why is it the case where we have to use mapToObj? |
|
This is how I did it
|
I had a slightly different approach to iteration that does not require the use of .limit(), hope this offers a new perspective!
Nonetheless both ways should still work. You can also use IntStream as the others have mentioned, but remember to use |
I did this method. Stream.rangeClosed(1,n) |
i did this, hope it helps List getCircles(int n) { |
Hey @ruthkangyr, IntStream's .map() takes in an IntUnaryOperator. Hence, the function provided must return an Integer. This makes sense as IntStream is a stream of integers (Note that it is not a Since you want a Stream, then you would have to call Hope this help! :) |
Summary
Hi! I'm not too sure on how to go about solving this question, I think what confused me was how to initialise the points for the circle objects to be created. If anyone has any suggested solutions I would love to know how you guys did it!
Screenshots (if any):
The text was updated successfully, but these errors were encountered: