<commit_before><?xml version="1.0" encoding="UTF-8"?>
  <section version="5.0" xmlns="http://docbook.org/ns/docbook"
                    xmlns:xlink="http://www.w3.org/1999/xlink"
                    xmlns:xi="http://www.w3.org/2001/XInclude"
                    xmlns:svg="http://www.w3.org/2000/svg"
                    xmlns:m="http://www.w3.org/1998/Math/MathML"
                    xmlns:html="http://www.w3.org/1999/xhtml"
                    xmlns:db="http://docbook.org/ns/docbook" xml:base="../../">
    <title>Sudoku Example</title>

    <programlisting><emphasis role="bold">Name:</emphasis> Sudoku
<emphasis role="bold">Main class:</emphasis> org.drools.examples.sudoku.Main
<emphasis role="bold">Type:</emphasis> java application
<emphasis role="bold">Rules file:</emphasis> sudokuSolver.drl, sudokuValidator.drl
<emphasis role="bold">Objective:</emphasis> Demonstrates the solving of logic problems, and complex pattern matching.e
</programlisting>

    <para>This example demonstrates how Drools can be used to find a solution
    in a large potential solution space based on a number of constraints. We
    use the popular puzzle of Sudoku. This example also shows how Drools can
    be integrated into a graphical interface and how callbacks can be used to
    interact with a running Drools rules engine in order to update the
    graphical interface based on changes in the working memory at
    runtime.</para>

    <section>
      <title>Sudoku Overview</title>

      <para>Sudoku is a logic-based number placement puzzle. The objective is
      to fill a 9x9 grid so that each column, each row, and each of the nine
      3x3 zones contains the digits from 1 to 9 once and only once.</para>

      <para>The puzzle setter provides a partially completed grid and the
      puzzle solver's task is to complete the grid with these
      constraints.</para>

      <para>The general strategy to solve the problem is to ensure that when
      you insert a new number it should be unique in that particular
      region(blocks) and also in that particular row and column.</para>

      <para>See <programlisting>URL: http://en.wikipedia.org/wiki/Sudoku</programlisting>
      for a more detailed description.</para>
    </section>

    <section>
      <title>Running the Example</title>

      <para>Download and install drools-examples as described above and then
      execute java org.drools.examples.sudoku.Main (this example requires Java
      5).</para>

      <para>A window will be displayed with a relatively simple partially
      filled grid. <screenshot>
          <screeninfo>New remote site</screeninfo>

          <mediaobject>
            <imageobject>
              <imagedata fileref="images/Chapter-Examples/SodukiExample/sudoku1.png" />
            </imageobject>
          </mediaobject>
        </screenshot></para>

      <para>Click on the Solve button and the Drools-based engine will fill
      out the remaining values. The console will display detailed information
      of the rules which are executing to solve the puzzle in a human readable
      form.</para>

      <para><computeroutput>Rule #3 determined the value at (4,1) could not be
      4 as this value already exists in the same column at (8,1) Rule #3
      determined the value at (5,5) could not be 2 as this value already
      exists in the same row at (5,6) Rule #7 determined (3,5) is 2 as this is
      the only possible cell in the column that can have this value Rule #1
      cleared the other PossibleCellValues for (3,5) as a ResolvedCellValue of
      2 exists for this cell. Rule #1 cleared the other PossibleCellValues for
      (3,5) as a ResolvedCellValue of 2 exists for this cell. ... Rule #3
      determined the value at (1,1) could not be 1 as this value already
      exists in the same zone at (2,1) Rule #6 determined (1,7) is 1 as this
      is the only possible cell in the row that can have this value Rule #1
      cleared the other PossibleCellValues for (1,7) as a ResolvedCellValue of
      1 exists for this cell. Rule #6 determined (1,1) is 8 as this is the
      only possible cell in the row that can have this value
      </computeroutput></para>
