In my Sudoku project, I'm working a lot with arrays and ArrayLists. Searching an array for things like a value (e.g. a matching digit of 1-9) or an open spot (e.g. open tile in column) can be cumbersome. At first I was for statements often.
But then I discovered Array.IndexOf. The syntax is straightforward Array.IndexOf(arrayName, objectValueToSearchFor). It searches one-dimensional array, starting with the first element (i.e. 0, remember arrays are zero-based) and ending with the last element.. Each element is compared to the specified objectValueToSearchFor. If it finds it, it returns the first element location.
Monday, August 30, 2010
Saturday, August 28, 2010
First C# Project - Sudoku
I finished studying the C# basics up to Collections and thought it was time to test what I've learned so far. What better way to test myself than to build a project from scratch. I love playing Sudoku and have an assortment of the magazine books. I chose to build a project that did the following:
- User loads in a beginning board (just like the game books), as a starting point.
- Then the SolverEngine runs through a series algorithms to solve each row, column, quad, and then finally the entire board.
Subscribe to:
Posts (Atom)
About
- Coder Paws
- Welcome to my blog! This blog is about my journey to become a Master .NET coder and teacher.