]> Untitled Git - axy/ft/pushswap.git/commitdiff
Slight tweak to simple algorithm to make no-op on sorted stack
author= <=>
Thu, 18 Dec 2025 12:15:58 +0000 (13:15 +0100)
committer= <=>
Thu, 18 Dec 2025 12:15:58 +0000 (13:15 +0100)
algorithm_simple.c

index 887046f3ad4c03554b172891d9c93d685bcca9bd..46eed27726eaaed292897417acfc8999ac21ce22 100644 (file)
@@ -1,12 +1,12 @@
 /* ************************************************************************** */
 /*                                                                            */
 /*                                                        :::      ::::::::   */
-/*   algorithm_selection_sort.c                         :+:      :+:    :+:   */
+/*   algorithm_simple.c                                 :+:      :+:    :+:   */
 /*                                                    +:+ +:+         +:+     */
 /*   By: clefrere <clefrere@student.42.fr>          +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2025/12/09 15:43:09 by clefrere          #+#    #+#             */
-/*   Updated: 2025/12/16 14:54:44 by agilliar         ###   ########.fr       */
+/*   Updated: 2025/12/18 13:12:35 by agilliar         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -18,6 +18,8 @@ void  algorithm_simple(const t_stacks *stacks, t_closure cb)
 
        sorted = list_new(stacks->a);
        list_sort(sorted);
+       if (stacks_is_solved(stacks))
+               return ;
        while (sorted.len)
        {
                if (stacks->a.list->val == sorted.ptr[0])