In the window that you are now reading, there are some practical tips and theories for each learning unit. There is also a list of tasks in this section. In principle, you can solve tasks in any order, but they are typically arranged in increasing difficulty. Some tasks are also easier to solve by using solutions from previous tasks. You do not need to rewrite these solutions, the system remembers them, and you can use them immediately if you want.
You begin to solve the task by clicking on it. This opens a web page in which you program a solution. Each page is linked to a specific task and contains four sections. You can change the partition layout in the settings.
In the upper left - instructions that briefly describe the task. Pay particular attention to the name of the predicate that you have to program - you must name it exactly as it is stated so that the system will recognize your solution. Of course, you can program several auxiliary predicates; there are no restrictions here.
Additionally, be aware of the number of arguments the target predicate demands. For example, the predicate mother(?X, ?Y)
requires two arguments, X
and Y
. The question mark before the name of the argument means that this argument can represent both the input and output. Arguments acting only as an input are marked with +
, and arguments that only work as an output, with -
. At the beginning, do not bother with this, but simply program it, the input / output will mostly be regulated by itself. Prolog is smart. 😉
In the bottom of the left section, the application will give you feedback. These can be in the form of a general plan (how to get started solving some task), or specific advice on what may be wrong with your current solution. Tips are different, sometimes they will also be in the form of a counterexample – a concrete set of inputs for which your program works incorrectly (a the particular input for which your program generates wrong output). There can also be Prolog warning and error messages in the program.
If such tip seems incorrect, first look at your program well. If they still seem wrong, let us know. If it's really wrong, I will buy you a coffee, otherwise you will buy it!
(Disclaimer: it is sometimes not possible to determine with certainty whether a mistake is present, in such cases the system uses words such as maybe, possibly and probably – such solutions are not considered as incorrect.)
A console on the right, typically black in color, where there is a Prolog prompt ?-
, is intended for your interaction with Prolog. In the background there is a minimally truncated SWI Prolog, which you can ask questions. The system has already loaded all the necessary data for each task (e.g. knowledge base). It also always automatically loads the current version of your program. In the Prolog section, you can ask any questions, not just those related to your program.
Finally, there is the central section: the text editor, in which you write your own solution. At first glance, maybe some features are missing, for example, “Autocomplete”, but you will quickly find that Prolog programs are short and do not require a lot of typing.
If your program exceeded 8-10 lines, you probably made it too complicated! The longest program in all tasks does not require more than 12 lines (and such tasks are rare). The buttons mentioned above are described below.
The central program part also contains the “Plan” and “Test” buttons. Most often, you will use the latter, which will automatically check your solution. The “Plan” button gives you general advice on how to tackle the given tasks; sometimes you can press it repeatedly, for more “revealing” tips. Of course, try to solve every task first without using any hints.
If the program is incorrect, CodeQ will sometimes offer a “Hint” button next to the test report. This button gives you a clue what may be wrong with your program. Some hints are prepared manually by the authors of the application, sometimes artificial intelligence is at work, sometimes you will get a counter-example on which the program does not work, but sometimes there is no hint at all. In this case, the program is probably terrible! Just kidding... maybe. 😉
CodeQ automatically stores your solutions on the server, but of course you have to be connected to the Internet. All changes are recorded in real time, so you do not need to worry about saving the code or loading it when your session expires. The duration of the session is, in principle, 60 minutes, and is terminated if you log on to another computer or another tab with the same username.
Warning: given that the system stores everything you write in real time (so, it is a keylogger !), we recommend that confidential messages are not written in the system. Otherwise we will read them, we promise! 😉
You can see all your solutions for a specific set by clicking on the link by the title.