Answer-Chaining - Positive divisors of a number

13

3

This challenge is officially over, resulting in the win of Wheat Wizard, with a total of 7 answers. Any other answer is welcome, but it won't influence the accepted answer for this challenge, nor the winner.


Task:

Print all the positive divisors of a number x taken as input.

Input:

A single number x which is the number (in base 10) whose positive divisors should be computed.

Output:

All the positive divisors of x. Any format is allowed, including \n,,,; and whitespace as separators, as long as it's understandable. The output can be an array of Integers or Strings, too (e.g: [1, 2, 3, 5, 30]). You may output the divisors to stdout, console or the equivalent in your language or they can be returned from a function.


Rules

  • A user may not answer twice in a row
  • Your answer may remove, add or replace at most 15 characters from the previous answer (whitespace does not count), besides for Answer 2 which can "transform" up to 20 characters to get things started
  • You are not allowed to post an answer in a programming language that already has an answer, the exception being a completely different version of that language (e.g: If I post an answer in Python 2.7, you can submit one in Python 3, but not in Python 2.6)
  • Standard loopholes are not allowed
  • You are not allowed to use built-ins for getting divisors, for the sake of this challenge
  • You must include the answer's number and the language name in the question's title and the number of characters changed from the previous answer

Scoring

The user with the most submissions once the things settle out wins. In case of a tie, the user with the highest score on one of their answer wins. If there is a tie at the score as well, then the user with the oldest submission(oldest highest-scored answer) will be declared the winner.

Note: "settle out" <=> 7 3 days have passed since the last answer was submitted


Examples:

Input, Output:

14 => [1, 2, 7, 14]
25 => [1, 5, 25]
65 => [1, 5, 13, 65]
114 => [1, 2, 3, 6, 19, 38, 57, 114]

Or any other equivalent output satisfying the mentioned conditions.


Final Note: This question is better if you sort the answers by the oldest. I'll post the first answer in Python 2.7, so you should post the second answer depending on that one. Good luck and have fun!


Leaderboard:

This list may be outdated, fell free to edit it:

1) Wheat Wizard [Current Leader ]: 7 answers - Python 1.6, 05AB1E, Actually, Del|m|t, WSF, Brain-Flak, Lenguage

2) Riley: 3 answers - Seriously, CJam, 2sable

3) Jonathan Allan: 2 answers - Python 3, Jelly

3) ETHproductions: 2 answers - Japt, Pyth

3) Mistah Figgins: 2 answers - Befunge-98, Brain-Flak Classic

6) Riker: 1 answer - MATL

6) dzaima: 1 answer - SOGL 0.8.2

6) LegionMammal978: 1 answer - Whitespace

6) Nick Clifford: 1 answer - Ohm

6) Lynn: 1 answer - GolfScript

6) MickyT: 1 answer - Cubix

Distance calculator

You can use this snippet to calculate the distance between two entries:

function L(s,t){if(s===t)return 0;var S=s.length,T=t.length;if(S*T===0)return S+T;for(var i=0,v0=[],v1=[];i<=T;i++)v0[i]=i;for(i=0;i<S;i++){v1[0]=i+1;for(var j=0;j<T;j++)v1[j+1]=Math.min(v1[j]+1,v0[j+1]+1,v0[j]+(s[i]!=t[j]));for(j=0;j<=T;j++)v0[j]=v1[j]}return v1[T]}
<textarea id=A rows=10></textarea><textarea id=B rows=10></textarea><br>
Distance: <span id=O>0</span> <button onclick="O.innerHTML=L(A.value.replace(/\s/g,''),B.value.replace(/\s/g,''))">Run</button>

Mr. Xcoder

Posted 2017-03-09T19:40:43.707

Reputation: 39 774

15 will work, 10 is standard though. I'd say keep it at 15 though, because this is harder than most. – Rɪᴋᴇʀ – 2017-03-09T19:52:49.333

2I hope you don't mind, but I added a distance calculator snippet to the bottom of the post :-) – ETHproductions – 2017-03-09T20:37:04.780

How can I possibly mind for improving the post? Thanks @ETHproductions – Mr. Xcoder – 2017-03-09T21:29:15.653

Would a function that finds most of the devisors but not all of them be considered a built in? – Post Rock Garf Hunter – 2017-03-10T00:33:18.420

@WheatWizard No, you are not allowed to use any kind of divisor built-in, it simplyfies your job but makes it very hard for others in programming languages that do not have useful built-ins – Mr. Xcoder – 2017-03-10T05:35:52.803

2That collaborative work to go toward brainfuck is beautiful :) – Walfrat – 2017-03-10T12:59:09.577

6IMPORTANT: Please edit the leaderboard when you make a submission, so it's easier to maintain.. – Mr. Xcoder – 2017-03-10T16:10:34.657

2It is awesome to see people bring the answers from Python to Brain-Flak, with a great collaborative work, from a widely spread language to one of the most obscure programming language ever created. Thanks to all who made it happen! Now I'm really interested to see what happens with this challenge, since DjMcMayhem has put a bounty on it. – Mr. Xcoder – 2017-03-15T05:52:23.893

