PROGRAM TO FIND THE MINIMUM PAGES ASSIGNED FOR A STUDENT
Given number of pages in n different books and m students. The books are arranged in ascending order of number of pages. Every student is assigned to read some consecutive books. The task is to assign books in such a way that the maximum number of pages assigned to a student is minimum.
PROGRAM TO SOLVE SUDOKU class GFG { public static boolean isSafe( int [][] board, int row, int col, int num) { // Row has the unique (row-clash) for ( int d = 0 ; d < board.length; d++) { // Check if the number we are trying to ...
PROGRAM TO SOLVE SUDOKU # A Utility Function to print the Grid def print_grid(arr): for i in range ( 9 ): for j in range ( 9 ): print arr[i][j], print ( 'n' ) # Function to Find the entry in # the Grid that is still not used # Searches the grid to find an # entry that is still unassigned. If # found, the reference parameters # row, col will be set the location # that is unassigned, and true is # returned. If no unassigned entries # remains, false is returned. # 'l' is a list variable that has # been passed from the solve_sudoku function # to keep track of incrementation # of Rows and Columns def find_empty_location(arr, l): for row in range ( 9 ): ...
PROGRAM TO PRINT ALL JUMPING NUMBERS SMALLER THAN OR EQUAL TO A GIVEN VALUE class Queue: def __init__( self ): self .lst = [] def is_empty( self ): return self .lst = = [] def enqueue( self , elem): self .lst.append(elem) def dequeue( self ): return self .lst.pop( 0 ) # Prints all jumping numbers smaller than or equal to # x starting with 'num'. It mainly does BFS starting # from 'num'. def bfs(x, num): # Create a queue and enqueue i to it q = Queue() q.enqueue(num) # Do BFS starting from 1 ...
Comments
Post a Comment