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

75%
+4 −0
Challenges Are they abundant, deficient or perfect?

Vyxal, 30 28 25 bytes Saved 1 4 bytes thanks to Aaron Miller ƛ∆K-±";£kɽƛ¥D„£_'t¥=;vṪ,£ Try it Online! A rather pitiful answer, but hey, it works. Gives deficient numbers, then perfect numbers...

posted 3y ago by user‭  ·  edited 3y ago by user‭

Answer
#3: Post edited by user avatar user‭ · 2021-06-16T19:33:48Z (over 3 years ago)
  • # [Vyxal](https://github.com/Lyxal/Vyxal), <s>30</s> 28 bytes
  • Saved 1 byte thanks to Aaron Miller
  • ```
  • ƛD∆K-±$";£kɽƛ¥D„£_'h¥=;ƛḢ;
  • ```
  • [Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=%C6%9BD%E2%88%86K-%C2%B1%24%22%3B%C2%A3k%C9%BD%C6%9B%C2%A5D%E2%80%9E%C2%A3_'h%C2%A5%3D%3B%C6%9B%E1%B8%A2%3B%2C%C2%A3&inputs=49&header=&footer=)
  • A rather pitiful answer, but hey, it works. Gives deficient numbers, then perfect numbers, then abundant numbers.
  • ```
  • ƛD∆K-±$";£
  • ƛ ; #For every number in the range [1,n]
  • D #Triplicate it
  • ∆K #Sum its proper divisors
  • - #Subtract the original number from that
  • ± #Get the sign of that (-1, 0, or 1)
  • $" #Make a 2-element list [sign, orig_num]
  • #Sort it
  • £ #Store it in the register
  • ```
  • For an input of 12, this gives `⟨⟨1|1⟩|⟨1|2⟩|⟨1|3⟩|⟨1|4⟩|⟨1|5⟩|⟨0|6⟩|⟨1|7⟩|⟨1|8⟩|⟨1|9⟩|⟨1|10⟩|⟨1|11⟩|⟨-1|12⟩⟩` (0 means perfect, -1 means deficient, 1 means abundant).
  • ```
  • kɽƛ¥D„£_'h¥=;ƛḢ;,£
  • kɽ #Push [-1, 0, 1]
  • ƛ #For every number in that range
  • ¥D #Make three copies of the register (the list above)
  • „ #Rotate stack so -1, 0, or 1 is on top
  • £_ #Store to register temporarily
  • ' ; #Filter the list from above
  • h #Take the head of each
  • ¥= #Keep if it equals the current element from [-1,0,1]
  • ƛḢ; #Drop the sign from each
  • , #Print this list of numbers
  • £ #Store original list to register again
  • ```
  • # [Vyxal](https://github.com/Lyxal/Vyxal), <s>30</s> <s>28</s> 25 bytes
  • Saved <s>1</s> 4 bytes thanks to Aaron Miller
  • ```
  • ƛ∆K-±";£kɽƛ¥D„£_'t¥=;vṪ
  • ```
  • [Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=%C6%9B%E2%88%86K-%C2%B1%22%3B%C2%A3k%C9%BD%C6%9B%C2%A5D%E2%80%9E%C2%A3_'t%C2%A5%3D%3Bv%E1%B9%AA%2C%C2%A3&inputs=49&header=&footer=)
  • A rather pitiful answer, but hey, it works. Gives deficient numbers, then perfect numbers, then abundant numbers.
  • ```
  • ƛD∆K-±$";£
  • ƛ ; #For every number in the range [1,n]
  • D #Triplicate it
  • ∆K #Sum its proper divisors
  • - #Subtract the original number from that
  • ± #Get the sign of that (-1, 0, or 1)
  • $" #Make a 2-element list [sign, orig_num]
  • #Sort it
  • £ #Store it in the register
  • ```
  • For an input of 12, this gives `⟨⟨1|1⟩|⟨1|2⟩|⟨1|3⟩|⟨1|4⟩|⟨1|5⟩|⟨0|6⟩|⟨1|7⟩|⟨1|8⟩|⟨1|9⟩|⟨1|10⟩|⟨1|11⟩|⟨-1|12⟩⟩` (0 means perfect, -1 means deficient, 1 means abundant). The explanation's old.
  • ```
  • kɽƛ¥D„£_'h¥=;ƛḢ;,£
  • kɽ #Push [-1, 0, 1]
  • ƛ #For every number in that range
  • ¥D #Make three copies of the register (the list above)
  • „ #Rotate stack so -1, 0, or 1 is on top
  • £_ #Store to register temporarily
  • ' ; #Filter the list from above
  • h #Take the head of each
  • ¥= #Keep if it equals the current element from [-1,0,1]
  • ƛḢ; #Drop the sign from each
  • , #Print this list of numbers
  • £ #Store original list to register again
  • ```
#2: Post edited by user avatar user‭ · 2021-06-16T18:25:46Z (over 3 years ago)
  • # [Vyxal](https://github.com/Lyxal/Vyxal), 30 bytes
  • ```
  • ɾƛD∆K-±$";s£kɽƛ¥D„£_'h¥=;ƛḢ;,£
  • ```
  • [Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=%C9%BE%C6%9BD%E2%88%86K-%C2%B1%24%22%3Bs%C2%A3k%C9%BD%C6%9B%C2%A5D%E2%80%9E%C2%A3_'h%C2%A5%3D%3B%C6%9B%E1%B8%A2%3B%2C%C2%A3&inputs=49&header=&footer=)
  • A rather pitiful answer, but hey, it works. Explanation coming soon.
  • # [Vyxal](https://github.com/Lyxal/Vyxal), <s>30</s> 28 bytes
  • Saved 1 byte thanks to Aaron Miller
  • ```
  • ƛD∆K-±$";£kɽƛ¥D„£_'h¥=;ƛḢ;,£
  • ```
  • [Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=%C6%9BD%E2%88%86K-%C2%B1%24%22%3B%C2%A3k%C9%BD%C6%9B%C2%A5D%E2%80%9E%C2%A3_'h%C2%A5%3D%3B%C6%9B%E1%B8%A2%3B%2C%C2%A3&inputs=49&header=&footer=)
  • A rather pitiful answer, but hey, it works. Gives deficient numbers, then perfect numbers, then abundant numbers.
  • ```
  • ƛD∆K-±$";£
  • ƛ ; #For every number in the range [1,n]
  • D #Triplicate it
  • ∆K #Sum its proper divisors
  • - #Subtract the original number from that
  • ± #Get the sign of that (-1, 0, or 1)
  • $" #Make a 2-element list [sign, orig_num]
  • #Sort it
  • £ #Store it in the register
  • ```
  • For an input of 12, this gives `⟨⟨1|1⟩|⟨1|2⟩|⟨1|3⟩|⟨1|4⟩|⟨1|5⟩|⟨0|6⟩|⟨1|7⟩|⟨1|8⟩|⟨1|9⟩|⟨1|10⟩|⟨1|11⟩|⟨-1|12⟩⟩` (0 means perfect, -1 means deficient, 1 means abundant).
  • ```
  • kɽƛ¥D„£_'h¥=;ƛḢ;,£
  • kɽ #Push [-1, 0, 1]
  • ƛ #For every number in that range
  • ¥D #Make three copies of the register (the list above)
  • „ #Rotate stack so -1, 0, or 1 is on top
  • £_ #Store to register temporarily
  • ' ; #Filter the list from above
  • h #Take the head of each
  • ¥= #Keep if it equals the current element from [-1,0,1]
  • ƛḢ; #Drop the sign from each
  • , #Print this list of numbers
  • £ #Store original list to register again
  • ```
#1: Initial revision by user avatar user‭ · 2021-06-16T18:11:53Z (over 3 years ago)
# [Vyxal](https://github.com/Lyxal/Vyxal), 30 bytes
                    
```
ɾƛD∆K-±$";s£kɽƛ¥D„£_'h¥=;ƛḢ;,£
```

[Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=%C9%BE%C6%9BD%E2%88%86K-%C2%B1%24%22%3Bs%C2%A3k%C9%BD%C6%9B%C2%A5D%E2%80%9E%C2%A3_'h%C2%A5%3D%3B%C6%9B%E1%B8%A2%3B%2C%C2%A3&inputs=49&header=&footer=)

A rather pitiful answer, but hey, it works. Explanation coming soon.