Exam 01 Piscine 42 Exclusive _verified_ May 2026

Exam 01 of the 42 Piscine is the first significant test of your survival skills in the intensive coding bootcamp.

This four-hour exam typically assesses your ability to master the basics of the Shell (Bash) and the initial concepts of the C programming language under strict, isolated conditions Key Exam Rules and Environment Total Isolation:

No communication with peers, no internet access, and no music or phones are allowed. Zero Tolerance:

If a phone rings in the cluster, the entire row may be disqualified and kicked out immediately. Grading Machine: You are graded by a program called the Moulinette

(or Deepthought). It requires perfect adherence to file names, function names, and paths. Sequential Success:

The grading is often "all-or-nothing" for progress; if you fail an early exercise, the following ones may not be graded. Common Exercise Topics

Expect exercises similar to your first few days of projects (Shell00 to C01). Basic Output: Programs like that simply display a character using the Character/String Manipulation:

Displaying the alphabet, strings, or manipulating ASCII values. Pointers and Values: Simple C functions like (setting a pointer to 42) or (swapping two integer values). Math Operations: exam 01 piscine 42 exclusive

Division and modulo operations, often using pointers to store multiple results. Pro Tips for Success


0. Only A (or only_z)

Task: Write a program that displays a specific character followed by a newline.

  • Concept: Basic write function usage.
  • Code Logic:
    #include <unistd.h>
    int main(void)
    write(1, "a", 1); // or "z" depending on subject
        write(1, "\n", 1);
        return (0);
    
  • Key takeaway: Know the write prototype: write(int fd, const void *buf, size_t count).

Level 1: The First Filter

Typical exercises: ft_atoi, ft_putnbr, ft_strcpy, ft_strdup, ft_iterative_factorial.

The Trap: Edge cases. ft_atoi with " ---+--+1234ab567" must return -1234. The Solution: Write the exact logic.

Critical for ft_strdup:

#include <stdlib.h> // for malloc

char *ft_strdup(char *src) char *dest; int i;

i = 0;
while (src[i])
	i++;
dest = malloc(sizeof(char) * (i + 1));
if (!dest)
	return (NULL);
i = 0;
while (src[i])
dest[i] = src[i];
	i++;
dest[i] = '\0';
return (dest);

Note: You MUST free this later if called. But in the exam function itself, you just return the malloc'd pointer.

After the exam

  • Review failing tests and feedback thoroughly — learning happens most here.
  • Re-implement failed portions from scratch later to cement understanding.
  • Share lessons with peers; teachbacks reinforce mastery.

Level 2: The Graveyard (60% of students die here)

Typical exercises: ft_atoi_base, ft_strjoin, ft_split, ft_strcspn, ft_range.

The Reality: You will likely get ft_atoi_base or ft_split.

Deep Guide for ft_atoi_base:

  1. Handle sign.
  2. Handle base validation (length >= 2, no duplicates, no '+' or '-').
  3. Convert.

Deep Guide for ft_range:

int *ft_range(int min, int max)
int *range;
    int i;
if (min >= max)
    return (NULL);
range = malloc(sizeof(int) * (max - min));
if (!range)
    return (NULL);
i = 0;
while (min < max)
range[i] = min;
    min++;
    i++;
return (range);

Trap: max - min vs max - min + 1. If min=0, max=3 → numbers: 0,1,2. That's 3 numbers. max - min = 3. Correct.

3. Solution Design

The solution is trivial when using ^. However, the exam may explicitly forbid using the ^ operator to test understanding of bitwise logic. In that case, we implement XOR via basic bitwise operations:

XOR = (a | b) & ~(a & b)

or equivalently:

XOR = (a & ~b) | (~a & b)

We choose the second form for clarity.

3.2 One‑line version (allowed ^)

Directly return a ^ b.


10. ft_countdown

Task: Print numbers from 9 down to 0.

  • Concept: Simple decrementing loop.
  • Output: 9876543210\n
🔴
🟡
🔵
🟢
🟣
🔴
🟡
🔵