Results 1 to 7 of 7
Thread: - - Python
Hybrid View
-
31st March 2017 19:00 #1Registered User
Join Date: Jan:2011
Location:
Posts: 306
- - Python
, Codefights . , - ( ). 66 Python 3 :
, 51 .Code:def checkWeights(b, p): return p - sum([sum(range(x[0],x[1] + 1)) for x in b])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
-
1st April 2017 01:08 #2Registered User
Join Date: Aug:2003
Location:
Posts: 175
, sum(1..n)=n*(n+1)/2 n m. .
58 . .
-
1st April 2017 01:14 #3Registered 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.
-
1st April 2017 01:54 #4Registered 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
-
1st April 2017 11:27 #5, . .
"640K ught to be enough for anybody" - Bill Gates, 1981
::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel
-
1st April 2017 11:56 #6Registered User
Join Date: Jul:2004
Location:
Posts: 621
55 lambda-...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
-
2nd April 2017 02:25 #7
-
, , : ~x == -x - 1Code:checkWeights = lambda b,p: p - sum( a-a*a-c*~c for a,c in b )/2
, . .
"640K ught to be enough for anybody" - Bill Gates, 1981
::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel




Reply With Quote

Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in