Post History
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...
Answer
#3: Post edited
# [Vyxal](https://github.com/Lyxal/Vyxal), <s>30</s> 28 bytesSaved 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
# [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
# [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.