Giter VIP home page Giter VIP logo

cpp's Introduction

Exercism C++ Track

Exercism Exercises in C++

Contributing Guide

Please see the contributing guides

The most useful way to start contributing to this track is to review Pull Requests and/or some of the open track issues. There are not many active contributors, so anyone reviewing PRs or Issues, even just to +1 someone elses opinion, is appreciated.

Adding an exercise

Here is a list of things that need to be done to add an exercise to this track.

  1. Add the exercise under the exercises/ directory.
  2. Create your test suite based on the canonical tests in the problem specifications repo, and add a comment at the top of the test suite noting the version of the test suite it implements.
  3. Create an example solution and name the files example.cpp and example.h. example.cpp is optional but encouraged.
  4. Add the test to the list in the root CMakeLists.txt file.
  5. Add the test to the config.json file. The configlet can help generate a unique UUID. You can download configlet using the script in bin/fetch-configlet.
  6. Add at least one topic for the exercise in the config.json file. Check the available topics in TOPICS.txt.
  7. Use the configlet tool to generate the README for your exercise.
  8. Try to match the formatting used in the other tests as closely as possible.

Testing an exercise

The Exercism build system has two unusual constraints. First, example solutions must be named example.h and example.cpp; this prevents Exercism from sending these files to the student. Second, student solutions must be named <exercise>.h and <exercise>.cpp, for example anagram.h and anagram.cpp.

The current CMake build system navigates this with an unusual approach: it copies all example solutions from the exercises/ tree to an alternate directory (which is ignored by git), renames the solutions as if they were student exercises, and runs a complete build in this new directory.

Maintainers can largely ignore the alternate exercise directory if they recopy their example solution before running a build. Re-running CMake will recopy all exercise files.

For example, a maintainer can copy, configure, compile, and test all exercises by running the following from the root directory:

cmake . && make

For an individual exercise, in this example anagram, the maintainer should edit:

exercises/anagram/example.h
exercises/anagram/example.cpp
exercises/anagram/anagram_test.cpp

Then copy, configure, compile, and test with:

cmake . && make test_anagram

cpp's People

Contributors

ahans avatar alexlesang avatar apprentilab-suzanne avatar arcuru avatar bethanyg avatar bnandras avatar bobahop avatar chgraef avatar dependabot[bot] avatar ee7 avatar elyashiv avatar erikschierboom avatar exercism-bot avatar henryrlee avatar jackhughesweb avatar k4rtik avatar kevdi avatar kevinwmatthews avatar kytrinyx avatar legalizeadulthood avatar marko213 avatar nobbz avatar objarni avatar pdmoore avatar sbromberger avatar siebenschlaefer avatar silvanocerza avatar smuroff avatar tesarect avatar vaeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cpp's Issues

const robot_name

I realized robot-name tests repeatedly start with

const robot_name::robot robot;
// ..

I think this is a hint for a design flaw, and being an exercise, encourages a bad idea.

The line instantiates a const robot_name::robot object using the default constructor. The compiler refuses to leave the object in an unspecified state, because the object is qualified const, and thereby looks for a user-provided default constructor.

To illustrate, consider:

int const i;

This won't compile. i has unspecified state, and its value may not change -- so what good is it? In contrast,

int const i{};

is fine. i is zeroed-out, left in a known determinate state, and that can be const and useful.

Being able to skip the work of leaving data in a specified state is a good thing. If you provide a non-trivial default constructor, the kind that would allow for that line above to compile, then you forbid fast instantiations of the object. To motivate, consider:

robot_name robot;
std::cin >> robot;
// ...

We work hard to construct robot when we know full well it's hard work for nothing. You may argue the problem is with std::cin being of a poor design in a way, not being functional-friendly, and I agree. But unfortunately it's not going to change soon, for all I can see, and right now it encourages default-construction to be fast.

Or, another case:

std::vector<robot_name::robot> robots(100000);
std::generate(begin(robots), end(robots), mutate_optimus_prime);

