<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=0196_-_Aranjamente</id>
	<title>0196 - Aranjamente - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=0196_-_Aranjamente"/>
	<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=0196_-_Aranjamente&amp;action=history"/>
	<updated>2026-05-01T16:03:21Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://wiki.universitas.ro/index.php?title=0196_-_Aranjamente&amp;diff=7701&amp;oldid=prev</id>
		<title>Hotico Iulia Denisa: /* Exemplul 2 */</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=0196_-_Aranjamente&amp;diff=7701&amp;oldid=prev"/>
		<updated>2023-12-09T19:39:06Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Exemplul 2&lt;/span&gt;&lt;/span&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;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:39, 9 December 2023&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-l33&quot;&gt;Line 33:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 33:&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;  4 5&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;  4 5&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;consola&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;consola&lt;/div&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;  &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&quot;&lt;/del&gt;Nu corespunde restricțiilor&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&quot;&lt;/del&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;  Nu corespunde restricțiilor&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;&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;== Rezolvare ==&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;== Rezolvare ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Hotico Iulia Denisa</name></author>
	</entry>
	<entry>
		<id>https://wiki.universitas.ro/index.php?title=0196_-_Aranjamente&amp;diff=7643&amp;oldid=prev</id>
		<title>Gabii: Pagină nouă: = Cerinţa = Se citesc două numere naturale nenule &lt;code&gt;n&lt;/code&gt; și &lt;code&gt;k&lt;/code&gt;. Să se afişeze, în ordine lexicografică, aranjamentele de câte &lt;code&gt;k&lt;/code&gt; elemente ale mulţimii &lt;code&gt;{1,2,..,n}&lt;/code&gt;.  = Date de intrare = Fişierul de intrare &lt;code&gt;aranjamenteIN.txt&lt;/code&gt; conţine pe prima linie numerele &lt;code&gt;n&lt;/code&gt; și &lt;code&gt;k&lt;/code&gt;, separate printr-un spatiu.  = Date de ieşire = Fişierul de ieşire &lt;code&gt;aranjamenteOUT.txt&lt;/code&gt; va conţine pe fiecar...</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=0196_-_Aranjamente&amp;diff=7643&amp;oldid=prev"/>
		<updated>2023-12-04T18:13:17Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă: = Cerinţa = Se citesc două numere naturale nenule &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt;. Să se afişeze, în ordine lexicografică, aranjamentele de câte &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt; elemente ale mulţimii &amp;lt;code&amp;gt;{1,2,..,n}&amp;lt;/code&amp;gt;.  = Date de intrare = Fişierul de intrare &amp;lt;code&amp;gt;aranjamenteIN.txt&amp;lt;/code&amp;gt; conţine pe prima linie numerele &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt;, separate printr-un spatiu.  = Date de ieşire = Fişierul de ieşire &amp;lt;code&amp;gt;aranjamenteOUT.txt&amp;lt;/code&amp;gt; va conţine pe fiecar...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Cerinţa =&lt;br /&gt;
Se citesc două numere naturale nenule &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt;. Să se afişeze, în ordine lexicografică, aranjamentele de câte &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt; elemente ale mulţimii &amp;lt;code&amp;gt;{1,2,..,n}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
= Date de intrare =&lt;br /&gt;
Fişierul de intrare &amp;lt;code&amp;gt;aranjamenteIN.txt&amp;lt;/code&amp;gt; conţine pe prima linie numerele &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt;, separate printr-un spatiu.&lt;br /&gt;
&lt;br /&gt;
= Date de ieşire =&lt;br /&gt;
Fişierul de ieşire &amp;lt;code&amp;gt;aranjamenteOUT.txt&amp;lt;/code&amp;gt; va conţine pe fiecare linie câte &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt; valori, separate prin câte un spaţiu, reprezentând elementele unei aranjări. În cazul în care restricțiile nu sunt îndeplinite, se va afișa mesajul &amp;quot;Nu corespunde restricțiilor&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
= Restricţii şi precizări =&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;0 &amp;lt; k &amp;lt; n &amp;lt; 9&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Exemplul 1 =&lt;br /&gt;
&amp;lt;code&amp;gt;aranjamenteIN.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
 4 2&lt;br /&gt;
&amp;lt;code&amp;gt;aranjamenteOUT.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
 1 2 &lt;br /&gt;
 1 3 &lt;br /&gt;
 1 4 &lt;br /&gt;
 2 1 &lt;br /&gt;
 2 3 &lt;br /&gt;
 2 4 &lt;br /&gt;
 3 1 &lt;br /&gt;
 3 2 &lt;br /&gt;
 3 4 &lt;br /&gt;
 4 1 &lt;br /&gt;
 4 2 &lt;br /&gt;
 4 3 &lt;br /&gt;
&lt;br /&gt;
= Exemplul 2 =&lt;br /&gt;
&amp;lt;code&amp;gt;aranjamenteIN.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
 4 5&lt;br /&gt;
consola&lt;br /&gt;
 &amp;quot;Nu corespunde restricțiilor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Rezolvare ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python3&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
def verifica_restrictii(n, k):&lt;br /&gt;
    if not (0 &amp;lt; k &amp;lt; n &amp;lt; 9):&lt;br /&gt;
        print(&amp;quot;Nu corespunde restricțiilor.&amp;quot;)&lt;br /&gt;
        return False&lt;br /&gt;
    return True&lt;br /&gt;
&lt;br /&gt;
def genereaza_aranjamente(n, k, aranjament_curent, numere_folosite, fisier_output):&lt;br /&gt;
    if len(aranjament_curent) == k:&lt;br /&gt;
        fisier_output.write(&amp;quot; &amp;quot;.join(map(str, aranjament_curent)) + &amp;quot;\n&amp;quot;)&lt;br /&gt;
        return&lt;br /&gt;
&lt;br /&gt;
    for i in range(1, n + 1):&lt;br /&gt;
        if i not in numere_folosite:&lt;br /&gt;
            numere_folosite.add(i)&lt;br /&gt;
            genereaza_aranjamente(n, k, aranjament_curent + [i], numere_folosite, fisier_output)&lt;br /&gt;
            numere_folosite.remove(i)&lt;br /&gt;
&lt;br /&gt;
def main():&lt;br /&gt;
    # Citirea datelor de intrare din fișier&lt;br /&gt;
    with open(&amp;quot;aranjamenteIN.txt&amp;quot;, &amp;quot;r&amp;quot;) as fisier_intrare:&lt;br /&gt;
        n, k = map(int, fisier_intrare.readline().split())&lt;br /&gt;
&lt;br /&gt;
    # Verificarea restricțiilor&lt;br /&gt;
    if not verifica_restrictii(n, k):&lt;br /&gt;
        return&lt;br /&gt;
&lt;br /&gt;
    # Deschiderea fișierului de ieșire pentru scriere&lt;br /&gt;
    with open(&amp;quot;aranjamenteOUT.txt&amp;quot;, &amp;quot;w&amp;quot;) as fisier_iesire:&lt;br /&gt;
        # Inițializarea listei de elemente și a setului de numere folosite&lt;br /&gt;
        aranjament_curent = []&lt;br /&gt;
        numere_folosite = set()&lt;br /&gt;
&lt;br /&gt;
        # Generarea aranjamentelor și scrierea lor în fișierul de ieșire&lt;br /&gt;
        genereaza_aranjamente(n, k, aranjament_curent, numere_folosite, fisier_iesire)&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    main()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Gabii</name></author>
	</entry>
</feed>