/push_swap

1337 - 42 Cursus (push_swap project)

Primary LanguageC

# **************************************************************************** #
#                                                                              #
#                                                         :::      ::::::::    #
#    push_swap                                          :+:      :+:    :+:    #
#                                                     +:+ +:+         +:+      #
#    By: aachhoub <aachhoub@student.1337.ma>        +#+  +:+       +#+         #
#                                                 +#+#+#+#+#+   +#+            #
#    Created: 2023/02/02      by aachhoub              #+#    #+#              #
#    Updated: 2023/02/02      by aachhoub             ###   ########.fr        #
#                                                                              #
# **************************************************************************** #

push_swap

This project requires you to sort data on a stack using a limited set of instructions and with the fewest possible moves. To accomplish this task, you will need to manipulate different sorting algorithms and select the optimal solution(s) for efficient data sorting.

Functions:

  • is_sorted: Checks if a stack is sorted or not.
  • tiny_sort: Uses the minimum instructions to sort a stack that has three nodes
  • push_and_save_three: Pushes all nodes from stack_a to stack_b except 3 nodes amongs the greter half of stack_a
  • sort: Sorts stack_a using an algorithms depending on the size of stack_a
  • get_cost: Gets the count of moves that a node requires in order to be moved to the head of a stack
  • cheapest_move: Decides which set of moves are suitable for a node in order to move it to the top of stack
  • lowest_index_position: Returns the index of the greater node in a stack (which also had the lowest index)
  • target_position: Assign the target position to all nodes
  • move: Performes a set of consecutive instructios to move a node to the head of a stack
  • fill_stack: Fills the stack_a
  • assign_index: Assigns an index to all nodes of stack_a from the greatest to the lowest
  • ft_stack_bottom: Returns the last node of a stack
  • ft_stack_before_bottom: Return the node before the last one of a stack
  • stack_new: Creates a new node
  • ft_stack_size: Returns the count of nodes in a stack
  • ft_stack_add_back: Adds a new node to the back of a stack
  • free_stack: Frees all allocated memory for nodes of a stack
  • exit_error: Exit and desplay an error message
  • valid_input: Checks if the input is valid
  • do_oper_a (bonus): Performs a specific instruction on stack_a
  • do_oper_b (bonus): Performs a specific instruction on stack_b

! Please note that the functions listed above are not an exhaustive list of all the functions available. I have created numerous other functions in previous projects that may also be useful, but they are not included in the list above.

Author

Abdo Achhoubi