int main(void){ printf("program starts\n"); // this is just a random sudoku i inputed. to test the code // uncomment out the user input if you want to solve your own sudoku int sudoku[9][9] ={ {2,8,5,0,0,0,0,0,0}, //1 {0,7,0,0,2,5,0,0,9}, //2 {0,0,0,0,0,0,0,0,4}, //3 {1,9,0,0,0,0,0,0,0}, //4 {6,0,0,0,9,0,0,1,0}, //5 {0,0,0,7,0,4,0,8,0}, //6 {0,0,0,8,0,3,0,0,0}, //7 {0,0,3,6,0,0,0,4,0}, //8 {0,0,0,0,0,0,5,0,0} //9 }; int (*pointer)[9][9] = &sudoku; // just creates a place to store value // default value is that all the location is 1 // convert will change the values from 1 to 0 if the location is unknown int values[9][9] = { {1,1,1,1,1,1,1,1,1}, //1 {1,1,1,1,1,1,1,1,1}, //2 {1,1,1,1,1,1,1,1,1}, //3 {1,1,1,1,1,1,1,1,1}, //4 {1,1,1,1,1,1,1,1,1}, //5 {1,1,1,1,1,1,1,1,1}, //6 {1,1,1,1,1,1,1,1,1}, //7 {1,1,1,1,1,1,1,1,1}, //8 {1,1,1,1,1,1,1,1,1} //9 }; int (*valuepointer)[9][9] = &values; // uncomment the next line you want to input your own sudoku //input(pointer); // converts the sudoku values to prime so it is easier to deal with convert(pointer, valuepointer); // use logic to solve sudoku totallogic(pointer, valuepointer, 1); // if the logic can not solve the sudoku // then guess and checking with recurbrute will begin if (issudokucomplete(valuepointer)==0){ recurbrute(pointer, valuepointer, 1); } // unconvert the values from primes to normal numbers // so the user can understand unconvert(pointer); // prints the finished sudoku for the user to see printraw(pointer); // i don't have a system pause because i am not a pleb // i run my programs from cmd prompt return 0; }
enum ndn_upcall_res incoming_content(struct ndn_closure *selfp, enum ndn_upcall_kind kind, struct ndn_upcall_info *info) { if (kind == NDN_UPCALL_FINAL) return(NDN_UPCALL_RESULT_OK); if (kind == NDN_UPCALL_INTEREST_TIMED_OUT) return(NDN_UPCALL_RESULT_REEXPRESS); if (kind != NDN_UPCALL_CONTENT && kind != NDN_UPCALL_CONTENT_UNVERIFIED) return(NDN_UPCALL_RESULT_ERR); printf("Got content matching %d components:\n", info->pi->prefix_comps); printraw(info->content_ndnb, info->pco->offset[NDN_PCO_E]); add_to_pool(selfp->intdata, info->content_ndnb, info->pco->offset[NDN_PCO_E]); return(NDN_UPCALL_RESULT_OK); }
enum ndn_upcall_res outgoing_content(struct ndn_closure *selfp, enum ndn_upcall_kind kind, struct ndn_upcall_info *info) { struct mini_store *md; struct ndn_charbuf *cob = NULL; int i; int res = 0; int which; md = selfp->data; which = md->me.intdata; if (kind == NDN_UPCALL_FINAL) { fprintf(stderr, "NDN_UPCALL_FINAL for store %d\n", which); for (i = 0; i < MINI_STORE_LIMIT; i++) ndn_charbuf_destroy(&md->cob[i]); return(NDN_UPCALL_RESULT_OK); } printf("Store %d got interest matching %d components, kind = %d", which, info->matched_comps, kind); /* Look through our little pile of content and send one that matches */ if (kind == NDN_UPCALL_INTEREST) { for (i = 0; i < MINI_STORE_LIMIT; i++) { cob = md->cob[i]; if (cob != NULL && cob_matches(info, cob)) { res = ndn_put(info->h, cob->buf, cob->length); if (res == -1) { fprintf(stderr, "... error sending data\n"); return(NDN_UPCALL_RESULT_ERR); } else { printf("... sent my content:\n"); printraw(cob->buf, cob->length); ndn_charbuf_destroy(&md->cob[i]); return(NDN_UPCALL_RESULT_INTEREST_CONSUMED); } } } printf("... no match\n"); } else printf("\n"); return(NDN_UPCALL_RESULT_ERR); }