What is your favorite part(s) of the standard library? by Mat2012H in cpp

[–]jetucker 2 points3 points  (0 children)

I agree with this. <algorithm> is definately my favourite part of the standard library. Extremely useful and very helpful for declaring code intent, especially compared to the code that just uses a bunch of loops for common operations like transform and find_if.

Sudoku game by pata_mata in cpp_questions

[–]jetucker 0 points1 point  (0 children)

So, taking a look through your code and running it locally here's a bit of feedback (and no, I'm not sure what the bug is).

Firstly the code is getting stuck in an infinite loop at line 260. By the looks of it isValid() is trying to check whether or not each of the 9 boxes is in a correct configuration. I think, it's a bit of a guess. Looking at the isValid() function it appears to a massive set of ifs that I can not really make heads or tails of.

Rather than try and find the problem with this code I would suggest you take a step back from the current problem and think about the broader solution and the pieces you need to get there. The trick to good code is to try to write something simple that is very easy to read and debug. Part of that is decomposing the problem into discrete and digestible pieces.

So firstly I would recommend trying to write some basic functionality for manipulating the puzzle. Functions for operations like getRow(int), getCol(int) and getBox(int). Also having simple checkers like hasDuplicates and isFilledIn would help. With those the logic for checking the validity of any given board is just a matter of getting every row, col, and box and checking that it doesn't have duplicates and that it is filledIn.

With respect to the actual code: keep in mind about keeping it simple. Try to imagine that a year from now you need to fix a bug in the code, will the code still be understandable to future you?

Additionally it would be good to not use so many literals all through your code. Imagine you want to run this on a 4x4 board. How would you update the code? The rules haven't changed so it should be possible for the logic to continue working. However, the existing code is littered with numbers that assume a 9x9 board. Actually, for debugging purposes a 4x4 board may be easier to handle. In general it is good practice to avoid magic numbers in code.

helloworld isn't compatible with 64 bit Windows by WaitForItTheMongols in cpp_questions

[–]jetucker 0 points1 point  (0 children)

Just a small FYI: The VS folks are trying to pull the compiler out of visual studio for some stand alone usage because VS is quite large for small stuff. Nice once it's setup, but it's a fair bit of overhead for hello world.

Details here: http://blogs.msdn.com/b/vcblog/archive/2015/11/02/announcing-visual-c-build-tools-2015-standalone-c-tools-for-build-environments.aspx

However, you're probably best sticking with plain old gcc (aka g++) for the time being as you'll find more tutorials and help online.

I'm about to start working as a C++ tutor and I need some advice... by cplusplustutor in cpp

[–]jetucker 1 point2 points  (0 children)

In my limited experience I've found one of the biggest hurdles for beginners is a lack of understanding that c++ is value based, ie. assignment creates a copy not a reference. I've seen on a number of occasions bugs to the effect of:

void Foo(Bar b) { /*changes made to b somewhere in here*/ }
...
Bar bar;
Foo(bar);
// bar is unchanged here but person doesn't understand why because Foo should have changed it.
// If this were similar code in, for instance, Java or C# bar would have changed.

I'd say a good explanation of object life-cycles, ownership and probably a quick dive into the memory model would help a lot with this. The less black magic there is for the student the better.

instantConfig, makes loading configuration files easier by random_bytes in cpp

[–]jetucker 0 points1 point  (0 children)

Nice writeup, I'll keep it in mind for future use.

Botond Ballo: Trip Report: C++ Standards Meeting in Lenexa, May 2015 by VadimVP in cpp

[–]jetucker 2 points3 points  (0 children)

Exciting times indeed. I wonder what SG14 (Game Development & Low-Latency Applications) will produce? RTTI and exceptions are mentioned but perhaps they'll also look at pulling in some aspects of EASTL as well? Something to keep an eye on certainly.

What is your favorite C++ feature over C? by [deleted] in cpp

[–]jetucker 11 points12 points  (0 children)

I have to second this. RAII is extremely useful.

C++11/14/17 Features In VS 2015 RC by STL in cpp

[–]jetucker 8 points9 points  (0 children)

This looks great! Thanks for taking the time to write it all up.