old thread: What are you working on, Sup Forums?
/dpt/ - Daily Programming Thread
learning lisp ironically
nice pic but this thread's a tad early
she is the cutest
>she
Doesn't really matter.
The only people who actually care are the nerds who want to pick the OP image.
Is there really anyone else that has reasons to complain?
first for Java
First for D
because it's a waste of a bit of a thread and it puts another in the archive, plus it leads to thread wars
How are you enjoying this year's advent of code?
Here's my day 3 pt 2.
int valid_triangle(int *arr)
{
if (arr[0] + arr[1] > arr[2] &&
arr[0] + arr[2] > arr[1] &&
arr[1] + arr[2] > arr[0])
return 1;
else
return 0;
}
int main(void)
{
char *ins = get_filebuffer(DAY(03));
int sides[3][3] = { { 0 } };
unsigned col = 0, row = 0;
unsigned valid = 0;
char *tok = strtok(ins, " \n");
while (tok != NULL)
{
sscanf(tok, "%d", &sides[row++ % 3][col % 3]); /* vertical */
if ((row % 3) == 2)
col++;
if (!(row % 3) && !(col % 3))
{
unsigned i; /* flatten array */
for (i = 0; i < 3; i++)
{
int arr[3] = { sides[i][0], sides[i][1], sides[i][2] };
if (valid_triangle(arr))
valid++;
}
}
tok = strtok(NULL, " \n");
}
printf("Valid triangles: %d\n", valid);
free(ins);
return 0;
}