This repository has been archived on 2026-05-11. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
prog-104-p-02-2030/Chains_across_the_Island/Fundamentals/practice/practice.c
T
lucas 6adb153201
Tests TP prog-104-p-02-2030 / test (push) Failing after 10s
go se coucher
2026-04-06 03:04:40 +02:00

48 lines
762 B
C

#include "practice.h"
#include "../../utils/lists.h"
#include "../basics/basics.h"
int is_palindrome(struct dlist *l)
{
if (!l || l->next != NULL) return 1;
struct dlist *tmp = l;
int indexb = 0;
while (tmp->next != NULL) {
indexb ++;
tmp = tmp->next;
}
struct dlist *back = tmp;
tmp = l;
int indexp = 0;
while (indexp < indexb){
if (tmp->data != back->data) return 0;
indexp ++;
indexb --;
tmp = tmp->next;
back = back->prev;
}
return 1;
}
struct list *reverse(struct list *l)
{
struct list *tmp =l;
struct list *rslt = NULL;
while(l != NULL){
rslt = list_append(rslt, l->data);
l = l->next;
}
return rslt;
}