Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New exercise: the Nonattacking Queens Problem. #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

fpottier
Copy link
Collaborator

This exercise uses the nondeterminism monad API, whose implementation has been the subject of several other exercises.

I have some problems with grading the last two questions (6-7). Grading works when learn-ocaml is executed in batch mode, with a timeout of 5 seconds. (I depend on the timeout mechanism to rule out a naïve solution to Question 7.) However, in the browser, I have several problems/questions:

  • How do I control the timeout value? I need to set it appropriately, so that a correct solution to Question 7 is accepted and a naïve solution is rejected.

  • How do I control the maximum stack size? The fact that tail recursion is not properly implemented causes even a correct solution to fail for very small values of n. This is problematic, as I would like to try larger values of n -- this is precisely how I can verify that the student's code is efficient.

exercises/queens/descr.md Outdated Show resolved Hide resolved
exercises/queens/descr.md Outdated Show resolved Hide resolved
@yurug
Copy link
Collaborator

yurug commented May 20, 2020

Thank you, @fpottier!

@yurug
Copy link
Collaborator

yurug commented May 20, 2020

I will push a patch to control timeout on a per-test basis.

About tail recursion, I will check that we use the more recent version of js_of_ocaml. The optimization of tail call in js_of_ocaml is (slowly but surely!) improving if I remember correctly.

@yurug
Copy link
Collaborator

yurug commented May 26, 2020

A timeout value is hardly portable but I guess that you have no other way to control the amount of computational resources consumed by the program. To improve portability, you could simply multiply the timeout value with a well-chosen ratio when grading in the JavaScript environment.

I found no obvious way to know if you are grading in learn-ocaml-client or in the web app. A (somewhat hackish) way would be to inspect the environment like this:

let batch_mode () =
  Sys.getenv_opt "SHELL" <> None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants