Python from scratch – Taking the shortcut
Preview
I started to learn Python from Scratch using Google Python class on my own around 3 months ago.
The first lesson was fast and I felt ease with the new language.
After that, I continued with my lessons doing the second lesson following the third lesson and the last one which was the Python RegEx part.
Achievements and Blocks
During this time I got many visitors and upvotes.
I received many comments and emails with advice and nice words and eventually, the leading technology blogging site dzone has selected me to be part of his unique talented writers.
Although I still have the last lesson to do which is called ‘Utilities‘ I found myself in a situation where I know I am progressing too slow and the reason for that are two major factors.
I am a father for two young children and now in the Winter/Springtime, they are mostly sick.
Also, I have a full-time job at work doing my QA Manager position.
It is very hard to learn when you have such huge gaps between each time you try to study adding to it the late time at night which is the only time available to me.
Brainstorming of python and taking the shortcut
So I did some brainstorming (Me and Myself) and decide that I need to jump forward and change the way I am studying Python from scratch and taking the shortcut.
Instead of going step by step which may take forever I will create a project.
This project will be hard enough to solve in a few hours.
It will need a plan, it will require me to study before I write any part of the code and it will make me deal with Python in a way that once I finished the project I will be way advanced than my original step by step plan.
And last it will be more fun than study step by step endlessly
Again, this is due to time limitations I am experiencing and I do not support such an act to anyone else (but me)
So I thought about it over and over and looked for a good project to make me an advanced coder.
And then the idea came- a game I like to play while reading the weekend newspaper.
Battleships game as a code
Battleships rules
Position of the battleships
- The Battleships board is 10 x 10 grid
- There are Ten ships:
- One ship of 4 consecutive cells- also called Battleship
- Two ships of 3 consecutive cells each- also called Cruiser
- Three ships of 2 consecutive cells each- also called Destroyer
- Four ships of 1 cell each- also called Submarine
- Each Ship may be horizontally or vertically
- No ship touches another, not even diagonally
- The ships are hidden- You need to find their exact location
Initial Data
- Numbers on the grid:
- Right- represents a number of cells in the same row belong to a ship(s).
- Bottom- represents a number of cells in the same column belongs to a ship(s).
- You may get a cell already marked as water and not part of a ship
- You may get a cell already marked as part of a ship.
- Following the rule 3, important information is the shape of the marked cell
- If it is rounded- we know for sure it is a Submarine
- Squared- We know it is part of Cruiser or Battleship
- If it is half rounder and half Squared- We know it is either the start or the end of Battleship, Cruiser or Destroyer.
Processing of the data
My code should get from the newspaper the initial data as seen in the above-attached example.
The code should analyze the data and eventually output the solution for that puzzle.
This is the solution for the above example-
Looking ahead
I am sure many of you, Python coders, already thinking about the code and even may have a strong lead to the answer.
I know it will take me more then others and I am planning to share with you the steps I am taking until the final solution.
Of course, I will appreciate tips and leads from you guys to help me going through this task.
Next post I will share with you how I am going to attack the problem.
How do I see the obstacles and will try to design the code in human words
Stay Tune
Hola,
I dont do python anymore.
In case you have the solution- tell me and i will publish it over here.
Holaaa saludes me podrias pasar el codigo del juego en python por favor
lvlau35@gmail.com