minor fixes

This commit is contained in:
alexandre 2024-04-08 22:18:16 +02:00
parent 871c7875dd
commit 98df9a36fe
3 changed files with 44 additions and 8 deletions

View File

@ -2,9 +2,10 @@
int get_date_index(creneau* edt, int len_creneau, date d) {
// could be done in log(n), I know
// yields the 1st occurence of d in edt
int x = -1;
for(int i = 0; i < len_creneau; i++) {
x = date_dist(edt[i].date, d);
x = date_dist(d, edt[i].date);
if(x >= 0) {
return i;
}
@ -12,6 +13,27 @@ int get_date_index(creneau* edt, int len_creneau, date d) {
return -1;
}
array get_all_date_index(creneau* edt, int len_edt, date d) {
array arr;
arr.a = malloc(sizeof(int)*8);
arr.memlen = 8;
arr.len = 0;
int x = -1;
int halt = 0;
for(int i = 0; i < len_edt-halt; i++) {
x = date_dist(d, edt[i].date);
if(x == 0) {
arr.a[arr.len] = i;
arr.len++;
} else if(x > 0) {
halt = len_edt;
}
}
return arr;
}
int get_next_friday(creneau* edt, int len_creneau, date d) {
// could be done in log(n), I know again
int x = -1;
@ -133,13 +155,9 @@ bool is_allowed_MP2I(creneau* edt, int len_edt, int grp, date end) {
printf("Invalid number of info colles at index %d for group %d\n", i, grp);
return false;
} else if(inf == 0) {
if(last_no_inf != -1 && last_no_inf != 5) {
printf("Invalid rotation of info colles at index %d for group %d\n", i, grp);
return false;
}
last_no_inf = 0;
} else if(last_no_inf > 5) {
printf("Too many info colles at index %d for group %d\n", i, grp);
printf("Too few info colles at index %d for group %d\n", i, grp);
return false;
} else {
if(last_no_inf != -1) {
@ -164,6 +182,18 @@ bool is_allowed_MP2I(creneau* edt, int len_edt, int grp, date end) {
}
*/
int heuristique(creneau* edt,int len_edt, int grp, date end) {
/*
- Both colles end at 7PM : -10
- Having the same colleur two weeks in a row : -45
- Having the same colleur at a 3w interval : -25
- Having the same colleur at a 4w interval : -10
- Two colles the same day : -20
- Same date over 2 weeks : -10
*/
return 0;
}
/*
void generate_colles_v1(creneau* edt, int len_edt, int n_groups, colleur* chads, int n_chads) {

7
main.c
View File

@ -25,15 +25,18 @@ int main() {
//print_one_week(rend, edt, 112, d1);
edt[3].group = 1;
edt[3].mat = ENGLISH;
/*
edt[6].group = 1;
edt[6].mat = INFO;
edt[20].group = 1;
edt[20].mat = PHYSICS;
edt[1].group = 1;
edt[1].mat = ENGLISH;
edt[21].group = 1;
edt[21].mat = MATH;
is_allowed_MP2I(edt,len_creneau, 1, d1);
*/
/*
date d1 = {19, 1, 3, 2024};

View File

@ -21,6 +21,9 @@ typedef struct creneau {date date; int group; char* name; topic mat;} creneau;
typedef struct colleur {char* name; topic mat; date* disp; int n_disp;} colleur;
// available creneaux for the colleurs
typedef struct array {int* a; int len; int memlen;} array;
// yes
static int width = 1200;
static int height = 900;