L'algorithme suivant représente un calcul :
{"options": {"blockly": {"readOnly": true}, "blocks": {"base_numberinput": {"output": "Number", "colour": 260, "tooltip": "Fourni un nombre", "inputs": [{"type": "dummy_input", "fields": [{"name": "value", "default": 0.0, "type": "number_input"}], "align": "left"}]}, "simple_input_output_print": {"previous_statement": true, "next_statement": true, "colour": 160, "tooltip": "Afficher une valeur", "inputs": [{"type": "value_input", "fields": [{"text": "Afficher", "type": "text"}], "align": "left", "name": "value", "check": null}]}, "base_varvalue": {"output": true, "colour": 330, "tooltip": "Fourni la valeur d'une variable", "inputs": [{"type": "dummy_input", "fields": [{"name": "var_name", "default": "x", "type": "variable"}], "align": "left"}]}, "base_simplecalculus": {"output": "Number", "colour": 260, "tooltip": "Effectue un calcul simple", "inputs": [{"type": "value_input", "fields": [], "align": "left", "name": "value_1", "check": "Number"}, {"type": "dummy_input", "fields": [{"name": "op", "values": [["+", "PLUS"], ["-", "MINUS"], ["\u00d7", "TIMES"], ["\u00f7", "DIV"]], "type": "dropdown"}], "align": "left"}, {"type": "value_input", "fields": [], "align": "left", "name": "value_2", "check": "Number"}], "inline": true}, "base_setvar": {"previous_statement": true, "next_statement": true, "colour": 330, "tooltip": "Affecter une valeur \u00e0 une variable", "inputs": [{"type": "value_input", "fields": [{"text": "mettre", "type": "text"}, {"name": "var_name", "default": "x", "type": "variable"}, {"text": "\u00e0", "type": "text"}], "align": "left", "name": "value", "check": null}]}, "simple_input_output_readnumber": {"output": true, "colour": 160, "tooltip": "Demander un nombre \u00e0 l'utilisateur", "inputs": [{"type": "dummy_input", "fields": [{"text": "demander un nombre", "type": "text"}], "align": "left"}]}, "base_start": {"next_statement": true, "colour": 65, "tooltip": "D\u00e9marrage de l'algorithme", "inputs": [{"type": "dummy_input", "fields": [{"text": "Au d\u00e9marrage", "type": "text"}], "align": "left"}], "creatable": false, "on_event": "start"}}}, "ast": [[{"type": "base_start", "deletable": false, "editable": false}, {"type": "base_setvar", "value": {"type": "simple_input_output_readnumber"}, "var_name": "x"}, {"type": "base_setvar", "value": {"type": "base_simplecalculus", "value_1": {"type": "base_simplecalculus", "value_1": {"type": "base_varvalue", "var_name": "x"}, "value_2": {"type": "base_numberinput", "value": 2.0}, "op": "MINUS"}, "value_2": {"type": "base_numberinput", "value": 2.0}, "op": "DIV"}, "var_name": "total"}, {"type": "simple_input_output_print", "value": {"type": "base_varvalue", "var_name": "total"}}]]}
Vous pouvez tenter de le modifier pour le comprendre.
{"environment": "input/output", "test_cases": [[0, -1.0], [1, -0.5], [2, 0.0], [3, 0.5], [4, 1.0], [5, 1.5], [6, 2.0], [7, 2.5], [8, 3.0], [9, 3.5], [10, 4.0], [11, 4.5], [12, 5.0], [13, 5.5], [14, 6.0], [15, 6.5], [16, 7.0], [17, 7.5], [18, 8.0], [19, 8.5]]}
{"options": {"runner": {"environment": "input/output", "test_cases": [[0, -1.0], [1, -0.5], [2, 0.0], [3, 0.5], [4, 1.0], [5, 1.5], [6, 2.0], [7, 2.5], [8, 3.0], [9, 3.5], [10, 4.0], [11, 4.5], [12, 5.0], [13, 5.5], [14, 6.0], [15, 6.5], [16, 7.0], [17, 7.5], [18, 8.0], [19, 8.5]]}, "blocks": {"base_numberinput": {"output": "Number", "colour": 260, "tooltip": "Fourni un nombre", "inputs": [{"type": "dummy_input", "fields": [{"name": "value", "default": 0.0, "type": "number_input"}], "align": "left"}]}, "simple_input_output_print": {"previous_statement": true, "next_statement": true, "colour": 160, "tooltip": "Afficher une valeur", "inputs": [{"type": "value_input", "fields": [{"text": "Afficher", "type": "text"}], "align": "left", "name": "value", "check": null}]}, "base_varvalue": {"output": true, "colour": 330, "tooltip": "Fourni la valeur d'une variable", "inputs": [{"type": "dummy_input", "fields": [{"name": "var_name", "default": "x", "type": "variable"}], "align": "left"}]}, "base_simplecalculus": {"output": "Number", "colour": 260, "tooltip": "Effectue un calcul simple", "inputs": [{"type": "value_input", "fields": [], "align": "left", "name": "value_1", "check": "Number"}, {"type": "dummy_input", "fields": [{"name": "op", "values": [["+", "PLUS"], ["-", "MINUS"], ["\u00d7", "TIMES"], ["\u00f7", "DIV"]], "type": "dropdown"}], "align": "left"}, {"type": "value_input", "fields": [], "align": "left", "name": "value_2", "check": "Number"}], "inline": true}, "base_setvar": {"previous_statement": true, "next_statement": true, "colour": 330, "tooltip": "Affecter une valeur \u00e0 une variable", "inputs": [{"type": "value_input", "fields": [{"text": "mettre", "type": "text"}, {"name": "var_name", "default": "x", "type": "variable"}, {"text": "\u00e0", "type": "text"}], "align": "left", "name": "value", "check": null}]}, "simple_input_output_readnumber": {"output": true, "colour": 160, "tooltip": "Demander un nombre \u00e0 l'utilisateur", "inputs": [{"type": "dummy_input", "fields": [{"text": "demander un nombre", "type": "text"}], "align": "left"}]}, "base_start": {"next_statement": true, "colour": 65, "tooltip": "D\u00e9marrage de l'algorithme", "inputs": [{"type": "dummy_input", "fields": [{"text": "Au d\u00e9marrage", "type": "text"}], "align": "left"}], "creatable": false, "on_event": "start"}}, "toolbox": [{"type": "base_numberinput"}, {"type": "base_setvar"}, {"type": "base_simplecalculus"}, {"type": "base_varvalue"}, {"type": "simple_input_output_print"}, {"type": "simple_input_output_readnumber"}]}, "ast": [[{"type": "base_start", "deletable": false, "editable": false}, {"type": "base_setvar", "value": {"type": "simple_input_output_readnumber"}, "var_name": "x"}, {"type": "base_setvar", "value": {"type": "base_simplecalculus", "value_1": {"type": "base_simplecalculus", "value_1": {"type": "base_varvalue", "var_name": "x"}, "value_2": {"type": "base_numberinput", "value": 2.0}, "op": "MINUS"}, "value_2": {"type": "base_numberinput", "value": 2.0}, "op": "DIV"}, "var_name": "total"}, {"type": "simple_input_output_print", "value": {"type": "base_varvalue", "var_name": "total"}}]]}