How do I call the reference solution in Cody?

1 回表示 (過去 30 日間)
George Bittar
George Bittar 2021 年 6 月 8 日
回答済み: Christian Schröder 2022 年 12 月 30 日
I created a problem in Cody that approximates e. To test the user's solution, I compare their solution to e. What I want to do instead is compare the user's solution to my reference solution. The question is how do I call the reference solution in the test suite?
This is currently my test suite.
sol=exp(1);
y_correct = playgame();
assessVariableEqual('y_correct',sol);
  1 件のコメント
David Hill
David Hill 2021 年 6 月 8 日
I don't think you can. Just place the reference solution into sol.

サインインしてコメントする。

回答 (1 件)

Christian Schröder
Christian Schröder 2022 年 12 月 30 日
Like David said, this is not possible. The reference solution is only used to verify that your problem is in fact solvable, i.e. that the test suite can be passed; it's not otherwise available within the test suite.
If you want for some code to be run in the test suite, then you need to put it into the test suite. And yes, this'll mean that it'll be visible to prospective solvers; if this is not desirable, then you might be able to write a file containing P-code as part of the test suite, but I would advise against this unless you have a good reason for it.

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by