5
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
12Can we output an array? – Quintec – 2018-10-31T11:57:15.047
3Can we sample without replacement, ie exclude 1,1 2,2 3,3... from the pairs? – JayCe – 2018-10-31T13:57:00.297
2(i.e., what's the distribution of the random numbers?) – user202729 – 2018-10-31T16:11:23.040
You should probably specify that the digits are pairwise independent and uniformly random. Otherwise, one can go with a degenerate distribution and write "cat (10 Bytes): 1[newline]1[newline]11[newline]121" – Yonatan N – 2018-11-02T00:23:08.223
@YonatanN The standard assumption on PPCGcfor the term
random
is that all possibilities have a non-zero chance of occuring. – Jo King – 2018-11-02T12:47:21.710Why did you accept my answer just yet, when there are two 9-byte solutions that are shorter? For code-golf challenges you should accept the shortest one (and sometimes the earliest edit/post if there are more than one shortest), or don't accept an answer at all. – Kevin Cruijssen – 2018-11-21T07:30:48.070