Here, creating a default robot is not so cheap, compared with a robot with no user-provided default constructor. We make a hundred thousand of these, and a moment later overwrite them with new ones. Instantiating the vector should be quick, because we don't care about the values -- we're going to change them in a moment.

You might argue this is a bad example; that we should use std::generate_n() with a std::back_inserter_iterator<> and a zero-sized std::vector<>, so the vector grows as needed and immediately with the object we want, not with unnecessary intermediates. That's fair enough. But one may also argue that the trap of the hidden performance price you pay with std::generate() and a pre-sized vector ain't cool either.

Also,

struct starship {
private:
  robot_name::robot robot;
};

The strarship type could be a wonderful value type -- except it's flawed by robot not allowing it to instantiate quickly. It's like the design of robot is intrusive, like a virus a politician would say, silently invading other objects that would like to reuse it.

And besides, when you see the line

robot_name::robot const robot;

you intuitively ask questions. "So... this is like int i, data with junk inside, and I can't change it?" and then you spend time looking at the class, and oh, right, it has a user-provided default constructor. Duh.

If the constructor is =default-ed or not provided at all then that line won't compile, and no one starts suspecting and asking questions.

This reminds me of a similar issue I remember encountering in the Eigen library, where they (used to?) provide a non-trivial default constructor for matrices. There, I've reported the issue to them, and IIRC the trouble was that the library exists since C++03, and, well, changing this sort of thing breaks backwards compatibility. And that's a big no-no for a popular library. The library is slower because of a technical debt that's hard to flatten out now.

The point I'm trying to make is that a line like

T const t;

raises eyebrows, and a user-provided default constructor allows for it. That there is no consensus on a sensible default for the state of an object, but users will always be either happy with or relying on fast construction. That exercism is a tool that spreads example, and bad example is worse than no example.

Okay maybe I'm going too far and taking the whole thing too seriously. Still hey let's remove the user-provided default ctor k? k? mm? maybe?

Having issues getting started

Hi, i thought i had managed to get to a point where i could start writing the first exercise(bob) however when i build my project i am getting this linker error. Is this part of the exercise or did i mess up on the installation of boost or any other part? The linking error is below:

Error 2 error LNK2019: unresolved external symbol "void __cdecl boost::throw_exception(class std::exception const &)" (?throw_exception@boost@@YAXABVexception@std@@@z) referenced in function "public: __thiscall boost::detail::shared_count::shared_count >(struct boost::unit_test::ut_detail::callback0_impl_t *)" (??$?0U?$callback0_impl_t@Uunused@ut_detail@unit_test@boost@@P6AXXZ@ut_detail@unit_test@boost@@@shared_count@detail@boost@@QAE@PAU?$callback0_impl_t@Uunused@ut_detail@unit_test@boost@@P6AXXZ@ut_detail@unit_test@2@@z) C:\Users\Nick\exercism\exercises\cpp\bob\bob_test.obj bob

Verify that nothing links to help.exercism.io

The old help site was deprecated in December 2015. We now have content that is displayed on the main exercism.io website, under each individual language on http://exercism.io/languages.

The content itself is maintained along with the language track itself, under the docs/ directory.

We decided on this approach since the maintainers of each individual language track are in the best position to review documentation about the language itself or the language track on Exercism.

Please verify that nothing in docs/ refers to the help.exercism.io site. It should instead point to http://exercism.io/languages/:track_id (at the moment the various tabs are not linkable, unfortunately, we may need to reorganize the pages in order to fix that).

Also, some language tracks reference help.exercism.io in the SETUP.md file, which gets included into the README of every single exercise in the track.

We may also have referenced non-track-specific content that lived on help.exercism.io. This content has probably been migrated to the Contributing Guide of the x-common repository. If it has not been migrated, it would be a great help if you opened an issue in x-common so that we can remedy the situation. If possible, please link to the old article in the deprecated help repository.

If nothing in this repository references help.exercism.io, then this can safely be closed.

Incomplete description for problem phone_number

