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

Not solvable input #1

Open
bncunha opened this issue Jun 3, 2019 · 2 comments
Open

Not solvable input #1

bncunha opened this issue Jun 3, 2019 · 2 comments

Comments

@bncunha
Copy link

bncunha commented Jun 3, 2019

Hello!

Your algorithm is awesome, but there are some inputs that is impossible to solve, like "812043765". You could check if is possible to solve before run the algorithm.

@dgurkaynak
Copy link
Owner

dgurkaynak commented Jun 11, 2019

Hey @bncunha, thank you for reaching out, but this was my school assignment. Maybe one day if I got bored too much, I can fix that 😁Or, as always any PRs are welcome.

@HCsuperc
Copy link

HCsuperc commented May 2, 2023

这个只需要加一个判断即可:在初始化生成序列后,判断一下去掉0后的序列的逆序数是奇数还是偶数。奇数情况是无解的,这个条件下就重新生成。
如:812043765对应序列是 81243765的逆序数和是11,无解。12345687逆序数是1,无解。

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

3 participants