Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > rec.puzzles > #28020

Re: Four Digit Code Problem

From ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups rec.puzzles
Subject Re: Four Digit Code Problem
Date 2026-08-20 11:58 +0000
Organization Stefan Ram
Message-ID <code-20260820125200@ram.dialup.fu-berlin.de> (permalink)
References <1166lru$3at5d$1@dont-email.me>

Show all headers | View raw


David Entwistle <qnivq.ragjvfgyr@ogvagrearg.pbz> wrote or quoted:
>    1. “Weighted prime product”: 2A + 3B + 5C + 7D = 111 
>    2. The 2-digit number AB is divisible by 3. 

  WARNING: PARTIAL SPOILER FOLLOWS BELOW THE SPOILER SPACE BELOW

























































  It seems, one might get exactly one solution, if the last condition
  with the "9" is removed.

import math
for i in range( 1000, 10000 ): # A != 0
 A, B, C, D =[ int( i )for i in str( i )]
 # digits are distinct   
 if A != B and A != B and A != D and B != C and B != D and C != D:
  # "Weighted prime product": 2A + 3B + 5C + 7D = 111
  if 2 * A + 3 * B + 5 * C + 7 * D == 111:
  # or 2 * 10 + A + 3 * 10 + B + 5 * 10 + C + 7 * 10 + D == 111:
   # The 2-digit number AB is divisible by 3   
   if int( ( A * 10 + B )/ 3 )== ( A * 10 + B )/ 3:
    # The 2-digit number CD is divisible by 4   
    if int( ( C * 10 + D )/ 4 )== ( C * 10 + D )/ 4:
     # gcd(AB,CD)=1
     if math.gcd(A * 10 + B,C * 10 + D)==1:
      # REMOVED: The 4-digit number ABCD is divisible by 9   
      # if int( ( A * 1000 + B * 100 + C * 10 + D )/ 9 )==\
      # ( A * 1000 + B * 100 + C * 10 + D )/ 9:
      print( f"{A}{B}{C}{D}" )

Back to rec.puzzles | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Four Digit Code Problem David Entwistle <qnivq.ragjvfgyr@ogvagrearg.pbz> - 2026-08-20 10:45 +0000
  Re: Four Digit Code Problem David Entwistle <qnivq.ragjvfgyr@ogvagrearg.pbz> - 2026-08-20 11:06 +0000
    Re: Four Digit Code Problem Phil Carmody <pc+usenet@asdf.org> - 2026-08-27 19:08 +0300
  Re: Four Digit Code Problem ram@zedat.fu-berlin.de (Stefan Ram) - 2026-08-20 11:58 +0000
    Re: Four Digit Code Problem David Entwistle <qnivq.ragjvfgyr@ogvagrearg.pbz> - 2026-08-20 15:42 +0000
      Re: Four Digit Code Problem David Entwistle <qnivq.ragjvfgyr@ogvagrearg.pbz> - 2026-08-20 15:50 +0000
  Re: Four Digit Code Problem James Dow Allen <user4353@newsgrouper.org.invalid> - 2026-08-20 12:51 +0000
    Re: Four Digit Code Problem David Entwistle <qnivq.ragjvfgyr@ogvagrearg.pbz> - 2026-08-20 15:32 +0000
      Re: Four Digit Code Problem Charlie Roberts <croberts@gmail.com> - 2026-08-22 13:05 -0400
      Re: Four Digit Code Problem Phil Carmody <pc+usenet@asdf.org> - 2026-08-27 22:37 +0300

csiph-web