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

NeedForSpeed using Java "Instead of using a loop, consider using a single expression based on one of the comparison operators (i.e. <=, >=, <, >, etc.)." #226

Open
adhamamr01 opened this issue Oct 20, 2024 · 2 comments

Comments

@adhamamr01
Copy link

The suggestion "Instead of using a loop, consider using a single expression based on one of the comparison operators (i.e. <=, >=, <, >, etc.). You can re-use the other methods already implemented in the class or add new ones as needed." shows up as an improvement to the logic of the last task required(canFinishRace(NeedForSpeed car)). However, is it possible to solve it without the loop?

@kahgoh
Copy link
Member

kahgoh commented Oct 21, 2024

Hi @adhamamr01! It is possible to solve this one using maths instead of loops. Using maths, it is possible to figure out how much battery is needed or how far the car can travel with the amount remaining. There are some community solutions using this method, such as this one and this one.

@adhamamr01
Copy link
Author

adhamamr01 commented Oct 22, 2024 via email

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

2 participants