<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sudoku Archives - Onestring Lab</title>
	<atom:link href="https://onestringlab.com/tag/sudoku/feed/" rel="self" type="application/rss+xml" />
	<link>https://onestringlab.com/tag/sudoku/</link>
	<description>Kode Kreativitas Kopi</description>
	<lastBuildDate>Mon, 04 May 2026 08:38:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://onestringlab.com/wp-content/uploads/2021/10/cropped-osl-high-res-e1455499003866-32x32.jpg</url>
	<title>Sudoku Archives - Onestring Lab</title>
	<link>https://onestringlab.com/tag/sudoku/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Belajar Bahasa C &#8211; Sudoku Solution Validator</title>
		<link>https://onestringlab.com/sudoku-solution-validator/</link>
		
		<dc:creator><![CDATA[Rajo Intan]]></dc:creator>
		<pubDate>Wed, 14 Dec 2022 02:02:00 +0000</pubDate>
				<category><![CDATA[Codewars]]></category>
		<category><![CDATA[C Language]]></category>
		<category><![CDATA[Solution Validator]]></category>
		<category><![CDATA[Sudoku]]></category>
		<guid isPermaLink="false">https://onestringlab.com/?p=871</guid>

					<description><![CDATA[<p>Sudoku Background Sudoku is a game played on a 9&#215;9 grid. The goal of the game is to fill all cells of the grid with &#8230; </p>
<p>The post <a href="https://onestringlab.com/sudoku-solution-validator/">Belajar Bahasa C &#8211; Sudoku Solution Validator</a> appeared first on <a href="https://onestringlab.com">Onestring Lab</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Sudoku Background</h2>



<p>Sudoku is a game played on a 9&#215;9 grid. The goal of the game is to fill all cells of the grid with digits from 1 to 9, so that each column, each row, and each of the nine 3&#215;3 sub-grids (also known as blocks) contain all of the digits from 1 to 9.<br>(More info at: http://en.wikipedia.org/wiki/Sudoku)</p>



<h2 class="wp-block-heading">Sudoku Solution Validator</h2>



<p>Write a function validSolution/ValidateSolution/valid_solution() that accepts a 2D array representing a Sudoku board, and returns true if it is a valid solution, or false otherwise. The cells of the sudoku board may also contain 0&#8217;s, which will represent empty cells. Boards containing one or more zeroes are considered to be invalid solutions.</p>



<p>The board is always 9 cells by 9 cells, and every cell only contains integers from 0 to 9.</p>



<h2 class="wp-block-heading">Examples</h2>



<pre class="wp-block-code"><code lang="csharp" class="language-csharp">validSolution([
  [5, 3, 4, 6, 7, 8, 9, 1, 2],
  [6, 7, 2, 1, 9, 5, 3, 4, 8],
  [1, 9, 8, 3, 4, 2, 5, 6, 7],
  [8, 5, 9, 7, 6, 1, 4, 2, 3],
  [4, 2, 6, 8, 5, 3, 7, 9, 1],
  [7, 1, 3, 9, 2, 4, 8, 5, 6],
  [9, 6, 1, 5, 3, 7, 2, 8, 4],
  [2, 8, 7, 4, 1, 9, 6, 3, 5],
  [3, 4, 5, 2, 8, 6, 1, 7, 9]
]); // =&gt; true

validSolution([
  [5, 3, 4, 6, 7, 8, 9, 1, 2], 
  [6, 7, 2, 1, 9, 0, 3, 4, 8],
  [1, 0, 0, 3, 4, 2, 5, 6, 0],
  [8, 5, 9, 7, 6, 1, 0, 2, 0],
  [4, 2, 6, 8, 5, 3, 7, 9, 1],
  [7, 1, 3, 9, 2, 4, 8, 5, 6],
  [9, 0, 1, 5, 3, 7, 2, 1, 4],
  [2, 8, 7, 4, 1, 9, 6, 3, 5],
  [3, 0, 0, 4, 8, 1, 1, 7, 9]
]); // =&gt; false</code></pre>



<h2 class="wp-block-heading">Solution</h2>



<pre class="wp-block-code"><code lang="csharp" class="language-csharp line-numbers">#include &lt;stdbool.h&gt;

bool validSolution(unsigned int board[9][9])
{
  /* Write your code here */
  int b, k, ko, bb, kk, jum, cek = 1;

  for (b = 0; b &lt; 9; b++)
  {
    jum = 0;
    for (k = 0; k &lt; 9; k++)
    {
      jum = jum + board[b][k];
    }
    if (jum != 45)
    {
      cek = 0;
    }
  }

  for (b = 0; b &lt; 9; b++)
  {
    jum = 0;
    for (k = 0; k &lt; 9; k++)
    {
      jum = jum + board[k][b];
    }
    if (jum != 45)
    {
      cek = 0;
    }
  }

  for (ko = 0; ko &lt; 9; ko++)
  {
    bb = (ko / 3) * 3;
    kk = (ko % 3) * 3;
    jum = 0;
    for (b = bb; b &lt; bb + 3; b++)
    {
      for (k = kk; k &lt; kk + 3; k++)
      {
        jum = jum + board[b][k];
      }
    }
    if (jum != 45)
    {
      cek = 0;
    }
  }
  return cek;
}</code></pre>
<p>The post <a href="https://onestringlab.com/sudoku-solution-validator/">Belajar Bahasa C &#8211; Sudoku Solution Validator</a> appeared first on <a href="https://onestringlab.com">Onestring Lab</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Belajar Python &#8211; Menyelesaikan Sudoku dengan Python</title>
		<link>https://onestringlab.com/implementasi-algoritma-binary-search-tree-pada-python/</link>
		
		<dc:creator><![CDATA[Rajo Intan]]></dc:creator>
		<pubDate>Mon, 18 Oct 2021 14:51:23 +0000</pubDate>
				<category><![CDATA[Kode]]></category>
		<category><![CDATA[Aplikasi]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Sudoku]]></category>
		<guid isPermaLink="false">https://onestringlab.com/?p=49</guid>

					<description><![CDATA[<p>Sudoku Sudoku adalah salah satu jenis puzzle atau permainan angka yang sangat populer. Tua dan muda memainkan permainan ini untuk mengisi waktu luang mereka atau &#8230; </p>
<p>The post <a href="https://onestringlab.com/implementasi-algoritma-binary-search-tree-pada-python/">Belajar Python &#8211; Menyelesaikan Sudoku dengan Python</a> appeared first on <a href="https://onestringlab.com">Onestring Lab</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Sudoku</h2>



<p>Sudoku adalah salah satu jenis puzzle atau permainan angka yang sangat populer. Tua dan muda memainkan permainan ini untuk mengisi waktu luang mereka atau untuk mengasah otak mereka dengan mudah. Meski merupakan game jadul, hingga kini penggemar sudoku terus bermunculan dan berkembang.</p>



<p>Sudoku, awalnya disebut Number Place, adalah teka-teki penempatan nomor kombinatorial berbasis logika. Dalam Sudoku klasik, tujuannya adalah untuk mengisi kisi 9 × 9 dengan angka sehingga setiap kolom, baris, dan masing-masing dari sembilan subkisi 3 × 3 yang membentuk kisi (juga disebut kotak, blok, atau wilayah) adalah semua berisi angka 1 sampai 9.</p>



<p>Bila Anda belum mengetahui konsep dasar dari bahasa pemrograman Python silahkan kunjungin artikel  <a href="https://onestringlab.com/konsep-dasar-python/" target="_blank" rel="noreferrer noopener nofollow">Konsep Dasar Python</a>.</p>



<h2 class="wp-block-heading">Kode Program</h2>



<pre class="wp-block-code"><code lang="python" class="language-python">import numpy as np

def possible(y, x, n):
    global grid
    for i in range (0,9):
        if grid[y][i] == n :
            return False
    for i in range(0,9):
        if grid[i][x] == n :
            return False
    x0 = (x//3)*3
    y0 = (y//3)*3
    for i in range (0,3):
        for j in range (0,3):
            if grid[y0+i][x0+j] == n :
                return False
    return True

def solve() :
    global grid
    for y in range (9) :
        for x in range (9) :
            if grid[y][x] == 0 :
                for n in range(1,10) :
                    if possible (y,x,n) :
                        grid[y][x] = n
                        solve()
                        grid[y][x] = 0
                return
    print(np.matrix(grid))

grid = [
        [7, 8, 0, 4, 0, 0, 1, 2, 0],
        [6, 0, 0, 0, 7, 5, 0, 0, 9],
        [0, 0, 0, 6, 0, 1, 0, 7, 8],
        [0, 0, 7, 0, 4, 0, 2, 6, 0],
        [0, 0, 1, 0, 5, 0, 9, 3, 0],
        [9, 0, 4, 0, 6, 0, 0, 0, 5],
        [0, 7, 0, 3, 0, 0, 0, 1, 2],
        [1, 2, 0, 0, 0, 7, 4, 0, 0],
        [0, 4, 9, 2, 0, 6, 0, 0, 7]
    ]


print('Puzzle:')
print(np.matrix(grid))
print('Solve:')
solve()

</code></pre>



<h2 class="wp-block-heading">Keluaran Program</h2>



<pre class="wp-block-code"><code lang="python" class="language-python">Puzzle:
[[7 8 0 4 0 0 1 2 0]
 [6 0 0 0 7 5 0 0 9]
 [0 0 0 6 0 1 0 7 8]
 [0 0 7 0 4 0 2 6 0]
 [0 0 1 0 5 0 9 3 0]
 [9 0 4 0 6 0 0 0 5]
 [0 7 0 3 0 0 0 1 2]
 [1 2 0 0 0 7 4 0 0]
 [0 4 9 2 0 6 0 0 7]]
Solve:
[[7 8 5 4 3 9 1 2 6]
 [6 1 2 8 7 5 3 4 9]
 [4 9 3 6 2 1 5 7 8]
 [8 5 7 9 4 3 2 6 1]
 [2 6 1 7 5 8 9 3 4]
 [9 3 4 1 6 2 7 8 5]
 [5 7 8 3 9 4 6 1 2]
 [1 2 6 5 8 7 4 9 3]
 [3 4 9 2 1 6 8 5 7]]</code></pre>



<h2 class="wp-block-heading">Kesimpulan</h2>



<p>Problem puzzle Sudoku diselesaikan dengan algoritma rekursif. Untuk artikel lain terkait dengan pemrograman Python silahkan lihat kumpulan artikelnya <a href="https://onestringlab.com/tag/aplikasi/" target="_blank" rel="noreferrer noopener nofollow">disini</a>.</p>
<p>The post <a href="https://onestringlab.com/implementasi-algoritma-binary-search-tree-pada-python/">Belajar Python &#8211; Menyelesaikan Sudoku dengan Python</a> appeared first on <a href="https://onestringlab.com">Onestring Lab</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
