Cody

# Problem 1972. Convert matrix to 3D array of triangular matrices

Created by Matthew Eicholtz in Community

Given a 2D numeric array x in which each column represents the vectorized form of an upper triangular matrix, return a 3D array y containing the concatenated triangular matrices.

• If the size of the input matrix x is MxN, then the size of the output matrix y is PxPxN, where M = sum(1:P)
• You may assume that P<=100

Example

If

```x = 1  7 13
2  8 14
3  9 15
4 10 16
5 11 17
6 12 18
```

then

```y(:,:,1) =  1  2  4
0  3  5
0  0  6
```
```y(:,:,2) =  7  8 10
0  9 11
0  0 12
```
```y(:,:,3) = 13 14 16
0 15 17
0  0 18
```

NOTE: If you are wondering why this seems like a strange task, it is inspired by a genotype->phenotype mapping I am doing in a genetic algorithm.

### Solution Stats

61.67% Correct | 38.33% Incorrect
Last solution submitted on Mar 28, 2019
{"ft_lang_label":"__label__en","ft_lang_prob":0.7435204,"math_prob":0.9872985,"size":631,"snap":"2019-13-2019-22","text_gpt3_token_len":226,"char_repetition_ratio":0.10526316,"word_repetition_ratio":0.0,"special_character_ratio":0.39461172,"punctuation_ratio":0.13461539,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99297476,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-05-24T07:22:35Z\",\"WARC-Record-ID\":\"<urn:uuid:26af3ba6-c7f7-45fa-97bf-7555618098cc>\",\"Content-Length\":\"81065\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:9188ec56-c412-4456-b2ce-4083c36ebacd>\",\"WARC-Concurrent-To\":\"<urn:uuid:73df8650-84eb-44fc-847f-4459200a0711>\",\"WARC-IP-Address\":\"23.13.150.165\",\"WARC-Target-URI\":\"https://kr.mathworks.com/matlabcentral/cody/problems/1972\",\"WARC-Payload-Digest\":\"sha1:J2CNUB7NH5JXHWL6UHEHXBODMMR2GXYC\",\"WARC-Block-Digest\":\"sha1:XSOYFQ4LXPNLVLNMYGCOIQCR6OXSKZ6A\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-22/CC-MAIN-2019-22_segments_1558232257553.63_warc_CC-MAIN-20190524064354-20190524090354-00368.warc.gz\"}"}