Ú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
- PlayStation 5
- Ingatlanos topic!
- Eredeti játékok OFF topik
- Kerékpárosok, bringások ide!
- GTA V
- A nagy Szóda, Szódakészítés topic - legyen egy kis fröccs is! :-)
- AMD Ryzen 9 / 7 / 5 9***(X) "Zen 5" (AM5)
- Civilization V
- Anglia - élmények, tapasztalatok
- Intel Core Ultra 3, Core Ultra 5, Ultra 7, Ultra 9 "Arrow Lake" LGA 1851
- További aktív témák...
- BESZÁMÍTÁS! ASRock B650M R7 7700 32GB DDR5 1TB SSD RX 7900 XTX 24GB Fractal Design Pop Air RGB 850W
- ÁRGARANCIA!Épített KomPhone i5 14600KF 32/64GB DDR5 RAM RTX 5070Ti 16GB GAMER PC termékbeszámítással
- AKCIÓ! HP EliteBook x360 830 G7 i5-10210U 16GB 1000GB 1 év garancia
- darkFlash GR12 Darkstorm Blue/Green
- Microsoft Surface Laptop 3 13.5" fekete i5-1035G7 16GB 512GB 1 év garancia
Állásajánlatok
Cég: Laptopszaki Kft.
Város: Budapest
Cég: BroadBit Hungary Kft.
Város: Budakeszi

