<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Задача №1: решение</title>
	<atom:link href="http://blog.fxposter.org/2007/09/18/task-1-solution/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.fxposter.org/2007/09/18/task-1-solution/</link>
	<description>Stories about Ruby, JavaScript, Objective-C and other cool tools</description>
	<lastBuildDate>Wed, 11 Jan 2012 18:45:17 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: FX Poster</title>
		<link>http://blog.fxposter.org/2007/09/18/task-1-solution/comment-page-1/#comment-1126</link>
		<dc:creator>FX Poster</dc:creator>
		<pubDate>Tue, 25 Sep 2007 09:17:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fxposter.org/2007/09/18/task-1-solution/#comment-1126</guid>
		<description>Ага, благодарю.
А я не знаю, как можно не юзая Древовидную структуру решить задачу за линейное время.</description>
		<content:encoded><![CDATA[<p>Ага, благодарю.<br />
А я не знаю, как можно не юзая Древовидную структуру решить задачу за линейное время.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Graber</title>
		<link>http://blog.fxposter.org/2007/09/18/task-1-solution/comment-page-1/#comment-1125</link>
		<dc:creator>Graber</dc:creator>
		<pubDate>Tue, 25 Sep 2007 07:05:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fxposter.org/2007/09/18/task-1-solution/#comment-1125</guid>
		<description>может уже не актуально, но все таки

// кто знает, как вывести n строк подряд - подскажите
print str_repeat(&quot;\t&quot;, $tree-&gt;level);

И еще вопрос: зачем использовать класс? Я сам всеми руками и ногами за, но для этой тривиальной задачи  мне кажется можно было обойтись и массивом array(&#039;name&#039;, &#039;children&#039;, &#039;level&#039;);</description>
		<content:encoded><![CDATA[<p>может уже не актуально, но все таки</p>
<p>// кто знает, как вывести n строк подряд &#8211; подскажите<br />
print str_repeat(&#8220;\t&#8221;, $tree-&gt;level);</p>
<p>И еще вопрос: зачем использовать класс? Я сам всеми руками и ногами за, но для этой тривиальной задачи  мне кажется можно было обойтись и массивом array(&#8216;name&#8217;, &#8216;children&#8217;, &#8216;level&#8217;);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: FX Poster</title>
		<link>http://blog.fxposter.org/2007/09/18/task-1-solution/comment-page-1/#comment-1086</link>
		<dc:creator>FX Poster</dc:creator>
		<pubDate>Wed, 19 Sep 2007 02:37:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fxposter.org/2007/09/18/task-1-solution/#comment-1086</guid>
		<description>&lt;p&gt;Решение не катит:&lt;br /&gt;
1. На один отступ больше. Ну это еще ладно. :)&lt;br /&gt;
2. Посмотри на свою выдачу и сравни с моей. Особенно обрати внимание на Nikon и Canon ;) Да и TV не там, где нужно.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Решение не катит:<br />
1. На один отступ больше. Ну это еще ладно. :)<br />
2. Посмотри на свою выдачу и сравни с моей. Особенно обрати внимание на Nikon и Canon ;) Да и TV не там, где нужно.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: troorl</title>
		<link>http://blog.fxposter.org/2007/09/18/task-1-solution/comment-page-1/#comment-1082</link>
		<dc:creator>troorl</dc:creator>
		<pubDate>Wed, 19 Sep 2007 01:48:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fxposter.org/2007/09/18/task-1-solution/#comment-1082</guid>
		<description>&lt;p&gt;Вот моё решение на Python. Делал только что в полпятого утра, так что уж извините за корявость :)&lt;/p&gt;
&lt;pre&gt;&lt;code class = &quot;python&quot;&gt;class node_data:
       def __init__(self, id, par, name):
               self.id = id
               self.par = par
               self.name = name

       id = int()
       par = int()
       name = str()

in_f = open(&#039;data.txt&#039;,&#039;r+&#039;)
in_arr = in_f.readlines()
node_list = list()

for i in in_arr:
       (id, par, name) = i.split(&quot;&#124;&quot;)
       node_list.append(node_data(int(id), int(par), name.split(&quot;\\n&quot;)[0]))

def nodes_print(cur_nod, n_l, indent, rep_list):
       for i in n_l:

               if(cur_nod.id not in rep_list):
                       rep_list.append(cur_nod.id)
                       print indent + cur_nod.name
               if i.par == cur_nod.id:
                       indent += &quot;\\t&quot;
                       nodes_print(i, n_l, indent, rep_list)

for i in node_list:
       if(i.par == 0):
               nodes_print(i, node_list, &quot;\\t&quot;, list())&lt;/code&gt;&lt;/pre&gt;
</description>
		<content:encoded><![CDATA[<p>Вот моё решение на Python. Делал только что в полпятого утра, так что уж извините за корявость :)</p>
<pre><code class = "python">class node_data:
       def __init__(self, id, par, name):
               self.id = id
               self.par = par
               self.name = name

       id = int()
       par = int()
       name = str()

in_f = open('data.txt','r+')
in_arr = in_f.readlines()
node_list = list()

for i in in_arr:
       (id, par, name) = i.split("|")
       node_list.append(node_data(int(id), int(par), name.split("\\n")[0]))

def nodes_print(cur_nod, n_l, indent, rep_list):
       for i in n_l:

               if(cur_nod.id not in rep_list):
                       rep_list.append(cur_nod.id)
                       print indent + cur_nod.name
               if i.par == cur_nod.id:
                       indent += "\\t"
                       nodes_print(i, n_l, indent, rep_list)

for i in node_list:
       if(i.par == 0):
               nodes_print(i, node_list, "\\t", list())</code></pre>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced

Served from: blog.fxposter.org @ 2012-02-11 01:40:22 -->
