<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="et">
	<id>http://www.lambda.ee/w/index.php?action=history&amp;feed=atom&amp;title=Ifi6057w5ex</id>
	<title>Ifi6057w5ex - Redigeerimiste ajalugu</title>
	<link rel="self" type="application/atom+xml" href="http://www.lambda.ee/w/index.php?action=history&amp;feed=atom&amp;title=Ifi6057w5ex"/>
	<link rel="alternate" type="text/html" href="http://www.lambda.ee/w/index.php?title=Ifi6057w5ex&amp;action=history"/>
	<updated>2026-10-28T12:41:06Z</updated>
	<subtitle>Selle lehekülje redigeerimiste ajalugu</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>http://www.lambda.ee/w/index.php?title=Ifi6057w5ex&amp;diff=13893&amp;oldid=prev</id>
		<title>PriitJ – 11. oktoober 2017, kell 06:19</title>
		<link rel="alternate" type="text/html" href="http://www.lambda.ee/w/index.php?title=Ifi6057w5ex&amp;diff=13893&amp;oldid=prev"/>
		<updated>2017-10-11T06:19:57Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;et&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←Vanem redaktsioon&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Redaktsioon: 11. oktoober 2017, kell 08:19&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;1. rida:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;1. rida:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;N lipu paigutamine lokaalse otsinguga.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;N lipu paigutamine lokaalse otsinguga.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;code&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;pre&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   import search&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   import search&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   import random&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   import random&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l75&quot;&gt;75. rida:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;75. rida:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   print(hill_climbing(p))&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   print(hill_climbing(p))&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;code&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;pre&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>PriitJ</name></author>
	</entry>
	<entry>
		<id>http://www.lambda.ee/w/index.php?title=Ifi6057w5ex&amp;diff=13880&amp;oldid=prev</id>
		<title>PriitJ: Uus lehekülg: &#039;N lipu paigutamine lokaalse otsinguga.  &lt;code&gt;   import search   import random    class HCNQueens(search.Problem):     def __init__(self, N):         self.N = N         self.init...&#039;</title>
		<link rel="alternate" type="text/html" href="http://www.lambda.ee/w/index.php?title=Ifi6057w5ex&amp;diff=13880&amp;oldid=prev"/>
		<updated>2017-10-04T09:19:10Z</updated>

		<summary type="html">&lt;p&gt;Uus lehekülg: &amp;#039;N lipu paigutamine lokaalse otsinguga.  &amp;lt;code&amp;gt;   import search   import random    class HCNQueens(search.Problem):     def __init__(self, N):         self.N = N         self.init...&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Uus lehekülg&lt;/b&gt;&lt;/p&gt;&lt;div&gt;N lipu paigutamine lokaalse otsinguga.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  import search&lt;br /&gt;
  import random&lt;br /&gt;
&lt;br /&gt;
  class HCNQueens(search.Problem):&lt;br /&gt;
    def __init__(self, N):&lt;br /&gt;
        self.N = N&lt;br /&gt;
        self.initial = [None]*N&lt;br /&gt;
        for i in range(N):&lt;br /&gt;
            self.initial[i] = random.randint(0,N-1)&lt;br /&gt;
&lt;br /&gt;
    def actions(self, state):&lt;br /&gt;
        acts = []&lt;br /&gt;
        for i in range(self.N):&lt;br /&gt;
            pos = state[i]&lt;br /&gt;
            for j in range(self.N):&lt;br /&gt;
                if j == pos: continue&lt;br /&gt;
                acts.append((i, j))&lt;br /&gt;
        return acts&lt;br /&gt;
&lt;br /&gt;
    def result(self, state, action):&lt;br /&gt;
        i, j = action&lt;br /&gt;
        newstate = list(state)&lt;br /&gt;
        newstate[i] = j&lt;br /&gt;
        return newstate&lt;br /&gt;
&lt;br /&gt;
    def conflict(self, row1, col1, row2, col2):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;Would putting two queens in (row1, col1) and (row2, col2) conflict?&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        return (row1 == row2 or  # same row&lt;br /&gt;
                col1 == col2 or  # same column&lt;br /&gt;
                row1 - col1 == row2 - col2 or  # same \ diagonal&lt;br /&gt;
                row1 + col1 == row2 + col2)   # same / diagonal&lt;br /&gt;
&lt;br /&gt;
    def value(self, state):&lt;br /&gt;
        h = 0&lt;br /&gt;
        for col in range(self.N - 1):&lt;br /&gt;
            row = state[col]&lt;br /&gt;
            for col2 in range(col + 1, self.N):&lt;br /&gt;
                row2 = state[col2]&lt;br /&gt;
                if self.conflict(row, col, row2, col2):&lt;br /&gt;
                    h += 1&lt;br /&gt;
        return h&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  def hill_climbing(problem):&lt;br /&gt;
    current = problem.initial&lt;br /&gt;
    curr_value = problem.value(problem.initial)&lt;br /&gt;
&lt;br /&gt;
    while True:&lt;br /&gt;
        max_value = 99999&lt;br /&gt;
        for action in problem.actions(current):&lt;br /&gt;
            neighbor = problem.result(current, action)&lt;br /&gt;
            neigh_value = problem.value(neighbor)&lt;br /&gt;
            if neigh_value &amp;lt; max_value:&lt;br /&gt;
                max_neighbor = neighbor&lt;br /&gt;
                max_value = neigh_value&lt;br /&gt;
&lt;br /&gt;
        if max_value &amp;gt;= curr_value:&lt;br /&gt;
            break&lt;br /&gt;
        else:&lt;br /&gt;
            current = max_neighbor&lt;br /&gt;
            curr_value = max_value&lt;br /&gt;
            print (curr_value, current)&lt;br /&gt;
&lt;br /&gt;
    return current&lt;br /&gt;
&lt;br /&gt;
  p = HCNQueens(36)&lt;br /&gt;
  print(p.value(p.initial), p.initial)&lt;br /&gt;
  #print(p.value([2,1,2,1]))&lt;br /&gt;
  #print (p.actions(p.initial))&lt;br /&gt;
  #print (p.result(p.initial,p.actions(p.initial)[0]))&lt;br /&gt;
&lt;br /&gt;
  print(hill_climbing(p))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>PriitJ</name></author>
	</entry>
</feed>