Cody

# Problem 1227. Generate a random matrix A of (1,-1)

Solution 2294704

Submitted on 19 May 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
x = 5; assert(isequal(unique(rand_plusminus1(x)),[-1;1]))

Unrecognized function or variable 'n'. Error in rand_plusminus1 (line 3) if n>0 Error in Test1 (line 2) assert(isequal(unique(rand_plusminus1(x)),[-1;1]))

2   Fail
x = 1; assert(isequal(abs(rand_plusminus1(x)),1))

Unrecognized function or variable 'n'. Error in rand_plusminus1 (line 3) if n>0 Error in Test2 (line 2) assert(isequal(abs(rand_plusminus1(x)),1))

3   Fail
x = 0; assert(isequal(rand_plusminus1(x),[]))

Unrecognized function or variable 'n'. Error in rand_plusminus1 (line 3) if n>0 Error in Test3 (line 2) assert(isequal(rand_plusminus1(x),[]))

4   Fail
x = 999; assert(isequal(unique(rand_plusminus1(x)),[-1;1]))

Unrecognized function or variable 'n'. Error in rand_plusminus1 (line 3) if n>0 Error in Test4 (line 2) assert(isequal(unique(rand_plusminus1(x)),[-1;1]))
{"ft_lang_label":"__label__en","ft_lang_prob":0.5922829,"math_prob":0.99147373,"size":498,"snap":"2020-34-2020-40","text_gpt3_token_len":157,"char_repetition_ratio":0.14574899,"word_repetition_ratio":0.0,"special_character_ratio":0.3634538,"punctuation_ratio":0.1368421,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98461115,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-08-12T08:06:37Z\",\"WARC-Record-ID\":\"<urn:uuid:11fadff0-0052-4ba1-9fd5-58715f5c9657>\",\"Content-Length\":\"73804\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:a414d22c-ab87-449c-b789-749e3d35cab2>\",\"WARC-Concurrent-To\":\"<urn:uuid:8c9ee97a-08ec-410a-a315-c39c5063a419>\",\"WARC-IP-Address\":\"23.66.56.59\",\"WARC-Target-URI\":\"https://jp.mathworks.com/matlabcentral/cody/problems/1227-generate-a-random-matrix-a-of-1-1/solutions/2294704\",\"WARC-Payload-Digest\":\"sha1:KGRCIXFMRR2WS3DECMQKEG7MRLR24ZZZ\",\"WARC-Block-Digest\":\"sha1:GE53AF37GONTUUMGHKX6EUKUU577WRDQ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-34/CC-MAIN-2020-34_segments_1596439738878.11_warc_CC-MAIN-20200812053726-20200812083726-00052.warc.gz\"}"}