<commit_before><?php

namespace DLX\Puzzles;

use \DLX\Grid;
use \Exception;

class Queens {

	/**
	 * @var int
	 */
	public $size;

	/**
	 * @var \DLX\Grid
	 */
	public $grid;

	/**
	 * @var array
	 */
	public $rowNames;


	/**
	 * @param int $size
	 *
	 * @throws Exception
	 * @return Queens
	 */
	public function __construct($size = 8) {
		$this->size = (int) $size;

		try {
			$this->createGrid( );
		}
		catch (Exception $e) {
			throw $e;
		}
	}

	/**
	 * @param void
	 *
	 * @throws Exception
	 * @return void
	 */
	protected function createGrid( ) {
		$this->createRowNames( );
		$nodes = $this->createNodes( );

		try {
			// 6N - 6; because 1N for each row and col, then 2N - 3 for each diagonal with single ends removed
			$this->grid = new Grid($nodes, (6 * $this->size) - 6, (4 * $this->size) - 6);
		}
		catch (Exception $e) {
			throw $e;
		}
	}

	/**
	 * Create the row names used to translate the solutions
	 *
	 * @param void
	 *
	 * @return void
	 */
	protected function createRowNames( ) {
		$rowNames = array(''); // rows are 1-index
		$len = strlen((string) $this->size);

		if (26 > $this->size) {
			for ($n = 0; $n < ($this->size * $this->size); ++$n) {
				$rowNames[] = chr(65 + floor($n / $this->size)) . str_pad(($n % $this->size) + 1, $len, '0', STR_PAD_LEFT);
			}
		}
		else {
			for ($n = 0; $n < ($this->size * $this->size); ++$n) {
				$rowNames[] = 'R'.str_pad(floor($n / $this->size) + 1, $len, '0', STR_PAD_LEFT) . 'F'.str_pad(($n % $this->size) + 1, $len, '0', STR_PAD_LEFT);
			}
		}
g($rowNames);

		$this->rowNames = $rowNames;
	}

	/**
	 * @param void<commit_msg>remove debugging code<commit_after><?php

namespace DLX\Puzzles;

use \DLX\Grid;
use \Exception;

class Queens {

	/**
	 * @var int
	 */
	public $size;

	/**
	 * @var \DLX\Grid
	 */
	public $grid;

	/**
	 * @var array
	 */
	public $rowNames;


	/**
	 * @param int $size
	 *
	 * @throws Exception
	 * @return Queens
	 */
	public function __construct($size = 8) {
		$this->size = (int) $size;

		try {
			$this->createGrid( );
		}
		catch (Exception $e) {
			throw $e;
		}
	}

	/**
	 * @param void
	 *
	 * @throws Exception
	 * @return void
	 */
	protected function createGrid( ) {
		$this->createRowNames( );
		$nodes = $this->createNodes( );

		try {
			// 6N - 6; because 1N for each row and col, then 2N - 3 for each diagonal with single ends removed
			$this->grid = new Grid($nodes, (6 * $this->size) - 6, (4 * $this->size) - 6);
		}
		catch (Exception $e) {
			throw $e;
		}
	}

	/**
	 * Create the row names used to translate the solutions
	 *
	 * @param void
	 *
	 * @return void
	 */
	protected function createRowNames( ) {
		$rowNames = array(''); // rows are 1-index
		$len = strlen((string) $this->size);

		if (26 > $this->size) {
			for ($n = 0; $n < ($this->size * $this->size); ++$n) {
				$rowNames[] = chr(65 + floor($n / $this->size)) . str_pad(($n % $this->size) + 1, $len, '0', STR_PAD_LEFT);
			}
		}
		else {
			for ($n = 0; $n < ($this->size * $this->size); ++$n) {
				$rowNames[] = 'R'.str_pad(floor($n / $this->size) + 1, $len, '0', STR_PAD_LEFT) . 'F'.str_pad(($n % $this->size) + 1, $len, '0', STR_PAD_LEFT);
			}
		}

		$this->rowNames = $rowNames;
	}

	/**
	 * @param void
{'fraction_non_alphanumeric': 0.20685358255451713, 'fraction_numerical': 0.014330218068535825, 'mean_word_length': 2.5677777777777777, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '306420', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1228, 'n_words': 316}