Index: apps/plugins/sudoku/sudoku.c =================================================================== --- apps/plugins/sudoku/sudoku.c (revision 15274) +++ apps/plugins/sudoku/sudoku.c (working copy) @@ -989,7 +989,7 @@ rb->lcd_update(); } -bool sudoku_generate(struct sudoku_state_t* state) +bool sudoku_generate(struct sudoku_state_t* state, char* target) { char* difficulty; char str[80]; @@ -1004,7 +1004,9 @@ rb->cpu_boost(true); #endif - res = sudoku_generate_board(&new_state,&difficulty); + do { + res = sudoku_generate_board(&new_state,&difficulty); + } while (rb->strcmp(difficulty,target) != 0 && rb->strcmp("any",target) != 0); #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(false); @@ -1068,6 +1070,24 @@ [SM_NEW] = { "New", NULL }, [SM_QUIT] = { "Quit", NULL }, }; + + static const struct menu_item diff[] = { + { "Random Difficulty (faster)", NULL }, + { "Very Easy", NULL }, + { "Easy", NULL }, + { "Medium", NULL }, + { "Hard", NULL }, + { "Fiendish", NULL }, + }; + + static const char difficulties[6][10] = { + { "any" }, + { "very easy" }, + { "easy" }, + { "medium" }, + { "hard" }, + { "fiendish" }, + }; m = menu_init(rb,items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); @@ -1101,7 +1121,10 @@ break; case SM_GENERATE: - sudoku_generate(state); + m = menu_init(rb,diff, sizeof(diff) / sizeof(*diff), + NULL, NULL, NULL, NULL); + result = menu_show(m); + sudoku_generate(state, difficulties[result]); break; case SM_NEW: