{
  "format": "tokbit",
  "version": 1,
  "name": "Guess the number in 7 tries",
  "main": [
    {
      "id": "hc1",
      "kind": "declare",
      "name": "secret",
      "type": "int",
      "init": "randint(1, 100)"
    },
    {
      "id": "hc2",
      "kind": "declare",
      "name": "guess",
      "type": "int",
      "init": "0"
    },
    {
      "id": "hc3",
      "kind": "declare",
      "name": "tries",
      "type": "int",
      "init": "0"
    },
    {
      "id": "hc4",
      "kind": "output",
      "values": "\"I'm thinking of a number from 1 to 100.\""
    },
    {
      "id": "hc11",
      "kind": "while",
      "condition": "guess != secret and tries < 7",
      "body": [
        {
          "id": "hc5",
          "kind": "input",
          "target": "guess",
          "prompt": "Your guess:"
        },
        {
          "id": "hc6",
          "kind": "assign",
          "target": "tries",
          "value": "tries + 1"
        },
        {
          "id": "hc10",
          "kind": "if",
          "condition": "guess < secret",
          "then": [
            {
              "id": "hc7",
              "kind": "output",
              "values": "\"Higher.\""
            }
          ],
          "else": [
            {
              "id": "hc9",
              "kind": "if",
              "condition": "guess > secret",
              "then": [
                {
                  "id": "hc8",
                  "kind": "output",
                  "values": "\"Lower.\""
                }
              ],
              "else": []
            }
          ]
        }
      ],
      "comment": "Repeats until the guess is right and tries are left."
    },
    {
      "id": "hc13",
      "kind": "if",
      "condition": "guess == secret",
      "then": [
        {
          "id": "hc12",
          "kind": "output",
          "values": "\"You got it! Guesses:\", tries"
        }
      ],
      "else": [
        {
          "id": "hc14",
          "kind": "output",
          "values": "\"Out of guesses. My number was:\", secret"
        }
      ]
    }
  ],
  "functions": [],
  "comment": "Guess the number, but at most 7 tries. Solution to the task from the Tokbit lesson.",
  "screen": "fit"
}
