Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

60%
+1 −0
Challenges Are they abundant, deficient or perfect?

Python 3, 235 185 141 118 bytes a=[[],[],[]] n=1;exec("d=sum(i for i in range(1,n)if n%i<1)-n;a[[[1,2][d<0],0][d>0]]+=n,;n+=1;"*int(input())) print(a) Try it online! Golfed 50 byt...

posted 3y ago by General Sebast1an‭  ·  edited 2y ago by General Sebast1an‭

Answer
#4: Post edited by user avatar General Sebast1an‭ · 2021-08-11T13:17:40Z (over 2 years ago)
  • # [Python 3], <s>235</s> <s>185</s> 141 bytes
  • <!-- language-all: lang-python -->
  • <pre><code>b=[];c=[];a=[]
  • for n in range(1,int(input())+1):
  • &#9;d=sum(i for i in range(1,n)if n%i&lt;1)
  • &#9;if d&gt;n:a+=n,
  • &#9;elif d&lt;n:b+=n,
  • &#9;else:c+=n,
  • print(a,c,b)
  • </code></pre>
  • [Try it online!][TIO-ks770mv3]
  • Golfed 50 bytes by [**@caird coinheringaahing**](https://codegolf.codidact.com/users/53912). Golfed 44 bytes by [**@bastolki**](https://codegolf.codidact.com/users/54221).
  • [Python 3]: https://docs.python.org/3/
  • [TIO-ks770mv3]: https://tio.run/##TY3BCgIhFEXX@hVvE/gYNxJtbOxHooU6Tj2oN@I4i77exiBoc7gHDtz8ro@Fj60Fd72dY4ffIeelAAMxFM/3pIwmroo4b1UhDgatFJNbt5ci6Cn9p4w0Ax9oNCjFPqcLWz841lKkZ/eRbfj5mmz87lz6hddRB2zNnD4 "Python 3 – Try It Online"
  • # [Python 3], <s>235</s> <s>185</s> <s>141</s> 118 bytes
  • <!-- language-all: lang-python -->
  • a=[[],[],[]]
  • n=1;exec("d=sum(i for i in range(1,n)if n%i<1)-n;a[[[1,2][d<0],0][d>0]]+=n,;n+=1;"*int(input()))
  • print(a)
  • [Try it online!][TIO-ks7io3nw]
  • Golfed 50 bytes by [**@caird coinheringaahing**](https://codegolf.codidact.com/users/53912). Golfed 44 bytes by [**@bastolki**](https://codegolf.codidact.com/users/54221). Golfed another 23 bytes by [**@bastolki**](https://codegolf.codidact.com/users/54221).
  • [Python 3]: https://docs.python.org/3/
  • [TIO-ks7io3nw]: https://tio.run/##HYxBCsIwEADvfUUoCFkbIVE8pfEjyx6CTXUPbkOagr4@VmFgmMvkT30ucmktBkQyf6iT4Hx6p7vup7BuL81qXopixaJKlEfSzgjwrOTAo4OT@IiIzpwJp9GSsbtvlmgIYrwM@6w/slTNkreqAaDL5dcRWnPXLw "Python 3 – Try It Online"
#3: Post edited by user avatar General Sebast1an‭ · 2021-08-11T07:58:04Z (over 2 years ago)
  • # [Python 3], <s>235</s> 185 bytes
  • <!-- language-all: lang-python -->
  • <pre><code>b=[1];c=[];a=[]
  • for n in range(2,int(input())+1):
  • &#9;d=1
  • &#9;for i in range(2,int(n**.5)+1):
  • &#9;&#9;if n%i&lt;1:
  • &#9;&#9;&#9;d+=i;j=n//i
  • &#9;&#9;&#9;if j!=i:d+=j
  • &#9;if d&gt;n:a+=n,
  • &#9;elif d&lt;n:b+=n,
  • &#9;else:c+=n,
  • print(a,c,b)
  • </code></pre>
  • [Try it online!][TIO-kq7n6zf0]
  • -50 by caird coinheringaahing
  • [Python 3]: https://docs.python.org/3/
  • [TIO-kq7n6zf0]: https://tio.run/##XY3LDoIwEEXX7VfUhQmljaQaNoXxRwiL8tJpyEAqLvz6So1u3NzcM3OSu762@0KXGDtoTFv10LSV24NPSxAkkERwdBuzs0baMqT1uWVSKiMtZwMYzpKH/x7l@an8WgwnQUesTepsUICVByoKTLj//AHQ7mfPEw1Xsk4Bac7GOXFNtvvxY7T9p68hrTjd607GaMo3 "Python 3 – Try It Online"
  • # [Python 3], <s>235</s> <s>185</s> 141 bytes
  • <!-- language-all: lang-python -->
  • <pre><code>b=[];c=[];a=[]
  • for n in range(1,int(input())+1):
  • &#9;d=sum(i for i in range(1,n)if n%i&lt;1)
  • &#9;if d&gt;n:a+=n,
  • &#9;elif d&lt;n:b+=n,
  • &#9;else:c+=n,
  • print(a,c,b)
  • </code></pre>
  • [Try it online!][TIO-ks770mv3]
  • Golfed 50 bytes by [**@caird coinheringaahing**](https://codegolf.codidact.com/users/53912). Golfed 44 bytes by [**@bastolki**](https://codegolf.codidact.com/users/54221).
  • [Python 3]: https://docs.python.org/3/
  • [TIO-ks770mv3]: https://tio.run/##TY3BCgIhFEXX@hVvE/gYNxJtbOxHooU6Tj2oN@I4i77exiBoc7gHDtz8ro@Fj60Fd72dY4ffIeelAAMxFM/3pIwmroo4b1UhDgatFJNbt5ci6Cn9p4w0Ax9oNCjFPqcLWz841lKkZ/eRbfj5mmz87lz6hddRB2zNnD4 "Python 3 – Try It Online"
#2: Post edited by (deleted user) · 2021-06-22T06:05:02Z (almost 3 years ago)
  • # [Python 3], 235 bytes
  • <!-- language-all: lang-python -->
  • <pre><code>from math import *
  • x=int(input());b=[ 1 ];c=[];a=[]
  • for n in range(2,x+1):
  • &#9;d=1
  • &#9;for i in range(2,int(sqrt(n))+1):
  • &#9;&#9;if n%i==0:
  • &#9;&#9;&#9;d+=i;j=n//i
  • &#9;&#9;&#9;if j!=i:d+=j
  • &#9;if d&gt;n:a.append(n)
  • &#9;elif d&lt;n:b.append(n)
  • &#9;else:c.append(n)
  • print([ a,c,b ])
  • </code></pre>
  • [Try it online!][TIO-kq6hualg]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-kq6hualg]: https://tio.run/##VY3LDoIwEEXX7VeMCxMqREXjpjj@CGFRXjJEhlprol9fadzoZpJ7zs0d@/bDzMcQejdPMBk/AE12dh428oXEPiG2T58oVdRYQg5V0WBZFWY5sp8dMBCDM3ztkkP2SnOlpWgxlyJK@pVx7HF3PmGlvj1BPfCaEPcxiDZFKkbk3Y5iXOS4QtILHmVM7YW12RprO26XESm6W6Rn1vU/fXS6@SHWxdclmKzJaqhUCPnpAw "Python 3 – Try It Online"
  • # [Python 3], <s>235</s> 185 bytes
  • <!-- language-all: lang-python -->
  • <pre><code>b=[1];c=[];a=[]
  • for n in range(2,int(input())+1):
  • &#9;d=1
  • &#9;for i in range(2,int(n**.5)+1):
  • &#9;&#9;if n%i&lt;1:
  • &#9;&#9;&#9;d+=i;j=n//i
  • &#9;&#9;&#9;if j!=i:d+=j
  • &#9;if d&gt;n:a+=n,
  • &#9;elif d&lt;n:b+=n,
  • &#9;else:c+=n,
  • print(a,c,b)
  • </code></pre>
  • [Try it online!][TIO-kq7n6zf0]
  • -50 by caird coinheringaahing
  • [Python 3]: https://docs.python.org/3/
  • [TIO-kq7n6zf0]: https://tio.run/##XY3LDoIwEEXX7VfUhQmljaQaNoXxRwiL8tJpyEAqLvz6So1u3NzcM3OSu762@0KXGDtoTFv10LSV24NPSxAkkERwdBuzs0baMqT1uWVSKiMtZwMYzpKH/x7l@an8WgwnQUesTepsUICVByoKTLj//AHQ7mfPEw1Xsk4Bac7GOXFNtvvxY7T9p68hrTjd607GaMo3 "Python 3 – Try It Online"
#1: Initial revision by (deleted user) · 2021-06-21T11:10:54Z (almost 3 years ago)
# [Python 3], 235 bytes

<!-- language-all: lang-python -->

<pre><code>from math import *
x=int(input());b=[ 1 ];c=[];a=[]
for n in range(2,x+1):
&#9;d=1
&#9;for i in range(2,int(sqrt(n))+1):
&#9;&#9;if n%i==0:
&#9;&#9;&#9;d+=i;j=n//i
&#9;&#9;&#9;if j!=i:d+=j
&#9;if d&gt;n:a.append(n)
&#9;elif d&lt;n:b.append(n)
&#9;else:c.append(n)
print([ a,c,b ])
</code></pre>

[Try it online!][TIO-kq6hualg]

[Python 3]: https://docs.python.org/3/
[TIO-kq6hualg]: https://tio.run/##VY3LDoIwEEXX7VeMCxMqREXjpjj@CGFRXjJEhlprol9fadzoZpJ7zs0d@/bDzMcQejdPMBk/AE12dh428oXEPiG2T58oVdRYQg5V0WBZFWY5sp8dMBCDM3ztkkP2SnOlpWgxlyJK@pVx7HF3PmGlvj1BPfCaEPcxiDZFKkbk3Y5iXOS4QtILHmVM7YW12RprO26XESm6W6Rn1vU/fXS6@SHWxdclmKzJaqhUCPnpAw "Python 3 – Try It Online"