← Back to selected work

push_swap

An algorithm project that sorts integers across two stacks using a restricted operation set.

Role
1337 / 42 Developer
Access
1337 / 42 validated project
[01]

Context

An algorithm project that sorts integers across two stacks using a restricted operation set. The implementation balances correctness with the curriculum's operation-count limits.

[02]

My responsibility

Built and validated through the 1337 / 42 project curriculum, with direct responsibility for implementation, debugging, testing, and evaluation requirements.

[03]

System scheme

Engineering scheme

Cost-aware two-stack sorting

Input → Processing → Output

The solver evaluates legal stack operations and emits a sequence that sorts the input within the curriculum's move limits.

  1. 01

    Input parser

    Validate integers, duplicates, range, and argument forms.

  2. 02

    Rank normalization

    Map values to sortable indices while preserving order.

  3. 03

    Stack model

    Represent stack A, stack B, and the permitted operations.

  4. 04

    Cost analysis

    Estimate rotations and transfers for candidate moves.

  5. 05

    Move selection

    Choose and apply the lowest-cost valid operation path.

  6. 06

    Instruction output

    Emit the final operation sequence for evaluation.

Operation count
Input safety
Algorithm complexity
Deterministic output
[04]

Implementation breakdown

  1. 01

    System design

    A cost-aware sorting strategy evaluates stack rotations and move combinations before applying the selected operation sequence.

[05]

Technical scope

C01
Advanced Sorting Algorithms02
[07]

Implementation details

  • Input parser: Validate integers, duplicates, range, and argument forms.
  • Rank normalization: Map values to sortable indices while preserving order.
  • Stack model: Represent stack A, stack B, and the permitted operations.
  • Cost analysis: Estimate rotations and transfers for candidate moves.
  • Move selection: Choose and apply the lowest-cost valid operation path.
  • Instruction output: Emit the final operation sequence for evaluation.
[08]

Engineering constraints

  • Analyzing enormous arrays dynamically avoiding high time complexity ($O(n^2)$).
  • Aggressively optimizing stack rotation logic mitigating redundant movements.

Need a system like this?

Tell me about the workflow, integration, or backend problem.

Discuss a project