> For the complete documentation index, see [llms.txt](https://42-guide.gitbook.io/42-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://42-guide.gitbook.io/42-guide/core-curriculum/rank-02/push-swap/push-swap-eval-question.md).

# Push Swap Eval Question

Guidelines

Please follow the guidelines below:

1. **Only grade the work turned in the Git repository of the evaluated student or group.**
2. **Double-check that the Git repository belongs to the student(s).** Ensure that the project is the expected one.
3. **Check that 'git clone' is used in an empty folder.**
4. **Ensure no malicious aliases** were used to fool you into evaluating something other than the official repository content.
5. **If applicable, review scripts used for testing or automation.**
6. **If you haven't completed the assignment you are evaluating, read the entire subject before starting the evaluation process.**
7. **Use the available flags to report empty repositories, non-functioning programs, Norm errors, cheating, etc.**
   * In these cases, the evaluation ends with a final grade of 0 (or -42 in the case of cheating). Students are encouraged to review their work to avoid repeating mistakes.
8. **Check for memory leaks** using tools like `leaks`, `valgrind`, or `e_fence`. If there are memory leaks, flag the issue.

## Mandatory Part

### Memory Leaks

* **Reminder:** Throughout the defense, no segfault, nor other unexpected terminations are allowed. The final grade is 0 in such cases. Use the appropriate flag.
* **Monitor memory usage** during the execution of `push_swap` (e.g., with `top`) to detect memory leaks.

| Yes  | No   |
| ---- | ---- |
| \[ ] | \[ ] |

### Error Management

Evaluate the following error management tests. If at least one fails, no points will be awarded for this section.

1. Run `push_swap` with non-numeric parameters. The program must display "Error".
2. Run `push_swap` with a duplicate numeric parameter. The program must display "Error".
3. Run `push_swap` with a parameter greater than `MAXINT`. The program must display "Error".
4. Run `push_swap` without parameters. The program must display nothing and give the prompt back.

| Yes  | No   |
| ---- | ---- |
| \[ ] | \[ ] |

### Push\_swap - Identity Test

Evaluate `push_swap` behavior when given an already sorted list. If at least one fails, no points will be awarded for this section.

1. Run `./push_swap 42`. The program should display nothing (0 instructions).
2. Run `./push_swap 2 3`. The program should display nothing (0 instructions).
3. Run `./push_swap 0 1 2 3`. The program should display nothing (0 instructions).
4. Run `./push_swap 0 1 2 3 4 5 6 7 8 9`. The program should display nothing (0 instructions).
5. Run `./push_swap 'Between 0 and 9 randomly sorted values chosen'`. The program should display nothing (0 instructions).

| Yes  | No   |
| ---- | ---- |
| \[ ] | \[ ] |

### Push\_swap - Simple Version

If the following tests fail, no points will be awarded for this section.

1. Run `ARG="2 1 0"; ./push_swap $ARG | ./checker_OS $ARG`. Check that the checker program displays "OK" and that the size of the instruction list from `push_swap` is 2 OR 3.
2. Run `ARG="Between 0 and 3 randomly chosen values"; ./push_swap $ARG | ./checker_OS $ARG`. Check that the checker program displays "OK" and the instruction list size is between 0 and 3.

| Yes  | No   |
| ---- | ---- |
| \[ ] | \[ ] |

### Another Simple Version

Execute the following tests. If at least one fails, no points will be awarded for this section.

1. Run `ARG="1 5 2 4 3"; ./push_swap $ARG | ./checker_OS $ARG`. Check that the checker program displays "OK" and the instruction list size is no more than 12 (ideally 8).
2. Run `ARG="5 random values"; ./push_swap $ARG | ./checker_OS $ARG`. Check that the checker program displays "OK" and the instruction list size is no more than 12. Repeat with several permutations.

| Yes  | No   |
| ---- | ---- |
| \[ ] | \[ ] |

### Push\_swap - Middle Version

Evaluate the following test. If it fails, no points will be awarded.

1. Run `ARG="<100 random values>"; ./push_swap $ARG | ./checker_OS $ARG`. Check that the checker program displays "OK" and the size of the instruction list is:

| Points | List Size |
| ------ | --------- |
| 5      | <700      |
| 4      | <900      |
| 3      | <1100     |
| 2      | <1300     |
| 1      | <1500     |

Repeat the test with different permutations before validating.

| Rate | Score |
| ---- | ----- |
| 0    | \[ ]  |
| 1    | \[ ]  |
| 2    | \[ ]  |
| 3    | \[ ]  |
| 4    | \[ ]  |
| 5    | \[ ]  |

### Push\_swap - Advanced Version

Evaluate the following test. If it fails, no points will be awarded.

1. Run `ARG="<500 random values>"; ./push_swap $ARG | ./checker_OS $ARG`. Check that the checker program displays "OK" and the size of the instruction list is:

| Points | List Size |
| ------ | --------- |
| 5      | <5500     |
| 4      | <7000     |
| 3      | <8500     |
| 2      | <10000    |
| 1      | <11500    |

Repeat the test with different permutations before validating.

## Bonus Part

### Checker Program - Error Management

Evaluate the following error management tests. If at least one fails, no points will be awarded.

1. Run `checker` with non-numeric parameters. The program must display "Error".
2. Run `checker` with a duplicate numeric parameter. The program must display "Error".
3. Run `checker` with a parameter greater than `MAXINT`. The program must display "Error".
4. Run `checker` without parameters. The program must display nothing and give the prompt back.
5. Run `checker` with valid parameters and an action that doesn't exist during the instruction phase. The program must display "Error".
6. Run `checker` with valid parameters and an action with spaces before/after the action during the instruction phase. The program must display "Error".

| Yes  | No   |
| ---- | ---- |
| \[ ] | \[ ] |

### Checker Program - False Tests

Evaluate the checker's ability to manage a list of instructions that doesn't sort the list.

1. Run `./checker 0 9 1 8 2 7 3 6 4 5`, then write the list `[sa, pb, rrr]`. Checker should display "KO".
2. Run `./checker` with a valid list and write an invalid instruction list that doesn't order the integers. Checker should display "KO". Repeat with multiple permutations.

| Yes  | No   |
| ---- | ---- |
| \[ ] | \[ ] |

### Checker Program - Right Tests

Evaluate the checker's ability to manage a list of instructions that sort the list.

1. Run `./checker 0 1 2` and press CTRL+D without instructions. The program should display "OK".
2. Run `./checker 0 9 1 8 2`, then input the list `[pb, ra, pb, ra, sa, ra, pa, pa]`. The program should display "OK".
3. Run `./checker` with a valid list and write an instruction list that sorts the integers. Checker should display "OK". Repeat with several permutations.

| Yes  | No   |
| ---- | ---- |
| \[ ] | \[ ] |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://42-guide.gitbook.io/42-guide/core-curriculum/rank-02/push-swap/push-swap-eval-question.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