The description for the phone_number problem does not match the tests. The description talks about invalid phone numbers but does not mention how to deal with this case and there are no tests for it (raise exception?). There is a test related to area_code which is not mentioned in the description.

Pass explicit list of multiples in "Sum of Multiples" exercise rather than defaulting to 3 and 5

Hello, as part of exercism/problem-specifications#198 we'd like to make the sum of multiples exercise less confusing. Currently, the README specifies that if no multiples are given it should default to 3 and 5.

We'd like to remove this default, so that a list of multiples will always be specified by the caller. This makes the behavior explicit, avoiding surprising behavior and simplifying the problem.

Please make sure this track's tests for the sum-of-multiples problem do not expect such a default. Any tests that want to test behavior for multiples of [3, 5] should explicitly pass [3, 5] as the list of multiples.

After all tracks have completed this change, then exercism/problem-specifications#209 can be merged to remove the defaults from the README.

The reason we'd like this change to happen before changing the README is that it was very confusing for students to figure out the default behavior. It wasn't clear from simply looking at the tests that the default should be 3 and 5, as seen in exercism/exercism#2654, so some had to resort to looking at the example solutions (which aren't served by exercism fetch, so they have to find it on GitHub). It was added to the README to fix this confusion, but now we'd like to be explicit so we can remove the default line from the README.

You can find the common test data at https://github.com/exercism/x-common/blob/master/sum-of-multiples.json, in case that is helpful.

Compilation issues for projects using require_equal_containers.h

Hello,

I have the following error for all the cpp projects using require_equal_containers.h. I tried boost 1.55 and 1.61 and I use this gcc on Xubuntu 14.04:

sdargo@ncelr51130 /exercism/cpp/etl/build $ gcc --version
gcc-4.8.real (Ubuntu 4.8.4-2ubuntu1
14.04.3) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Thanks for your help!

