<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Alle subsequence Zerlegungen]]></title><description><![CDATA[<p>Hallo, ich habe einen String und brauche dafuer alle Sub-Zerlegungen als 2-dimensionales Array/Liste. Zusaetzlich sollte eine Zerlegung mit lentgh == 1 nur auf eine vorherige Zerlegung folgen koennen wenn diese len&gt;1 war.<br />
Bsp.:<br />
Mein string &quot;1234&quot;, und die Loesung sollte so aussehen:<br />
&lsqb;&lsqb;&quot;1234&quot;], [&quot;1&quot;, &quot;234&quot;], [&quot;12&quot;, &quot;34&quot;], [&quot;123&quot;, &quot;4&quot;], [&quot;1&quot;, &quot;23&quot;, &quot;4&quot;&rsqb;&rsqb;</p>
<p>Die Zerlegungen<br />
[&quot;1, &quot;2&quot;, &quot;34&quot;], [&quot;12&quot;, &quot;3&quot;, &quot;4&quot;] usw. sind aber nicht erlaubt da hier 2 Zerlegungen mit length == 1 aufeinander folgen.</p>
<p>Ich habe den Algorithmus bereits in Python</p>
<pre><code>def getSubSequences(self, s, minLength=1):
	    if len(s) &gt;= minLength:
		for i in range(minLength, len(s) + 1):
		    for p in self.getSubSequences(s[i:], 1 if i &gt; 1 else 2):
		        yield [s[:i&rsqb;&rsqb; + p
	    elif not s:
		yield []
</code></pre>
<p>Weis aber nicht wie ich diesen in C++ uebertragen kann, da ich hier keine yields habe...</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/332848/alle-subsequence-zerlegungen</link><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Apr 2026 10:55:40 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/332848.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 25 May 2015 21:35:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Alle subsequence Zerlegungen on Mon, 25 May 2015 21:35:34 GMT]]></title><description><![CDATA[<p>Hallo, ich habe einen String und brauche dafuer alle Sub-Zerlegungen als 2-dimensionales Array/Liste. Zusaetzlich sollte eine Zerlegung mit lentgh == 1 nur auf eine vorherige Zerlegung folgen koennen wenn diese len&gt;1 war.<br />
Bsp.:<br />
Mein string &quot;1234&quot;, und die Loesung sollte so aussehen:<br />
&lsqb;&lsqb;&quot;1234&quot;], [&quot;1&quot;, &quot;234&quot;], [&quot;12&quot;, &quot;34&quot;], [&quot;123&quot;, &quot;4&quot;], [&quot;1&quot;, &quot;23&quot;, &quot;4&quot;&rsqb;&rsqb;</p>
<p>Die Zerlegungen<br />
[&quot;1, &quot;2&quot;, &quot;34&quot;], [&quot;12&quot;, &quot;3&quot;, &quot;4&quot;] usw. sind aber nicht erlaubt da hier 2 Zerlegungen mit length == 1 aufeinander folgen.</p>
<p>Ich habe den Algorithmus bereits in Python</p>
<pre><code>def getSubSequences(self, s, minLength=1):
	    if len(s) &gt;= minLength:
		for i in range(minLength, len(s) + 1):
		    for p in self.getSubSequences(s[i:], 1 if i &gt; 1 else 2):
		        yield [s[:i&rsqb;&rsqb; + p
	    elif not s:
		yield []
</code></pre>
<p>Weis aber nicht wie ich diesen in C++ uebertragen kann, da ich hier keine yields habe...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2454766</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2454766</guid><dc:creator><![CDATA[Freaky256]]></dc:creator><pubDate>Mon, 25 May 2015 21:35:34 GMT</pubDate></item><item><title><![CDATA[Reply to Alle subsequence Zerlegungen on Tue, 26 May 2015 18:57:55 GMT]]></title><description><![CDATA[<p>Hatte gerade langeweile dahier hier eine einigermaßen direkte Übersetzung deines Perl Codes in C++ (ich hab Null Ahnung von Perl und weiß auch nicht was yield überhaupt macht):</p>
<pre><code>#include &lt;vector&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;

typedef std::vector&lt;std::string&gt; SubSeq;

std::vector&lt;SubSeq&gt; getSubSequences(const std::string&amp; s, size_t minLength = 1)
{
  std::vector&lt;SubSeq&gt; result;
  for(size_t i = minLength; i &lt; s.length(); ++i)
  {
    for(auto&amp; p : getSubSequences(s.substr(i), i &gt; 1 ? 1 : 2))
    {
      SubSeq ss(1, s.substr(0, i));
      ss.insert(ss.end(), p.begin(), p.end());
      result.push_back(std::move(ss));
    }
  }
  if(s.length() &gt;= minLength)
    result.push_back(SubSeq(1, s));
  return result;
}

int main()
{
  auto r = getSubSequences(&quot;1234&quot;);
  for(auto&amp; seq : r)
  {
    for(auto&amp; ss : seq)
      std::cout &lt;&lt; ss &lt;&lt; ' ';
    std::cout &lt;&lt; '\n';
  }
  std::cin.get();
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2454828</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2454828</guid><dc:creator><![CDATA[sebi707]]></dc:creator><pubDate>Tue, 26 May 2015 18:57:55 GMT</pubDate></item><item><title><![CDATA[Reply to Alle subsequence Zerlegungen on Tue, 26 May 2015 19:19:10 GMT]]></title><description><![CDATA[<p>*räusper* python.<br />
<a href="http://www.python-kurs.eu/generatoren.php" rel="nofollow">http://www.python-kurs.eu/generatoren.php</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2454836</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2454836</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Tue, 26 May 2015 19:19:10 GMT</pubDate></item><item><title><![CDATA[Reply to Alle subsequence Zerlegungen on Tue, 26 May 2015 19:24:00 GMT]]></title><description><![CDATA[<p>Oh Python natürlich. Hab ich mich irgendwie verlesen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2454838</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2454838</guid><dc:creator><![CDATA[sebi707]]></dc:creator><pubDate>Tue, 26 May 2015 19:24:00 GMT</pubDate></item></channel></rss>