void phase_4(String input) { int arr[2]; //make array to hold our 2 ints int i1 = arr[0]; //first input int i2 = arr[1]; //second input int a = sscanf(input, "%d, %d", i1, i2); // x/s 0x4028f5 --> %d %d" in phase_4 if(i1 <= 14) //checks 1st int { int a = func4(i1, 0, 14); //recursion. must = 4 to be valid if(a != 4 || i2 != 4) { explode_bomb(); }else { return; } } else { explode_bomb(); } }
void phase6() { int arr[6], i; for(i = 0; i < 6; i++) if(arr[i] > 6) explode_bomb(); }
/* * phase1c.c - The user's input must match the specified string */ void phase_1(char *input) { #if defined(PROBLEM) if (strings_not_equal(input, "SOME_STRING_SET") != 0) explode_bomb(); #elif defined(SOLUTION) printf("SOME_STRING_GET\n"); #else invalid_phase("1c"); #endif }
/* * phase2b.c - To defeat this stage the user must enter the geometric * sequence starting at 1, with a factor of 2 between each number */ void phase_2(char *input) { #if defined(PROBLEM) int i; int numbers[6]; read_six_numbers(input, numbers); if (numbers[0] != 1) explode_bomb(); for(i = 1; i < 6; i++) { if (numbers[i] != numbers[i-1] * 2) explode_bomb(); } #elif defined(SOLUTION) printf("1 2 4 8 16 32\n"); #else invalid_phase("2b"); #endif }
//TODO: Modified by Max and Matt C, added bomb decrementing. Tested, works as intended. void * countdown(void *param) { struct coords *c; struct fire f; c = (struct coords *)param; sleep(3); f = explode_bomb(c->x, c->y, c->len); player_array[c->id]->explode(); sleep(1); unexplode_bomb(f); return NULL; }
void phase_6(char *input) { #if defined(PROBLEM) listNode *start = &node1; listNode *p; int indices[6]; listNode *pointers[6]; int i, j; read_six_numbers(input, indices); /* Check the range of the indices and whether or not any repeat */ for (i = 0; i < 6; i++) { if ((indices[i] < 1) || (indices[i] > 6)) explode_bomb(); for (j = i + 1; j < 6; j++) { if (indices[i] == indices[j]) explode_bomb(); } } /* Reverse the permutation */ for (i = 0; i < 6; i++) { indices[i] = 7 - indices[i]; } /* Rearrange the list according to the user input */ for (i = 0; i < 6; i++) { p = start; for (j = 1; j < indices[i]; j++) p = p -> next; pointers[i] = p; } start = pointers[0]; p = start; for (i = 1; i < 6; i++) { p->next = pointers[i]; p = p->next; } p->next = NULL; /* Now see if the list is sorted in descending order*/ p = start; for (i = 0; i < 5; i++) { if (p->value < p->next->value) explode_bomb(); p = p->next; } #elif defined(SOLUTION) listNode *start = &node1; listNode *p; /* sort */ start = fun6(start); /* emit the (inverted) node indices of the sorted list */ p = start; while (p) { printf("%d ", 7 - p->index); p = p->next; } printf("\n"); #else invalid_phase("6b"); #endif }
void phase_3(String input) { int arr[2]; //make array to hold our 2 ints int i1 = arr[0]; //first input int i2 = arr[1]; //second input int a = sscanf(input, "%d, %d", &i1, &i2); if(a > 1) //checks if more than two ints were entered { explode_bomb(); } if(i1 > 7) //checks if 1st int is > 7 { explode_bomb(); } ans = i2; switch(i1) { /* this part might be a little funky. but following some sort of variation of the below got me 3 right answers. the switch cases dont seem to have any breaks. so jmpq kind of sets a starting point for this cascade of bs arithmetic to occur, eventually giving a valid second number. neat */ case 0: ans = 0; case 1: ans = 457; ans = ans- 63; case 2: ans = 0; ans = ans - 334; case 3: ans = 0; ans = ans - 822; case 4: ans = 0; ans = ans + 822; case 5: ans = 0; ans = ans - 822; case 6: ans = 0; ans = ans + 822; case 7: ans = 0; ans = ans - 822; } if(i1 < 5) { // this is cmpl $0x5,0x8(%rsp) etc explode_bomb(); //only 5/7 cases allowed, alright then } if(i2 == ans) { //if the 2nd integer matches, we win return; } }