Exercism.io


What is this?

  • Exercism.io is a great tool that can help you develop your problem solving skills

Why is developing problem solving skills so important when becoming a developer?

  • Developers solve problems by writing software, if you develop the ability to solve problems you will become a great developer and not just one that copies code from the internet and hopes it works, don't be that guy or girl :)

The following is your first test to make sure you know how to follow directions and problem solve, good luck!

Setup exercism.io so that you can get started in sharpening your C# skills.

  1. Go to exercism.io and login with your GitHub account, you have one of those right? ;)

  2. Select the Languages tab (exercism.io/languages), then select the C# language, as of this writing there are 112 Problems for you to solve

  3. Read that page, and towards the middle you will see a link labeled command-line client which takes us to exercism.io/clients/cli
  4. Choose the windows link which takes you to exercism.io/clients/cli/windows, follow the instructions carefully to install a tool called Chocolatey, ignore the "optional" section where it talks about using Bash or Zsh. That's beyond what you will be doing, so don't worry about it for now
  5. Test your installation by running the exercism command in the command prompt (cmd.exe or powershell.exe), refer to bit.ly/open-cmd for assistance on how to open the command prompt with Administrator Privileges
  6. Configure the exercism tool by adding your own API key and find out where the exercises will be downloaded to

    • Important! In the command prompt type exercism configure --key=YOUR_EXERCISM_KEY your key can be found at bit.ly/exercism-key, replace the YOUR_EXERCISM_KEY with your actual key before running the command. This command will also create the exercism folder automagically which is where the exercises will be downloaded to :)

      Congratulations! you are all set and will be able to download exercises from exercism.io
  7. Let's now work through an exercise together so you know what to expect for the remaining 111 exercises ;)

    • You must first fork a repo that will assist you in keeping things organized, please fork the following repo bit.ly/exercism-csharp by clicking the Fork the button on that page

    • Then, you must clone your fork of the repo on your machine

      • On your computer open the command prompt and navigate to your exercism folder by typing cd c:\Users\USER_NAME\exercism then type the following git clone PATH_TO_REPO. Remember to make sure you replace both USER_NAME and PATH_TO_REPO with your own values before executing these commands. When you fork someone else's repo you are creating a copy of it on your own GitHub account, you can get the path by clicking the Clone or download button, verify that the path contains your username in it i.e.[email protected]:YOUR_USER_NAME/exercism-csharp.git

      • In the exercism folder located on your computer you should now have the exercism-csharp directory that was created when you ran the git clone command

    • Finally, let's fetch the first exercise from exercism.io

      • In the command prompt run exercism fetch csharp hello-world this command will fetch the Hello World in C# exercise and it will also create the csharp directory automagically inside the exercism folder, now visit the about page at bit.ly/exercism-helloworld-csharp to review the information. In short, you should now have a csharp directory in the exercism folder, this new directory will store all the exercises that you will eventually download from exercism.io; the new csharp directory should only have one subfolder named hello-world right now, please verify the existence of this hello-world subfolder before continuing with this guide

    • Welcome back! Now, let's review what you have done

      • You should have two directories in the exercism folder on your computer. Important! The csharp directory is automagically created by running the exercism fetch csharp hello-world command
  8. Open the exercism-csharp folder and double click on the Exercism_CSharp.sln visual studio solution file

    This will open Visual Studio 2017, your Solution Explorer panel should look like the following

  9. It's now time to add the hello-world project to your solution

    • With the Solution Explorer panel visible, right click on the solution's root level which is the top level item labeled Solution 'Exercism_CSharp'(0 project), a menu should become visible, half way down you will see the Add option, click it and then select Existing Project...
    • An open file dialog window should be visible, now browse and locate the c:\Users\USER_NAME\exercism\csharp\hello-world\HelloWorld.csproj file, select it and then press the Open button on the dialog window
    • You have successfully added an existing project to the solution, way to go!
  10. What's left, you might ask. Well, I need to show you how to interact with this project and then solve it so that you can then upload it back to exercism.io and have the entire world critique your solution. Get used to having others look at your code, and give there 2 cents on how they could have done it better :P

    • On-wards we go! Quick review. You have a Solution with one project. The HelloWorld project contains three files: README.md, HelloWorld.cs and HelloWorldTest.cs

    • The README.md contains what are known as the specs or specifications (objectives) of the code you must write, study this file first and make sure you fully understand what you need to do

    • The HelloWorld.cs is your sandbox, this is where you will add your own code

    • The HelloWorldTest.cs contains Unit Tests, just google to find out more about Unit Tests in C#, but trust me when I say they will be checking to make sure you write valid code and meet the specs

    • Get really good at reading Unit Tests, they can be very useful at understanding what is expected of your code

  11. Without further ado, here is the solution to your first exercise

    • Get to it and start writing some code, but first make sure you can run the Unit Tests that will check your code
    • In Visual Studio, select the View menu option, select Other Windows and then click on Terminal Window (the keyboard shortcut is Ctrl+\, Ctrl+\). If you don't have this option then make sure you have the Whack Whack Terminal add-on installed, see the Tools section of this workbook if you don't have it installed
    • I positioned this panel on the bottom right of my Visual Studio environment, if this screenshot makes your head spin make sure you google how to position panels in Visual Studio 2017

      It would look like the following, where the Terminal Window panel is below the Solution Explorer panel, this layout works for me so it should work for you too, try it!

    • Run the Unit Tests, make sure the Terminal Window panel has focus (just click on it) and run cd C:\Users\USER_NAME\exercism\csharp\hello-world Remember that you added an existing project that is located at this path and the Solution is located at a different path. I don't want to confuse you, but look at the exercism directory on you computer and you will see two folders: csharp and exercism-csharp. In order to execute the code for the HelloWorld project you have to navigate to the location where this project was downloaded, the hello-world directory

    • Clear as mud I know, sorry for the confusion. Don't know of a better way to manage this Solution with the existing project exercism downloads but you must just accept it and move on, no time to waste ;)

    • Now, run dotnet test and watch the Terminal Window explode with lines of text. So much red, my eyes hurt (I'm used to it) :P

    • What's going on here? Errors have occurred due to the fact that the HelloWorld.cs does not fulfill the specs specified in the README.md. The HelloWorldTest.cs Unit Test file threw errors that you must decipher and fix

    • If you read the README.md (I hope this is not the first time), you will find out that in order to fulfill the specs, the Hello() function in the HelloWorld.cs file must return the string "Hello, World!". That's very easy to do, just replace the body of the Hello() function with return "Hello, World!" and save the file. Now go collect that pay check, if it was that easy I would be a millionaire by now :)

    • In the Terminal Window panel run dotnet test, if you see the following my job is done and you have successfully solved your first exercise with flying colors (red then green) :P

    • Clean up before I let you go, in the Terminal Window run the cls command to clear out all those previous lines of text, your terminal should show the path of C:\Users\USER_NAME\exercism\csharp\hello-world and then run exercism submit HelloWorld.cs and if nothing blows up then you have submitted your first completed exercise for all the world to see, I'm proud of you!

  12. Continue downloading and solving exercises, I would suggest you complete at least one per day. Go to exercism.io/languages/csharp/exercises, 1 down 111 more to go ;)

results matching ""

    No results matching ""