[ 50%] Building CXX object CMakeFiles/etl.dir/etl_test.cpp.o
In file included from /usr/local/include/boost/test/tools/floating_point_comparison.hpp:21:0,
from /usr/local/include/boost/test/tools/old/impl.hpp:21,
from /usr/local/include/boost/test/test_tools.hpp:46,
from /usr/local/include/boost/test/unit_test.hpp:18,
from /home/sdargo/exercism/cpp/etl/etl_test.cpp:3:
/usr/local/include/boost/test/tools/detail/print_helper.hpp: In instantiation of ‘struct boost::test_tools::tt_detail::print_log_value >’:
/usr/local/include/boost/test/tools/detail/print_helper.hpp:178:40: required from ‘std::ostream& boost::test_tools::tt_detail::operator<<(std::ostream&, const boost::test_tools::tt_detail::print_helper_t&) [with T = std::pair; std::ostream = std::basic_ostream]’
/usr/local/include/boost/test/utils/wrap_stringstream.hpp:66:19: required from ‘boost::basic_wrap_stringstream& boost::operator<<(boost::basic_wrap_stringstream&, const T&) [with CharT = char; T = boost::test_tools::tt_detail::print_helper_t >]’
/usr/local/include/boost/test/tools/old/impl.hpp:212:19: required from ‘boost::test_tools::assertion_result boost::test_tools::tt_detail::equal_coll_impl::operator()(Left, Left, Right, Right) [with Left = std::_Rb_tree_const_iterator >; Right = std::_Rb_tree_const_iterator >]’
/home/sdargo/exercism/cpp/etl/etl_test.cpp:15:5: required from here
/usr/local/include/boost/test/tools/detail/print_helper.hpp:47:5: error: static assertion failed: Type has to implement operator<< to be printable
BOOST_STATIC_ASSERT_MSG( (boost::has_left_shiftstd::ostream,T::value),
^
make[2]: *** [CMakeFiles/etl.dir/etl_test.cpp.o] Error 1
make[1]: *** [CMakeFiles/etl.dir/all] Error 2
make: *** [all] Error 2

Setting up C++ dev environment

The error that was demo'd on the Installing C++ tab has happened to me, even though I followed the instructions to the T. Stack Overflow as been less than helpful as well.

Move exercises to subdirectory

The problems api (x-api) now supports having exercises collected in a subdirectory
named exercises.

That is to say that instead of having a mix of bin, docs, and individual exercises,
we can have bin, docs, and exercises in the root of the repository, and all
the exercises collected in a subdirectory.

In other words, instead of this:

x{TRACK_ID}/
├── LICENSE
├── README.md
├── bin
│   └── fetch-configlet
├── bowling
│   ├── bowling_test.ext
│   └── example.ext
├── clock
│   ├── clock_test.ext
│   └── example.ext
├── config.json
└── docs
│   ├── ABOUT.md
│   └── img
... etc

we can have something like this:

x{TRACK_ID}/
├── LICENSE
├── README.md
├── bin
│   └── fetch-configlet
├── config.json
├── docs
│   ├── ABOUT.md
│   └── img
├── exercises
│   ├── bowling
│   │   ├── bowling_test.ext
│   │   └── example.ext
│   └── clock
│       ├── clock_test.ext
│       └── example.ext
... etc

This has already been deployed to production, so it's safe to make this change whenever you have time.

Ref: exercism/exercism#3336

When using prebuilt boost for Windows, CMake can't find the libraries

CMake's FindBoost module expects the libraries in certain locations, but the prebuilt binary package for Windows doesn't contain the libraries in the expected location.

For example, for 32-bit compilation with Visual Studio Express 2013, you get the directory boost_1_55_0/lib32-msvc-12.0, not the directory lib

triangle: incorrect test in some tracks

Please check if there's a test that states that a triangle with sides 2, 4, 2 is invalid. The triangle inequality states that for any triangle, the sum of the lengths of any two sides must be greater than or equal to the length of the remaining side. If this doesn't affect this track, go ahead and just close the issue.

Name nucleobases, not nucleosides

The primary nucleobases are cytosine (DNA and RNA), guanine (DNA and RNA), adenine (DNA and RNA), thymine (DNA) and uracil (RNA), abbreviated as C, G, A, T, and U, respectively. Because A, G, C, and T appear in the DNA, these molecules are called DNA-bases; A, G, C, and U are called RNA-bases. - Wikipedia

In other words, we should rename the values in the RNA transcription problem to reflect the following:

  • cytidine -> cytosine
  • guanosine -> guanine
  • adenosine -> adenine
  • thymidine -> thymine
  • uridine -> uracil

nucleotide-count, invalid input

The tests do expect that I throw an exception, when I ask for the count of X, but calling the constructor with invalid DNA seems to be ok, there are no tests for const dna::counter dna { "X" }.

Is there any special reason why this one was left out?

In the other tracks I have solved this, similar cases were expected to raise/throw/error out.

How to set up a local dev environment

See issue exercism/exercism#2092 for an overview of operation welcome contributors.


Provide instructions on how to contribute patches to the exercism test suites
and examples: dependencies, running the tests, what gets tested on Travis-CI,
etc.

The contributing document
in the x-api repository describes how all the language tracks are put
together, as well as details about the common metadata, and high-level
information about contributing to existing problems, or adding new problems.

The README here should be language-specific, and can point to the contributing
guide for more context.

From the OpenHatch guide:

Here are common elements of setting up a development environment you’ll want your guide to address:

Preparing their computer
Make sure they’re familiar with their operating system’s tools, such as the terminal/command prompt. You can do this by linking to a tutorial and asking contributors to make sure they understand it. There are usually great tutorials already out there - OpenHatch’s command line tutorial can be found here.
If contributors need to set up a virtual environment, access a virtual machine, or download a specific development kit, give them instructions on how to do so.
List any dependencies needed to run your project, and how to install them. If there are good installation guides for those dependencies, link to them.

Downloading the source
Give detailed instructions on how to download the source of the project, including common missteps or obstacles.

How to view/test changes
Give instructions on how to view and test the changes they’ve made. This may vary depending on what they’ve changed, but do your best to cover common changes. This can be as simple as viewing an html document in a browser, but may be more complicated.

Installation will often differ depending on the operating system of the contributor. You will probably need to create separate instructions in various parts of your guide for Windows, Mac and Linux users. If you only want to support development on a single operating system, make sure that is clear to users, ideally in the top-level documentation.

Critera for test pass on cpp and python differ for word-count

Another one I spotted. :)

