refactoring code before(right side), after(left side) #Python #RefactoringCode context : The functions check if the 'value' can be inserted in a particular position(x, y) in its row or column , in a game of sudoku.
                                            Refactoring: The first if condition checks if the position (x, y) is possible in the board. We observe that it doesn't tell to much directly and have to read the if conditions to understand. So we move it out of function and put it in a lambda function 'in_board'.
Now the code expresses itself and can be reused in other functions too. Second refactoring is of the loop which compares each value in row/column of (x, y) and match it with the value. return False if value is present and true if not present.
This could be refactored by using all builtin function which makes the code more expressive.
United States 트렌드
- 1. Cowboys 67.6K posts
 - 2. Nick Smith Jr 8,203 posts
 - 3. Cardinals 30.1K posts
 - 4. Kawhi 3,954 posts
 - 5. #WWERaw 60.1K posts
 - 6. #LakeShow 3,260 posts
 - 7. Jerry 44.7K posts
 - 8. Kyler 8,150 posts
 - 9. Blazers 7,342 posts
 - 10. Logan Paul 9,838 posts
 - 11. No Luka 3,258 posts
 - 12. Jacoby Brissett 5,359 posts
 - 13. Jonathan Bailey 16.8K posts
 - 14. Pickens 6,604 posts
 - 15. Koa Peat 6,155 posts
 - 16. Cuomo 169K posts
 - 17. Javonte 4,233 posts
 - 18. Valka 4,231 posts
 - 19. AJ Dybantsa 1,605 posts
 - 20. Bronny 14.5K posts
 
Something went wrong.
Something went wrong.