Add GCD Permutation Problem Solution with Comprehensive Testing Suite#1
Draft
Add GCD Permutation Problem Solution with Comprehensive Testing Suite#1
Conversation
Co-authored-by: HusseinElhaddad <71013980+HusseinElhaddad@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Collatz Conjecture and GCD Permutation Problem
Add GCD Permutation Problem Solution with Comprehensive Testing Suite
Sep 7, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a complete solution to the GCD Permutation competitive programming problem as requested in the issue. The problem requires finding a permutation
qsuch that for any given permutationp, the greatest common divisor of adjacent sumsGCD(pi+qi, pi+1+qi+1) ≥ 3for all positions.Implementation Details
The solution uses a multi-strategy approach:
[n, n-1, ..., 1]n ≤ 8), exhaustive search ensures a solution is foundKey Files Added
gcd_permutation.cpp- Main solution with optimized algorithmverify_solution.cpp- Validation tool to check solution correctnesstest_expected.cpp- Automated testing against known correct solutionsGCD_PERMUTATION_README.md- Comprehensive documentationMakefile- Build automation for easy compilation and testingTesting & Verification
All provided test cases pass verification:
The solution handles edge cases and provides multiple construction strategies to ensure a valid permutation is always found, as guaranteed by the problem constraints.
Usage
The existing Titanic ML project remains completely untouched and functional. This addition is self-contained and documented separately.
Created from VS Code via the GitHub Pull Request extension.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.