The cpp tests require you to ignore punctuation and case:

BOOST_AUTO_TEST_CASE(normalizes_case)
{
    const map<string, int> expected{{"go", 3}};

    const auto actual = word_count::words("go Go GO");

    REQUIRE_EQUAL_CONTAINERS(expected, actual);
}
BOOST_AUTO_TEST_CASE(ignores_punctuation)
{
    const map<string, int> expected{{"car", 1}, {"carpet", 1}, 
        {"as", 1}, {"java", 1}, {"javascript", 1}};

    const auto actual = word_count::words("car : carpet as java : javascript!!&@$%^&");

    REQUIRE_EQUAL_CONTAINERS(expected, actual);
}

The python tests require you to preserve both of these:

def test_preserves_punctuation(self):
    self.assertEqual(
        {'car': 1, 'carpet': 1, 'as': 1, 'java': 1, ':': 2, 'javascript!!&@$%^&': 1},
        word_count('car : carpet as java : javascript!!&@$%^&')
    )

def test_mixed_case(self):
    self.assertEqual(
        {'go': 1, 'Go': 1, 'GO': 1},
        word_count('go Go GO')
    )

It would be good to have consistency.

Links:
https://github.com/exercism/xcpp/blob/master/word-count/word_count_test.cpp
https://github.com/exercism/xpython/blob/master/word-count/word_count_test.py

rna-transcription issue with single versus double quotes.

