Skip to content

Create LongDivision.java #3691

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

Merged
merged 27 commits into from
Nov 6, 2022
Merged

Create LongDivision.java #3691

merged 27 commits into from
Nov 6, 2022

Conversation

adjamalbek
Copy link
Contributor

@adjamalbek adjamalbek commented Oct 26, 2022

It's not a simple division, it's a division which is implemented using Long Division Principle, which saves us a lot of time, where some users approach using while loop.

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.

It's not a simple division, it's a division which is implemented using Long Division Principle, which saves us a lot of time, where some users approach using while loop.
@adjamalbek adjamalbek changed the title Create divide_two_integers.java Create DivideTwoIntegers.java Oct 27, 2022
@debasishbsws
Copy link
Member

Add Some JUnit test

@adjamalbek
Copy link
Contributor Author

I did:
#3710

@adjamalbek
Copy link
Contributor Author

Test and Main are combined, all the errors were fixed, please kindly review, thank you

@adjamalbek
Copy link
Contributor Author

Requesting review from @siriak and @yanglbme and @debasishbsws for approval and merging.

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a well-known computer science problem and algorithm? Please add some links to problem statement and algorithm explanation

@adjamalbek
Copy link
Contributor Author

Is this a well-known computer science problem and algorithm? Please add some links to problem statement and algorithm explanation

Here is the problem Problem
Where it's asking to implement a method which divides 2 integers, however there is a time complexity which would not allow a most common method of using the while loop for counting, therefore I did implement a Long Division method Method wikipedia, which saves us a lot of time. However I did state it in the upper comments and in the file itself.

@siriak
Copy link
Member

siriak commented Oct 31, 2022

Then please call it LongDivision and add a link to Wikipedia

Here is my own implementation of the Long Division for 2 integers 
https://en.wikipedia.org/wiki/Long_division
@adjamalbek
Copy link
Contributor Author

I have a left a source and short description in the Main Java class and added a comment, also the name of the Class was changed

@adjamalbek adjamalbek changed the title Create DivideTwoIntegers.java Create LongDivision.java Oct 31, 2022
Copy link
Member

@debasishbsws debasishbsws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@siriak Long division is an algorithm to divide long numbers, in small step-by-step from. It doesn't make any sense if the inputs are bounded to only integers. input and output should be in a string so that very big size numbers can be divided using this.

@adjamalbek
Copy link
Contributor Author

adjamalbek commented Nov 1, 2022

This my 1st attempt by using integers only, I can write a code in a future and update the current method, which will accept numbers as strings, cause initially it was and integer division by long division method. The reason that I cannot apply the long numbers, is because in the problem I can't use * nor / operators

@adjamalbek
Copy link
Contributor Author

Can you please add hackoberfest tag, it was indeed difficult problem, I will update this method, however deadline is today for hacktoberfest, thank you

@debasishbsws debasishbsws requested a review from siriak November 1, 2022 11:00
debasishbsws
debasishbsws previously approved these changes Nov 5, 2022
@debasishbsws debasishbsws enabled auto-merge (squash) November 5, 2022 11:28
Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@siriak siriak disabled auto-merge November 6, 2022 10:18
@siriak siriak merged commit 1c7da7a into TheAlgorithms:master Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants