Numbers Manipulation challenge

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite
1












Use any programming language to generate two random digits between 1 and 9 (including both). Then your program should display:

- in the first line: the first random digit,

- in the second line: the second random digit,

- in the third line: a number whose tens and units digits are the first and second random digits respectively,

- in the fourth line: the number from the third line raised to the power of 2.



For example, if digits "9" and "2" were generated, your program should display exactly:

9

2

92

8464










share|improve this question



















  • 8




    Can we output an array?
    – Quintec
    3 hours ago






  • 1




    Can we sample without replacement, ie exclude 1,1 2,2 3,3... from the pairs?
    – JayCe
    1 hour ago















up vote
2
down vote

favorite
1












Use any programming language to generate two random digits between 1 and 9 (including both). Then your program should display:

- in the first line: the first random digit,

- in the second line: the second random digit,

- in the third line: a number whose tens and units digits are the first and second random digits respectively,

- in the fourth line: the number from the third line raised to the power of 2.



For example, if digits "9" and "2" were generated, your program should display exactly:

9

2

92

8464










share|improve this question



















  • 8




    Can we output an array?
    – Quintec
    3 hours ago






  • 1




    Can we sample without replacement, ie exclude 1,1 2,2 3,3... from the pairs?
    – JayCe
    1 hour ago













up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





Use any programming language to generate two random digits between 1 and 9 (including both). Then your program should display:

- in the first line: the first random digit,

- in the second line: the second random digit,

- in the third line: a number whose tens and units digits are the first and second random digits respectively,

- in the fourth line: the number from the third line raised to the power of 2.



For example, if digits "9" and "2" were generated, your program should display exactly:

9

2

92

8464










share|improve this question















Use any programming language to generate two random digits between 1 and 9 (including both). Then your program should display:

- in the first line: the first random digit,

- in the second line: the second random digit,

- in the third line: a number whose tens and units digits are the first and second random digits respectively,

- in the fourth line: the number from the third line raised to the power of 2.



For example, if digits "9" and "2" were generated, your program should display exactly:

9

2

92

8464







code-golf random






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 hours ago









l4m2

4,1131432




4,1131432










asked 4 hours ago









Monolica

284113




284113







  • 8




    Can we output an array?
    – Quintec
    3 hours ago






  • 1




    Can we sample without replacement, ie exclude 1,1 2,2 3,3... from the pairs?
    – JayCe
    1 hour ago













  • 8




    Can we output an array?
    – Quintec
    3 hours ago






  • 1




    Can we sample without replacement, ie exclude 1,1 2,2 3,3... from the pairs?
    – JayCe
    1 hour ago








8




8




Can we output an array?
– Quintec
3 hours ago




Can we output an array?
– Quintec
3 hours ago




1




1




Can we sample without replacement, ie exclude 1,1 2,2 3,3... from the pairs?
– JayCe
1 hour ago





Can we sample without replacement, ie exclude 1,1 2,2 3,3... from the pairs?
– JayCe
1 hour ago











19 Answers
19






active

oldest

votes

















up vote
3
down vote














C (gcc), 68 67 bytes



-1 byte thanks to cleblanc





f(r)r=rand()%81*10/9+11;printf("%dn%dn%dn%d",r/10,r%10,r,r*r);


Try it online!






share|improve this answer






















  • save one byte using r;f() --> f(r)
    – cleblanc
    2 hours ago

















up vote
2
down vote














Python 3, 83 bytes





from random import*
a,b=map(randint,(1,1),(9,9))
k=a*10+b
[*map(print,[a,b,k,k*k])]


Try it online!






share|improve this answer




















  • 82 bytes.
    – Erik the Outgolfer
    1 hour ago






  • 1




    76 bytes
    – nwellnhof
    1 hour ago

















up vote
2
down vote














Perl 6, 39 bytes





.comb,$_,$_²([~] roll 1..9: 2)>>.put


Try it online!






