Ú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
- Asus Rog Strix B250f Gaming
- ÁRGARANCIA! Épített KomPhone Ultra 7 265KF 32/64GB RAM RX 9070 XT 16GB GAMER PC termékbeszámítással
- Apple iPhone 13 Pro Max 256GB - ÚJSZERŰ, Kártyafüggetlen, Ezüst, 100% Akku - 1 Év Garanciával
- LG 40U990A-W / 40" Ívelt Nano IPS Black / 5K UHD 120Hz / 2x ThunderBolt 5.0 / Adobe RGB 99%
- LENOVO TABLET 10 (N4100),10.1",WUXGA, 2-IN-1 TABLET,Ceruza,LTE kártya,8GB DDR4,128GB SSD,WIN11
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
