aoc-2015/jour14/jour14.m

51 lines
1.6 KiB
Mathematica
Raw Normal View History

2021-03-25 18:35:10 +01:00
#import "raindeer.h"
2021-03-26 16:53:45 +01:00
#import "troupeau.h"
2021-03-25 18:35:10 +01:00
#import <Foundation/Foundation.h>
int main()
{
// obligatoire dans un main
NSAutoreleasePool *myPool = [[NSAutoreleasePool alloc] init];
NSString *path = @"input";
NSError *err;
NSString *contentFile = [[NSString alloc] initWithContentsOfFile:path
encoding:NSUTF8StringEncoding
error:&err];
NSArray *lines = [contentFile componentsSeparatedByString:@"\n"];
NSMutableArray *listDeer = [[NSMutableArray alloc] init];
2021-03-26 16:53:45 +01:00
Troupeau *troupeau = [[Troupeau alloc] init];
2021-03-25 18:35:10 +01:00
for (NSString *tmp in lines)
{
NSArray *parsedSpace = [tmp componentsSeparatedByString:@" "];
if ([parsedSpace count] > 2)
{
Raindeer *rd = [Raindeer initWithName:[parsedSpace objectAtIndex:0]
zatSpeed:[[parsedSpace objectAtIndex:3] integerValue]
boostTime:[[parsedSpace objectAtIndex:6] integerValue]
LunchTime:[[parsedSpace objectAtIndex:13] integerValue]];
2021-03-26 16:53:45 +01:00
[troupeau newDeer:rd];
2021-03-25 18:35:10 +01:00
}
}
2021-03-26 16:53:45 +01:00
/*
2021-03-25 18:35:10 +01:00
int ret = 0;
int tmp = 0;
for (Raindeer *rd in listDeer)
{
tmp = [rd calculDistance:2503];
if (tmp > ret)
ret = tmp;
[rd release];
}
2021-03-26 16:53:45 +01:00
*/
NSLog(@"le résultat est : %d", [troupeau courseUne:1000]);
NSLog(@"le résultat est : %d", [troupeau courseDeux:1000]);
2021-03-25 18:35:10 +01:00
//finir le main par ça
[contentFile release];
[listDeer release];
[myPool drain];
return 0;
}