Results 1 to 7 of 7

Thread: - - Python

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Jan:2011
    Location:
    Posts: 306

    - - Python

    , Codefights . , - ( ). 66 Python 3 :

    Code:
    def checkWeights(b, p):
        return p - sum([sum(range(x[0],x[1] + 1)) for x in b])
    , 51 .
    Asrock Z370 Gaming K6 | i7-8700k | FD Celsius S24 | FD Define R5 | Corsair 2X8GB 3000Mhz |MSI GTX1080 Gaming |Samsung 960 Evo 512GB | Seagate 2TB | Corsair RM1000W | Acer xb271hu | Corsair K70 RGB KB |Logitech G900 mouse |Razer Vespula Pad |Arctis Pro Wireless HS

  2. #2
    Registered User
    Join Date: Aug:2003
    Location:
    Posts: 175
    , sum(1..n)=n*(n+1)/2 n m. .
    58 . .

  3. #3
    Registered User
    Join Date: Jul:2004
    Location:
    Posts: 621
    @-RVG-: : "x[i]", "b" : "for x, y in b". "sum(range(x, y+1))" .
    55
    Last edited by DimKo; 1st April 2017 at 01:18.

  4. #4
    Registered User
    Join Date: Jan:2011
    Location:
    Posts: 306
    , 60 . . :
    Code:
    return p - sum([(x+y)/2*(y-x+1) for x,y in b])
    Last edited by -RVG-; 1st April 2017 at 01:55.
    Asrock Z370 Gaming K6 | i7-8700k | FD Celsius S24 | FD Define R5 | Corsair 2X8GB 3000Mhz |MSI GTX1080 Gaming |Samsung 960 Evo 512GB | Seagate 2TB | Corsair RM1000W | Acer xb271hu | Corsair K70 RGB KB |Logitech G900 mouse |Razer Vespula Pad |Arctis Pro Wireless HS

  5. #5
    ɐ-əpoɔᴉu⋂ ɐ ə anrieff's Avatar
    Join Date: Apr:2004
    Location: Sofia
    Posts: 8,448
    Quote Originally Posted by DimKo View Post
    @-RVG-: : "x[i]", "b" : "for x, y in b". "sum(range(x, y+1))" .
    55
    DimKo, 55? 58 .
    Python:

    Code:
    def checkWeights(boxes, packageWeight):
        return something

    Code:
    checkWeights = lambda boxes, packageWeight: something
    . 4 54.
    , . .
    "640K ught to be enough for anybody" - Bill Gates, 1981
    ::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel

  6. #6
    Registered User
    Join Date: Jul:2004
    Location:
    Posts: 621
    Code:
    # 58
    def checkWeights(b, p):
      return p - sum([y*y - x*x + y + x for x, y in b])/2
    
    # 56
    def checkWeights(b, p):
      return p - sum(y*y - x*x + y + x for x, y in b)/2
    
    # 55
    def checkWeights(b, p):
      for x, y in b:
        p -= y*y - x*x + y + x >> 1    
      return p
    
    # 52
    checkWeights = lambda b, p: p - sum(y*y - x*x + y + x for x, y in b)/2
    55 lambda-...

  7. #7
    ɐ-əpoɔᴉu⋂ ɐ ə anrieff's Avatar
    Join Date: Apr:2004
    Location: Sofia
    Posts: 8,448
    -
    Code:
    checkWeights = lambda b,p: p - sum( a-a*a-c*~c for a,c in b )/2
    , , : ~x == -x - 1
    , . .
    "640K ught to be enough for anybody" - Bill Gates, 1981
    ::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |