Python Forum
I code a program to solve puzzle but i can't make it more dynamic.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I code a program to solve puzzle but i can't make it more dynamic.
#2
Maybe run two loops: one for the number to check, one for the division test.

max_check = 10000
dividends = [3, 4, 7, 5, 6, 8, 9]
for n in range(1,max_check):
    for dividend in dividends:
        if n % dividend:
            break
    else:
        print(f"{n} is evenly divided by {dividends}")
        break
else:
    print(f"No numbers found evenly divisible by {dividends} that are less than {max_check}")
Reply


Messages In This Thread
RE: I code a program to solve puzzle but i can't make it more dynamic. - by bowlofred - Apr-16-2020, 09:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Frog Puzzle Random To Custom MoreMoney 4 540 Mar-26-2024, 08:38 AM
Last Post: MoreMoney
  hi need help to make this code work correctly atulkul1985 5 846 Nov-20-2023, 04:38 PM
Last Post: deanhystad
  newbie question - can't make code work tronic72 2 729 Oct-22-2023, 09:08 PM
Last Post: tronic72
  Cleaning my code to make it more efficient BSDevo 13 1,451 Sep-27-2023, 10:39 PM
Last Post: BSDevo
  Code challenge I need to solve for a Bootcamp ramonrocha 1 514 Sep-05-2023, 03:41 PM
Last Post: deanhystad
  how to make bot that sends instagram auto password reset code kraixx 2 1,451 Mar-04-2023, 09:59 PM
Last Post: jefsummers
  Make code non-blocking? Extra 0 1,172 Dec-03-2022, 10:07 PM
Last Post: Extra
  Make the code shorter quest 2 1,538 Mar-14-2022, 04:28 PM
Last Post: deanhystad
  Is it possible to make a program recognize how many clicks it has had on the monitor? jao 0 1,175 Feb-25-2022, 06:31 PM
Last Post: jao
  How would you (as an python expert) make this code more efficient/simple coder_sw99 3 1,841 Feb-21-2022, 10:52 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020