<commit_msg>avoid long line<commit_after><?xml version="1.0" encoding="UTF-8"?>
  <section version="5.0" xmlns="http://docbook.org/ns/docbook"
                    xmlns:xlink="http://www.w3.org/1999/xlink"
                    xmlns:xi="http://www.w3.org/2001/XInclude"
                    xmlns:svg="http://www.w3.org/2000/svg"
                    xmlns:m="http://www.w3.org/1998/Math/MathML"
                    xmlns:html="http://www.w3.org/1999/xhtml"
                    xmlns:db="http://docbook.org/ns/docbook" xml:base="../../">
    <title>Sudoku Example</title>

    <programlisting><emphasis role="bold">Name:</emphasis> Sudoku
<emphasis role="bold">Main class:</emphasis> org.drools.examples.sudoku.Main
<emphasis role="bold">Type:</emphasis> java application
<emphasis role="bold">Rules file:</emphasis> sudokuSolver.drl, sudokuValidator.drl
<emphasis role="bold">Objective:</emphasis> Demonstrates the solving of logic problems, and complex pattern matching.e
</programlisting>

    <para>This example demonstrates how Drools can be used to find a solution
    in a large potential solution space based on a number of constraints. We
    use the popular puzzle of Sudoku. This example also shows how Drools can
    be integrated into a graphical interface and how callbacks can be used to
    interact with a running Drools rules engine in order to update the
    graphical interface based on changes in the working memory at
    runtime.</para>

    <section>
      <title>Sudoku Overview</title>

      <para>Sudoku is a logic-based number placement puzzle. The objective is
      to fill a 9x9 grid so that each column, each row, and each of the nine
      3x3 zones contains the digits from 1 to 9 once and only once.</para>

      <para>The puzzle setter provides a partially completed grid and the
      puzzle solver's task is to complete the grid with these
      constraints.</para>

      <para>The general strategy to solve the problem is to ensure that when
      you insert a new number it should be unique in that particular
      region(blocks) and also in that particular row and column.</para>

      <para>See <programlisting>URL: http://en.wikipedia.org/wiki/Sudoku</programlisting>
      for a more detailed description.</para>
    </section>

    <section>
      <title>Running the Example</title>

      <para>Download and install drools-examples as described above and then
      execute java org.drools.examples.sudoku.Main (this example requires Java
      5).</para>

      <para>A window will be displayed with a relatively simple partially
      filled grid. <screenshot>
          <screeninfo>New remote site</screeninfo>

          <mediaobject>
            <imageobject>
              <imagedata fileref="images/Chapter-Examples/SodukiExample/sudoku1.png" />
            </imageobject>
          </mediaobject>
        </screenshot></para>

      <para>Click on the Solve button and the Drools-based engine will fill
      out the remaining values. The console will display detailed information
      of the rules which are executing to solve the puzzle in a human readable
      form.</para>

      <para><screen>Rule #3 determined the value at (4,1) could not be 4 as this value already exists in the same column at (8,1)
Rule #3 determined the value at (5,5) could not be 2 as this value already exists in the same row at (5,6)
Rule #7 determined (3,5) is 2 as this is the only possible cell in the column that can have this value
Rule #1 cleared the other PossibleCellValues for (3,5) as a ResolvedCellValue of 2 exists for this cell.
Rule #1 cleared the other PossibleCellValues for (3,5) as a ResolvedCellValue of 2 exists for this cell.
... 
Rule #3 determined the value at (1,1) could not be 1 as this value already  exists in the same zone at (2,1)
Rule #6 determined (1,7) is 1 as this is the only possible cell in the row that can have this value
Rule #1 cleared the other PossibleCellValues for (1,7) as a ResolvedCellValue of 1 exists for this cell.
Rule #6 determined (1,1) is 8 as this is the only possible cell in the row that can have this value</screen></para>

{'fraction_non_alphanumeric': 0.08610944076969332, 'fraction_numerical': 0.019242333132892364, 'mean_word_length': 2.975143403441683, 'pattern_counts': {'":': 0, '<': 111, '<?xml version=': 2, '>': 111, 'https://': 0, 'lorem ipsum': 0, 'www.': 10, 'xml': 18}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5222357', 'n_tokens_mistral': 2396, 'n_tokens_neox': 2229, 'n_words': 969}