3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SudokuSolver { protected $sudokuColumns; public function __construct (array $sudoku) { $this->sudoku = $sudoku; } // could be static as well public function printOut ($sudoku) { foreach ($sudoku as $column) { foreach ($column as $cell) { echo "|"; if (null !== $cell) { echo $cell; } else { echo " "; } } echo "|\n"; } } public function solve() { $this->checkConsistenz(); } protected function checkConsistenz () { $columns = $this->sudoku; // check rows -> own method $rows = array(); foreach ($columns as $columnIndex => $column) { foreach ($column as $rowIndex => $cell) { $rows[$rowIndex][$columnIndex] = $cell; } $this->printOut($rows); } } protected function checkRow ($rowIndex) { } } $sudoku = array(); $sudoku[] = array(null,3,null, null,null,null, null,null,null); $sudoku[] = array(null,null,null, 1,9,5, null,null,null); $sudoku[] = array(null,null,8, null,null,null, null,6,null); $sudoku[] = array(8,null,null, null,6,null, null,null,null); $sudoku[] = array(4,null,null, 8,null,null, null,null,1); $sudoku[] = array(null,null,null ,null,2,null, null,null,null); $sudoku[] = array(null,6,null, null,null,null, 2,8,null); $sudoku[] = array(null,null,null, 4,1,9, null,null,5); $sudoku[] = array(null,null,null, null,null,null, null,7,null); $sudokuSolver = new SudokuSolver($sudoku); $sudokuSolver->printOut($sudoku); $sudokuSolver->solve($sudoku);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GZYMP
function name:  (null)
number of ops:  30
compiled vars:  !0 = $sudoku, !1 = $sudokuSolver
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   ASSIGN                                                   !0, <array>
   55     1        ASSIGN_DIM                                               !0
          2        OP_DATA                                                  <array>
   56     3        ASSIGN_DIM                                               !0
          4        OP_DATA                                                  <array>
   57     5        ASSIGN_DIM                                               !0
          6        OP_DATA                                                  <array>
   58     7        ASSIGN_DIM                                               !0
          8        OP_DATA                                                  <array>
   59     9        ASSIGN_DIM                                               !0
         10        OP_DATA                                                  <array>
   60    11        ASSIGN_DIM                                               !0
         12        OP_DATA                                                  <array>
   61    13        ASSIGN_DIM                                               !0
         14        OP_DATA                                                  <array>
   62    15        ASSIGN_DIM                                               !0
         16        OP_DATA                                                  <array>
   63    17        ASSIGN_DIM                                               !0
         18        OP_DATA                                                  <array>
   65    19        NEW                                              $12     'SudokuSolver'
         20        SEND_VAR_EX                                              !0
         21        DO_FCALL                                      0          
         22        ASSIGN                                                   !1, $12
   66    23        INIT_METHOD_CALL                                         !1, 'printOut'
         24        SEND_VAR_EX                                              !0
         25        DO_FCALL                                      0          
   67    26        INIT_METHOD_CALL                                         !1, 'solve'
         27        SEND_VAR_EX                                              !0
         28        DO_FCALL                                      0          
         29      > RETURN                                                   1

Class SudokuSolver:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GZYMP
function name:  __construct
number of ops:  4
compiled vars:  !0 = $sudoku
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ASSIGN_OBJ                                               'sudoku'
          2        OP_DATA                                                  !0
   10     3      > RETURN                                                   null

End of function __construct

Function printout:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 15
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 15
Branch analysis from position: 3
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/GZYMP
function name:  printOut
number of ops:  17
compiled vars:  !0 = $sudoku, !1 = $column, !2 = $cell
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1      > FE_RESET_R                                       $3      !0, ->15
          2    > > FE_FETCH_R                                               $3, !1, ->15
   17     3    > > FE_RESET_R                                       $4      !1, ->12
          4    > > FE_FETCH_R                                               $4, !2, ->12
   18     5    >   ECHO                                                     '%7C'
   19     6        TYPE_CHECK                                  1020          !2
          7      > JMPZ                                                     ~5, ->10
   20     8    >   ECHO                                                     !2
          9      > JMP                                                      ->11
   22    10    >   ECHO                                                     '+'
   17    11    > > JMP                                                      ->4
         12    >   FE_FREE                                                  $4
   25    13        ECHO                                                     '%7C%0A'
   16    14      > JMP                                                      ->2
         15    >   FE_FREE                                                  $3
   27    16      > RETURN                                                   null

End of function printout

Function solve:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GZYMP
function name:  solve
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_METHOD_CALL                                         'checkConsistenz'
          1        DO_FCALL                                      0          
   32     2      > RETURN                                                   null

End of function solve

Function checkconsistenz:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 18
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 18
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 13
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/GZYMP
function name:  checkConsistenz
number of ops:  20
compiled vars:  !0 = $columns, !1 = $rows, !2 = $column, !3 = $columnIndex, !4 = $cell, !5 = $rowIndex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   FETCH_OBJ_R                                      ~6      'sudoku'
          1        ASSIGN                                                   !0, ~6
   38     2        ASSIGN                                                   !1, <array>
   39     3      > FE_RESET_R                                       $9      !0, ->18
          4    > > FE_FETCH_R                                       ~10     $9, !2, ->18
          5    >   ASSIGN                                                   !3, ~10
   40     6      > FE_RESET_R                                       $12     !2, ->13
          7    > > FE_FETCH_R                                       ~13     $12, !4, ->13
          8    >   ASSIGN                                                   !5, ~13
   41     9        FETCH_DIM_W                                      $15     !1, !5
         10        ASSIGN_DIM                                               $15, !3
         11        OP_DATA                                                  !4
   40    12      > JMP                                                      ->7
         13    >   FE_FREE                                                  $12
   43    14        INIT_METHOD_CALL                                         'printOut'
         15        SEND_VAR_EX                                              !1
         16        DO_FCALL                                      0          
   39    17      > JMP                                                      ->4
         18    >   FE_FREE                                                  $9
   45    19      > RETURN                                                   null

End of function checkconsistenz

Function checkrow:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GZYMP
function name:  checkRow
number of ops:  2
compiled vars:  !0 = $rowIndex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   RECV                                             !0      
   50     1      > RETURN                                                   null

End of function checkrow

End of class SudokuSolver.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.47 ms | 1394 KiB | 13 Q