finish 05, add function template, add optimisations flag
This commit is contained in:
parent
1588f6ec5f
commit
1afd931b84
25
05/_.h
Normal file
25
05/_.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <strings.h>
|
||||
#include <wctype.h>
|
||||
#include <math.h>
|
||||
|
||||
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
|
||||
#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
|
||||
#define ABS(X) ((X) >= 0 ? (X) : -(X))
|
||||
|
||||
char** str_split(char* a_str, const char a_delim);
|
||||
|
||||
int str_index(char *str, char c);
|
||||
|
||||
int number_of_element(char *str, char c);
|
||||
|
||||
long gmc(long a, long b);
|
||||
long lmc(long a, long b);
|
||||
long lmcs(int array[], int n);
|
1176
05/main.txt
Normal file
1176
05/main.txt
Normal file
File diff suppressed because it is too large
Load diff
175
05/main2.txt
Normal file
175
05/main2.txt
Normal file
|
@ -0,0 +1,175 @@
|
|||
56,79,55,52,85,41,61,97,64,72,86,46,58,48,96,62,76,12,13
|
||||
16,95,77,51,17,49,33,56,97
|
||||
95,38,49,61,32,19,77,22,13,27,56
|
||||
84,22,89,64,45,79,34,85,72,96,48,55,29
|
||||
84,34,18,93,63,16,95,77,51,32,17,26,54,27,44,11,19,42,28,38,49,33,56
|
||||
79,72,96,45,76,58,64,46,55,84,86,63,22,52,18,93,85,31,47,41,29,89,81
|
||||
33,34,84,32,49,93,54,63,95,27,83,17,77,28,29,38,42,26,44,11,18
|
||||
34,18,93,63,83,95,51,32,26,27,11,19,42,28,49,33,56
|
||||
31,29,84,18,93,63,16,95,51,26,54,27,19,42,28,38,49
|
||||
31,55,13,22,84,47,72
|
||||
95,77,51,32,17,26,54,27,44,11,42,28,38,49,33,56,61,62,13,48,97,12,22
|
||||
34,18,93,63,16,77,51,32,17,26,54,44,11,28,38,49,33,56,61
|
||||
45,89,84,93,77
|
||||
95,29,84,85,16,83,96,41,89,64,31,52,77,76,34,72,32
|
||||
51,32,17,26,54,27,44,11,19,42,28,38,49,33,56,61,13,48,97,12,22
|
||||
13,77,38,49,62,95,12,32,48,54,44,56,17,11,19,28,22,26,51,42,61,97,27
|
||||
41,45,89,52,55,31,29,84,34,18,93,83,95,77,51,17,26,54,27,44,11
|
||||
85,89,31,29,84,34,63,16,95,77,51,27,44
|
||||
72,62,47,49,97,45,76,61,79,38,13,22,56
|
||||
89,18,46,55,63,72,85,41,64,83,16,52,45,51,96,17,31,93,29
|
||||
58,41,45,52,55,18,93,83,95,77,51
|
||||
97,12,22,86,47,79,81,58,76,46,64,96,72,85,41,45,89,52,55,31,29,84,18
|
||||
79,81,58,76,46,64,72,85,41,45,89,52,55,31,29,84,34,93,63,16,83
|
||||
44,58,28,54,86,79,27,22,49,62,47,19,11,38,13,42,48,26,61,81,33
|
||||
19,64,49,56,28,11,46,44,22,33,62,47,48,79,86
|
||||
42,26,28,52,83,95,29,44,54
|
||||
11,33,54,32,27,51,16,19,42,95,61,44,56,97,77,13,28,38,49
|
||||
19,31,27,95,55,44,77,93,54,63,26,45,52,29,17,83,34,84,18,11,16,32,89
|
||||
18,63,16,77,51,32,54,27,44,42,49,33,56,61,62
|
||||
49,58,72,86,76,46,13,12,33,47,38,28,79,56,48,97,42,62,61,64,85
|
||||
33,56,61,13,48,97,12,22,79,58,76,64,41,45,52
|
||||
77,26,51,85,41,54,27,17,34,32,44
|
||||
19,62,33,54,95,97,13,26,12,77,32,83,56
|
||||
17,26,27,44,19,42,28,38,49,33,56,62,13,48,97,22,86,47,81
|
||||
72,48,89,29,97,86,47,22,76,79,58,85,81,41,12,84,31,96,55,45,34,52,64
|
||||
77,17,27,11,19,42,33
|
||||
95,84,93,27,83,72,34,16,45,55,31,54,52,89,32
|
||||
84,63,77,83,38,42,32,27,16,19,26,11,49,34,44,33,17,95,56
|
||||
26,54,27,44,19,42,33,56,13,48,97,12,22,86,47,79,81
|
||||
47,85,34,18,79,72,64,76,97,46,96
|
||||
48,12,17,86,47,62,33,38,32,54,49,11,97,79,44
|
||||
28,49,33,56,61,62,13,22,47,76,46,72,41
|
||||
85,41,45,89,52,55,31,29,84,34,18,93,63,16,83,95,51,32,17,26,54,27,44
|
||||
81,46,64,45,52,55,29,34,16,95,77
|
||||
27,93,95,18,54,55,83,34,28,52,63,29,31,77,26
|
||||
12,55,56,13,89,47,85,46,48,64,58,45,79
|
||||
84,16,85,31,52
|
||||
47,52,97,31,64,29,41,76,79,46,48,96,86,34,12
|
||||
32,93,63,49,44,31,29,42,54
|
||||
31,84,34,18,63,16,83,95,77,51,32,17,54,27,44,11,19,42,28,38,49
|
||||
41,52,55,31,29,84,34,18,93,63,16,95,32,26,27,44,11
|
||||
41,29,34,32,17,54,11
|
||||
42,38,49,56,61,62,13,48,97,86,47,79,81,58,76,46,96,72,85
|
||||
89,52,31,93,16,17,26,54,19
|
||||
77,42,28,49,97,22,86
|
||||
85,89,22,76,47,34,84,81,55,63,29,52,72,18,79,96,58,86,45,31,41
|
||||
28,38,49,33,56,61,62,13,48,97,12,86,81,58,76,46,64,96,72,85,41
|
||||
32,93,41,52,89,77,64,31,83,84,29,18,63,85,72,34,96,46,45,17,55
|
||||
77,51,26,33,48,97,86
|
||||
18,63,32,17,19,38,33,56,62
|
||||
51,32,29,77,31,54,83,93,84,27,18
|
||||
93,63,83,95,32,27,28,49,61
|
||||
38,49,33,56,62,13,48,97,12,86,47,79,58,76,46,64,96,72,85,41,45
|
||||
17,63,77,61,42,19,38,27,49,33,11,32,16,83,93,51,62,54,56
|
||||
28,81,12,33,19,97,44,79,42,47,46,11,22,49,38,64,61,62,56,48,76,13,86
|
||||
13,49,72,19,22,76,42,97,61,12,48,81,62,86,96,28,33,46,47,79,58,64,38
|
||||
64,12,72,96,76,46,45
|
||||
27,11,56,62,12,86,47
|
||||
84,34,18,93,63,16,83,95,77,51,32,17,26,54,27,44,11,19,28,38,49,33,56
|
||||
96,34,52,45,83,16,26,93,64,55,95,29,72,31,51
|
||||
62,72,89,96,76,86,64,45,22,56,79,12,41,47,85,52,97,55,61
|
||||
11,19,49,56,61,22,79,81,58,64,96
|
||||
58,76,46,72,85,41,89,52,55,31,29,34,18,93,16,83,95,77,51
|
||||
56,61,62,13,48,22,79,81,76,96,85,41,89,52,55
|
||||
26,17,96,18,54,45,16,84,72,93,95
|
||||
51,32,17,27,44,11,38,49,33,56,62,13,48,12,22,86,47
|
||||
63,16,83,95,77,51,32,17,26,54,27,19,42,28,49,33,61,62,13
|
||||
55,29,84,63,17,54,38
|
||||
13,48,97,12,22,86,47,79,81,76,46,64,96,72,85,41,45,89,52,55,31,29,84
|
||||
32,55,16,51,89,18,93,63,83,52,85,77,95,84,54,96,45,26,29,72,41
|
||||
54,27,44,19,42,28,38,61,62,13,97,12,22,86,79
|
||||
47,96,52,55,29,34,83
|
||||
12,22,47,79,46,96,72,85,41,89,84
|
||||
28,51,38,56,17,49,95,26,42,11,77,97,19,44,27,83,54,32,12,61,33,48,13
|
||||
64,83,34,26,77,18,55
|
||||
28,33,56,61,48,97,22,86,47,79,81,58,76,46,64,96,72,85,41
|
||||
38,62,22,19,27,49,28,47,13
|
||||
28,83,17,16,26,93,61,34,51
|
||||
26,49,62,48,97,12,22,86,58
|
||||
97,61,55,52,41,62,22,45,85,64,47,96,13,56,76,81,58
|
||||
63,95,77,51,32,17,26,54,27,44,11,42,28,38,49,33,56,61,62,13,48
|
||||
86,56,44,62,28,13,33,17,79,54,12,49,11,22,38,32,42,61,48
|
||||
11,38,42,54,27,22,62,12,61,19,48,44,49,86,56,81,17,97,33,47,13,28,26
|
||||
31,18,93,63,95,77,51,17,26,54,27,11,19,38,49
|
||||
63,51,31,55,64,16,84,18,83,76,72,29,85,46,32,52,34
|
||||
13,97,86,79,64,72,85,41,84
|
||||
55,34,77,51,32,54,11,19,42
|
||||
55,95,84,51,16,77,38,27,93,19,54,34,42
|
||||
62,11,56,13,38,26,97,48,54,86,27,61,22,17,49,19,77
|
||||
54,77,62,27,56,17,16,83,26,97,32,61,95
|
||||
45,89,52,31,29,84,18,93,16,83,95,77,51,32,17,54,27,11,19
|
||||
17,26,27,11,19,28,49,56,61,62,13,48,12,22,47
|
||||
96,72,85,52,55,31,29,84,63,51,17,26,54
|
||||
22,86,47,79,81,58,76,46,64,96,72,85,41,45,52,55,31,29,34,18,63
|
||||
55,76,79,52,85
|
||||
31,29,84,34,18,93,63,16,83,95,77,51,17,26,54,27,44,11,42,28,49
|
||||
42,48,13,79,47,19,56,49,11,96,86
|
||||
95,77,51,17,54,44,13,48,97,12,22
|
||||
41,31,84,16,83,17,54,44,11
|
||||
12,41,86,52,93,46,89
|
||||
51,61,42,62,18,54,49,95,83,17,56
|
||||
81,58,76,46,64,96,72,85,41,45,89,52,55,31,29,34,18,93,63,16,83,95,77
|
||||
51,77,42,32,54,17,83,27,49,28,95,61,97,19,48
|
||||
11,54,48,51,95,27,17,62,44,28,32,19,61,83,13,49,97,42,33,77,38,26,16
|
||||
18,63,16,77,51,17,27,11,19,42,38,49,33,56,62
|
||||
86,47,79,81,58,76,46,64,96,72,85,45,89,52,55,31,29,84,34,18,93,63,16
|
||||
95,89,41,76,16,63,31,79,52,64,46,72,45,81,55,96,83
|
||||
55,84,63,83,17,44,11,42,38
|
||||
64,33,28,56,38,47,97,12,86,96,61,81,22,13,79,76,62,11,46,42,48,49,58
|
||||
31,97,12,81,41,46,58,89,61
|
||||
97,22,81,46,64,72,29
|
||||
48,42,64,56,58,11,76,96,47,49,33,81,38,19,86,46,97
|
||||
77,51,32,11,49,33,56,62,13,97,86
|
||||
58,29,72,79,76,93,86,84,52,89,12,34,85,18,46
|
||||
72,45,89,52,55,31,29,34,18,93,63,16,83,77,17,26,27
|
||||
33,19,13,77,56,26,11
|
||||
89,55,72,31,29,85,12,45,41,22,76,96,86,13,62,79,52,81,47,58,46,48,97
|
||||
79,64,96,41,45,29,84,63,16
|
||||
44,26,27,83,95,54,49,33,34,42,29
|
||||
89,48,79,47,46,22,72,86,97,33,49,96,62
|
||||
81,45,46,72,93,52,58,79,95,76,63,83,89,84,31,55,41,29,34,96,85
|
||||
33,86,96,81,58,85,72,97,13,46,48,79,76,61,12,22,64,89,52,47,62,45,41
|
||||
76,64,72,85,41,89,52,55,34,93,16,83,95,77,32
|
||||
33,56,61,48,97,12,22,86,47,79,81,76,46,89,52
|
||||
34,95,51,54,27,42,33,56,61
|
||||
77,51,32,17,26,54,27,44,11,19,42,28,38,49,33,56,61,62,13,48,97,12,22
|
||||
63,51,55,76,58,45,46,16,95,64,72,96,34
|
||||
42,13,11,54,49,27,62,38,83,26,93,77,32,28,16,51,63,95,33,17,61,19,44
|
||||
63,51,38,31,54,84,29,55,28,44,77
|
||||
61,62,13,48,97,22,47,81,58,46,96,72,41,89,52,55,31
|
||||
97,12,22,86,47,81,58,76,46,64,72,85,41,45,89,52,31,29,84,34,18
|
||||
31,93,16,95,26,27,49
|
||||
48,33,56,51,26,28,38,63,62,42,54,11,44,95,77
|
||||
79,42,28,96,12,86,56,47,38,49,81,33,72,48,61
|
||||
81,58,76,64,41,45,55,31,84,34,93,63,83,95,77
|
||||
72,13,79,58,19,47,49,12,46,38,42,76,64,56,62,81,48,28,61,96,22
|
||||
84,93,63,16,95,17,19,38,56
|
||||
95,84,89,45,41,76,79
|
||||
33,54,97,86,79,38,27,17,22,47,62,13,44,49,28,42,48,11,32,12,26,61,56
|
||||
34,18,93,63,83,95,77,32,17,26,54,27,11,19,42,49,33,56,61
|
||||
89,79,81,49,85,58,12,76,45
|
||||
89,95,93,84,44,18,51,31,54,63,11,29,55,26,27,83,34
|
||||
62,47,81,58,76,85,45,52,55,31,29
|
||||
81,85,76,79,55,97,45,41,86,62,13,96,72,89,12,29,22,47,64,31,52,58,46
|
||||
38,11,27,58,49,81,97,28,48,47,86,42,79,13,61,44,76,12,56,19,62,22,54
|
||||
54,61,11,95,44,49,26,62,51,18,63,56,28
|
||||
13,48,97,22,86,47,79,81,58,76,46,64,96,72,85,41,45,89,52,55,31,29,84
|
||||
29,41,63,44,18,11,32,45,27
|
||||
85,89,32,18,83,95,51,55,72,93,64,84,63,26,96,34,41,16,45,31,77
|
||||
44,47,64,13,49,33,56
|
||||
79,55,52,58,46,95,41
|
||||
18,45,29,84,93,89,51,32,77,34,96,63,95,85,26,52,55,64,72
|
||||
77,51,32,17,26,54,27,44,11,19,28,38,49,33,61,62,48,22,86
|
||||
54,28,49,33,61,62,97,22,76
|
||||
44,19,27,79,42,13,54,22,49,33,47,81,86,48,38,28,62,61,56,12,97,58,11
|
||||
33,56,61,62,48,22,79,58,72
|
||||
38,28,48,12,26,58,86
|
||||
12,42,38,22,51,47,61
|
||||
56,38,62,13,86,79,27,28,44,12,97,81,46,49,33,47,61
|
||||
18,76,51,29,52,83,41
|
||||
13,48,97,12,86,47,81,46,96,72,85,45,84
|
||||
97,12,22,86,47,79,81,58,76,46,96,72,85,45,89,52,55,31,29,34,18
|
||||
58,47,19,12,26,11,79,42,13,44,22,33,38,54,49,56,61,62,86,27,48
|
||||
11,19,42,28,38,49,33,61,62,13,48,97,12,22,86,47,79,81,58,76,46,64,96
|
||||
28,49,56,61,13,48,86,81,58,76,46
|
84
05/mylib.c
Normal file
84
05/mylib.c
Normal file
|
@ -0,0 +1,84 @@
|
|||
#include "_.h"
|
||||
|
||||
// NOT MY CODE
|
||||
// https://stackoverflow.com/questions/9210528/split-string-with-delimiters-in-c
|
||||
char** str_split(char* str, const char a_delim)
|
||||
{
|
||||
char *a_str = strdup(str);
|
||||
char** result = 0;
|
||||
size_t count = 0;
|
||||
char* tmp = a_str;
|
||||
char* last_comma = 0;
|
||||
char delim[2];
|
||||
delim[0] = a_delim;
|
||||
delim[1] = 0;
|
||||
|
||||
while (*tmp)
|
||||
{
|
||||
if (a_delim == *tmp)
|
||||
{
|
||||
count++;
|
||||
last_comma = tmp;
|
||||
}
|
||||
tmp++;
|
||||
}
|
||||
|
||||
count += last_comma < (a_str + strlen(a_str) - 1);
|
||||
|
||||
count++;
|
||||
|
||||
result = malloc(sizeof(char*) * count);
|
||||
|
||||
if (result)
|
||||
{
|
||||
size_t idx = 0;
|
||||
char* token = strtok(a_str, delim);
|
||||
|
||||
while (token)
|
||||
{
|
||||
//assert(idx < count);
|
||||
*(result + idx++) = strdup(token);
|
||||
token = strtok(0, delim);
|
||||
}
|
||||
//assert(idx == count - 1);
|
||||
*(result + idx) = 0;
|
||||
}
|
||||
|
||||
free(a_str);
|
||||
return result;
|
||||
}
|
||||
|
||||
int str_index(char *str, char c) {
|
||||
|
||||
int i = 0;
|
||||
while (str[i])
|
||||
if (str[i++] == c)
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int number_of_element(char *str, char c) {
|
||||
int nbr = 0;
|
||||
for (int i = 0; str[i] != '\0'; i++)
|
||||
if (str[i] == c)
|
||||
nbr++;
|
||||
return nbr;
|
||||
}
|
||||
|
||||
long gmc(long a, long b) {
|
||||
if (b == 0)
|
||||
return a;
|
||||
return gmc(b, a % b);
|
||||
}
|
||||
|
||||
long lmc(long a, long b) {
|
||||
return (a / gmc(a, b)) * b;
|
||||
}
|
||||
|
||||
long lmcs(int array[], int n) {
|
||||
long result = array[0];
|
||||
for (int i = 1; i < n; i++)
|
||||
result = lmc(result, array[i]);
|
||||
return result;
|
||||
}
|
66
05/part1.c
Normal file
66
05/part1.c
Normal file
|
@ -0,0 +1,66 @@
|
|||
#include "_.h"
|
||||
|
||||
int strslen(char **strs) {
|
||||
int count = 0;
|
||||
for (int i = 0; strs[i] != NULL; i++)
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
int is_first(char **inputs_1, int verif, int verif_2, int j, int k) {
|
||||
|
||||
for (int i = 0; inputs_1[i] != NULL; i++) {
|
||||
char **inputs_1_split = str_split(inputs_1[i], '|');
|
||||
int number_left = atoi(inputs_1_split[0]);
|
||||
int number_right = atoi(inputs_1_split[1]);
|
||||
|
||||
if (number_left != verif && number_right != verif)
|
||||
continue;
|
||||
if (number_left != verif_2 && number_right != verif_2)
|
||||
continue;
|
||||
|
||||
if (j > k) {
|
||||
if (number_left == verif)
|
||||
continue;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
if (number_right == verif)
|
||||
continue;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
if (argc != 3)
|
||||
return 1;
|
||||
|
||||
char **inputs_1 = str_split(strdup(argv[1]), '\n');
|
||||
char **inputs_2 = str_split(strdup(argv[2]), '\n');
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; inputs_2[i] != NULL; i++) {
|
||||
char **inputs_2_comma = str_split(inputs_2[i], ',');
|
||||
int is_good = 1;
|
||||
for (int j = 0; inputs_2_comma[j] != NULL; j++) {
|
||||
int verif = atoi(inputs_2_comma[j]);
|
||||
for (int k = 0; inputs_2_comma[k] != NULL; k++) {
|
||||
int verif_2 = atoi(inputs_2_comma[k]);
|
||||
if (k != j)
|
||||
is_good = is_first(inputs_1, verif_2, verif, j, k) == 0 ? 0 : is_good;
|
||||
}
|
||||
}
|
||||
if (is_good)
|
||||
count += atoi(inputs_2_comma[strslen(inputs_2_comma) / 2]);
|
||||
}
|
||||
|
||||
printf("count: %d\n", count);
|
||||
|
||||
return 0;
|
||||
}
|
1
05/part1.sh
Executable file
1
05/part1.sh
Executable file
|
@ -0,0 +1 @@
|
|||
gcc -lm -g -Wall -Wextra -include_.h part1.c mylib.c
|
82
05/part2.c
Normal file
82
05/part2.c
Normal file
|
@ -0,0 +1,82 @@
|
|||
#include "_.h"
|
||||
|
||||
int strslen(char **strs) {
|
||||
int count = 0;
|
||||
for (int i = 0; strs[i] != NULL; i++)
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
int is_first(char ***inputs_1_split, int verif, int verif_2, int j, int k) {
|
||||
|
||||
for (int i = 0; inputs_1_split[i] != NULL; i++) {
|
||||
int number_left = atoi(inputs_1_split[i][0]);
|
||||
int number_right = atoi(inputs_1_split[i][1]);
|
||||
|
||||
if (number_left != verif && number_right != verif)
|
||||
continue;
|
||||
if (number_left != verif_2 && number_right != verif_2)
|
||||
continue;
|
||||
|
||||
if (j > k) {
|
||||
if (number_left == verif)
|
||||
continue;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
if (number_right == verif)
|
||||
continue;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void swap(char **str_1, char **str_2) {
|
||||
char *tmp = *str_1;
|
||||
*str_1 = *str_2;
|
||||
*str_2 = tmp;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
if (argc != 3)
|
||||
return 1;
|
||||
|
||||
char **inputs_1 = str_split(strdup(argv[1]), '\n');
|
||||
char ***inputs_1_split = calloc(strslen(inputs_1) + 1, sizeof(char**));
|
||||
for (int i = 0; inputs_1[i] != NULL; i++)
|
||||
inputs_1_split[i] = str_split(inputs_1[i], '|');
|
||||
char **inputs_2 = str_split(strdup(argv[2]), '\n');
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; inputs_2[i] != NULL; i++) {
|
||||
char **inputs_2_comma = str_split(inputs_2[i], ',');
|
||||
int is_good = 1;
|
||||
int is_good_final = 1;
|
||||
for (int j = 0; inputs_2_comma[j] != NULL; j++) {
|
||||
int verif = atoi(inputs_2_comma[j]);
|
||||
for (int k = 0; inputs_2_comma[k] != NULL; k++) {
|
||||
int verif_2 = atoi(inputs_2_comma[k]);
|
||||
if (k != j)
|
||||
is_good = is_first(inputs_1_split, verif_2, verif, j, k);
|
||||
is_good_final = is_good == 0 ? 0 : is_good_final;
|
||||
if (!is_good) {
|
||||
swap(&inputs_2_comma[j], &inputs_2_comma[k]);
|
||||
j = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!is_good_final) {
|
||||
count += atoi(inputs_2_comma[strslen(inputs_2_comma) / 2]);
|
||||
}
|
||||
}
|
||||
|
||||
printf("count: %d\n", count);
|
||||
|
||||
return 0;
|
||||
}
|
1
05/part2.sh
Executable file
1
05/part2.sh
Executable file
|
@ -0,0 +1 @@
|
|||
gcc -O3 -Ofast -g3 -lm -Wall -Wextra -include_.h part2.c mylib.c
|
21
05/test.txt
Normal file
21
05/test.txt
Normal file
|
@ -0,0 +1,21 @@
|
|||
47|53
|
||||
97|13
|
||||
97|61
|
||||
97|47
|
||||
75|29
|
||||
61|13
|
||||
75|53
|
||||
29|13
|
||||
97|29
|
||||
53|29
|
||||
61|53
|
||||
97|53
|
||||
61|29
|
||||
47|13
|
||||
75|47
|
||||
97|75
|
||||
47|61
|
||||
75|61
|
||||
47|29
|
||||
75|13
|
||||
53|13
|
6
05/test2.txt
Normal file
6
05/test2.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
75,47,61,53,29
|
||||
97,61,53,29,13
|
||||
75,29,13
|
||||
75,97,47,61,53
|
||||
61,13,29
|
||||
97,13,75,29,47
|
|
@ -23,3 +23,5 @@ int number_of_element(char *str, char c);
|
|||
long gmc(long a, long b);
|
||||
long lmc(long a, long b);
|
||||
long lmcs(int array[], int n);
|
||||
|
||||
long strslen(char **strs);
|
||||
|
|
|
@ -82,3 +82,10 @@ long lmcs(int array[], int n) {
|
|||
result = lmc(result, array[i]);
|
||||
return result;
|
||||
}
|
||||
|
||||
long strslen(char **strs) {
|
||||
long count = 0;
|
||||
while (strs[count])
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
gcc -lm -g -Wall -Wextra -include_.h part1.c mylib.c
|
||||
gcc -O3 -Ofast -lm -g -Wall -Wextra -include_.h part1.c mylib.c
|
||||
|
|
|
@ -1 +1 @@
|
|||
gcc -lm -g -Wall -Wextra -include_.h part2.c mylib.c
|
||||
gcc -O3 -Ofast -lm -g -Wall -Wextra -include_.h part2.c mylib.c
|
||||
|
|
Loading…
Reference in a new issue