advent-of-code/05/day5.c

34 lines
673 B
C
Raw Normal View History

#include <stdio.h>
#include <stdlib.h>
2018-12-05 18:52:24 +01:00
struct ArrayWithLength {
int length;
char* content;
};
2018-12-05 18:52:24 +01:00
int isSameLetter(char a, char b) {
char diff = (a > b) ? a - b : b - a;
return diff == 32;
}
struct ArrayWithLength processArray(char* input, int length) {
char output [length];
int outputLength = 0;
for (int i=0; i<length-1; i++) {
if (isSameLetter(input[i], input[i+1]) == 1) {
i++;
} else {
output[outputLength] = input[i];
outputLength++;
}
}
struct ArrayWithLength ret;
ret.length = outputLength;
ret.content = output;
return ret;
}
int main() {
return 0;
}