BTW, there has to be bounties for helpers too. Probably 50 or 100? – Matthew Roh – 2017-03-15T13:15:53.637

Does the challenge being over mean that you still update the scoreboard, or that you can answer twice in a row? – MildlyMilquetoast – 2017-03-25T18:14:53.333

I don't update the leaderboard. It is officially closed. However, you can upload 2 answers in a row now, but they won't count to the leaderboard – Mr. Xcoder – 2017-03-25T18:16:26.033

Answers

12

Answer 20, Brain-Flak, 11

I would like to just take the time to thank everyone that has helped contribute to this goal:

  • Riley, 20 bytes

  • LegionMammal, 15 bytes

  • ETHproductions, 11 bytes

  • Lynn, 1 byte

The following users were not able to contribute bytes directly but did help in other ways:

  • Mistah Figgins

  • DJMcMayhem

  • feersum

Thanks everyone for making this possible!

"qd:A(),(;{A\%!},pe#&f!0pv'%QTS|Q@░┼_¥f::+!vUGw
)((({})<>)){((({}[()]<n=int(input({})(<>))><>)<{i=1div=wvhile(({})){({}[()])<>}{}}{}<>([{}()]{})><>)<>{ifn%i==g00div.append(<{}<>{}<>>i)i=i+1}{}printdiv)}
#R
{}T:.eX╜R;j`;╜0%Y*`M∩\"ILD¹s%_Ï,

Try it online!

Post Rock Garf Hunter

Posted 2017-03-09T19:40:43.707

Reputation: 55 382

6Finally, Brain Flak! Thanks to all who helped achieving this goal! Congratulations to Wheat Wizard for being the user with the most answers so far and for the great work and time spent around this challenge! – Mr. Xcoder – 2017-03-14T18:56:37.090

7

Answer 3: MATL, Distance 15

:tGw\~)
%n=int(input())
%i=1
%div=[]
%while (i<=n):
%    if n % i == 0:
%        div.append(i)
%    i+=1
%print(div)

Rɪᴋᴇʀ

Posted 2017-03-09T19:40:43.707

Reputation: 7 410

2MATL's % make it really hard to continue. Good luck to others and I really hope that this challenge won't "die" here! – Mr. Xcoder – 2017-03-09T20:20:15.243

Isn't this using a built in? – Jonathan Allan – 2017-03-09T20:29:21.807

@JonathanAllan No, definitely not. The builtin for divisors is Z\. The relevant code here is the :tGw\~) (which I wrote in chat, not a builtin) – James – 2017-03-09T20:31:42.277

Indeed, there is no built-in – Mr. Xcoder – 2017-03-09T20:32:33.950

@DJMcMayhem sure I can see the code, just saw \ in a table in MATL doc as "divisors" and thought the rest was getting input or something. – Jonathan Allan – 2017-03-09T20:37:12.740

1

@JonathanAllan The table can be a little confusing. Z\, not \, is "divisors". The heading in the last three columns indicates the prefix (X, Y, or Z). \ by itself is the first column, i.e. "mod"

– Luis Mendo – 2017-03-09T21:11:06.323

7

Answer 7, Japt, 15

ò f!vU"Gw\((()<>))
n=int(input())
i=1
div=[]
while (i<=n):
    if n % i == 0:
        div.append(i)
    i=i+1
print(div)#Rḍ⁸T”

Try it online!

Changed #b∫I:b;\?t to ò f!vU (10 points) and added some more Brain-Flak code by changing ~(() to ((()<>)) (5 points). I believe the code we're working toward is

((({})<>)){((({}[()]<(({})(<>))><>)<{(({})){({}[()])<>}{}}{}<>([{}()]{})><>)<>{(<{}<>{}<>>)}{})}{}

Explanation

ò           Generate the range [0...input].
  f         Filter to only items Z where
   !vU        U.v(Z) returns truthily. (`fvU` would be Z.v(U))
              This returns true if U is divisible by Z, false otherwise.
      "...  The rest of the program is enclosed in this string, which is passed as an extra
            argument to `f`. Fortunately, `f` ignores it.
            Implicit: output result of last expression

ETHproductions

Posted 2017-03-09T19:40:43.707

Reputation: 47 880

6

Answer 8, 05AB1E, 14

"'ò f!vUGw\((()<>)){((({'
n=int(input())
i=1
div=[]
while (i<=n):
    if n % i == 0:
        div.append(i)
    i=i+1
print(div)
'#Rḍ⁸T”'".e

Try it online!

Explanation

Luckily 05AB1E has a builtin Python interpreter (of sorts). In order to make this run we push

'ò f!vUGw\((()<>)){((({'
n=int(input())
i=1
div=[]
while (i<=n):
    if n % i == 0:
        div.append(i)
    i=i+1
print(div)
'#Rḍ⁸T”'

