07 Sep 2017
The project is now bootstrapped: the CMake scripts to build the library and executables and link them to the dependencies and the Travis CI is setup. I started by coding the main class (named it just
logic), created a
lozti namespace to separate my things from the rest of the world and it should be ok for now. Aside from
logic there is the
piece and the
matrix classes, but they are not ready yet to be commented.
I do something that many condemn: I always try to use STL, Boost and templates first, not worrying very much if the code will be unreadable for the newbies. I known people think it’s not so nice but I don’t have problems when I re-reading my code even a year later. I think the code should be readable but I don’t think everyone should be able to read it, unless the readability doesn’t condemn the elegance of your program. Most of the programmers I know doesn’t remember what
std::find_if exactly does but I prefer to use it in my code instead of a 4-line loop just because STL is not evil and everyone should know it by heart (and because it’s easier to write sometimes). Oh, and of course: I do this unless the owner of the code I write (a.k.a. my employer) asks me to do otherwise.
Anyway, I like inheritance avoiding and the way STL and Boost uses templates and I intent to do that aswell. You might see very few virtual methods in my code and maybe many templates. Sometimes the
vtables come in the way of the performance and, although I know it is very rare, I prefer to leave it behind. I’m saying this because I think I might need
std::vector matrices and I don’t intent to use inheritance to make other classes support both. But I might be wrong. Or not.
07 Sep 2017
After chasing after a nice score on Project Euler I decided it isn’t motivating me enough. I managed to solved less than 50 problems using C++ and it still didn’t made me want to “wake up early in sunday morning” just to code.
I decided to change my challenge to code a C++ game. I tried once to create a simple side scrolling game with some friends but because of some non-technical related problems we failed in the first few weeks, and this time I’ll do it by myself. I don’t have any graphical design skills but for the purpose of practicing algorithms it doesn’t matter. At least for now.
I researched a little and it seems that one of the simplest games to create is a Tetris-like one. It doesn’t require collision detection, advanced graphics or complex mathematics so it should be ok to be coded using only C++, Boost and a simple graphics library like SDL, for example. I don’t want to create an awesome game, I just need to have an awesome experience coding something nice, so don’t be surprised if the game is almost unusable. ;)
Anyway, the name of the game is Lozti and the name is based in the 5 pieces used in Tetris: L, O, Z, T and I. The code is published in GitHub and I expect to post the development progress from time to time.
19 Jul 2017
After hitting the wall in a mock interview I decided to reboot this project. I nailed the offline test I have been given but I failed miserably in the mock interview due to lack of preparation. I feel I need to exercise a lot my coding interview skills and this is what I’m going to do.
Thinking about the Leonhard project a little bit I feel I need to do something like the Boost.Test library. It is really useful for testing and I think I might use it in the future in this project. I’m a little reluctant to use a third-party software but I don’t think adopting the Boost library is going to enable anyone to cheat much in the challenges.
24 Oct 2016
After doing some thinking I decided to name the Project Euler solutions project after Euler himself: Leonhard. For now it’s just a couple of CMake scripts with some simple C++ codes in it to serve as a boilerplate to solve and test the Project Euler problems.
While designing it I thought it should at least be able to do the following:
- include and execute any developed solution (in C++, of course);
- test the result of a solution against a pre-defined value;
- measure the time spent while executing any solution;
- do all the steps above in batch mode (in one command only);
- implement classes to be used as libraries in one or more solutions.
I believe if all the items above are achieved I’ll have a nice place to solve the problems. I’ll try to code it in the next days and, at least for now, it’ll have just a command line interface. Let’s see how this thing flows.
10 May 2016
After doing some interviews I just realized I have much to learn in the algorithms field. I failed a couple of tests miserably and I decided it’s time to improve my algorithm skills.
I opened an account in the Project Euler website a few years ago but I completed only the first five tests and gave up. For those who doesn’t know what it is, it is basically a lot of mathematical/computer challenges that require more than just mathematical insights to solve. Anyway, a friend of mine told me at the time he was going to do all the tests he could but I thought it wasn’t cool enough to try it too. Silly me. Now I’m gonna do all I can using the simplest tools possible: a simple programing language, a simple editor, a simple compiler and my simple and stupid brain and hands.
As I’m doing this just to improve my algorithm skills, I think it isn’t fair to use a programing language which does most of the problems just by using its basic features. For the sake of an example, the first language I can think of is Python. If you need to calculate the factor of one hundred it has big integer builtin. If you need to calculate week days it has calendars builtin. If you need anything else it probably have more than what you need. Builtin too.
So, I decided I’m going to do this using C++ and GCC. And, because I don’t use it too much yet, I’m going to use C++11 for now. I think C++ is a great choice because sometimes object orientation helps a lot when solving some kind of problems and the language doesn’t keep you away from the computing problems. I know I’m gonna have a hard time handling thinks like big numbers but this is what I want: to code complex algorithms and improve my skills.
I’m going to try to post at least once a month about my progress. I think this is going to be a fun adventure and will release some of the source code under an open source license. I cannot promess I’m going to release everything but it is just because I can’t release the answers.
Anyway, stay tuned for updates.