From 47b2d968ce981423a66553826b39f4612251831e Mon Sep 17 00:00:00 2001 From: VIliam Date: Mon, 4 Nov 2024 14:00:46 +0100 Subject: [PATCH] cv6 --- cv6/a_station.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cv6/a_station.c b/cv6/a_station.c index 8f659d6..1eff1af 100644 --- a/cv6/a_station.c +++ b/cv6/a_station.c @@ -13,9 +13,15 @@ void destroy_station(struct station* station){ } int select_track(struct station* station, const char* target){ - return 0; + unsigned long hash = 5381; + int c; + while ((c = *target++)) { + hash = ((hash << 5) + hash) + c; // hash * 33 + c + } + return hash % station->track_count; } + void add_target_capacity(struct station* station,const char* target, int capacity){ }