Skip to content

Add Pancake Sort to the sorting algorithms #786

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

Closed
wants to merge 1 commit into from
Closed

Add Pancake Sort to the sorting algorithms #786

wants to merge 1 commit into from

Conversation

arthurvergacas
Copy link
Contributor

Add Pancake Sort

In the spirit of Hacktoberfest, I've decided to add one of my favorite sorting algorithms: the Pancake Sort!

The main reason to like this algorithm, besides the replacement of comparisons with reversals, is of course its name; after all, who doesn't like pancakes? 🥞 😋

If something is off, please don't hesitate to comment in this PR!

@@ -0,0 +1,79 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

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

This is just me being nitpicky again ;) This comment block should just start with /*

}

/**
* The Pancake Sort algorithm. Note that even though it's a completely different
Copy link
Contributor

Choose a reason for hiding this comment

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

Aaaaand this one should just have the single sentence in the first line followed by an empty line ;)

@defaude
Copy link
Contributor

defaude commented Oct 20, 2021

Aside from me nagging about comment style, this looks really nice. Thank you!

@arthurvergacas
Copy link
Contributor Author

AAAAAA hahadhasd omg I didn't even realize that I had to change this one as well. I sent this pr before the one about Fermat, so I didn't have all my new knowledge about js comments and stuff. I'll change it asap. And thank you for the compliment! :)

@arthurvergacas
Copy link
Contributor Author

arthurvergacas commented Oct 20, 2021

her @defaude..... I may have made something stupid.......... What if, hypothetically, I clicked on "Delete fork after the pull request is merged" when the pr about Fermat was merged, and, also hypothetically, this pr was in that fork as well, and now I can't make any changes here..... Could I possibly close this one and replace it with a new?? jasdasdhas I'm so sorry for all this mess, I had no idea that deleting the fork would do this 😭 😭

@defaude
Copy link
Contributor

defaude commented Oct 20, 2021

Oh dang. I see that your forked repo is gone. Well, take this as an opportunity to learn something :D

When working with forked repos, it's always a good idea

  • to create a new branch for each PR
  • to auto-delete the source branch once a PR is merged
  • to not auto-delete the whole fork once a PR is merged ;)

In my opinion, deleting a repo should always be a deliberate decision and be executed manually, as well. Therefore, I think this whole "delete my fork after merge" feature is dangerous at best.

However, you still have your local working copy of the repository, I guess? This means your commits aren't lost! You can just re-create the forked repository (should be created under the same name, and remote URL, I guess).

  1. Compare the commits you have in your local working copy with the master of the freshly-created fork.
  2. Most likely, it will say something around "diverged: you have 1 commit and origni/master has XYZ commits"
  3. => git rebase (should re-apply the 1 new commit you're interested in onto the latest upstream commit)
  4. => git status (should now tell you that you have 1 new commit only)
  5. => git push

@defaude
Copy link
Contributor

defaude commented Oct 20, 2021

tbh I think it's interesting that your changes are still here somehow :) It seems Github has saved your changes in this PR even though the source repo doesn't exist anymore. However, you have most likely no way to add additional commits - I mean, where would you? :)

@arthurvergacas
Copy link
Contributor Author

Well, take this as an opportunity to learn something :D

Yeah!! Embrace the errors!!! hahadh

And indeed, I didn't know about the rebase command, and I'm sure it will be useful in the future. Thanks! :)

Buuuut I think that we are still missing something, and I may have a guess of what it is.

When I do git log in the master in my local repo I get the following:

image

Note the date there: October 13th. But when I look into the Algorithms repo that I just forked, this commit doesn't exist!

image

And because of that, when I rebase in my local repo my commit is gone (:sob:) and when I make all the necessary changes, commit and push, Github just tells me that my fork is ahead of the origin, and I should open a new PR.

Buuuut (for the second time) I did find this. It's a github article that talks about working on a PR whose fork has been gone. But in the end, they say to open a new PR ;-;.

What do you think I should do? Open a new PR and close this one? Keep trying to recover it? Give up completely on git and start a farm in the hills?

I'm open to any of your suggestions (including the farm one, I've always loved sheeps anyway 🐑 )

@raklaptudirm
Copy link
Member

Is it really hard to just copy the two files, re-fork the repository, paste the two files and re-open a pr :)

@arthurvergacas
Copy link
Contributor Author

Well, not hard at all! I just hesitated to re-open a pr because I was afraid of any extra work that you guys might have to do. But if there's nothing wrong with closing it and opening a new one, I'm completely down for it! In fact, I'll do it rn! :))

But one more time, thanks @defaude for all your help and support in trying to recover my repo! :) It surely means a lot! :) 😊

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

Successfully merging this pull request may close these issues.

3 participants