Hi, me again. I have found an issue with rna-transcription. In the call to transcription::to_rna('A') (for example, the A is in single quotes. As shown by this stackoverflow question I posted, the A should be in double quotes, as well as the U it is being compared with. I am not sure if this is a universal error, as I have only tested it with g++ 4.7 and g++4.8. But I am submitting this issue just the same. Tell me what you think.

Ordering of exercises

I notice that exercise leap is relatively later in the track, while being cognitively much simpler than exercises like word-count. It would be great to have the exercises ordered by increasing difficulty.

Copy track icon into language track repository

Right now all of the icons used for the language tracks (which can be seen at http://exercism.io/languages) are stored in the exercism/exercism.io repository in public/img/tracks/. It would make a lot more sense to keep these images along with all of the other language-specific stuff in each individual language track repository.

There's a pull request that is adding support for serving up the track icon from the x-api, which deals with language-specific stuff.

In order to support this change, each track will need to

In other words, at the end of it you should have the following file:

./img/icon.png

See exercism/exercism#2925 for more details.

Problem testing word-count on C++

I started with "Word_count".

Everything setup ok and I run make to get an expected error:

$ make
Scanning dependencies of target word-count
[ 50%] Building CXX object CMakeFiles/word-count.dir/word_count_test.cpp.o
/home/camponez/exercism/cpp/word-count/word_count_test.cpp: In member function ‘void counts_one_word::test_method()’:
/home/camponez/exercism/cpp/word-count/word_count_test.cpp:28:25: error: ‘word_count’ has not been declared
const auto actual = word_count::words("word");
^
CMakeFiles/word-count.dir/build.make:54: recipe for target 'CMakeFiles/word-count.dir/word_count_test.cpp.o' failed
make[2]: *** [CMakeFiles/word-count.dir/word_count_test.cpp.o] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/word-count.dir/all' failed
make[1]: *** [CMakeFiles/word-count.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2

After I implement an empty class just to get to the first fail test, I got an unexpected error:

$ make
Scanning dependencies of target word-count
[ 50%] Building CXX object CMakeFiles/word-count.dir/word_count_test.cpp.o
In file included from /usr/include/boost/test/unit_test.hpp:19:0,
from /home/camponez/exercism/cpp/word-count/word_count_test.cpp:3:
/usr/include/boost/test/test_tools.hpp: In instantiation of ‘boost::test_tools::predicate_result boost::test_tools::tt_detail::equal_coll_impl(Left, Left, Right, Right) [with Left = std::_Rb_tree_const_iterator<std::pair<const std::basic_string, int> >; Right = __gnu_cxx::__normal_iterator<const char*, std::basic_string >]’:
/home/camponez/exercism/cpp/word-count/word_count_test.cpp:30:5: required from here
/usr/include/boost/test/test_tools.hpp:639:25: error: no match for ‘operator!=’ (operand types are ‘const std::pair<const std::basic_string, int>’ and ‘const char’)
if( *left_begin != *right_begin ) {
^
/usr/include/boost/test/test_tools.hpp:639:25: note: candidates are:
In file included from /usr/include/boost/shared_ptr.hpp:17:0,
from /usr/include/boost/test/predicate_result.hpp:24,
from /usr/include/boost/test/test_tools.hpp:19,
from /usr/include/boost/test/unit_test.hpp:19,
from /home/camponez/exercism/cpp/word-count/word_count_test.cpp:3:
/usr/include/boost/smart_ptr/shared_ptr.hpp:738:40: note: template<class T, class U> bool boost::operator!=(const boost::shared_ptr&, const boost::shared_ptr&)
template<class T, class U> inline bool operator!=(shared_ptr const & a, shared_ptr const & b) BOOST_NOEXCEPT
^

/usr/include/c++/4.9/bits/stl_iterator.h:822:5: note: template argument deduction/substitution failed:
In file included from /usr/include/boost/test/unit_test.hpp:19:0,
from /home/camponez/exercism/cpp/word-count/word_count_test.cpp:3:
/usr/include/boost/test/test_tools.hpp:639:25: note: ‘const std::pair<const std::basic_string, int>’ is not derived from ‘const __gnu_cxx::__normal_iterator<_IteratorL, _Container>’
if( left_begin != *right_begin ) {
^
CMakeFiles/word-count.dir/build.make:54: recipe for target 'CMakeFiles/word-count.dir/word_count_test.cpp.o' failed
make[2]: *
* [CMakeFiles/word-count.dir/word_count_test.cpp.o] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/word-count.dir/all' failed
make[1]: *** [CMakeFiles/word-count.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2

What am I doing wrong?

exercise grains overflows unsigned long long

From @JAC42 in exercism/exercism#2176

In C++, the test for total number of grains merely tests to see whether you get the maximum value for unsigned long long, not for the correct number of grains. I believe 2^64 is max number allowed in unsigned long long, and the total grains on the board is greater than that given 64 squares.

clock: canonical test data has been improved

The JSON file containing canonical inputs/outputs for the Clock exercise has gotten new data.

There are two situations that the original data didn't account for:

  • Sometimes people perform computation/mutation in the display method instead of in add. This means that you might have two copies of clock that are identical, and if you add 1440 minutes to one and 2880 minutes to the other, they display the same value but are not equal.
  • Sometimes people only account for one adjustment in either direction, meaning that if you add 1,000,000 minutes, then the clock would not end up with a valid display time.

If this track has a generator for the Clock exercise, go ahead and regenerate it now. If it doesn't, then please verify the implementation of the test suite against the new data. If any cases are missing, they should be added.

See exercism/problem-specifications#166

Compilation error for word-count problem

I've started on cpp track recently and I have problems compiling the second task (word-count problem). http://pastebin.com/RyHTtAje - this is compile output I'm getting. As I understand - although there is code in a test suit to teach boost to print std::pair's :

namespace boost
{
// teach Boost.Test how to print std::pair
template <typename K, typename V>
inline wrap_stringstream&
operator<<(wrap_stringstream& wrapped, std::pair<const K, V> const& item)
{
    return wrapped << '<' << item.first << ',' << item.second << '>';
}
}

boost is not really in the mood to learn..

gigasecond: use times (not dates) for inputs and outputs

A duration of a gigasecond should be measured in seconds, not
days.

The gigasecond problem has been implemented in a number of languages,
and this issue has been generated for each of these language tracks.
This may already be fixed in this track, if so, please make a note of it
and close the issue.

There has been some discussion about whether or not gigaseconds should
take daylight savings time into account, and the conclusion was "no", since
not all locations observe daylight savings time.

readme for nucleotide-count in cpp is misleading

Hi Guys,

Firstly, thank you very much for this resource - I'm enjoying the problems very much.

This is just a small issue, but in the readme for nucleotide-count in cpp, the first meaningful line says:

Write a class `DNA` that takes a DNA string ...

The problem actually requires you to create a namespace called dna, and a class called counter to get the tests working (unless I am missing a way to do it with a class called dna). It would be great if you could clarify the readme.

Thanks again. :)

update docs -- multiple files

Someone mentioned that the C++ track says that you can't submit multiple files.

For the longest time this was true, but we recently managed to finish adding support for this.

exercism submit file1 file2 file3

When someone has a moment, it would be nice to verify that this actually works and does what you would expect, and then update the docs.

Delete configlet binaries from history?

I made a really stupid choice a while back to commit the cross-compiled
binaries for configlet (the tool that sanity-checks the config.json
against the implemented problems) into the repository itself.

Those binaries are HUGE, and every time they change the entire 4 or 5 megs get
recommitted. This means that cloning the repository takes a ridiculously long
time.

I've added a script that can be run on travis to grab the latest release from
the configlet repository (bin/fetch-configlet), and travis is set up to run
this now instead of using the committed binary.

I would really like to thoroughly delete the binaries from the entire git
history, but this will break all the existing clones and forks.

The commands I would run are:

# ensure this happens on an up-to-date master
git checkout master && git fetch origin && git reset --hard origin/master

# delete from history
git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch bin/configlet-*' --prune-empty

# clean up
rm -rf .git/refs/original/
git reflog expire --all
git gc --aggressive --prune

# push up the new master, force override existing master branch
git push -fu origin master

If we do this everyone who has a fork will need to make sure that their master
is reset to the new upstream master:

git checkout master
git fetch upstream master
git reset --hard upstream/master
git push -fu origin master

We can at-mention (@) all the contributors and everyone who has a fork here in this
issue if we decide to do it.

The important question though, is: Is it worth doing?

Do you have any other suggestions of how to make sure this doesn't confuse people and break their
repository if we do proceed with this change?

Inconsistency in `triangle`s test

There is some inconsistency in the tests for triangle exercise.

The tests do expect to throw an DomainError when all sides of the triangle are 0, but to return triangle::illegal when we have negative length sides or don't fullfil the triangle inequality.

To make this consistent, we should either throw something in all three cases or return triangle::illegal in all cases.

To line up with other tracks that support some kind of throwing, I think we should throw in every case and get rid of triangle::illegal.

Meetup - 5th Monday

There is an interesting edge case in the meetup problem:
some months have five Mondays.

March of 2015 has five Mondays (the fifth being March 30th), whereas
February of 2015 does not, and so should produce an error.


Thanks, @JKesMc9tqIQe9M for pointing out the edge case.
See exercism.io#2142.

Make Hamming conform to official definition

From issue exercism/exercism#1867

Wikipedia says the Hamming distance is not defined for strings of different length.

I am not saying the problems cannot be different, but for such a well-defined concept it would make sense to stick to one definition, especially when the READMEs provide so little information about what is expected from the implementation.

Let's clean this up so that we're using the official definition.

rna-transcription: don't transcribe both ways

I can't remember the history of this, but we ended up with a weird non-biological thing in the RNA transcription exercise, where some test suites also have tests for transcribing from RNA back to DNA. This makes no sense.

If this track does have tests for the reverse transcription, we should remove them, and also simplify the reference solution to match.

If this track doesn't have any tests for RNA->DNA transcription, then this issue can be closed.

See exercism/problem-specifications#148

Update documentation to discuss CLion

CLion works with CMake based projects, so the C++ track has no problems in that regard. I used it at a Utah C++ Programmers meetup and it seemed to work fine. Now that CLion has been released, the documentation should mention that as an option for users of the C++ track.

Anagram Issue with tests

When I try to compile my program (which has no other errors in it) I get the error
anagram_test.cpp:9:45: error: cannot call constructor 'anagram::anagram' directly [-fpermissive]

I think you could just say
auto subject = anagram("diaper");
for the offending line, and all others like it.

scrabble-score: replace 'multibillionaire' with 'oxyphenbutazone'

The word multibillionaire is too long for the scrabble board. Oxyphenbutazone, on the other hand, is legal.

Please verify that there is no test for multibillionaire in the scrabble-score in this track. If the word is included in the test data, then it should be replaced with oxyphenbutazone. Remember to check the case (if the original is uppercase, then the replacement also should be).

If multibillionaire isn't used, then this issue can safely be closed.

See exercism/problem-specifications#86

Link to getting started instructions

The readme for the first exercise (or possibly all exercises, just to be safe) should link to the getting started in C++ page on the help site, just in case people didn't read that before starting the exercises.

food_chain::sing() test

The last test of the “food_chain” problem is defined as follows:

BOOST_AUTO_TEST_CASE(the_whole_song)
{
    BOOST_REQUIRE_EQUAL(food_chain::verses(1, 8), food_chain::sing());
}

This has some flaws:

  • It reveals the easiest, most idiomatic, best solution on how to implement sing.
  • you can't fail it, because you just copy the expectation.

So this test should either be removed or expect should be hardcoded/loaded from auch file.

Create exercises specific to generic programming in C++

Generic programming in C++ presents some interesting design choices. For instance we could create an exercise that did not fix the specific data type for computing prime factors of a number. We would only require that the data type used model the concept of an integer. It could be signed, unsigned, arbitrary precision, bignum, fixed-point, etc.

Prime factors may or may not be a good example to demonstrate generic programming techniques, but it might be a good stepping stone to start down a series of exercises that involve more and more generic programming techniques.

I think these generic programming exercises should come later in the sequence because it's a fairly advanced topic that many day-to-day C++ programmers don't get into. They consume generic code all the time, but don't often write generic code.

Here are some topics I think we should consider for generic programming exercises:

  • Type functions along the lines of std::is_integral<T>
  • Using type traits classes, such as associating enum values with a specific type derived from a common interface type
  • Generic containers, perhaps a quadtree
  • Generic algorithms

I think some of the designs presented in Modern C++ Design could serve as starting points for exercises as well.

crypto-square wrong tests

Hi,

I think that the last 2 tests for the crypto-square problem are wrong. You can verify that by
stacking the segment in output of the normalized cipher text which should yield the plaintext in
normalized form:

E.g.

vrela 
epems     ==>     veeorptieeprlmapasoo (far away from truth) 
etpao 
oirpo

Correct

vrel 
aepe 
mset       ==>  vampiresarepeopletoo
paoo 
irpo

Also the following result

msemoa anindn inndla etltsh ui
does not satisfy the property stated in the README

Imperfect squares will have n empty spaces. Those spaces should be distributed evenly across the last n rows.

binary: improve tests for invalid numbers

We should have separate tests for:

  • alphabetic characters at the beginning of a valid binary number
  • alphabetic characters at the end of a valid binary number
  • alphabetic characters in the middle of an otherwise valid binary number
  • invalid digits (e.g. 2)

If the test suite for binary has test cases that cover these edge cases, this issue can safely be closed.

See exercism/problem-specifications#95

Document formatting conventions for this repo

Formatting styles vary widely in the C++ community. Document the formatting style used by this repo.

  • Namespaces don't indent
  • Whitespace as per editor config #92
  • Identifier conventions
  • Separate test cases with single blank line
  • Separate test case phases (setup, exercise, verify, teardown) with a single blank line
  • Test only one behavior per test case

Others?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.