NAME=push_swap
-SRCS=algorithm_complex.c algorithm_leafsort.c algorithm_simple.c cheatalloc.c clist.c closure.c frac.c leaf_sort.c leaf_sort_index.c leaf_sort_parse.c list.c main_pushswap.c op_output.c op_p.c op_parse.c op_r.c op_rr.c op_s.c ops.c ops_count.c ops_optimizer.c ops_stackops.c output.c psval.c slice.c splitsort.c splitsort_final.c splitsort_iter.c splitsort_part.c stack.c stacks.c stacks_get.c
+SRCS=algorithm_complex.c algorithm_leafsort.c algorithm_simple.c cheatalloc.c clist.c closure.c disorder.c frac.c leaf_sort.c leaf_sort_index.c leaf_sort_parse.c list.c main_pushswap.c op_output.c op_p.c op_parse.c op_r.c op_rr.c op_s.c ops.c ops_count.c ops_optimizer.c ops_stackops.c output.c psval.c slice.c splitsort.c splitsort_final.c splitsort_iter.c splitsort_part.c stack.c stacks.c stacks_get.c
RESSRCS=_res_leaf_sort_lookup.h
--- /dev/null
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* disorder.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: clefrere <clefrere@student.42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2025/12/18 10:15:56 by clefrere #+# #+# */
+/* Updated: 2025/12/18 13:46:37 by clefrere ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "pushswap.h"
+
+t_frac compute_disorder(const t_stack *a)
+{
+ t_frac res;
+ size_t i;
+ size_t j;
+ t_clist *current;
+ t_clist *other;
+
+ current = a->list;
+ i = 0;
+ res = frac_new(0, 0);
+ while (i++ < a->len)
+ {
+ other = current->prev;
+ j = i;
+ while (j++ < a->len)
+ {
+ if (current->val == other->val)
+ cheatexit(1);
+ if (current->val > other->val)
+ res.num++;
+ res.den++;
+ }
+ current = current->prev;
+ }
+ return (res);
+}
/* By: clefrere <clefrere@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/02 11:02:44 by agilliar #+# #+# */
-/* Updated: 2025/12/18 13:29:32 by agilliar ### ########.fr */
+/* Updated: 2025/12/18 13:46:31 by clefrere ### ########.fr */
/* */
/* ************************************************************************** */
t_frac frac_mul(t_frac lhs, t_frac rhs);
bool frac_lte(t_frac lhs, t_frac rhs);
+t_frac compute_disorder(const t_stack *a);
+
#endif