Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

##SageMath:(削除) 143 (削除ここまで) 131 bytes

SageMath:(削除) 143 (削除ここまで) 131 bytes

x=1
def w():
 l=x.divisors()
 return 2*x>=sum(l)or max(2*x==sum(i)for i in subsets(l))
while n:
 while w():x+=1
 print x;n-=1;x+=1

It's moreorless not even golfed, there's not too much to golf anyways in the code. The biggest thing is that you should do the test 2*x>=sum(l) first, it would save a lot of computation time. One has to realize that max on booleans is or Second thing is that w(x) is False for weird numbers and True for non-weird numbers. Ungolfed version:

def w(x) :
 Divisors = x.divisors()
 return 2*x >= sum(Divisors) or max ( sum(SubS) == 2*x for SubS in subsets(Divisors) )
x=1
for k in xrange(n) :
 while w(x) : x += 1
 print x
 x += 1

##SageMath:(削除) 143 (削除ここまで) 131 bytes

x=1
def w():
 l=x.divisors()
 return 2*x>=sum(l)or max(2*x==sum(i)for i in subsets(l))
while n:
 while w():x+=1
 print x;n-=1;x+=1

It's moreorless not even golfed, there's not too much to golf anyways in the code. The biggest thing is that you should do the test 2*x>=sum(l) first, it would save a lot of computation time. One has to realize that max on booleans is or Second thing is that w(x) is False for weird numbers and True for non-weird numbers. Ungolfed version:

def w(x) :
 Divisors = x.divisors()
 return 2*x >= sum(Divisors) or max ( sum(SubS) == 2*x for SubS in subsets(Divisors) )
x=1
for k in xrange(n) :
 while w(x) : x += 1
 print x
 x += 1

SageMath:(削除) 143 (削除ここまで) 131 bytes

x=1
def w():
 l=x.divisors()
 return 2*x>=sum(l)or max(2*x==sum(i)for i in subsets(l))
while n:
 while w():x+=1
 print x;n-=1;x+=1

It's moreorless not even golfed, there's not too much to golf anyways in the code. The biggest thing is that you should do the test 2*x>=sum(l) first, it would save a lot of computation time. One has to realize that max on booleans is or Second thing is that w(x) is False for weird numbers and True for non-weird numbers. Ungolfed version:

def w(x) :
 Divisors = x.divisors()
 return 2*x >= sum(Divisors) or max ( sum(SubS) == 2*x for SubS in subsets(Divisors) )
x=1
for k in xrange(n) :
 while w(x) : x += 1
 print x
 x += 1
added 137 characters in body
Source Link
yo'
  • 613
  • 4
  • 8

##SageMath:(削除) 143 (削除ここまで) 131 bytes

x=1
def w():
 l=x.divisors()
 return 2*x>=sum(l)or max(2*x==sum(i)for i in subsets(l))
while n:
 while w():x+=1
 print x;n-=1;x+=1

It's moreorless not even golfed, there's not too much to golf anyways in the code. The biggest thing is that you should do the test 2*x>=sum(l) first, it would save a lot of computation time. One has to realize that max on booleans is or Second thing is that w(x) is False for weird numbers and True for non-weird numbers. Ungolfed version:

def w(x) :
 Divisors = x.divisors()
 return 2*x >= sum(Divisors) or max ( sum(SubS) == 2*x for SubS in subsets(Divisors) )
x=1
for k in xrange(n) :
 while not w(x) : x += 1
 print x
 x += 1

##SageMath:(削除) 143 (削除ここまで) 131 bytes

x=1
def w():
 l=x.divisors()
 return 2*x>=sum(l)or max(2*x==sum(i)for i in subsets(l))
while n:
 while w():x+=1
 print x;n-=1;x+=1

It's moreorless not even golfed, there's not too much to golf anyways in the code. The biggest thing is that you should do the test 2*x>=sum(l) first, it would save a lot of computation time. Ungolfed version:

def w(x) :
 Divisors = x.divisors()
 return 2*x >= sum(Divisors) or max ( sum(SubS) == 2*x for SubS in subsets(Divisors) )
x=1
for k in xrange(n) :
 while not w(x) : x += 1
 print x
 x += 1

##SageMath:(削除) 143 (削除ここまで) 131 bytes

x=1
def w():
 l=x.divisors()
 return 2*x>=sum(l)or max(2*x==sum(i)for i in subsets(l))
while n:
 while w():x+=1
 print x;n-=1;x+=1

It's moreorless not even golfed, there's not too much to golf anyways in the code. The biggest thing is that you should do the test 2*x>=sum(l) first, it would save a lot of computation time. One has to realize that max on booleans is or Second thing is that w(x) is False for weird numbers and True for non-weird numbers. Ungolfed version:

def w(x) :
 Divisors = x.divisors()
 return 2*x >= sum(Divisors) or max ( sum(SubS) == 2*x for SubS in subsets(Divisors) )
x=1
for k in xrange(n) :
 while w(x) : x += 1
 print x
 x += 1
deleted 63 characters in body
Source Link
yo'
  • 613
  • 4
  • 8

##SageMath: 143(削除) 143 (削除ここまで) 131 bytes

x=1
def w(x):
 l=x.divisors()
 for i inreturn subsets2*x>=sum(l):
 ifor summax(2*x==sum(i)==2*x:returnfor 1
i returnin 2*x>=sumsubsets(l)
x=1)
while n:
 while w(x):x+=1
 print x;n-=1;x+=1

It's moreorless not even golfed, there's not too much to golf anyways in the code. The biggest thing is that you should do the test 2*x>=sum(l) first, it would save a lot of computation time. Ungolfed version:

def w(x) :
 Divisors = x.divisors()
 ifreturn 2*x >= sum(Divisors) : return False
 for SubDivor inmax subsets(Divisors):
  if sum(SubDivSubS) == 2*x :for returnSubS False
in returnsubsets(Divisors) True)
x=1
for k in xrange(n) :
 while not w(x) : x += 1
 print x
 x += 1

##SageMath: 143 bytes

def w(x):
 l=x.divisors()
 for i in subsets(l):
 if sum(i)==2*x:return 1
 return 2*x>=sum(l)
x=1
while n:
 while w(x):x+=1
 print x;n-=1;x+=1

It's moreorless not even golfed, there's not too much to golf anyways in the code. The biggest thing is that you should do the test 2*x>=sum(l) first, it would save a lot of computation time. Ungolfed version:

def w(x) :
 Divisors = x.divisors()
 if 2*x >= sum(Divisors) : return False
 for SubDiv in subsets(Divisors):
  if sum(SubDiv) == 2*x : return False
 return True
x=1
for k in xrange(n) :
 while not w(x) : x += 1
 print x
 x += 1

##SageMath:(削除) 143 (削除ここまで) 131 bytes

x=1
def w():
 l=x.divisors()
 return 2*x>=sum(l)or max(2*x==sum(i)for i in subsets(l))
while n:
 while w():x+=1
 print x;n-=1;x+=1

It's moreorless not even golfed, there's not too much to golf anyways in the code. The biggest thing is that you should do the test 2*x>=sum(l) first, it would save a lot of computation time. Ungolfed version:

def w(x) :
 Divisors = x.divisors()
 return 2*x >= sum(Divisors) or max ( sum(SubS) == 2*x for SubS in subsets(Divisors) )
x=1
for k in xrange(n) :
 while not w(x) : x += 1
 print x
 x += 1
Source Link
yo'
  • 613
  • 4
  • 8
Loading

AltStyle によって変換されたページ (->オリジナル) /