go se coucher
Tests TP prog-104-p-02-2030 / test (push) Failing after 10s

This commit is contained in:
2026-04-06 03:04:40 +02:00
parent 30efd857c1
commit 6adb153201
@@ -1,11 +1,47 @@
#include "practice.h" #include "practice.h"
#include "../../utils/lists.h"
#include "../basics/basics.h"
int is_palindrome(struct dlist *l) int is_palindrome(struct dlist *l)
{ {
//FIXME 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 *reverse(struct list *l)
{ {
//FIXME struct list *tmp =l;
struct list *rslt = NULL;
while(l != NULL){
rslt = list_append(rslt, l->data);
l = l->next;
}
return rslt;
} }