diff --git a/Makefile b/Makefile index 8acf246..455f8c4 100644 --- a/Makefile +++ b/Makefile @@ -6,11 +6,11 @@ # By: cchauvet > i) & 1) != tofind) - i--; - return (sizeof(int) * 8 - i - 1); -} - - -int ft_bit_finder_right(int big, int tofind) -{ - return ((int) sizeof(int) * 8 - 1 - ft_bit_finder_left(big, tofind)); -} diff --git a/ft_bit_finder.o b/ft_bit_finder.o deleted file mode 100644 index 4ad5bf9..0000000 Binary files a/ft_bit_finder.o and /dev/null differ diff --git a/ft_get_bit_max.c b/ft_bitlen.c similarity index 63% rename from ft_get_bit_max.c rename to ft_bitlen.c index 58c04d4..73a7cfc 100644 --- a/ft_get_bit_max.c +++ b/ft_bitlen.c @@ -1,31 +1,29 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* ft_get_bit_max.c :+: :+: :+: */ +/* ft_bitlen.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: cchauvet ft_bit_finder_left(max, 1)) - max = tab[i]; + if (nb >> i & 1) + y = i; i++; } - return (max); + return (y); } diff --git a/ft_get_bit_min.c b/ft_get_bit_min.c deleted file mode 100644 index cc3d37b..0000000 --- a/ft_get_bit_min.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_get_bit_min.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cchauvet max) + max = *tab; + tab++; + } + return (max); } diff --git a/ft_get_max.o b/ft_get_max.o deleted file mode 100644 index f02e597..0000000 Binary files a/ft_get_max.o and /dev/null differ diff --git a/ft_get_min.o b/ft_get_min.o deleted file mode 100644 index b8e0eaf..0000000 Binary files a/ft_get_min.o and /dev/null differ diff --git a/ft_is_sorted.c b/ft_is_sorted.c index 4d9853b..b541476 100644 --- a/ft_is_sorted.c +++ b/ft_is_sorted.c @@ -6,7 +6,7 @@ /* By: cchauvet = 0 && !ft_is_sorted(tab_a)) + y = ft_tablen(tab_a); + while (0 < y && (!ft_is_sorted(tab_a) && !ft_tablen(tab_b))) { - if (tab_a[tab_index] % 2 == 1) - { + if (((tab_a[ft_tablen(tab_a) - 1] >> i) & 1) == 1) ft_pb(tab_a, tab_b); - tab_index--; - } else ft_ra(tab_a); - loop_index--; + y--; } while (tab_b[0] != STOP_VALUE) ft_pa(tab_a, tab_b); - tab_index = ft_tablen(tab_a); - while (--tab_index >= 0 && !ft_is_sorted(tab_a)) - tab_a[tab_index] = tab_a[tab_index] >> 1; + i++; } - free(tab_a); - free(tab_b); } diff --git a/ft_radix.o b/ft_radix.o deleted file mode 100644 index 084b841..0000000 Binary files a/ft_radix.o and /dev/null differ diff --git a/ft_sort.c b/ft_sort.c index e3544be..c7ccab3 100644 --- a/ft_sort.c +++ b/ft_sort.c @@ -6,19 +6,19 @@ /* By: cchauvet len) + size = len; + ptr = malloc((size + 1) * sizeof(char)); + if (ptr == NULL) + return (NULL); + ptr[size] = '\0'; + while (size-- > 0) + ptr[size] = s[start + size]; + return (ptr); +} + +size_t ft_seglen(const char *s, char c) { size_t len; diff --git a/ft_get_min.c b/ft_strlen.c similarity index 64% rename from ft_get_min.c rename to ft_strlen.c index 01c7813..09ec805 100644 --- a/ft_get_min.c +++ b/ft_strlen.c @@ -1,34 +1,23 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* ft_get_min.c :+: :+: :+: */ +/* ft_strlen.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: cchauvet tab[i]) - min = i; + i = 0; + while (s[i] != '\0') i++; - } - return (min); -} - -int get_min(int *tab, int size) -{ - return (tab[get_min_index(tab, size)]); + return (i); } diff --git a/ft_swap.o b/ft_swap.o deleted file mode 100644 index 22b1580..0000000 Binary files a/ft_swap.o and /dev/null differ diff --git a/ft_tablen.o b/ft_tablen.o deleted file mode 100644 index ddd152e..0000000 Binary files a/ft_tablen.o and /dev/null differ diff --git a/main.c b/main.c index 7688a2e..793f5c0 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ /* By: cchauvet -#include "pushswap.h" - -int main() -{ - int tab_a[5] = {0,1,2,3,-1}; - int tab_b[5] = {-1}; - int i; - - i = 0; - printf("a: "); - while (tab_a[i] != -1) - { - printf("%d, ", tab_a[i]); - i++; - } - printf("\nb: "); - i = 0; - while (tab_b[i] != -1) - { - printf("%d, ", tab_b[i]); - i++; - } - printf("\n"); - ft_pa(tab_a, tab_b); - i = 0; - printf("a: "); - while (tab_a[i] != -1) - { - printf("%d, ", tab_a[i]); - i++; - } - printf("\nb: "); - i = 0; - while (tab_b[i] != -1) - { - printf("%d, ", tab_b[i]); - i++; - } -}