Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
feat: init (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
mahautlatinis authored Oct 3, 2023
1 parent 0ce4c08 commit 0440e4a
Show file tree
Hide file tree
Showing 77 changed files with 114 additions and 1,999 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/macos-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: tests macos

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: macos-latest

steps:
- uses: actions/checkout@v3
- name: mandatory tests
run: cd push_swap; make; ./push_swap 1 2 3 4 5;
shell: bash
17 changes: 17 additions & 0 deletions .github/workflows/norminette.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: norminette

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
norminette_job:
runs-on: ubuntu-latest
name: norminette
steps:
- uses: actions/checkout@v2
- uses: alexandregv/norminette-action@v3
with:
flags: './push_swap'
71 changes: 0 additions & 71 deletions Makefile

This file was deleted.

Binary file removed push_swap
Binary file not shown.
23 changes: 0 additions & 23 deletions push_swap.h

This file was deleted.

71 changes: 71 additions & 0 deletions push_swap/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: mahautlatinis <[email protected] +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/05/29 11:04:13 by user42 #+# #+# #
# Updated: 2023/10/03 23:07:27 by mahautlatin ### ########.fr #
# #
# **************************************************************************** #

SRCS_SORTER = ./srcs/sorter/main.c \
./srcs/sorter/short_suites/short_suites.c \
./srcs/sorter/long_suites/step1_target_index.c \
./srcs/sorter/long_suites/step2_keep_push.c \
./srcs/sorter/long_suites/step3_find_shortest_action.c \
./srcs/sorter/long_suites/step4_sort.c

SRCS_COMMON = ./srcs/common/stack/stack_utils0.c \
./srcs/common/stack/stack_utils1.c \
./srcs/common/stack/stack_utils2.c \
./srcs/common/stack/stack_utils3.c \
./srcs/common/utils/utils0.c \
./srcs/common/actions/push_stack.c \
./srcs/common/actions/reverse_rotate_stack.c \
./srcs/common/actions/rotate_stack.c \
./srcs/common/actions/swap_stack.c \
./srcs/common/parsing/parsing_utils.c \
./srcs/common/exit/exit.c

SRCS_CHECKER = ./srcs/checker_bonus/get_next_line.c \
./srcs/checker_bonus/get_next_line_utils.c \
./srcs/checker_bonus/main.c

OBJS_SORTER = ${SRCS_SORTER:.c=.o}
OBJS_COMMON = ${SRCS_COMMON:.c=.o}
OBJS_CHECKER = ${SRCS_CHECKER:.c=.o}

INCLUDE = ./srcs/include

NAME = push_swap
NAME_CHECKER = checker

CC = gcc
CFLAGS = -Wall -Wextra -Werror
RM = rm -rf

all: ${NAME}

.c.o:
${CC} ${CFLAGS} -I${INCLUDE} -c $< -o ${<:.c=.o}


${NAME}: ${OBJS_COMMON} ${OBJS_SORTER}
${CC} ${CFLAGS} -I${INCLUDE} -o ${NAME} ${OBJS_COMMON} ${OBJS_SORTER}

${NAME_CHECKER}: ${OBJS_COMMON} ${OBJS_CHECKER}
${CC} ${CFLAGS} -I${INCLUDE} -o ${NAME_CHECKER} ${OBJS_COMMON} ${OBJS_CHECKER}

clean:
${RM} ${OBJS_COMMON} ${OBJS_CHECKER} ${OBJS_SORTER}

fclean: clean
${RM} ${NAME} ${NAME_CHECKER}

re: fclean all

bonus: checker

.PHONY: checker bonus all clean fclean re
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: user42 <user42@student.42.fr> +#+ +:+ +#+ */
/* By: mahautlatinis <mahautlatinis@student.42 +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/06/12 11:11:25 by malatini #+# #+# */
/* Updated: 2021/06/18 10:41:03 by user42 ### ########.fr */
/* Updated: 2023/10/03 23:09:54 by mahautlatin ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -44,7 +44,7 @@ int execute_read_action(char *action, t_mem *mem)
rrb(mem->b, 0, mem);
else if (!ft_strcmp(action, "rrr"))
rrr(mem->a, mem->b, 0, mem);
else if (!ft_strcmp(action, "sa"))
else if (!ft_strcmp(action, "sa"))
sa(mem->a, 0, mem);
else if (!ft_strcmp(action, "sb"))
sb(mem->b, 0, mem);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* step2.c :+: :+: :+: */
/* step2_keep_push.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: malatini <[email protected]> +#+ +:+ +#+ */
/* By: mahautlatinis <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/06/09 15:36:14 by malatini #+# #+# */
/* Updated: 2021/06/13 15:38:13 by malatini ### ########.fr */
/* Updated: 2023/10/03 23:09:20 by mahautlatin ### ########.fr */
/* */
/* ************************************************************************** */

#include <sorter/sorter.h>

/* Compte la plus longue suite de target_index triés dans l'ordre croissant*/
/* Va renseigner keep a true si bool define est true */
int largest_keep_a(t_s_elem *start, t_stack *stack, bool define)
{
t_s_elem *elem;
Expand Down Expand Up @@ -43,7 +41,6 @@ int largest_keep_a(t_s_elem *start, t_stack *stack, bool define)
return (count);
}

/* Retourne l'adresse du premiere élément de la suite triée à garder sur A */
t_s_elem *get_max_keep(t_stack *stack)
{
t_s_elem *elem;
Expand All @@ -58,15 +55,14 @@ t_s_elem *get_max_keep(t_stack *stack)
cur = largest_keep_a(elem, stack, false);
if (cur > max_keep)
{
max_keep = cur;
max = elem;
max_keep = cur;
max = elem;
}
elem = elem->next;
}
return (max);
}

/* Va determiner la plus longue suite d'index triés et mettre keep a true */
void set_keep(t_mem *mem)
{
t_s_elem *max;
Expand All @@ -77,7 +73,6 @@ void set_keep(t_mem *mem)
mem->maxsize = largest_keep_a(max, stack, true);
}

/* Mets sur la stack B tous ceux dont keep = false */
void push_keep_false_b(t_mem *mem)
{
int size;
Expand Down
File renamed without changes.
Loading

0 comments on commit 0440e4a

Please sign in to comment.