share|improve this answer





























    up vote
    2
    down vote














    R, 48 bytes





    cat(x<-sample(9,2,T),y<-x%*%c(10,1),y^2,sep="
    ")


    Try it online!






    share|improve this answer



























      up vote
      2
      down vote














      PowerShell, 48 bytes





      ($a,$b=1..9+1..9|Random -c 2)
      ($x="$a$b")
      +$x*$x


      Try it online!



      Concatenates two ranges 1..9 together, pipes that to Get-Random with a -count of 2 to pull out two elements, stores them into $a and $b, and encapsulates that in parens to place a copy of them on the pipeline.



      Next we string concatenate $a$b and store it into $x, again placing in parens to put a copy on the pipeline. Finally we take $x squared and leave it on the pipeline.



      All the results are gathered from the pipeline and an implicit Write-Output gives us newlines between elements for free.






      share|improve this answer




















      • Smart get-random
        – mazzy
        1 hour ago

















      up vote
      2
      down vote














      Pyth, 14 bytes



      ^
      i,
      hO9
      hO9T2


      Note that the newlines are significant. Try it online here.



      Explanation, with newlines replaced with ¶ character:



      ^¶i,¶hO9¶hO9T2 Implicit: T=10

      O9 Choose a random number in [0-9)
      h Increment
      ¶ Output with newline - value printed is yielded as expression result
      ¶hO9 Do the above again
      , Wrap the two previous results in a two-element array
      i T Convert to decimal from base 10
      ¶ Output with newline
      ^ 2 Square the previous result, implicit print





      share|improve this answer




















      • @Downvoter - any particular reason why?
        – Sok
        1 hour ago

















      up vote
      2
      down vote














      Japt, 14 bytes



      9õ ï ö
      pU¬Uì ²



      9õ ï ö
      pU¬Uì ² Full program
      -----------------------------------------
      9õ Range [1,9]
      ï Cartesian product with itself
      ö get a random element
      This result is assigned to U

      p Push into U
      U¬ Elements in U joined
      Uì ² and elements joined squared
      Implicit output each element
      separated with new line -R


      Try it online!






      share|improve this answer


















      • 1




        Mq can return 0
        – Shaggy
        2 hours ago










      • @Shaggy didn't notice that the random numbers range was [1, 9]. It should be fixed now
        – Luis felipe De jesus Munoz
        1 hour ago


















      up vote
      2
      down vote













      T-SQL, 142 105 115 114 96 bytes





      DECLARE @ AS char=LEFT(RAND()*9+1,1),@a AS char=LEFT(RAND()*9+1,1)SELECT @,@a,@+@a,POWER(@+@a,2)


      -37 bytes: Realized I could just use two different random numbers and use the first digits from each!
      +10 bytes: Edited to meet requirements of range from 1-9, instead of 0-9
      -1 byte: Changed RIGHT() to LEFT() in @b
      -18 bytes: Various changes suggested by BradC



      Ungolfed:



      -- Setting RAND() separately in these produces different numbers.
      -- [RAND() * b + a] sets the range for a random number, from a to b inclusive.
      -- Set the variable string to the first number.
      DECLARE @ AS char = LEFT(RAND() * 9 + 1, 1),
      @a AS char = LEFT(RAND() * 9 + 1, 1)

      SELECT @, -- first digit
      @a, -- second digit
      @ + @a, -- first two digits combined (not added, as they are type char)
      POWER(@ + @a, 2) -- first two digits combined, squared (POWER function will cast the first argument to a number if it is a string)





      share|improve this answer


















      • 1




        Nice work, a few ways to save more: use char instead of varchar, use @ by itself for one of the two variables (its valid!), simplify each RAND to RAND()*9+1 (which is 10-1, your code wasn't allowing for 9s).
        – BradC
        26 mins ago










      • Ooo, you'd have to change your SELECT math, but you can declare both variables as INT, and just let it to an implicit converstion, dropping the LEFT altogether! DECLARE @ AS INT=RAND()*9+1,@b AS INT=...
        – BradC
        18 mins ago










      • The stuff in the first comment definitely works, I'll edit that in. Problem with making the variables ints is that I would need to cast each individually as chars in the SELECT where necessary. With that, since each variable would need to be converted twice (in @+@a and POWER(@+@a,2)), it'd add more characters than it would save.
        – Meerkat
        11 mins ago

















      up vote
      1
      down vote













      JavaScript (ES6), 67 bytes





      f=_=>(n=Math.random()*90+10|0)%10?(n/10|0)+`
      $n%10
      $n
      `+n*n:f()


      Try it online!






      share|improve this answer



























        up vote
        1
        down vote














        Charcoal, 16 bytes



        ≔⭆²⊕‽⁹θ↓θθ⸿IXIθ²


        Try it online! Link is to verbose version of code. Explanation:



        ≔⭆²⊕‽⁹θ


        Generate two random characters in the range 1 to 9.



        ↓θ


        Output them downwards i.e. on separate lines.



        θ⸿


        Output them horizontally on their own line.



        IXIθ²


        Cast to integer, square, cast back to string for implicit print.






        share|improve this answer



























          up vote
          1
          down vote














          Jelly, 10 9 bytes



          9ṗ2XṄ€ḌṄ²


          Try it online!



          How it works



          9ṗ2XṄ€ḌṄ² Main link. No arguments.

          9 Set the return value to 9.
          ṗ2 Promote 9 to [1, ..., 9] and take the second Cartesian power, yielding
          [[1, 1], [1, 2], ..., [9, 8], [9, 9]].
          X Pseudo-randomly select one of the pairs.
          Ṅ€ Print each integer in the pair, followed by a newline.
          Ḍ Undecimal; convert the integer pair from base 10 to an integer.
          Ṅ Print the integer, followed by a newline.
          ² Take the square.
          (implicit) Print the last return value.





          share|improve this answer





























            up vote
            1
            down vote














            Ruby, 41 bytes





            puts [(a=11+10*rand(81)/9)/10,a%10,a,a*a]


            Try it online!






            share|improve this answer



























              up vote
              1
              down vote













              Vim, 44 bytes



              :%!$RANDOM

              :s/0//g
              2f:hy2hVpo=0*0
              kYPa



              Try it online!



              Not the right tool for the job. This produces most likely the desired output



              Step by step:



              • :%!$RANDOM Enter Enter

                Produces a string like /bin/bash: 25266: command not found


              • :s/0//g

                removes all zeroes


              • 2f:hy2hVp

                moves the cursor one to the left of the colon after the number, copy the last two digits and replace the entire string with those


              • o Ctrl+R = Ctrl+R 0* Ctrl+R 0 Enter

                add a new line and evaluate an expression. In this case, I'll multiply the number in register 0 (the one that was just copied) with itself. Result:


              • Esc kYPa Enter

                Copy the upper line and paste it above. The cursor ends up in the first line, on the first character. Now we just have to append a line break to it


              Limitations: If the result of $RANDOM is a number with less than two non-zero digits, this will not produce the desired output






              share|improve this answer





























                up vote
                1
                down vote













                Java 8, 99 98 90 81 80 bytes





                v->int i=81;i*=Math.random();return(i=i*10/9+11)/10+"n"+i%10+"n"+i+"n"+i*i;


                -8 bytes after being inspired by @Arnauld's JavaScript answer.

                -9 bytes thanks to @nwellnhof.



                Try it online.



                Explanation:



                v-> // Method with empty unused parameter and no return-type
                int i=81;i*=Math.random();// Create a random integer `i` in the range [0,81)
                return(i=i*10/9+11) // Set `i` to 10 times `i`, integer-divided by 9, and 11 added
                /10+"n" // Return the first digit of `i`, a newline,
                +i%10+"n" // the last digit of `i`, a newline,
                +i+"n" // `i` itself, a newline,
                +i*i; // and `i` multiplied by itself
                // All concatted to each other





                share|improve this answer






















                • @nwellnhof Thanks! And been able to golf 1 more byte with my previous trick of int i=81;i*=Math.random();return(i=i*10/9+11).
                  – Kevin Cruijssen
                  1 hour ago

















                up vote
                1
                down vote














                05AB1E, 14 11 bytes



                2F9LΩ=}J=n,


                -3 bytes thanks to @Emigna.



                Try it online.



                Explanation:





                2F } # Loop 2 times:
                9LΩ # Create a list in the range [1,9], and pick a random element from it
                = # Output it (without popping it from the stack)
                J # Join them together
                = # Output it (without popping it from the stack)
                n # Take it to the power of 2
                , # And output it as well





                11 bytes alternative:



                9LãΩ©`®JDn»


                Try it online.



                Explanation:





                9L # List in the range [1,9]
                ã # Cartesian product with itself: [[1,1],[1,2],[1,3],...,[9,7],[9,8],[9,9]]
                Ω # Take a random element from it
                © # Store it in the register (without popping)
                ` # Pop and push both items as separated items onto the stack
                ® # Retrieve the list of digits from the register again
                J # Join them together to a single 2-digit number
                Dn # Duplicate it, and take the power of 2 of the copy
                » # Merge all values on the stack by newlines (and output implicitly)





                share|improve this answer


















                • 1




                  Shorter in a looP: 2F9LΩ=}J=n,
                  – Emigna
                  3 hours ago










                • @Emigna I was about to look for shorter alternatives, but smart use of the =!
                  – Kevin Cruijssen
                  3 hours ago


















                up vote
                1
                down vote














                Python 2, 84 75 bytes





                from random import*
                k=randint(9,89)*10/9+1
                for x in k/10,k%10,k,k*k:print x


                Try it online!




                Saved



                • -1 bytes, thanks to Erik the Outgolfer

                • -8 bytes, thanks to nwellnhof





                share|improve this answer






















                • Moderate golf: 83 bytes.
                  – Erik the Outgolfer
                  1 hour ago










                • @EriktheOutgolfer Thanks :)
                  – TFeld
                  45 mins ago










                • @nwellnhof Thanks :)
                  – TFeld
                  45 mins ago

















                up vote
                0
                down vote














                C# (.NET Core), 130 bytes





                Random r=new Random();int a=r.Next(1,9),b=r.Next(1,9),c=int.Parse(a.ToString()+b.ToString());Console.Write(a+" "+b+" "+c+" "+c*c);


                Try it online!



                Ungolfed:



                Random r = new Random(); // initializes random number generator
                int a = r.Next(1, 9), // gets random number between 1 and 9 inclusive
                b = r.Next(1, 9), // gets random number between 1 and 9 inclusive
                c = int.Parse(a.ToString() + b.ToString()); // concatenates a and b into one two-digit number
                Console.Write(a + " " + b + " " + c + " " + c*c); // writes a, b, c, and c^2 to the console





                share|improve this answer





























                  up vote
                  0
                  down vote














                  K (oK), 28 bytes



                  t:2?10;t,:10/t;$t,:t[2]*t[2]


                  Explanation



                  t:2?10 //define t as two random numbers from 1-10
                  t,:10/t //join the base 10 joining of the elements of t to t
                  t,:t[2]*t[2]//join the square of the index 2 element to t
                  $ //String each element of the result (to output on newlines)


                  Try it online!



                  Cleaner Output, 32 bytes



                  t:2?10;t,:10/t;`0:$t,:t[2]*t[2];

                  `0: //Cleanly prints the strings


                  Try it online!






                  share|improve this answer





























                    up vote
                    0
                    down vote














                    PHP, 64 bytes





                    <?$d=($c=(10*($a=rand(1,9))+$b=rand(1,9)))*$c;echo"$a
                    $b
                    $c
                    $d";


                    Try it online!





                    share




















                      Your Answer





                      StackExchange.ifUsing("editor", function ()
                      return StackExchange.using("mathjaxEditing", function ()
                      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
                      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
                      );
                      );
                      , "mathjax-editing");

                      StackExchange.ifUsing("editor", function ()
                      StackExchange.using("externalEditor", function ()
                      StackExchange.using("snippets", function ()
                      StackExchange.snippets.init();
                      );
                      );
                      , "code-snippets");

                      StackExchange.ready(function()
                      var channelOptions =
                      tags: "".split(" "),
                      id: "200"
                      ;
                      initTagRenderer("".split(" "), "".split(" "), channelOptions);

                      StackExchange.using("externalEditor", function()
                      // Have to fire editor after snippets, if snippets enabled
                      if (StackExchange.settings.snippets.snippetsEnabled)
                      StackExchange.using("snippets", function()
                      createEditor();
                      );

                      else
                      createEditor();

                      );

                      function createEditor()
                      StackExchange.prepareEditor(
                      heartbeatType: 'answer',
                      convertImagesToLinks: false,
                      noModals: true,
                      showLowRepImageUploadWarning: true,
                      reputationToPostImages: null,
                      bindNavPrevention: true,
                      postfix: "",
                      imageUploader:
                      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                      allowUrls: true
                      ,
                      onDemand: true,
                      discardSelector: ".discard-answer"
                      ,immediatelyShowMarkdownHelp:true
                      );



                      );













                       

                      draft saved


                      draft discarded


















                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f175006%2fnumbers-manipulation-challenge%23new-answer', 'question_page');

                      );

                      Post as a guest






























                      19 Answers
                      19






                      active

                      oldest

                      votes








                      19 Answers
                      19






                      active

                      oldest

                      votes









                      active

                      oldest

                      votes






                      active

                      oldest

                      votes








                      up vote
                      3
                      down vote














                      C (gcc), 68 67 bytes



                      -1 byte thanks to cleblanc





                      f(r)r=rand()%81*10/9+11;printf("%dn%dn%dn%d",r/10,r%10,r,r*r);


                      Try it online!






                      share|improve this answer






















                      • save one byte using r;f() --> f(r)
                        – cleblanc
                        2 hours ago














                      up vote
                      3
                      down vote














                      C (gcc), 68 67 bytes



                      -1 byte thanks to cleblanc





                      f(r)r=rand()%81*10/9+11;printf("%dn%dn%dn%d",r/10,r%10,r,r*r);


                      Try it online!






                      share|improve this answer






















                      • save one byte using r;f() --> f(r)
                        – cleblanc
                        2 hours ago












                      up vote
                      3
                      down vote










                      up vote
                      3
                      down vote










                      C (gcc), 68 67 bytes



                      -1 byte thanks to cleblanc





                      f(r)r=rand()%81*10/9+11;printf("%dn%dn%dn%d",r/10,r%10,r,r*r);


                      Try it online!






                      share|improve this answer















                      C (gcc), 68 67 bytes



                      -1 byte thanks to cleblanc





                      f(r)r=rand()%81*10/9+11;printf("%dn%dn%dn%d",r/10,r%10,r,r*r);


                      Try it online!







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 2 hours ago

























                      answered 2 hours ago









                      nwellnhof

                      5,098920




                      5,098920











                      • save one byte using r;f() --> f(r)
                        – cleblanc
                        2 hours ago
















                      • save one byte using r;f() --> f(r)
                        – cleblanc
                        2 hours ago















                      save one byte using r;f() --> f(r)
                      – cleblanc
                      2 hours ago




                      save one byte using r;f() --> f(r)
                      – cleblanc
                      2 hours ago










                      up vote
                      2
                      down vote














                      Python 3, 83 bytes





                      from random import*
                      a,b=map(randint,(1,1),(9,9))
                      k=a*10+b
                      [*map(print,[a,b,k,k*k])]


                      Try it online!






                      share|improve this answer




















                      • 82 bytes.
                        – Erik the Outgolfer
                        1 hour ago






                      • 1




                        76 bytes
                        – nwellnhof
                        1 hour ago














                      up vote
                      2
                      down vote














                      Python 3, 83 bytes





                      from random import*
                      a,b=map(randint,(1,1),(9,9))
                      k=a*10+b
                      [*map(print,[a,b,k,k*k])]


                      Try it online!






                      share|improve this answer




















                      • 82 bytes.
                        – Erik the Outgolfer
                        1 hour ago






                      • 1




                        76 bytes
                        – nwellnhof
                        1 hour ago












                      up vote
                      2
                      down vote










                      up vote
                      2
                      down vote










                      Python 3, 83 bytes





                      from random import*
                      a,b=map(randint,(1,1),(9,9))
                      k=a*10+b
                      [*map(print,[a,b,k,k*k])]


                      Try it online!






                      share|improve this answer













                      Python 3, 83 bytes





                      from random import*
                      a,b=map(randint,(1,1),(9,9))
                      k=a*10+b
                      [*map(print,[a,b,k,k*k])]


                      Try it online!







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered 3 hours ago









                      ovs

                      18k21058




                      18k21058











                      • 82 bytes.
                        – Erik the Outgolfer
                        1 hour ago






                      • 1




                        76 bytes
                        – nwellnhof
                        1 hour ago
















                      • 82 bytes.
                        – Erik the Outgolfer
                        1 hour ago






                      • 1




                        76 bytes
                        – nwellnhof
                        1 hour ago















                      82 bytes.
                      – Erik the Outgolfer
                      1 hour ago




                      82 bytes.
                      – Erik the Outgolfer
                      1 hour ago




                      1




                      1




                      76 bytes
                      – nwellnhof
                      1 hour ago




                      76 bytes
                      – nwellnhof
                      1 hour ago










                      up vote
                      2
                      down vote














                      Perl 6, 39 bytes





                      .comb,$_,$_²([~] roll 1..9: 2)>>.put


                      Try it online!






                      share|improve this answer


























                        up vote
                        2
                        down vote














                        Perl 6, 39 bytes





                        .comb,$_,$_²([~] roll 1..9: 2)>>.put


                        Try it online!






                        share|improve this answer
























                          up vote
                          2
                          down vote










                          up vote
                          2
                          down vote










                          Perl 6, 39 bytes





                          .comb,$_,$_²([~] roll 1..9: 2)>>.put


                          Try it online!






                          share|improve this answer















                          Perl 6, 39 bytes





                          .comb,$_,$_²([~] roll 1..9: 2)>>.put


                          Try it online!







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 3 hours ago

























                          answered 3 hours ago









                          nwellnhof

                          5,098920




                          5,098920




















                              up vote
                              2
                              down vote














                              R, 48 bytes





                              cat(x<-sample(9,2,T),y<-x%*%c(10,1),y^2,sep="
                              ")


                              Try it online!






                              share|improve this answer
























                                up vote
                                2
                                down vote














                                R, 48 bytes





                                cat(x<-sample(9,2,T),y<-x%*%c(10,1),y^2,sep="
                                ")


                                Try it online!






                                share|improve this answer






















                                  up vote
                                  2
                                  down vote










                                  up vote
                                  2
                                  down vote










                                  R, 48 bytes





                                  cat(x<-sample(9,2,T),y<-x%*%c(10,1),y^2,sep="
                                  ")


                                  Try it online!






                                  share|improve this answer













                                  R, 48 bytes





                                  cat(x<-sample(9,2,T),y<-x%*%c(10,1),y^2,sep="
                                  ")


                                  Try it online!







                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered 3 hours ago









                                  Giuseppe

                                  15.6k31051




                                  15.6k31051




















                                      up vote
                                      2
                                      down vote














                                      PowerShell, 48 bytes





                                      ($a,$b=1..9+1..9|Random -c 2)
                                      ($x="$a$b")
                                      +$x*$x


                                      Try it online!



                                      Concatenates two ranges 1..9 together, pipes that to Get-Random with a -count of 2 to pull out two elements, stores them into $a and $b, and encapsulates that in parens to place a copy of them on the pipeline.



                                      Next we string concatenate $a$b and store it into $x, again placing in parens to put a copy on the pipeline. Finally we take $x squared and leave it on the pipeline.



                                      All the results are gathered from the pipeline and an implicit Write-Output gives us newlines between elements for free.






                                      share|improve this answer




















                                      • Smart get-random
                                        – mazzy
                                        1 hour ago














                                      up vote
                                      2
                                      down vote














                                      PowerShell, 48 bytes





                                      ($a,$b=1..9+1..9|Random -c 2)
                                      ($x="$a$b")
                                      +$x*$x


                                      Try it online!



                                      Concatenates two ranges 1..9 together, pipes that to Get-Random with a -count of 2 to pull out two elements, stores them into $a and $b, and encapsulates that in parens to place a copy of them on the pipeline.



                                      Next we string concatenate $a$b and store it into $x, again placing in parens to put a copy on the pipeline. Finally we take $x squared and leave it on the pipeline.



                                      All the results are gathered from the pipeline and an implicit Write-Output gives us newlines between elements for free.






                                      share|improve this answer




















                                      • Smart get-random
                                        – mazzy
                                        1 hour ago












                                      up vote
                                      2
                                      down vote










                                      up vote
                                      2
                                      down vote










                                      PowerShell, 48 bytes





                                      ($a,$b=1..9+1..9|Random -c 2)
                                      ($x="$a$b")
                                      +$x*$x


                                      Try it online!



                                      Concatenates two ranges 1..9 together, pipes that to Get-Random with a -count of 2 to pull out two elements, stores them into $a and $b, and encapsulates that in parens to place a copy of them on the pipeline.



                                      Next we string concatenate $a$b and store it into $x, again placing in parens to put a copy on the pipeline. Finally we take $x squared and leave it on the pipeline.



                                      All the results are gathered from the pipeline and an implicit Write-Output gives us newlines between elements for free.






                                      share|improve this answer













                                      PowerShell, 48 bytes





                                      ($a,$b=1..9+1..9|Random -c 2)
                                      ($x="$a$b")
                                      +$x*$x


                                      Try it online!



                                      Concatenates two ranges 1..9 together, pipes that to Get-Random with a -count of 2 to pull out two elements, stores them into $a and $b, and encapsulates that in parens to place a copy of them on the pipeline.



                                      Next we string concatenate $a$b and store it into $x, again placing in parens to put a copy on the pipeline. Finally we take $x squared and leave it on the pipeline.



                                      All the results are gathered from the pipeline and an implicit Write-Output gives us newlines between elements for free.







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered 2 hours ago









                                      AdmBorkBork

                                      25.2k361219




                                      25.2k361219











                                      • Smart get-random
                                        – mazzy
                                        1 hour ago
















                                      • Smart get-random
                                        – mazzy
                                        1 hour ago















                                      Smart get-random
                                      – mazzy
                                      1 hour ago




                                      Smart get-random
                                      – mazzy
                                      1 hour ago










                                      up vote
                                      2
                                      down vote














                                      Pyth, 14 bytes



                                      ^
                                      i,
                                      hO9
                                      hO9T2


                                      Note that the newlines are significant. Try it online here.



                                      Explanation, with newlines replaced with ¶ character:



                                      ^¶i,¶hO9¶hO9T2 Implicit: T=10

                                      O9 Choose a random number in [0-9)
                                      h Increment
                                      ¶ Output with newline - value printed is yielded as expression result
                                      ¶hO9 Do the above again
                                      , Wrap the two previous results in a two-element array
                                      i T Convert to decimal from base 10
                                      ¶ Output with newline
                                      ^ 2 Square the previous result, implicit print





                                      share|improve this answer




















                                      • @Downvoter - any particular reason why?
                                        – Sok
                                        1 hour ago














                                      up vote
                                      2
                                      down vote














                                      Pyth, 14 bytes



                                      ^
                                      i,
                                      hO9
                                      hO9T2


                                      Note that the newlines are significant. Try it online here.



                                      Explanation, with newlines replaced with ¶ character:



                                      ^¶i,¶hO9¶hO9T2 Implicit: T=10

                                      O9 Choose a random number in [0-9)
                                      h Increment
                                      ¶ Output with newline - value printed is yielded as expression result
                                      ¶hO9 Do the above again
                                      , Wrap the two previous results in a two-element array
                                      i T Convert to decimal from base 10
                                      ¶ Output with newline
                                      ^ 2 Square the previous result, implicit print





                                      share|improve this answer




















                                      • @Downvoter - any particular reason why?
                                        – Sok
                                        1 hour ago












                                      up vote
                                      2
                                      down vote










                                      up vote
                                      2
                                      down vote










                                      Pyth, 14 bytes



                                      ^
                                      i,
                                      hO9
                                      hO9T2


                                      Note that the newlines are significant. Try it online here.



                                      Explanation, with newlines replaced with ¶ character:



                                      ^¶i,¶hO9¶hO9T2 Implicit: T=10

                                      O9 Choose a random number in [0-9)
                                      h Increment
                                      ¶ Output with newline - value printed is yielded as expression result
                                      ¶hO9 Do the above again
                                      , Wrap the two previous results in a two-element array
                                      i T Convert to decimal from base 10
                                      ¶ Output with newline
                                      ^ 2 Square the previous result, implicit print





                                      share|improve this answer













                                      Pyth, 14 bytes



                                      ^
                                      i,
                                      hO9
                                      hO9T2


                                      Note that the newlines are significant. Try it online here.



                                      Explanation, with newlines replaced with ¶ character:



                                      ^¶i,¶hO9¶hO9T2 Implicit: T=10

                                      O9 Choose a random number in [0-9)
                                      h Increment
                                      ¶ Output with newline - value printed is yielded as expression result
                                      ¶hO9 Do the above again
                                      , Wrap the two previous results in a two-element array
                                      i T Convert to decimal from base 10
                                      ¶ Output with newline
                                      ^ 2 Square the previous result, implicit print






                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered 2 hours ago









                                      Sok

                                      3,219722




                                      3,219722











                                      • @Downvoter - any particular reason why?
                                        – Sok
                                        1 hour ago
















                                      • @Downvoter - any particular reason why?
                                        – Sok
                                        1 hour ago















                                      @Downvoter - any particular reason why?
                                      – Sok
                                      1 hour ago




                                      @Downvoter - any particular reason why?
                                      – Sok
                                      1 hour ago










                                      up vote
                                      2
                                      down vote














                                      Japt, 14 bytes



                                      9õ ï ö
                                      pU¬Uì ²



                                      9õ ï ö
                                      pU¬Uì ² Full program
                                      -----------------------------------------
                                      9õ Range [1,9]
                                      ï Cartesian product with itself
                                      ö get a random element
                                      This result is assigned to U

                                      p Push into U
                                      U¬ Elements in U joined
                                      Uì ² and elements joined squared
                                      Implicit output each element
                                      separated with new line -R


                                      Try it online!






                                      share|improve this answer


















                                      • 1




                                        Mq can return 0
                                        – Shaggy
                                        2 hours ago










                                      • @Shaggy didn't notice that the random numbers range was [1, 9]. It should be fixed now
                                        – Luis felipe De jesus Munoz
                                        1 hour ago















                                      up vote
                                      2
                                      down vote














                                      Japt, 14 bytes



                                      9õ ï ö
                                      pU¬Uì ²



                                      9õ ï ö
                                      pU¬Uì ² Full program
                                      -----------------------------------------
                                      9õ Range [1,9]
                                      ï Cartesian product with itself
                                      ö get a random element
                                      This result is assigned to U

                                      p Push into U
                                      U¬ Elements in U joined
                                      Uì ² and elements joined squared
                                      Implicit output each element
                                      separated with new line -R


                                      Try it online!






                                      share|improve this answer


















                                      • 1




                                        Mq can return 0
                                        – Shaggy
                                        2 hours ago










                                      • @Shaggy didn't notice that the random numbers range was [1, 9]. It should be fixed now
                                        – Luis felipe De jesus Munoz
                                        1 hour ago













                                      up vote
                                      2
                                      down vote










                                      up vote
                                      2
                                      down vote










                                      Japt, 14 bytes



                                      9õ ï ö
                                      pU¬Uì ²



                                      9õ ï ö
                                      pU¬Uì ² Full program
                                      -----------------------------------------
                                      9õ Range [1,9]
                                      ï Cartesian product with itself
                                      ö get a random element
                                      This result is assigned to U

                                      p Push into U
                                      U¬ Elements in U joined
                                      Uì ² and elements joined squared
                                      Implicit output each element
                                      separated with new line -R


                                      Try it online!






                                      share|improve this answer















                                      Japt, 14 bytes



                                      9õ ï ö
                                      pU¬Uì ²



                                      9õ ï ö
                                      pU¬Uì ² Full program
                                      -----------------------------------------
                                      9õ Range [1,9]
                                      ï Cartesian product with itself
                                      ö get a random element
                                      This result is assigned to U

                                      p Push into U
                                      U¬ Elements in U joined
                                      Uì ² and elements joined squared
                                      Implicit output each element
                                      separated with new line -R


                                      Try it online!







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited 1 hour ago

























                                      answered 3 hours ago









                                      Luis felipe De jesus Munoz

                                      3,46011049




                                      3,46011049







                                      • 1




                                        Mq can return 0
                                        – Shaggy
                                        2 hours ago










                                      • @Shaggy didn't notice that the random numbers range was [1, 9]. It should be fixed now
                                        – Luis felipe De jesus Munoz
                                        1 hour ago













                                      • 1




                                        Mq can return 0
                                        – Shaggy
                                        2 hours ago










                                      • @Shaggy didn't notice that the random numbers range was [1, 9]. It should be fixed now
                                        – Luis felipe De jesus Munoz
                                        1 hour ago








                                      1




                                      1




                                      Mq can return 0
                                      – Shaggy
                                      2 hours ago




                                      Mq can return 0
                                      – Shaggy
                                      2 hours ago












                                      @Shaggy didn't notice that the random numbers range was [1, 9]. It should be fixed now
                                      – Luis felipe De jesus Munoz
                                      1 hour ago





                                      @Shaggy didn't notice that the random numbers range was [1, 9]. It should be fixed now
                                      – Luis felipe De jesus Munoz
                                      1 hour ago











                                      up vote
                                      2
                                      down vote













                                      T-SQL, 142 105 115 114 96 bytes





                                      DECLARE @ AS char=LEFT(RAND()*9+1,1),@a AS char=LEFT(RAND()*9+1,1)SELECT @,@a,@+@a,POWER(@+@a,2)


                                      -37 bytes: Realized I could just use two different random numbers and use the first digits from each!
                                      +10 bytes: Edited to meet requirements of range from 1-9, instead of 0-9
                                      -1 byte: Changed RIGHT() to LEFT() in @b
                                      -18 bytes: Various changes suggested by BradC



                                      Ungolfed:



                                      -- Setting RAND() separately in these produces different numbers.
                                      -- [RAND() * b + a] sets the range for a random number, from a to b inclusive.
                                      -- Set the variable string to the first number.
                                      DECLARE @ AS char = LEFT(RAND() * 9 + 1, 1),
                                      @a AS char = LEFT(RAND() * 9 + 1, 1)

                                      SELECT @, -- first digit
                                      @a, -- second digit
                                      @ + @a, -- first two digits combined (not added, as they are type char)
                                      POWER(@ + @a, 2) -- first two digits combined, squared (POWER function will cast the first argument to a number if it is a string)





                                      share|improve this answer


















                                      • 1




                                        Nice work, a few ways to save more: use char instead of varchar, use @ by itself for one of the two variables (its valid!), simplify each RAND to RAND()*9+1 (which is 10-1, your code wasn't allowing for 9s).
                                        – BradC
                                        26 mins ago










                                      • Ooo, you'd have to change your SELECT math, but you can declare both variables as INT, and just let it to an implicit converstion, dropping the LEFT altogether! DECLARE @ AS INT=RAND()*9+1,@b AS INT=...
                                        – BradC
                                        18 mins ago










                                      • The stuff in the first comment definitely works, I'll edit that in. Problem with making the variables ints is that I would need to cast each individually as chars in the SELECT where necessary. With that, since each variable would need to be converted twice (in @+@a and POWER(@+@a,2)), it'd add more characters than it would save.
                                        – Meerkat
                                        11 mins ago














                                      up vote
                                      2
                                      down vote













                                      T-SQL, 142 105 115 114 96 bytes





                                      DECLARE @ AS char=LEFT(RAND()*9+1,1),@a AS char=LEFT(RAND()*9+1,1)SELECT @,@a,@+@a,POWER(@+@a,2)


                                      -37 bytes: Realized I could just use two different random numbers and use the first digits from each!
                                      +10 bytes: Edited to meet requirements of range from 1-9, instead of 0-9
                                      -1 byte: Changed RIGHT() to LEFT() in @b
                                      -18 bytes: Various changes suggested by BradC



                                      Ungolfed:



                                      -- Setting RAND() separately in these produces different numbers.
                                      -- [RAND() * b + a] sets the range for a random number, from a to b inclusive.
                                      -- Set the variable string to the first number.
                                      DECLARE @ AS char = LEFT(RAND() * 9 + 1, 1),
                                      @a AS char = LEFT(RAND() * 9 + 1, 1)

                                      SELECT @, -- first digit
                                      @a, -- second digit
                                      @ + @a, -- first two digits combined (not added, as they are type char)
                                      POWER(@ + @a, 2) -- first two digits combined, squared (POWER function will cast the first argument to a number if it is a string)





                                      share|improve this answer


















                                      • 1




                                        Nice work, a few ways to save more: use char instead of varchar, use @ by itself for one of the two variables (its valid!), simplify each RAND to RAND()*9+1 (which is 10-1, your code wasn't allowing for 9s).
                                        – BradC
                                        26 mins ago










                                      • Ooo, you'd have to change your SELECT math, but you can declare both variables as INT, and just let it to an implicit converstion, dropping the LEFT altogether! DECLARE @ AS INT=RAND()*9+1,@b AS INT=...
                                        – BradC
                                        18 mins ago










                                      • The stuff in the first comment definitely works, I'll edit that in. Problem with making the variables ints is that I would need to cast each individually as chars in the SELECT where necessary. With that, since each variable would need to be converted twice (in @+@a and POWER(@+@a,2)), it'd add more characters than it would save.
                                        – Meerkat
                                        11 mins ago












                                      up vote
                                      2
                                      down vote










                                      up vote
                                      2
                                      down vote









                                      T-SQL, 142 105 115 114 96 bytes





                                      DECLARE @ AS char=LEFT(RAND()*9+1,1),@a AS char=LEFT(RAND()*9+1,1)SELECT @,@a,@+@a,POWER(@+@a,2)


                                      -37 bytes: Realized I could just use two different random numbers and use the first digits from each!
                                      +10 bytes: Edited to meet requirements of range from 1-9, instead of 0-9
                                      -1 byte: Changed RIGHT() to LEFT() in @b
                                      -18 bytes: Various changes suggested by BradC



                                      Ungolfed:



                                      -- Setting RAND() separately in these produces different numbers.
                                      -- [RAND() * b + a] sets the range for a random number, from a to b inclusive.
                                      -- Set the variable string to the first number.
                                      DECLARE @ AS char = LEFT(RAND() * 9 + 1, 1),
                                      @a AS char = LEFT(RAND() * 9 + 1, 1)

                                      SELECT @, -- first digit
                                      @a, -- second digit
                                      @ + @a, -- first two digits combined (not added, as they are type char)
                                      POWER(@ + @a, 2) -- first two digits combined, squared (POWER function will cast the first argument to a number if it is a string)





                                      share|improve this answer














                                      T-SQL, 142 105 115 114 96 bytes





                                      DECLARE @ AS char=LEFT(RAND()*9+1,1),@a AS char=LEFT(RAND()*9+1,1)SELECT @,@a,@+@a,POWER(@+@a,2)


                                      -37 bytes: Realized I could just use two different random numbers and use the first digits from each!
                                      +10 bytes: Edited to meet requirements of range from 1-9, instead of 0-9
                                      -1 byte: Changed RIGHT() to LEFT() in @b
                                      -18 bytes: Various changes suggested by BradC



                                      Ungolfed:



                                      -- Setting RAND() separately in these produces different numbers.
                                      -- [RAND() * b + a] sets the range for a random number, from a to b inclusive.
                                      -- Set the variable string to the first number.
                                      DECLARE @ AS char = LEFT(RAND() * 9 + 1, 1),
                                      @a AS char = LEFT(RAND() * 9 + 1, 1)

                                      SELECT @, -- first digit
                                      @a, -- second digit
                                      @ + @a, -- first two digits combined (not added, as they are type char)
                                      POWER(@ + @a, 2) -- first two digits combined, squared (POWER function will cast the first argument to a number if it is a string)






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited 7 mins ago

























                                      answered 1 hour ago









                                      Meerkat

                                      1215




                                      1215







                                      • 1




                                        Nice work, a few ways to save more: use char instead of varchar, use @ by itself for one of the two variables (its valid!), simplify each RAND to RAND()*9+1 (which is 10-1, your code wasn't allowing for 9s).
                                        – BradC
                                        26 mins ago










                                      • Ooo, you'd have to change your SELECT math, but you can declare both variables as INT, and just let it to an implicit converstion, dropping the LEFT altogether! DECLARE @ AS INT=RAND()*9+1,@b AS INT=...
                                        – BradC
                                        18 mins ago










                                      • The stuff in the first comment definitely works, I'll edit that in. Problem with making the variables ints is that I would need to cast each individually as chars in the SELECT where necessary. With that, since each variable would need to be converted twice (in @+@a and POWER(@+@a,2)), it'd add more characters than it would save.
                                        – Meerkat
                                        11 mins ago












                                      • 1




                                        Nice work, a few ways to save more: use char instead of varchar, use @ by itself for one of the two variables (its valid!), simplify each RAND to RAND()*9+1 (which is 10-1, your code wasn't allowing for 9s).
                                        – BradC
                                        26 mins ago










                                      • Ooo, you'd have to change your SELECT math, but you can declare both variables as INT, and just let it to an implicit converstion, dropping the LEFT altogether! DECLARE @ AS INT=RAND()*9+1,@b AS INT=...
                                        – BradC
                                        18 mins ago










                                      • The stuff in the first comment definitely works, I'll edit that in. Problem with making the variables ints is that I would need to cast each individually as chars in the SELECT where necessary. With that, since each variable would need to be converted twice (in @+@a and POWER(@+@a,2)), it'd add more characters than it would save.
                                        – Meerkat
                                        11 mins ago







                                      1




                                      1




                                      Nice work, a few ways to save more: use char instead of varchar, use @ by itself for one of the two variables (its valid!), simplify each RAND to RAND()*9+1 (which is 10-1, your code wasn't allowing for 9s).
                                      – BradC
                                      26 mins ago




                                      Nice work, a few ways to save more: use char instead of varchar, use @ by itself for one of the two variables (its valid!), simplify each RAND to RAND()*9+1 (which is 10-1, your code wasn't allowing for 9s).
                                      – BradC
                                      26 mins ago












                                      Ooo, you'd have to change your SELECT math, but you can declare both variables as INT, and just let it to an implicit converstion, dropping the LEFT altogether! DECLARE @ AS INT=RAND()*9+1,@b AS INT=...
                                      – BradC
                                      18 mins ago




                                      Ooo, you'd have to change your SELECT math, but you can declare both variables as INT, and just let it to an implicit converstion, dropping the LEFT altogether! DECLARE @ AS INT=RAND()*9+1,@b AS INT=...
                                      – BradC
                                      18 mins ago












                                      The stuff in the first comment definitely works, I'll edit that in. Problem with making the variables ints is that I would need to cast each individually as chars in the SELECT where necessary. With that, since each variable would need to be converted twice (in @+@a and POWER(@+@a,2)), it'd add more characters than it would save.
                                      – Meerkat
                                      11 mins ago




                                      The stuff in the first comment definitely works, I'll edit that in. Problem with making the variables ints is that I would need to cast each individually as chars in the SELECT where necessary. With that, since each variable would need to be converted twice (in @+@a and POWER(@+@a,2)), it'd add more characters than it would save.
                                      – Meerkat
                                      11 mins ago










                                      up vote
                                      1
                                      down vote













                                      JavaScript (ES6), 67 bytes





                                      f=_=>(n=Math.random()*90+10|0)%10?(n/10|0)+`
                                      $n%10
                                      $n
                                      `+n*n:f()


                                      Try it online!






                                      share|improve this answer
























                                        up vote
                                        1
                                        down vote













                                        JavaScript (ES6), 67 bytes





                                        f=_=>(n=Math.random()*90+10|0)%10?(n/10|0)+`
                                        $n%10
                                        $n
                                        `+n*n:f()


                                        Try it online!






                                        share|improve this answer






















                                          up vote
                                          1
                                          down vote










                                          up vote
                                          1
                                          down vote









                                          JavaScript (ES6), 67 bytes





                                          f=_=>(n=Math.random()*90+10|0)%10?(n/10|0)+`
                                          $n%10
                                          $n
                                          `+n*n:f()


                                          Try it online!






                                          share|improve this answer












                                          JavaScript (ES6), 67 bytes





                                          f=_=>(n=Math.random()*90+10|0)%10?(n/10|0)+`
                                          $n%10
                                          $n
                                          `+n*n:f()


                                          Try it online!







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered 3 hours ago









                                          Arnauld

                                          67.1k584282




                                          67.1k584282




















                                              up vote
                                              1
                                              down vote














                                              Charcoal, 16 bytes



                                              ≔⭆²⊕‽⁹θ↓θθ⸿IXIθ²


                                              Try it online! Link is to verbose version of code. Explanation:



                                              ≔⭆²⊕‽⁹θ


                                              Generate two random characters in the range 1 to 9.



                                              ↓θ


                                              Output them downwards i.e. on separate lines.



                                              θ⸿


                                              Output them horizontally on their own line.



                                              IXIθ²


                                              Cast to integer, square, cast back to string for implicit print.






                                              share|improve this answer
























                                                up vote
                                                1
                                                down vote














                                                Charcoal, 16 bytes



                                                ≔⭆²⊕‽⁹θ↓θθ⸿IXIθ²


                                                Try it online! Link is to verbose version of code. Explanation:



                                                ≔⭆²⊕‽⁹θ


                                                Generate two random characters in the range 1 to 9.



                                                ↓θ


                                                Output them downwards i.e. on separate lines.



                                                θ⸿


                                                Output them horizontally on their own line.



                                                IXIθ²


                                                Cast to integer, square, cast back to string for implicit print.






                                                share|improve this answer






















                                                  up vote
                                                  1
                                                  down vote










                                                  up vote
                                                  1
                                                  down vote










                                                  Charcoal, 16 bytes



                                                  ≔⭆²⊕‽⁹θ↓θθ⸿IXIθ²


                                                  Try it online! Link is to verbose version of code. Explanation:



                                                  ≔⭆²⊕‽⁹θ


                                                  Generate two random characters in the range 1 to 9.



                                                  ↓θ


                                                  Output them downwards i.e. on separate lines.



                                                  θ⸿


                                                  Output them horizontally on their own line.



                                                  IXIθ²


                                                  Cast to integer, square, cast back to string for implicit print.






                                                  share|improve this answer













                                                  Charcoal, 16 bytes



                                                  ≔⭆²⊕‽⁹θ↓θθ⸿IXIθ²


                                                  Try it online! Link is to verbose version of code. Explanation:



                                                  ≔⭆²⊕‽⁹θ


                                                  Generate two random characters in the range 1 to 9.



                                                  ↓θ


                                                  Output them downwards i.e. on separate lines.



                                                  θ⸿


                                                  Output them horizontally on their own line.



                                                  IXIθ²


                                                  Cast to integer, square, cast back to string for implicit print.







                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered 2 hours ago









                                                  Neil

                                                  77.2k744174




                                                  77.2k744174




















                                                      up vote
                                                      1
                                                      down vote














                                                      Jelly, 10 9 bytes



                                                      9ṗ2XṄ€ḌṄ²


                                                      Try it online!



                                                      How it works



                                                      9ṗ2XṄ€ḌṄ² Main link. No arguments.

                                                      9 Set the return value to 9.
                                                      ṗ2 Promote 9 to [1, ..., 9] and take the second Cartesian power, yielding
                                                      [[1, 1], [1, 2], ..., [9, 8], [9, 9]].
                                                      X Pseudo-randomly select one of the pairs.
                                                      Ṅ€ Print each integer in the pair, followed by a newline.
                                                      Ḍ Undecimal; convert the integer pair from base 10 to an integer.
                                                      Ṅ Print the integer, followed by a newline.
                                                      ² Take the square.
                                                      (implicit) Print the last return value.





                                                      share|improve this answer


























                                                        up vote
                                                        1
                                                        down vote














                                                        Jelly, 10 9 bytes



                                                        9ṗ2XṄ€ḌṄ²


                                                        Try it online!



                                                        How it works



                                                        9ṗ2XṄ€ḌṄ² Main link. No arguments.

                                                        9 Set the return value to 9.
                                                        ṗ2 Promote 9 to [1, ..., 9] and take the second Cartesian power, yielding
                                                        [[1, 1], [1, 2], ..., [9, 8], [9, 9]].
                                                        X Pseudo-randomly select one of the pairs.
                                                        Ṅ€ Print each integer in the pair, followed by a newline.
                                                        Ḍ Undecimal; convert the integer pair from base 10 to an integer.
                                                        Ṅ Print the integer, followed by a newline.
                                                        ² Take the square.
                                                        (implicit) Print the last return value.





                                                        share|improve this answer
























                                                          up vote
                                                          1
                                                          down vote










                                                          up vote
                                                          1
                                                          down vote










                                                          Jelly, 10 9 bytes



                                                          9ṗ2XṄ€ḌṄ²


                                                          Try it online!



                                                          How it works



                                                          9ṗ2XṄ€ḌṄ² Main link. No arguments.

                                                          9 Set the return value to 9.
                                                          ṗ2 Promote 9 to [1, ..., 9] and take the second Cartesian power, yielding
                                                          [[1, 1], [1, 2], ..., [9, 8], [9, 9]].
                                                          X Pseudo-randomly select one of the pairs.
                                                          Ṅ€ Print each integer in the pair, followed by a newline.
                                                          Ḍ Undecimal; convert the integer pair from base 10 to an integer.
                                                          Ṅ Print the integer, followed by a newline.
                                                          ² Take the square.
                                                          (implicit) Print the last return value.





                                                          share|improve this answer















                                                          Jelly, 10 9 bytes



                                                          9ṗ2XṄ€ḌṄ²


                                                          Try it online!



                                                          How it works



                                                          9ṗ2XṄ€ḌṄ² Main link. No arguments.

                                                          9 Set the return value to 9.
                                                          ṗ2 Promote 9 to [1, ..., 9] and take the second Cartesian power, yielding
                                                          [[1, 1], [1, 2], ..., [9, 8], [9, 9]].
                                                          X Pseudo-randomly select one of the pairs.
                                                          Ṅ€ Print each integer in the pair, followed by a newline.
                                                          Ḍ Undecimal; convert the integer pair from base 10 to an integer.
                                                          Ṅ Print the integer, followed by a newline.
                                                          ² Take the square.
                                                          (implicit) Print the last return value.






                                                          share|improve this answer














                                                          share|improve this answer



                                                          share|improve this answer








                                                          edited 2 hours ago

























                                                          answered 2 hours ago









                                                          Dennis♦

                                                          183k32293725




                                                          183k32293725




















                                                              up vote
                                                              1
                                                              down vote














                                                              Ruby, 41 bytes





                                                              puts [(a=11+10*rand(81)/9)/10,a%10,a,a*a]


                                                              Try it online!






                                                              share|improve this answer
























                                                                up vote
                                                                1
                                                                down vote














                                                                Ruby, 41 bytes





                                                                puts [(a=11+10*rand(81)/9)/10,a%10,a,a*a]


                                                                Try it online!






                                                                share|improve this answer






















                                                                  up vote
                                                                  1
                                                                  down vote










                                                                  up vote
                                                                  1
                                                                  down vote










                                                                  Ruby, 41 bytes





                                                                  puts [(a=11+10*rand(81)/9)/10,a%10,a,a*a]


                                                                  Try it online!






                                                                  share|improve this answer













                                                                  Ruby, 41 bytes





                                                                  puts [(a=11+10*rand(81)/9)/10,a%10,a,a*a]


                                                                  Try it online!







                                                                  share|improve this answer












                                                                  share|improve this answer



                                                                  share|improve this answer










                                                                  answered 2 hours ago









                                                                  G B

                                                                  7,3371327




                                                                  7,3371327




















                                                                      up vote
                                                                      1
                                                                      down vote













                                                                      Vim, 44 bytes



                                                                      :%!$RANDOM

                                                                      :s/0//g
                                                                      2f:hy2hVpo=0*0
                                                                      kYPa



                                                                      Try it online!



                                                                      Not the right tool for the job. This produces most likely the desired output



                                                                      Step by step:



                                                                      • :%!$RANDOM Enter Enter

                                                                        Produces a string like /bin/bash: 25266: command not found


                                                                      • :s/0//g

                                                                        removes all zeroes


                                                                      • 2f:hy2hVp

                                                                        moves the cursor one to the left of the colon after the number, copy the last two digits and replace the entire string with those


                                                                      • o Ctrl+R = Ctrl+R 0* Ctrl+R 0 Enter

                                                                        add a new line and evaluate an expression. In this case, I'll multiply the number in register 0 (the one that was just copied) with itself. Result:


                                                                      • Esc kYPa Enter

                                                                        Copy the upper line and paste it above. The cursor ends up in the first line, on the first character. Now we just have to append a line break to it


                                                                      Limitations: If the result of $RANDOM is a number with less than two non-zero digits, this will not produce the desired output






                                                                      share|improve this answer


























                                                                        up vote
                                                                        1
                                                                        down vote













                                                                        Vim, 44 bytes



                                                                        :%!$RANDOM

                                                                        :s/0//g
                                                                        2f:hy2hVpo=0*0
                                                                        kYPa



                                                                        Try it online!



                                                                        Not the right tool for the job. This produces most likely the desired output



                                                                        Step by step:



                                                                        • :%!$RANDOM Enter Enter

                                                                          Produces a string like /bin/bash: 25266: command not found


                                                                        • :s/0//g

                                                                          removes all zeroes


                                                                        • 2f:hy2hVp

                                                                          moves the cursor one to the left of the colon after the number, copy the last two digits and replace the entire string with those


                                                                        • o Ctrl+R = Ctrl+R 0* Ctrl+R 0 Enter

                                                                          add a new line and evaluate an expression. In this case, I'll multiply the number in register 0 (the one that was just copied) with itself. Result:


                                                                        • Esc kYPa Enter

                                                                          Copy the upper line and paste it above. The cursor ends up in the first line, on the first character. Now we just have to append a line break to it


                                                                        Limitations: If the result of $RANDOM is a number with less than two non-zero digits, this will not produce the desired output






                                                                        share|improve this answer
























                                                                          up vote
                                                                          1
                                                                          down vote










                                                                          up vote
                                                                          1
                                                                          down vote









                                                                          Vim, 44 bytes



                                                                          :%!$RANDOM

                                                                          :s/0//g
                                                                          2f:hy2hVpo=0*0
                                                                          kYPa



                                                                          Try it online!



                                                                          Not the right tool for the job. This produces most likely the desired output



                                                                          Step by step:



                                                                          • :%!$RANDOM Enter Enter

                                                                            Produces a string like /bin/bash: 25266: command not found


                                                                          • :s/0//g

                                                                            removes all zeroes


                                                                          • 2f:hy2hVp

                                                                            moves the cursor one to the left of the colon after the number, copy the last two digits and replace the entire string with those


                                                                          • o Ctrl+R = Ctrl+R 0* Ctrl+R 0 Enter

                                                                            add a new line and evaluate an expression. In this case, I'll multiply the number in register 0 (the one that was just copied) with itself. Result:


                                                                          • Esc kYPa Enter

                                                                            Copy the upper line and paste it above. The cursor ends up in the first line, on the first character. Now we just have to append a line break to it


                                                                          Limitations: If the result of $RANDOM is a number with less than two non-zero digits, this will not produce the desired output






                                                                          share|improve this answer














                                                                          Vim, 44 bytes



                                                                          :%!$RANDOM

                                                                          :s/0//g
                                                                          2f:hy2hVpo=0*0
                                                                          kYPa



                                                                          Try it online!



                                                                          Not the right tool for the job. This produces most likely the desired output



                                                                          Step by step:



                                                                          • :%!$RANDOM Enter Enter

                                                                            Produces a string like /bin/bash: 25266: command not found


                                                                          • :s/0//g

                                                                            removes all zeroes


                                                                          • 2f:hy2hVp

                                                                            moves the cursor one to the left of the colon after the number, copy the last two digits and replace the entire string with those


                                                                          • o Ctrl+R = Ctrl+R 0* Ctrl+R 0 Enter

                                                                            add a new line and evaluate an expression. In this case, I'll multiply the number in register 0 (the one that was just copied) with itself. Result:


                                                                          • Esc kYPa Enter

                                                                            Copy the upper line and paste it above. The cursor ends up in the first line, on the first character. Now we just have to append a line break to it


                                                                          Limitations: If the result of $RANDOM is a number with less than two non-zero digits, this will not produce the desired output







                                                                          share|improve this answer














                                                                          share|improve this answer



                                                                          share|improve this answer








                                                                          edited 1 hour ago

























                                                                          answered 1 hour ago









                                                                          oktupol

                                                                          6379




                                                                          6379




















                                                                              up vote
                                                                              1
                                                                              down vote













                                                                              Java 8, 99 98 90 81 80 bytes





                                                                              v->int i=81;i*=Math.random();return(i=i*10/9+11)/10+"n"+i%10+"n"+i+"n"+i*i;


                                                                              -8 bytes after being inspired by @Arnauld's JavaScript answer.

                                                                              -9 bytes thanks to @nwellnhof.



                                                                              Try it online.



                                                                              Explanation:



                                                                              v-> // Method with empty unused parameter and no return-type
                                                                              int i=81;i*=Math.random();// Create a random integer `i` in the range [0,81)
                                                                              return(i=i*10/9+11) // Set `i` to 10 times `i`, integer-divided by 9, and 11 added
                                                                              /10+"n" // Return the first digit of `i`, a newline,
                                                                              +i%10+"n" // the last digit of `i`, a newline,
                                                                              +i+"n" // `i` itself, a newline,
                                                                              +i*i; // and `i` multiplied by itself
                                                                              // All concatted to each other





                                                                              share|improve this answer






















                                                                              • @nwellnhof Thanks! And been able to golf 1 more byte with my previous trick of int i=81;i*=Math.random();return(i=i*10/9+11).
                                                                                – Kevin Cruijssen
                                                                                1 hour ago














                                                                              up vote
                                                                              1
                                                                              down vote













                                                                              Java 8, 99 98 90 81 80 bytes





                                                                              v->int i=81;i*=Math.random();return(i=i*10/9+11)/10+"n"+i%10+"n"+i+"n"+i*i;


                                                                              -8 bytes after being inspired by @Arnauld's JavaScript answer.

                                                                              -9 bytes thanks to @nwellnhof.



                                                                              Try it online.



                                                                              Explanation:



                                                                              v-> // Method with empty unused parameter and no return-type
                                                                              int i=81;i*=Math.random();// Create a random integer `i` in the range [0,81)
                                                                              return(i=i*10/9+11) // Set `i` to 10 times `i`, integer-divided by 9, and 11 added
                                                                              /10+"n" // Return the first digit of `i`, a newline,
                                                                              +i%10+"n" // the last digit of `i`, a newline,
                                                                              +i+"n" // `i` itself, a newline,
                                                                              +i*i; // and `i` multiplied by itself
                                                                              // All concatted to each other





                                                                              share|improve this answer






















                                                                              • @nwellnhof Thanks! And been able to golf 1 more byte with my previous trick of int i=81;i*=Math.random();return(i=i*10/9+11).
                                                                                – Kevin Cruijssen
                                                                                1 hour ago












                                                                              up vote
                                                                              1
                                                                              down vote










                                                                              up vote
                                                                              1
                                                                              down vote









                                                                              Java 8, 99 98 90 81 80 bytes





                                                                              v->int i=81;i*=Math.random();return(i=i*10/9+11)/10+"n"+i%10+"n"+i+"n"+i*i;


                                                                              -8 bytes after being inspired by @Arnauld's JavaScript answer.

                                                                              -9 bytes thanks to @nwellnhof.



                                                                              Try it online.



                                                                              Explanation:



                                                                              v-> // Method with empty unused parameter and no return-type
                                                                              int i=81;i*=Math.random();// Create a random integer `i` in the range [0,81)
                                                                              return(i=i*10/9+11) // Set `i` to 10 times `i`, integer-divided by 9, and 11 added
                                                                              /10+"n" // Return the first digit of `i`, a newline,
                                                                              +i%10+"n" // the last digit of `i`, a newline,
                                                                              +i+"n" // `i` itself, a newline,
                                                                              +i*i; // and `i` multiplied by itself
                                                                              // All concatted to each other





                                                                              share|improve this answer














                                                                              Java 8, 99 98 90 81 80 bytes





                                                                              v->int i=81;i*=Math.random();return(i=i*10/9+11)/10+"n"+i%10+"n"+i+"n"+i*i;


                                                                              -8 bytes after being inspired by @Arnauld's JavaScript answer.

                                                                              -9 bytes thanks to @nwellnhof.



                                                                              Try it online.



                                                                              Explanation:



                                                                              v-> // Method with empty unused parameter and no return-type
                                                                              int i=81;i*=Math.random();// Create a random integer `i` in the range [0,81)
                                                                              return(i=i*10/9+11) // Set `i` to 10 times `i`, integer-divided by 9, and 11 added
                                                                              /10+"n" // Return the first digit of `i`, a newline,
                                                                              +i%10+"n" // the last digit of `i`, a newline,
                                                                              +i+"n" // `i` itself, a newline,
                                                                              +i*i; // and `i` multiplied by itself
                                                                              // All concatted to each other






                                                                              share|improve this answer














                                                                              share|improve this answer



                                                                              share|improve this answer








                                                                              edited 1 hour ago

























                                                                              answered 3 hours ago









                                                                              Kevin Cruijssen

                                                                              32.7k554176




                                                                              32.7k554176











                                                                              • @nwellnhof Thanks! And been able to golf 1 more byte with my previous trick of int i=81;i*=Math.random();return(i=i*10/9+11).
                                                                                – Kevin Cruijssen
                                                                                1 hour ago
















                                                                              • @nwellnhof Thanks! And been able to golf 1 more byte with my previous trick of int i=81;i*=Math.random();return(i=i*10/9+11).
                                                                                – Kevin Cruijssen
                                                                                1 hour ago















                                                                              @nwellnhof Thanks! And been able to golf 1 more byte with my previous trick of int i=81;i*=Math.random();return(i=i*10/9+11).
                                                                              – Kevin Cruijssen
                                                                              1 hour ago




                                                                              @nwellnhof Thanks! And been able to golf 1 more byte with my previous trick of int i=81;i*=Math.random();return(i=i*10/9+11).
                                                                              – Kevin Cruijssen
                                                                              1 hour ago










                                                                              up vote
                                                                              1
                                                                              down vote














                                                                              05AB1E, 14 11 bytes



                                                                              2F9LΩ=}J=n,


                                                                              -3 bytes thanks to @Emigna.



                                                                              Try it online.



                                                                              Explanation:





                                                                              2F } # Loop 2 times:
                                                                              9LΩ # Create a list in the range [1,9], and pick a random element from it
                                                                              = # Output it (without popping it from the stack)
                                                                              J # Join them together
                                                                              = # Output it (without popping it from the stack)
                                                                              n # Take it to the power of 2
                                                                              , # And output it as well





                                                                              11 bytes alternative:



                                                                              9LãΩ©`®JDn»


                                                                              Try it online.



                                                                              Explanation:





                                                                              9L # List in the range [1,9]
                                                                              ã # Cartesian product with itself: [[1,1],[1,2],[1,3],...,[9,7],[9,8],[9,9]]
                                                                              Ω # Take a random element from it
                                                                              © # Store it in the register (without popping)
                                                                              ` # Pop and push both items as separated items onto the stack
                                                                              ® # Retrieve the list of digits from the register again
                                                                              J # Join them together to a single 2-digit number
                                                                              Dn # Duplicate it, and take the power of 2 of the copy
                                                                              » # Merge all values on the stack by newlines (and output implicitly)





                                                                              share|improve this answer


















                                                                              • 1




                                                                                Shorter in a looP: 2F9LΩ=}J=n,
                                                                                – Emigna
                                                                                3 hours ago










                                                                              • @Emigna I was about to look for shorter alternatives, but smart use of the =!
                                                                                – Kevin Cruijssen
                                                                                3 hours ago















                                                                              up vote
                                                                              1
                                                                              down vote














                                                                              05AB1E, 14 11 bytes



                                                                              2F9LΩ=}J=n,


                                                                              -3 bytes thanks to @Emigna.



                                                                              Try it online.



                                                                              Explanation:





                                                                              2F } # Loop 2 times:
                                                                              9LΩ # Create a list in the range [1,9], and pick a random element from it
                                                                              = # Output it (without popping it from the stack)
                                                                              J # Join them together
                                                                              = # Output it (without popping it from the stack)
                                                                              n # Take it to the power of 2
                                                                              , # And output it as well





                                                                              11 bytes alternative:



                                                                              9LãΩ©`®JDn»


                                                                              Try it online.



                                                                              Explanation:





                                                                              9L # List in the range [1,9]
                                                                              ã # Cartesian product with itself: [[1,1],[1,2],[1,3],...,[9,7],[9,8],[9,9]]
                                                                              Ω # Take a random element from it
                                                                              © # Store it in the register (without popping)
                                                                              ` # Pop and push both items as separated items onto the stack
                                                                              ® # Retrieve the list of digits from the register again
                                                                              J # Join them together to a single 2-digit number
                                                                              Dn # Duplicate it, and take the power of 2 of the copy
                                                                              » # Merge all values on the stack by newlines (and output implicitly)





                                                                              share|improve this answer


















                                                                              • 1




                                                                                Shorter in a looP: 2F9LΩ=}J=n,
                                                                                – Emigna
                                                                                3 hours ago










                                                                              • @Emigna I was about to look for shorter alternatives, but smart use of the =!
                                                                                – Kevin Cruijssen
                                                                                3 hours ago













                                                                              up vote
                                                                              1
                                                                              down vote










                                                                              up vote
                                                                              1
                                                                              down vote










                                                                              05AB1E, 14 11 bytes



                                                                              2F9LΩ=}J=n,


                                                                              -3 bytes thanks to @Emigna.



                                                                              Try it online.



                                                                              Explanation:





                                                                              2F } # Loop 2 times:
                                                                              9LΩ # Create a list in the range [1,9], and pick a random element from it
                                                                              = # Output it (without popping it from the stack)
                                                                              J # Join them together
                                                                              = # Output it (without popping it from the stack)
                                                                              n # Take it to the power of 2
                                                                              , # And output it as well





                                                                              11 bytes alternative:



                                                                              9LãΩ©`®JDn»


                                                                              Try it online.



                                                                              Explanation:





                                                                              9L # List in the range [1,9]
                                                                              ã # Cartesian product with itself: [[1,1],[1,2],[1,3],...,[9,7],[9,8],[9,9]]
                                                                              Ω # Take a random element from it
                                                                              © # Store it in the register (without popping)
                                                                              ` # Pop and push both items as separated items onto the stack
                                                                              ® # Retrieve the list of digits from the register again
                                                                              J # Join them together to a single 2-digit number
                                                                              Dn # Duplicate it, and take the power of 2 of the copy
                                                                              » # Merge all values on the stack by newlines (and output implicitly)





                                                                              share|improve this answer















                                                                              05AB1E, 14 11 bytes



                                                                              2F9LΩ=}J=n,


                                                                              -3 bytes thanks to @Emigna.



                                                                              Try it online.



                                                                              Explanation:





                                                                              2F } # Loop 2 times:
                                                                              9LΩ # Create a list in the range [1,9], and pick a random element from it
                                                                              = # Output it (without popping it from the stack)
                                                                              J # Join them together
                                                                              = # Output it (without popping it from the stack)
                                                                              n # Take it to the power of 2
                                                                              , # And output it as well





                                                                              11 bytes alternative:



                                                                              9LãΩ©`®JDn»


                                                                              Try it online.



                                                                              Explanation:





                                                                              9L # List in the range [1,9]
                                                                              ã # Cartesian product with itself: [[1,1],[1,2],[1,3],...,[9,7],[9,8],[9,9]]
                                                                              Ω # Take a random element from it
                                                                              © # Store it in the register (without popping)
                                                                              ` # Pop and push both items as separated items onto the stack
                                                                              ® # Retrieve the list of digits from the register again
                                                                              J # Join them together to a single 2-digit number
                                                                              Dn # Duplicate it, and take the power of 2 of the copy
                                                                              » # Merge all values on the stack by newlines (and output implicitly)






                                                                              share|improve this answer














                                                                              share|improve this answer



                                                                              share|improve this answer








                                                                              edited 56 mins ago

























                                                                              answered 3 hours ago









                                                                              Kevin Cruijssen

                                                                              32.7k554176




                                                                              32.7k554176







                                                                              • 1




                                                                                Shorter in a looP: 2F9LΩ=}J=n,
                                                                                – Emigna
                                                                                3 hours ago










                                                                              • @Emigna I was about to look for shorter alternatives, but smart use of the =!
                                                                                – Kevin Cruijssen
                                                                                3 hours ago













                                                                              • 1




                                                                                Shorter in a looP: 2F9LΩ=}J=n,
                                                                                – Emigna
                                                                                3 hours ago










                                                                              • @Emigna I was about to look for shorter alternatives, but smart use of the =!
                                                                                – Kevin Cruijssen
                                                                                3 hours ago








                                                                              1




                                                                              1




                                                                              Shorter in a looP: 2F9LΩ=}J=n,
                                                                              – Emigna
                                                                              3 hours ago




                                                                              Shorter in a looP: 2F9LΩ=}J=n,
                                                                              – Emigna
                                                                              3 hours ago












                                                                              @Emigna I was about to look for shorter alternatives, but smart use of the =!
                                                                              – Kevin Cruijssen
                                                                              3 hours ago





                                                                              @Emigna I was about to look for shorter alternatives, but smart use of the =!
                                                                              – Kevin Cruijssen
                                                                              3 hours ago











                                                                              up vote
                                                                              1
                                                                              down vote














                                                                              Python 2, 84 75 bytes





                                                                              from random import*
                                                                              k=randint(9,89)*10/9+1
                                                                              for x in k/10,k%10,k,k*k:print x


                                                                              Try it online!




                                                                              Saved



                                                                              • -1 bytes, thanks to Erik the Outgolfer

                                                                              • -8 bytes, thanks to nwellnhof





                                                                              share|improve this answer






















                                                                              • Moderate golf: 83 bytes.
                                                                                – Erik the Outgolfer
                                                                                1 hour ago










                                                                              • @EriktheOutgolfer Thanks :)
                                                                                – TFeld
                                                                                45 mins ago










                                                                              • @nwellnhof Thanks :)
                                                                                – TFeld
                                                                                45 mins ago














                                                                              up vote
                                                                              1
                                                                              down vote














                                                                              Python 2, 84 75 bytes





                                                                              from random import*
                                                                              k=randint(9,89)*10/9+1
                                                                              for x in k/10,k%10,k,k*k:print x


                                                                              Try it online!




                                                                              Saved



                                                                              • -1 bytes, thanks to Erik the Outgolfer

                                                                              • -8 bytes, thanks to nwellnhof





                                                                              share|improve this answer






















                                                                              • Moderate golf: 83 bytes.
                                                                                – Erik the Outgolfer
                                                                                1 hour ago










                                                                              • @EriktheOutgolfer Thanks :)
                                                                                – TFeld
                                                                                45 mins ago










                                                                              • @nwellnhof Thanks :)
                                                                                – TFeld
                                                                                45 mins ago












                                                                              up vote
                                                                              1
                                                                              down vote










                                                                              up vote
                                                                              1
                                                                              down vote










                                                                              Python 2, 84 75 bytes





                                                                              from random import*
                                                                              k=randint(9,89)*10/9+1
                                                                              for x in k/10,k%10,k,k*k:print x


                                                                              Try it online!




                                                                              Saved



                                                                              • -1 bytes, thanks to Erik the Outgolfer

                                                                              • -8 bytes, thanks to nwellnhof





                                                                              share|improve this answer















                                                                              Python 2, 84 75 bytes





                                                                              from random import*
                                                                              k=randint(9,89)*10/9+1
                                                                              for x in k/10,k%10,k,k*k:print x


                                                                              Try it online!




                                                                              Saved



                                                                              • -1 bytes, thanks to Erik the Outgolfer

                                                                              • -8 bytes, thanks to nwellnhof






                                                                              share|improve this answer














                                                                              share|improve this answer



                                                                              share|improve this answer








                                                                              edited 45 mins ago

























                                                                              answered 3 hours ago









                                                                              TFeld

                                                                              12.8k2836




                                                                              12.8k2836











                                                                              • Moderate golf: 83 bytes.
                                                                                – Erik the Outgolfer
                                                                                1 hour ago










                                                                              • @EriktheOutgolfer Thanks :)
                                                                                – TFeld
                                                                                45 mins ago










                                                                              • @nwellnhof Thanks :)
                                                                                – TFeld
                                                                                45 mins ago
















                                                                              • Moderate golf: 83 bytes.
                                                                                – Erik the Outgolfer
                                                                                1 hour ago










                                                                              • @EriktheOutgolfer Thanks :)
                                                                                – TFeld
                                                                                45 mins ago










                                                                              • @nwellnhof Thanks :)
                                                                                – TFeld
                                                                                45 mins ago















                                                                              Moderate golf: 83 bytes.
                                                                              – Erik the Outgolfer
                                                                              1 hour ago




                                                                              Moderate golf: 83 bytes.
                                                                              – Erik the Outgolfer
                                                                              1 hour ago












                                                                              @EriktheOutgolfer Thanks :)
                                                                              – TFeld
                                                                              45 mins ago




                                                                              @EriktheOutgolfer Thanks :)
                                                                              – TFeld
                                                                              45 mins ago












                                                                              @nwellnhof Thanks :)
                                                                              – TFeld
                                                                              45 mins ago




                                                                              @nwellnhof Thanks :)
                                                                              – TFeld
                                                                              45 mins ago










                                                                              up vote
                                                                              0
                                                                              down vote














                                                                              C# (.NET Core), 130 bytes





                                                                              Random r=new Random();int a=r.Next(1,9),b=r.Next(1,9),c=int.Parse(a.ToString()+b.ToString());Console.Write(a+" "+b+" "+c+" "+c*c);


                                                                              Try it online!



                                                                              Ungolfed:



                                                                              Random r = new Random(); // initializes random number generator
                                                                              int a = r.Next(1, 9), // gets random number between 1 and 9 inclusive
                                                                              b = r.Next(1, 9), // gets random number between 1 and 9 inclusive
                                                                              c = int.Parse(a.ToString() + b.ToString()); // concatenates a and b into one two-digit number
                                                                              Console.Write(a + " " + b + " " + c + " " + c*c); // writes a, b, c, and c^2 to the console





                                                                              share|improve this answer


























                                                                                up vote
                                                                                0
                                                                                down vote














                                                                                C# (.NET Core), 130 bytes





                                                                                Random r=new Random();int a=r.Next(1,9),b=r.Next(1,9),c=int.Parse(a.ToString()+b.ToString());Console.Write(a+" "+b+" "+c+" "+c*c);


                                                                                Try it online!



                                                                                Ungolfed:



                                                                                Random r = new Random(); // initializes random number generator
                                                                                int a = r.Next(1, 9), // gets random number between 1 and 9 inclusive
                                                                                b = r.Next(1, 9), // gets random number between 1 and 9 inclusive
                                                                                c = int.Parse(a.ToString() + b.ToString()); // concatenates a and b into one two-digit number
                                                                                Console.Write(a + " " + b + " " + c + " " + c*c); // writes a, b, c, and c^2 to the console





                                                                                share|improve this answer
























                                                                                  up vote
                                                                                  0
                                                                                  down vote










                                                                                  up vote
                                                                                  0
                                                                                  down vote










                                                                                  C# (.NET Core), 130 bytes





                                                                                  Random r=new Random();int a=r.Next(1,9),b=r.Next(1,9),c=int.Parse(a.ToString()+b.ToString());Console.Write(a+" "+b+" "+c+" "+c*c);


                                                                                  Try it online!



                                                                                  Ungolfed:



                                                                                  Random r = new Random(); // initializes random number generator
                                                                                  int a = r.Next(1, 9), // gets random number between 1 and 9 inclusive
                                                                                  b = r.Next(1, 9), // gets random number between 1 and 9 inclusive
                                                                                  c = int.Parse(a.ToString() + b.ToString()); // concatenates a and b into one two-digit number
                                                                                  Console.Write(a + " " + b + " " + c + " " + c*c); // writes a, b, c, and c^2 to the console





                                                                                  share|improve this answer















                                                                                  C# (.NET Core), 130 bytes





                                                                                  Random r=new Random();int a=r.Next(1,9),b=r.Next(1,9),c=int.Parse(a.ToString()+b.ToString());Console.Write(a+" "+b+" "+c+" "+c*c);


                                                                                  Try it online!



                                                                                  Ungolfed:



                                                                                  Random r = new Random(); // initializes random number generator
                                                                                  int a = r.Next(1, 9), // gets random number between 1 and 9 inclusive
                                                                                  b = r.Next(1, 9), // gets random number between 1 and 9 inclusive
                                                                                  c = int.Parse(a.ToString() + b.ToString()); // concatenates a and b into one two-digit number
                                                                                  Console.Write(a + " " + b + " " + c + " " + c*c); // writes a, b, c, and c^2 to the console






                                                                                  share|improve this answer














                                                                                  share|improve this answer



                                                                                  share|improve this answer








                                                                                  edited 46 mins ago

























                                                                                  answered 57 mins ago









                                                                                  Meerkat

                                                                                  1215




                                                                                  1215




















                                                                                      up vote
                                                                                      0
                                                                                      down vote














                                                                                      K (oK), 28 bytes



                                                                                      t:2?10;t,:10/t;$t,:t[2]*t[2]


                                                                                      Explanation



                                                                                      t:2?10 //define t as two random numbers from 1-10
                                                                                      t,:10/t //join the base 10 joining of the elements of t to t
                                                                                      t,:t[2]*t[2]//join the square of the index 2 element to t
                                                                                      $ //String each element of the result (to output on newlines)


                                                                                      Try it online!



                                                                                      Cleaner Output, 32 bytes



                                                                                      t:2?10;t,:10/t;`0:$t,:t[2]*t[2];

                                                                                      `0: //Cleanly prints the strings


                                                                                      Try it online!






                                                                                      share|improve this answer


























                                                                                        up vote
                                                                                        0
                                                                                        down vote














                                                                                        K (oK), 28 bytes



                                                                                        t:2?10;t,:10/t;$t,:t[2]*t[2]


                                                                                        Explanation



                                                                                        t:2?10 //define t as two random numbers from 1-10
                                                                                        t,:10/t //join the base 10 joining of the elements of t to t
                                                                                        t,:t[2]*t[2]//join the square of the index 2 element to t
                                                                                        $ //String each element of the result (to output on newlines)


                                                                                        Try it online!



                                                                                        Cleaner Output, 32 bytes



                                                                                        t:2?10;t,:10/t;`0:$t,:t[2]*t[2];

                                                                                        `0: //Cleanly prints the strings


                                                                                        Try it online!






                                                                                        share|improve this answer
























                                                                                          up vote
                                                                                          0
                                                                                          down vote










                                                                                          up vote
                                                                                          0
                                                                                          down vote










                                                                                          K (oK), 28 bytes



                                                                                          t:2?10;t,:10/t;$t,:t[2]*t[2]


                                                                                          Explanation



                                                                                          t:2?10 //define t as two random numbers from 1-10
                                                                                          t,:10/t //join the base 10 joining of the elements of t to t
                                                                                          t,:t[2]*t[2]//join the square of the index 2 element to t
                                                                                          $ //String each element of the result (to output on newlines)


                                                                                          Try it online!



                                                                                          Cleaner Output, 32 bytes



                                                                                          t:2?10;t,:10/t;`0:$t,:t[2]*t[2];

                                                                                          `0: //Cleanly prints the strings


                                                                                          Try it online!






                                                                                          share|improve this answer















                                                                                          K (oK), 28 bytes



                                                                                          t:2?10;t,:10/t;$t,:t[2]*t[2]


                                                                                          Explanation



                                                                                          t:2?10 //define t as two random numbers from 1-10
                                                                                          t,:10/t //join the base 10 joining of the elements of t to t
                                                                                          t,:t[2]*t[2]//join the square of the index 2 element to t
                                                                                          $ //String each element of the result (to output on newlines)


                                                                                          Try it online!



                                                                                          Cleaner Output, 32 bytes



                                                                                          t:2?10;t,:10/t;`0:$t,:t[2]*t[2];

                                                                                          `0: //Cleanly prints the strings


                                                                                          Try it online!







                                                                                          share|improve this answer














                                                                                          share|improve this answer



                                                                                          share|improve this answer








                                                                                          edited 1 min ago

























                                                                                          answered 29 mins ago









                                                                                          Thaufeki

                                                                                          16117




                                                                                          16117




















                                                                                              up vote
                                                                                              0
                                                                                              down vote














                                                                                              PHP, 64 bytes





                                                                                              <?$d=($c=(10*($a=rand(1,9))+$b=rand(1,9)))*$c;echo"$a
                                                                                              $b
                                                                                              $c
                                                                                              $d";


                                                                                              Try it online!





                                                                                              share
























                                                                                                up vote
                                                                                                0
                                                                                                down vote














                                                                                                PHP, 64 bytes





                                                                                                <?$d=($c=(10*($a=rand(1,9))+$b=rand(1,9)))*$c;echo"$a
                                                                                                $b
                                                                                                $c
                                                                                                $d";


                                                                                                Try it online!





                                                                                                share






















                                                                                                  up vote
                                                                                                  0
                                                                                                  down vote










                                                                                                  up vote
                                                                                                  0
                                                                                                  down vote










                                                                                                  PHP, 64 bytes





                                                                                                  <?$d=($c=(10*($a=rand(1,9))+$b=rand(1,9)))*$c;echo"$a
                                                                                                  $b
                                                                                                  $c
                                                                                                  $d";


                                                                                                  Try it online!





                                                                                                  share













                                                                                                  PHP, 64 bytes





                                                                                                  <?$d=($c=(10*($a=rand(1,9))+$b=rand(1,9)))*$c;echo"$a
                                                                                                  $b
                                                                                                  $c
                                                                                                  $d";


                                                                                                  Try it online!






                                                                                                  share











                                                                                                  share


                                                                                                  share










                                                                                                  answered 1 min ago









                                                                                                  Jo.

                                                                                                  98419




                                                                                                  98419



























                                                                                                       

                                                                                                      draft saved


                                                                                                      draft discarded















































                                                                                                       


                                                                                                      draft saved


                                                                                                      draft discarded














                                                                                                      StackExchange.ready(
                                                                                                      function ()
                                                                                                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f175006%2fnumbers-manipulation-challenge%23new-answer', 'question_page');

                                                                                                      );

                                                                                                      Post as a guest













































































                                                                                                      Comments

                                                                                                      Popular posts from this blog

                                                                                                      What does second last employer means? [closed]

                                                                                                      Installing NextGIS Connect into QGIS 3?

                                                                                                      One-line joke