as a string to the top of the stack. We have to use string literals instead of comments here because 05AB1E really doesn't like comments in its Python code. We also have to get rid of the " in the original code because it causes the string to end prematurely.

Once the string has been pushed we use .e to execute it as python code.

Work towards Brain-Flak

I was able to add 5 extra characters towards the goal of making a Brain-Flak answer. I would have been able to add 6 but alas I forgot whitespace doesn't count towards the point score.

So far we have:

((({})<>)){((({}     ((  )   )       (              <              )           (          )   )
((({})<>)){((({}[()]<(({})(<>))><>)<{(({})){({}[()])<>}{}}{}<>([{}()]{})><>)<>{(<{}<>{}<>>)}{})}{}

Post Rock Garf Hunter

Posted 2017-03-09T19:40:43.707

Reputation: 55 382

6

Answer 13, Pyth, 15

f!%QTS|Q"@░┼_¥
f!vUGw((({})<>)){((({}[()]n=int(input({})(<>))i=1div=while((<>)){ifn%i==0div.append(i)i=i+1}printdiv)}#R{}T.eX
╜R;`;╜%Y*`M∩

Try it online!

Explanation

So I don't know much Pyth, but what I do know is that the source code is in the form of a tree, each command taking a specific number of arguments to its right. The tree of the divisor program I wrote looks like this:

     f
    / \
   !   S
   |   |
   %   Q
  / \
 Q   T

Q is the input. f takes two arguments, F and A, and returns the items T in A where F(T) returns a truthy value. In this case, F is a function which returns the logical NOT of Q%T, and A is SQ, which creates the range [1...Q]. This has the effect of filtering to only the integers T in [1...Q] where Q%T == 0.

In order to avoid parsing the rest of the code, the entire thing is wrapped in a string, then |Q"... returns the logical OR of Q and the string. Since Q is always positive, it's always truthy, and thus always gets returned from the logical OR.


Work toward Brain-Flak

((({})<>)){((({}[()] (({})(<>))      ((             <>                 )   )  {(          )  })}{}
((({})<>)){((({}[()]<(({})(<>))><>)<{(({})){({}[()])<>}{}}{}<>([{}()]{})><>)<>{(<{}<>{}<>>)}{})}{}

ETHproductions

Posted 2017-03-09T19:40:43.707

Reputation: 47 880

Really curious to see who will submit the Brain-Flak answer, if it ever happens.. – Mr. Xcoder – 2017-03-10T16:12:01.323

We're getting closer. We should be there by answer 20 (if not earlier) – CalculatorFeline – 2017-03-10T16:14:05.360

Well, we've got 54 chars to go... – ETHproductions – 2017-03-10T16:16:53.023

Well, we're about halfway there, and this stated around answer 8, so we should finish around 18. – CalculatorFeline – 2017-03-10T16:19:21.260

6

Answer 16, GolfScript, 15

~:
),(;{
\%!},p#&f!0pv'%QTS|Q"@░┼_¥f::+!vUGw((({})<>)){((({}[()]<n=int(input({})(<>))><>)<{i=1div=wvhile(({})){({}<>)){ifn%i==g00div.append(i)i=i+1{}printdiv)}#R{}T:.eX╜R;j`;╜0%Y*`M∩\

Try it online!

I added ~:␤),(;{␤\%!},p#, using newline as a variable name to fit the size constraint, and squished the entire program back onto one line to comment it out. This was distance 14. Then, I added { before }printdiv for Brain-Flak.

~:␤                    Read input, store as NL
   ),(;                Range [1, 2... NL]
       {␤\%!},         Filter elements that divide NL
              p#       Print and comment everything else out

Work towards Brain-Flak

((({})<>)){((({}[()]<(({})(<>))><>)<{(({})){({}     <>                 )   )  {(          ) {})}{}
((({})<>)){((({}[()]<(({})(<>))><>)<{(({})){({}[()])<>}{}}{}<>([{}()]{})><>)<>{(<{}<>{}<>>)}{})}{}

Lynn

Posted 2017-03-09T19:40:43.707

Reputation: 55 648

6

Answer 17, CJam, 15

qd:A
),(;
{A\%!},p
e#&f!0pv'%QTS|Q"@░┼_¥f::+!vUGw((({})<>)){((({}[()]<n=int(input({})(<>))><>)<{i=1div=wvhile(({})){({}[()])<>}{}}{)){ifn%i==g00div.append(i)i=i+1{}printdiv)}#R{}T:.eX╜R;j`;╜0%Y*`M∩\

Try it online!

qd:A     # Get input as decimal and store it in A
),(;     # range [0..A]
{    },  # Filter where
 A\%!    # A mod this value == 0
       p # print 
e#...    # comment

Work towards Brain-Flak (30 to go)

)({}((({})<>)){((({}[()]<(({})(<>))><>)<{(({})){({}[()])<>}{}}{            )   )  {(          ) {})}{}
 (  (( {})<>)){((({}[()]<(({})(<>))><>)<{(({})){({}[()])<>}{}}{}<>([{}()]{})><>)<>{(<{}<>{}<>>)}{})}{}

Riley

Posted 2017-03-09T19:40:43.707

Reputation: 11 345

We are actually only 30 away. instead of omitting the extra 4 characters you can transform )({}((( to ()({})(( at the cost of only two, this is not the exact program we had in mind but () and ({}) are both no-ops in this context. – Post Rock Garf Hunter – 2017-03-13T16:30:44.183

@WheatWizard Nice! I didn't look at the actual code, just ran it through the distance checker in the question. – Riley – 2017-03-13T16:32:21.610

5

Answer 4 - Jelly, 4

:tGw\~)
%n=int(input())
%i=1
%div=[]
%while (i<=n):
%    if n % i == 0:
%        div.append(i)
%    i+=1
%print(div)Rḍ⁸T

Try it online!

Relevant code:

Rḍ⁸T

The ) acts as a break between links as far as the parser is concerned (I believe).

The built-in would be ÆD, instead this creates a range from 1 to the input with R, checks for divisibility by the input with ḍ⁸, then returns a list of the truthy one-based indexes with T.

Jonathan Allan

Posted 2017-03-09T19:40:43.707

Reputation: 67 804

5

Answer 9, Whitespace, 15

f!vUGw((({})<>)){((({}n=int(input())i=1div=while(i<=n):ifn%i==0:div.append(i)i=i+1printdiv)}#R{}T”.e<SPACES>

Where <SPACES> is replaced by the following string, where T is 0x09, L is 0x0A, and S is 0x20:

SSSLSLSTLTTTTTSSSLLSSSLSTSSTLSTSSTLTSSTLTSSSLSSSTLTSSSSTSSTLSTSSTLTSTTLTSTLLSLSL
LSSTLSLSTLSTSSSTSTSLTLSSLSLSLLSSSSLLLL

Literal newline added for clarity. Noticed that the rules only specify non-whitespace characters. Nope, couldn't help myself.

Work towards Brain-Flak

I have no idea what was going on earlier, so we now have:

((({})<>)){((({}     ((  )   )       (              <              )           (          )   )}{}
((({})<>)){((({}[()]<(({})(<>))><>)<{(({})){({}[()])<>}{}}{}<>([{}()]{})><>)<>{(<{}<>{}<>>)}{})}{}

LegionMammal978

Posted 2017-03-09T19:40:43.707

Reputation: 15 731

5

Answer 18, WSF, 15

q   

































































    d:A(),(;{A\%!},pe#&f!0pv'%QTS|Q"@░┼_¥f::+!vUGw)(({})<>)){((({}[()]<n=int(input({})(<>))><>)<{i=1div=wvhile(({})){({}[()])<>}{}}{}<>([{}()]{})><>){ifn%i==g00div.append(i)i=i+1{}printdiv)}#R{}T:.eX╜R;j`;╜0%Y*`M∩\

(This takes input and output via character code)

Explanation

WSF is essentially brainfuck except it uses whitespace instead of brainfuck's usual set of operators. Here is the code decompiled into brainfuck:

,
[->+>>>>+<<<<<]>

[
[-<+>>>>+<<<]<[->+<]
>>>>>[-<<+>>]<[->+<]<
[>+>->+<[>]>[<+>-]<<[<]>-]
>>[-]+>[<->[-]]
<
[<<<<.>>>>-]<[->+<]<<<
-
]

Progress towards Brain-Flak

Since WSF is only whitespace I was able to add 15 more characters onto the Brain-Flak code. This puts us at 15 away from the answer, so feel free to post it.

()({})(({})<>)){((({}[()]<(({})(<>))><>)<{(({})){({}[()])<>}{}}{}<>([{}()]{})>  )  {(          ) {})}{}
()({})(({})<>)){((({}[()]<(({})(<>))><>)<{(({})){({}[()])<>}{}}{}<>([{}()]{})><>)<>{(<{}<>{}<>>)}{})}{}

Since I am not going to get to post the Brain-flak answer myself, I thought I would just take the time to thank everyone that has helped contribute to this goal:

  • Riley, 16 bytes

  • LegionMammal, 15 bytes

  • ETHproductions, 11 bytes

  • Lynn, 1 byte

The following users were not able to contribute bytes directly but did help in other ways:

  • Mistah Figgins

Thanks everyone for making this possible!

Post Rock Garf Hunter

Posted 2017-03-09T19:40:43.707

Reputation: 55 382

5

Answer 19, 2sable, 15

"qd:A(),(;{A\%!},pe#&f!0pv'%QTS|Q@░┼_¥f::+!vUGw)(({})<>)){((({}[()]<n=int(input({})(<>))><>)<{i=1div=wvhile(({})){({}[()])<>}{}}{}<>([{}()]{})><>){ifn%i==g00div.append(>>i)i=i+1}{}printdiv)}#R{}T:.eX╜R;j`;╜0%Y*`M∩\"
ILD¹s%_Ï,

Try it online!

I removed the extra whitespace, wrapped everything that existed before into a string, then:

IL        # Push [1 .. input]
  D       # Duplicate
   ¹s%    # For each element: input % element
      _   # Logical not
       Ï  # Keep the values from [1 .. input] where this is 1
        , # print

Riley

Posted 2017-03-09T19:40:43.707

Reputation: 11 345

5

Answer 21, Cubix, 15

Finally managed to fit this in :) Thankfully it is after the Brain-Flak answer got done, because I think I would have hindered. Needed the full 15 to implement.

"qd:A(),(;{A\%!},pe#&f!0pv'%QTS|Q@░┼_¥f::+!vUGw
)(Is{})%?;ONou{((({}[()]<n=int(inpu;<@!-;<>))><>)<{i=1div=wvhile(({})){({}[()])<>}{}}{}<>([{}()]{})><>)<>{ifn%i==g00div.append(<{}<>{}<>>i)i=i+1}{}printdiv)}
#R
{}T:.eX╜R;j`;╜0%Y*`M∩\"ILD¹s%_Ï,

This maps to the following cube

              " q d : A ( )
              , ( ; { A \ %
              ! } , p e # &
              f ! 0 p v ' %
              Q T S | Q @ ░
              ┼ _ ¥ f : : +
              ! v U G w ) (
I s { } ) % ? ; O N o u { ( ( ( { } [ ( ) ] < n = i n t
( i n p u ; < @ ! - ; < > ) ) > < > ) < { i = 1 d i v =
w v h i l e ( ( { } ) ) { ( { } [ ( ) ] ) < > } { } } {
} < > ( [ { } ( ) ] { } ) > < > ) < > { i f n % i = = g
0 0 d i v . a p p e n d ( < { } < > { } < > > i ) i = i
+ 1 } { } p r i n t d i v ) } # R { } T : . e X ╜ R ; j
` ; ╜ 0 % Y * ` M ∩ \ " I L D ¹ s % _ Ï , . . . . . . .
              . . . . . . .
              . . . . . . .
              . . . . . . .
              . . . . . . .
              . . . . . . .
              . . . . . . .
              . . . . . . .

You can try it here, but you will need to paste it in. I suspect some of the specials are causing problems for the permalink.

The code is essentially over 2 lines. The important parts are:

I s     ) % ? ; O N o u 
        u ; < @ ! - ; 

I s ) This gets the input, swaps the top of the stack (0 would have worked as well) and increments
% ? Get the mod and test. If 0 carry on forward or drop down to the redirect
; O N o Drop the mod results and output the number followed by a newline
u U turn onto the line below
Following is in order executed
; - ! @ Remove the 10 from stack, subtract number from input, test and terminate if zero
< ; u Redirect target for first test. Remove top of stack (either mod or subtract result) and u-turn back up to increment

MickyT

Posted 2017-03-09T19:40:43.707

Reputation: 11 735

4

Answer 6, Python 1.6, 15

#b∫I:b;\?t"Gw\~(()
n=int(input())
i=1
div=[]
while (i<=n):
    if n % i == 0:
        div.append(i)
    i=i+1
print(div)#Rḍ⁸T”

I removed the % symbols and commented out the first line and a bit of the last line. This alone cost me 10 of my 15 points. However I was not yet done; since Python 1 doesn't have += I had to replace i+=1 with i=i+1 costing me an extra 3 points. Since I had 2 left over I also added (( to the beginning. I am planning to make a submission in Brain-Flak later and I need parens.

Post Rock Garf Hunter

Posted 2017-03-09T19:40:43.707

Reputation: 55 382

1+1 even after OP said that Python was done with, apparently not.... – HyperNeutrino – 2017-03-10T21:24:49.160

4

Answer 10, Ohm, distance 5

@░┼_¥
f!vUGw((({})<>)){((({}n=int(input())i=1div=while(i<=n):ifn%i==0:div.append(i)i=i+1printdiv)}#R{}T”.e<SPACES>

...where <SPACES> is replaced by that monstrous string from the Whitespace answer.

A bit of a cheeky answer, since everything else is just a wire that lays unexecuted.

Nick Clifford

Posted 2017-03-09T19:40:43.707

Reputation: 1 184

Any work towards Brain-Flak here? – CalculatorFeline – 2017-03-10T02:18:09.590

@CalculatorFeline Afraid not. – Nick Clifford – 2017-03-10T02:18:59.273

Too bad. 10 chars towards Brainflak! If only. – CalculatorFeline – 2017-03-10T02:20:13.370

4

Answer 12, Seriously, 15

╩"@░┼_¥
f!vUGw((({})<>)){((({}[()]n=int(input())i=1div=while((<>)){ifn%i==0div.append(i)i=i+1}printdiv)}#R{}T.e"X
╜R;`;╜%Y*`M∩

Try it online!

The only difference from the Actually answer is that Seriously uses backticks to mark a function where Actually uses and and we just make the extra characters into a string then pop and discard it.


Work Towards Brain-Flak

((({})<>)){((({}[()] ((  )   )       ((             <>                 )   )  {(          )  })}{}
((({})<>)){((({}[()]<(({})(<>))><>)<{(({})){({}[()])<>}{}}{}<>([{}()]{})><>)<>{(<{}<>{}<>>)}{})}{}

Riley

Posted 2017-03-09T19:40:43.707

Reputation: 11 345

+1 bringing the contest one step closer to Brain-Flak. Just 1 question: Do you know any programming language very similar to Seriously? – Mr. Xcoder – 2017-03-10T15:58:50.923

Other than actually. – Mr. Xcoder – 2017-03-10T15:59:32.557

@Mr.Xcoder I haven't used any. I only knew Seriously was this similar because Actually is just Seriously version 2.0 – Riley – 2017-03-10T16:00:18.833

4

Answer 14, Del|m|t, 15

                                                f!%QTS|Q"@░┼_¥f!vUGw((({})<>)){((({}[()]<n=int(input({})(<>))><>)<{i=1div=while(({})){({}<>)){ifn%i==0div.append(i)i=i+1}printdiv)}#R{}T.eX╜R;`;╜%Y*`M∩

Try it online!

Explanation

I am really starting to abuse the fact that whitespace is not counted towards the difference here. Del|m|t doesn't really care all that much what characters you you so the vast majority of the code is a sequence of spaces and carriage returns at the beginning of the program. The actual visible parts of the code are not executed at all.

Here is the code transcribed into a more "reasonable" fashion:

O R ^ V O @ A K T A J O @ A K U N R O @ B K U @ A K T Q ^ X @ B K T R ^ P O @ A K T K R ^ _ @ ^ @

Try it online!

How it works at the low level

To start we have O R ^ V this serves to take input on the first loop and works as a no-op all other times.

We then use O to make a copy of the input for later.

@ A K T recalls the variable stored in memory position -1 (at the beginning of the program this is 0) and A J increments it. O @ A K U Stores the now incremented value back in memory position -1 for our next loop around.

N calculates the mod of the copy of the input we made a while back and the value just recalled from memory and R negates it.

Together N R create a boolean that indicates whether or not the our input is divisible by the TOS.

We store a copy of this boolean to memory space -2 using O @ B K U and recall the value from memory space -2 using @ A K T.

We swap the top two elements with Q to ensure that the boolean is on top and output the value if the boolean is true using ^ X.

If the boolean was false we have an extra value that needs to be eradicated so we recall the boolean we stored in space -2 with @ B K T and pop a value if it is false R ^ P.

We duplicate the input value with O and subtract the value at memory -1 with @ A K T K. If this is zero we exit R ^ _.

Lastly we have @ ^ this skips whatever the next value is. We need this because there is a bunch of junk (actually only a @ symbol) generated by the visible portion of the code.

Once it reaches the end it loops back to the beginnning.

How it works at the high level

The basic idea is that we have a value primarily stored at memory location -1 that is incremented each time we loop. If that value divides our input we output it and when the two are equal we end execution.

Progress Towards Brain-Flak

Because whitespace does not count towards the difference I was able to change the code without spending any of my 15 points and thus all of them were invested into the Brain-Flak code.

Here is our current standing.

((({})<>)){((({}[()]<(({})(<>))><>)<{(({})){({}     <>                 )   )  {(          )  })}{}
((({})<>)){((({}[()]<(({})(<>))><>)<{(({})){({}[()])<>}{}}{}<>([{}()]{})><>)<>{(<{}<>{}<>>)}{})}{}

Post Rock Garf Hunter

Posted 2017-03-09T19:40:43.707

Reputation: 55 382

Please update the leaderboard everytime you submit an answer. – Mr. Xcoder – 2017-03-10T20:54:57.223

Only 39 characters left for the Brain-Flak answer! :) That means we still need at least 3 answers... – HyperNeutrino – 2017-03-10T21:48:45.497

4

Answer 15, Befunge-98, 15

&f!0pv
'         %QTS|Q" @ ░┼_¥f
:
:      
+      
!         vUGw(((   {})<>)){((({}[()
]    <    n=int(i   nput({})(<>))><>)
<      {i=1di     v
  =
w    v  
       hile(({      })){({}<>)){ifn%i==
g
0
0    div.app   en   d(i)i=i+1}printdiv)}#R{}T
:      
.    eX╜R;
j      
`      ;╜
0      
%  Y*`M∩
\

Try it Online!

(There is probably a lot of unnecessary whitespace, but I can't be bother to golf it out right now)

I used all 15 for the Befunge program, so no changes to the Brain-flak this time.

My main strategy for this was to send the IP going vertically, and using whitespace to execute certain characters from the preexisting code.

Explanation:

The code that matters to the Befunge program is this:

&f!0pv
'                 @
:
:
+
!
]    <
<                 v
w    v
g
0
0    d
:
.    e
j
`
0
%    `
\

Which is equivalent to:

&f!0pv   Gets input, and stores it at (0, 0) (where the & is)
         The v goes down, hits the < and ], which turns the IP up along the first line

!+::'&   There is a 0 at the bottom of the stack, so ! changes it to a 1 and + increments
         :: duplicates twice, and '& gets the input value

\%       swaps the input and iterator mods them
  0`j.   Checks if input mod iterator is 0 - if it is, print iterator

:00gw    gets the input again, and compares it to the iterator.
         If they are different, the IP travels right to the v
         Otherwise, it continues straight, and hits arrows leading to the end (@)

de`      pushes 0, to be used in the increment line

MildlyMilquetoast

Posted 2017-03-09T19:40:43.707

Reputation: 2 907

3

Answer 1 - Python 2.7

n=input()
i=1
div=[]
while (i<=n):
    if n % i == 0:
        div.append(i)
    i+=1
print(div)

Distance: NA - First answer

Try it online!

Mr. Xcoder

Posted 2017-03-09T19:40:43.707

Reputation: 39 774

3

Answer 2 - Python 3, 5

n=int(input())
i=1
div=[]
while (i<=n):
    if n % i == 0:
        div.append(i)
    i+=1
print(div)

Try it online!

Jonathan Allan

Posted 2017-03-09T19:40:43.707

Reputation: 67 804

Now you have closed the answer list in Python. Good! – Mr. Xcoder – 2017-03-09T20:07:19.840

@Mr.Xcoder What if someone uses Python 3.5 and uses the async or await built-ins? Would that count as a completely different language? – HyperNeutrino – 2017-03-10T21:23:33.813

3

Answer 5 - SOGL 0.8.2, 9

b∫I:b;\?t"Gw\~)
%n=int(input())
%i=1
%div=[]
%while (i<=n):
%    if n % i == 0:
%        div.append(i)
%    i+=1
%print(div)Rḍ⁸T”

Explanation:

b∫              repeat input times                [0]
  I             increment (the loop is 0-based)   [1]
   :b           duplicate                         [1, 1]
     ;          put the input one under the stack [1, 114, 1]
      \?        if divides                        [1, 1]
        t        output                           [1, 1]
         "...”   push that long string            [1, 1, "Gw\~...Rḍ⁸T"]

Note: the interpreter currently needs the \ns be replaced with in order to not count it as input, but the parser itself considers both interchangable.

dzaima

Posted 2017-03-09T19:40:43.707

Reputation: 19 048

3

Answer 11, Actually, 15

╩@░┼_¥
f!vUGw((({})<>)){((({}]n=int(input())i=1div=while(i<=n):ifn%i==0:div.append(i)i=i+1printdiv)}#R{}T”.e
╜R;⌠;╜%Y*⌡M∩

Try it online!

Explanation

Actually has a nice builtin ÷ for finding the factors of a number, however we are not allowed to use such builtins.

I begin by storing the input to the registers so that it will be unharmed by what is to come. I do this using but I could have just as easily used one of the other commands available.

Then I paste the code we already had (I removed all the whitespace because it was annoying to work with, I can do this because "whitespace does not count"). Luckily this does a whole lot of nothing when the stack is empty.

Then we have the rest of the program

╜   Pull our input from the register
R   Create the range of n
;   Duplicate the range
⌠   Declare a function
 ;  Duplicate n
 ╜  Pull from register
 %  Mod
 Y  Logical not
 *  Multiply by n
⌡   End Function
M   Map the function across the range
∩   Remove the zeros with a Intersection

Work Towards Brain-Flak

All that work and I was only able to get one extra paren in.

((({})<>)){((({}   ] ((  )   )       (              <              )           (          )   )}{}
((({})<>)){((({}[()]<(({})(<>))><>)<{(({})){({}[()])<>}{}}{}<>([{}()]{})><>)<>{(<{}<>{}<>>)}{})}{}

Post Rock Garf Hunter

Posted 2017-03-09T19:40:43.707

Reputation: 55 382

You know, if we enclose the Brain-Flak code in [] we can have Brainfcuk code after it. Might open up possibilities. – CalculatorFeline – 2017-03-10T02:58:01.560

@CalculatorFeline I don't think we do. Brain-Flak on its own does next to nothing in brainfuck. Making a submission in brainfuck would be very hard but I don't think Brain-Flak is going to harm it any. – Post Rock Garf Hunter – 2017-03-10T03:06:12.453

Well, Brainfuck planning would be a good idea at this stage. Bytes that can't go towards Flak can be placed in other planning (like BF, Syms, or conventional languages). – CalculatorFeline – 2017-03-10T04:25:49.637

@CalculatorFeline The thing is there is pretty much no such thing as bytes that can't go towards Brain-Flak. Unless a language has some pretty weird rules about parens (in which case it is probably already unusable) we can use extra bytes to insert parens. – Post Rock Garf Hunter – 2017-03-10T05:14:04.743

Why does your code output an extra 0 before the array?? – Mr. Xcoder – 2017-03-10T05:47:53.363

@Mr.Xcoder Its an implicit zero at the bottom of the stack. – Post Rock Garf Hunter – 2017-03-10T05:48:28.393

Uh, ok...I am not familiarised with Actually, sorry. My bad – Mr. Xcoder – 2017-03-10T05:50:12.383

@Mr.Xcoder No problem. I am not familiar myself. This is my first post in Actually. – Post Rock Garf Hunter – 2017-03-10T05:51:23.960

3

23, Brain-Flak Classic, 13

"qd:A(),(;{A\%!},pe#&f!0pv'%QTS|Q@░┼_¥f::+!vUGw)(Is(({})<>))%?;ONou{((({}[]<n=int(inpu;({})(@!-;<>))><>)<{i=1div=wvhile(({})){({}[])<>}{}}{}<>({<({}[])>[]}[]{}{})><>)<>{ifn%i==g00div.append(<{}<>{}<>>i)i=i+1}{}printdiv)}#R{}T:.eX╜R;j`;╜0%Y*`M∩\"ILD¹s%_Ï,

Originally, @Wheat Wizard had posted the brain-flak-classic code as it was on answer 22:

()({})((({})<>)){((({}[()]<(({})(<>))><>)<{(({})){({}[()])<>}{}}{}<>({<({}[]{})           ><>)<>{(<{}<>{}<>>)}{})}{}
()({})((({})<>)){((({}[  ]<(({})(<>))><>)<{(({})){({}[  ])<>}{}}{}<>({<({}[]  )>[]}[]{}{})><>)<>{(<{}<>{}<>>)}{})}{}

This is 17 characters off. However, I was able to compress this by simply moving the {}) further right in the proposed code to get

()({})((({})<>)){((({}[()]<(({})(<>))><>)<{(({})){({}[()])<>}{}}{}<>({<({}[]         {})><>)<>{(<{}<>{}<>>)}{})}{}
()({})((({})<>)){((({}[  ]<(({})(<>))><>)<{(({})){({}[  ])<>}{}}{}<>({<({}[])>[]}[]{}{})><>)<>{(<{}<>{}<>>)}{})}{}

Which is only 13 characters off! So all I did was add/remove brackets to get the proposed code.


The original code I posted had a typo, it's fixed now. (Thanks @WheatWizard!)

MildlyMilquetoast

Posted 2017-03-09T19:40:43.707

Reputation: 2 907

1

22, Lenguage, 15

Lenguage is a esolang that cares only about how long the program is not about its content. So we can create any lenguage program we want by padding the last program with the proper amount of whitespace. Lenguage is compiled into brainfuck so we will reuse the brainfuck program I wrote a while ago

,[->+>>>>+<<<<<]>[[-<+>>>>+<<<]<[->+<]>>>>>[-<<+>>]<[->+<]<[>+>->+<[>]>[<+>-]<<[<]>-]>>[-]+>[<->[-]]<[<<<<.>>>>-]<[->+<]<<<-]

I made a few changes to the main program to facilitate later answers, but the end result looks like:

<SPACES>"qd:A(),(;{A\%!},pe#&f!0pv'%QTS|Q@░┼_¥f::+!vUGw)(Is(({})<>))%?;ONou{((({}[()]<n=int(inpu;({})(@!-;<>))><>)<{i=1div=wvhile(({})){({}[()])<>}{}}{}<>({<[{}[]{})><>)<>{ifn%i==g00div.append(<{}<>{}<>>i)i=i+1}{}printdiv)}#R{}T:.eX╜R;j`;╜0%Y*`M∩\"ILD¹s%_Ï,

where <SPACES> represents 55501429195173976989402130752788553046280971902194531020486729504671367937656404963353269263683332162717880399306 space characters.

Am I abusing the whitespace doesn't count rule? Perhaps.

Work towards Brain-Flak Classic

We had all of those parens already there so I thought I would start us along the way towards Brain-Flak Classic.

()({})((({})<>)){((({}[()]<(({})(<>))><>)<{(({})){({}[()])<>}{}}{}<>({<({}[]         {})><>)<>{(<{}<>{}<>>)}{})}{}
()({})((({})<>)){((({}[  ]<(({})(<>))><>)<{(({})){({}[  ])<>}{}}{}<>({<({}[])>[]}[]{}{})><>)<>{(<{}<>{}<>>)}{})}{}

Post Rock Garf Hunter

Posted 2017-03-09T19:40:43.707

Reputation: 55 382

Another target... That's madness. I like it! – Mr. Xcoder – 2017-03-17T19:48:10.803

So the top row of Brain-flak Classic is what we have, and the bottom is what we need? – MildlyMilquetoast – 2017-03-18T18:38:51.697

@MistahFiggins yes – Post Rock Garf Hunter – 2017-03-18T18:39:43.953

1Tada! Brain-Flak Classic is closer because I moved some parens around – MildlyMilquetoast – 2017-03-18T18:43:16.657