Ú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
- Geri Bátyó: Agglegénykonyha 14 – Kések, késélezés
- Okos Otthon / Smart Home
- Le Mans Ultimate
- Fejhallgató erősítő és DAC topik
- Samsung Galaxy S25 Ultra - titán keret, acélos teljesítmény
- Marathon (2025)
- Itt a Galaxy S26 széria: az Ultra fejlődött, a másik kettő alig
- Parfüm topik
- Xiaomi 14T - nem baj, hogy nem Pro
- Villanyszerelés
- 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
- Apple iPhone 15 Pro Max 256 GB White Titanium 1 év Garancia Beszámítás Házhozszállítás
- ÓRIÁSI BOMBA AKCIÓK! PSN, STEAM, UBISOFT CONNECT, EA APP, XBOX EREDETI KULCSOK 100% GARANCIA
- BESZÁMÍTÁS! Asus H510M i5 10400F 16GB DDR4 512GB SSD RTX 2060 Super 8GB Rampage SHIVA 650W
- REFURBISHED - DELL Thunderbolt Dock WD19TB (210-ARJD), WD19TBS (210-AZBV)
- Frissen pasztázva! Playstation 4 Pro 1 TB + kontroller 6 hó garancia, számlával!
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
