Compare commits

..

No commits in common. "31dcab585339a70a62ee0e1934fb12811d065c8e" and "afb38673ea9f5c45e7c3e8701eb7e44ca66eed6a" have entirely different histories.

2 changed files with 5 additions and 22 deletions

View file

@ -14,6 +14,7 @@
* caractère nul.
* - La chaîne de caractère contient forcément des caractères non-nuls.
*/
/*
static char parse_digit(char *line, Node *digits_tree) {
if (isdigit(line[0])) {
return line[0];
@ -21,6 +22,7 @@ static char parse_digit(char *line, Node *digits_tree) {
return Node_stringToDigit(digits_tree, line);
}
}
*/
/**
* Lire tous les caractères d'une ligne :
@ -28,16 +30,12 @@ static char parse_digit(char *line, Node *digits_tree) {
* - Si aucun chiffre n'a é trouvé, retourner 0
*/
static char first_digit(char *line) {
char current_digit = '\0';
Node *digits_tree = Node_new('\0');
while (line[0] != '\0' && !isdigit(current_digit)) {
current_digit = parse_digit(line, digits_tree);
while (line[0] != '\0' && !isdigit(line[0])) {
line++;
}
if (current_digit != '\0') {
return current_digit;
if (*line != '\0') {
return *line;
} else {
return 0;
}
@ -47,20 +45,16 @@ unsigned int get_calibration_sum(FILE *input_file) {
unsigned int sum = 0;
char *current_line, *reversed_line;
char intermediate_buffer[3];
intermediate_buffer[2] = '\0';
while (!feof(input_file)) {
current_line = read_line(input_file);
reversed_line = strrev(current_line);
if (*current_line != '\0') {
intermediate_buffer[0] = first_digit(current_line);
intermediate_buffer[1] = first_digit(reversed_line);
sum += atoi(intermediate_buffer);
}
free(reversed_line);
free(current_line);
}

View file

@ -86,14 +86,3 @@ void Node_printTree(Node *root_node) {
print_node(root_node, 0);
putchar('\n');
}
/**
* Transformer une chaîne de caractères en un chiffre à l'aide d'un arbre
* n-aire
*/
char Node_stringToDigit(Node *root_node, char *string) {
(void) root_node;
(void) string;
return '\0';
}