Új hozzászólás Aktív témák
-
olli
tag
válasz
kovisoft
#4449
üzenetére
Köszi mindenkinek a segítséget.
Ez lett a megoldás:
cmd:pip install pandas openpyxlimport itertools
import pandas as pd
numbers = range(1, 91)
target_sum = 225
combinations = itertools.combinations(numbers, 5)
valid_combinations = [comb for comb in combinations if sum(comb) == target_sum]
df = pd.DataFrame(valid_combinations, columns=["A", "B", "C", "D", "E"])
df.to_excel(r"C:\Users\Public\kombinaciok_225.xlsx", index=False)
print("Kész! A fájl neve: kombinaciok_225.xlsx") -
olli
tag
válasz
kovisoft
#4446
üzenetére
import itertools
# Define the range of numbers (1 to 90)
numbers = range(1, 91)
# Define the target sum
target_sum = 225
# Generate all combinations of 5 numbers from the range 1 to 90
combinations = itertools.combinations(numbers, 5)
# Filter combinations whose sum equals the target_sum
valid_combinations = [comb for comb in combinations if sum(comb) == target_sum]
# Format the first 299018 valid combinations for Excel
formatted_combinations = "\n".join([",".join(map(str, comb)) for comb in valid_combinations[:299018]])
# Print the formatted combinations for Excel
print(formatted_combinations)
c:\Work\python>python x.py > x.txt
c:\Work\python>type x.txt | find /c /v ""
299018
hiba:
>>> c:\Work\python>python x.py > x.txt
File "<stdin>", line 1
c:\Work\python>python x.py > x.txt
^
SyntaxError: unexpected character after line continuation character
>>> c:\Work\python>type x.txt | find /c /v ""
File "<stdin>", line 1
c:\Work\python>type x.txt | find /c /v ""
^
SyntaxError: unexpected character after line continuation character
>>> 299018 -
olli
tag
Sziasztok!
import itertools
# Define the range of numbers (1 to 90)
numbers = range(1, 91)
# Define the target sum
target_sum = 225
# Generate all combinations of 5 numbers from the range 1 to 90
combinations = itertools.combinations(numbers, 5)
# Filter combinations whose sum equals the target_sum
valid_combinations = [comb for comb in combinations if sum(comb) == target_sum]
# Format the first 299018 valid combinations for Excel
formatted_combinations = "\n".join([",".join(map(str, comb)) for comb in valid_combinations[:299018]])
# Print the formatted combinations for Excel
print(formatted_combinations)
A fenti táblázat 299018 sora helyett csak 9030 sort kaptam vissza. Ez korlát, vagy valahol be kell állítani? -
olli
tag
válasz
Atomantiii
#4317
üzenetére
Lemaradt a print...
Bocs, magamnak válaszoltam. -
olli
tag
Sziasztok!
Abszolut kezdőként kérdezem: IDLE Shell 3.12.6 megnyitom.import itertools
# Define the range of numbers (1 to 90)
numbers = range(1, 91)
# Define the target sum
target_sum = 225
# Generate all combinations of 5 numbers from the range 1 to 90
combinations = itertools.combinations(numbers, 5)
# Filter combinations whose sum equals the target_sum
valid_combinations = [comb for comb in combinations if sum(comb) == target_sum]
# Count the number of valid combinations
num_valid_combinations = len(valid_combinations)
valid_combinations, num_valid_combinationsKódot soronként bemásolom, sorok végén enter.
Kód lefut, rákérdez a futtatásra.
Ugyan itt: New File megnyit, kód bemásol, mentés ujmind.py
Run> Run Module : = RESTART: C:/Users/win11/AppData/Local/Programs/Python/Python312/ujmind.py és semmi..
Mit csinálok rosszul?
Új hozzászólás Aktív témák
- Renault, Dacia topik
- sziku69: Fűzzük össze a szavakat :)
- Luck Dragon: Asszociációs játék. :)
- Okos Otthon / Smart Home
- Melyik tápegységet vegyem?
- Genshin Impact (PC, PS4, Android, iOS)
- Brogyi: CTEK akkumulátor töltő és másolatai
- Linux kezdőknek
- Milyen billentyűzetet vegyek?
- Telekom otthoni szolgáltatások (TV, internet, telefon)
- További aktív témák...
- Új Lenovo Thinkbook 14 G7 WUXGA IPS Ultra7 155H 16mag 32GB 1TB SSD Intel Arc Win11 Pro Garancia
- Új HP 16 Victus FHD IPS 144Hz Ryzen7 8845HS 5.1Ghz 16GB 1TB SSD Nvidia RTX 4060 8GB Win11 Garancia
- Új Asus Zenbook S14 WQXGA OLED 120Hz Ultra7 258V 32GB 1TB SSD Intel Arc 140V 16GB Win11 Garancia
- Asus 17 TUF Gaming FHD IPS 144Hz G-Sync Ryzen7 7435HS 16GB 512GB Nvidia RTX 4060 8GB Win11 Garancia
- Új Acer Nitro V15 FHD IPS 144Hz Ryzen7 7735HS 16GB DDR5 512GB SSD Nvidia RTX 4060 8GB Win11 Garancia
- HOWEAR HW ULTRA 3 Call okosóra
- Lenovo ThinkPad X1 Yoga G6 (6th Gen) - i7-1185G7, 32GB, 512GB SSD, multitouch + TOLL
- Dell Precision 5530 15,6" FHD, i7 8850H, 16GB RAM, Quadro 4GB VGA, 512GB SSD, jó akku, számla, gar
- AKCIÓ! LENOVO ThinkPad P15 Gen2 munkaállomás - i7 11800H 16GB DDR4 512GB SSD Quadro T1200 4GB W
- iPhone 11 64GB White -1 ÉV GARANCIA - Kártyafüggetlen, MS4305, 100% Akksi
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
