﻿ Swift Array Programming Exercise: Check if a given array of integers contains 3 twice, or 5 twice - w3resource

# Swift Array Programming Exercises: Check if a given array of integers contains 3 twice, or 5 twice

## Swift Array Programming: Exercise-14 with Solution

Write a Swift program to check if a given array of integers contains 3 twice, or 5 twice.

Pictorial Presentation: Sample Solution:

Swift Code:

``````func double_35(_ a: [Int]) -> Bool {
if a == [3, 3] || a == [5, 5]
{
return true
} else {
return false
}
}
print(double_35([3, 3]))
print(double_35([5, 5]))
print(double_35([1, 2]))
```
```

Sample Output:

```true
true
false
```

Swift Programming Code Editor:

Improve this sample solution and post your code through Disqus

What is the difficulty level of this exercise?

﻿

Inviting useful, relevant, well-written and unique guest posts
{"ft_lang_label":"__label__en","ft_lang_prob":0.6834486,"math_prob":0.8013524,"size":1469,"snap":"2019-43-2019-47","text_gpt3_token_len":351,"char_repetition_ratio":0.12832764,"word_repetition_ratio":0.08906882,"special_character_ratio":0.25459495,"punctuation_ratio":0.105882354,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9869743,"pos_list":[0,1,2],"im_url_duplicate_count":[null,5,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-11-14T21:02:42Z\",\"WARC-Record-ID\":\"<urn:uuid:5f88abc3-c0b3-49e7-a9dd-e78c263603fb>\",\"Content-Length\":\"110657\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:327bd735-9468-4bc5-ae64-f9cecdfc6c79>\",\"WARC-Concurrent-To\":\"<urn:uuid:a3e42a86-aca8-4ef8-9047-0168f1930928>\",\"WARC-IP-Address\":\"104.26.15.93\",\"WARC-Target-URI\":\"https://www.w3resource.com/swift-programming-exercises/array/swift-array-exercise-14.php\",\"WARC-Payload-Digest\":\"sha1:5YDX54AJZDHXDDVCWMCQKZ3LYJ7R4454\",\"WARC-Block-Digest\":\"sha1:BYPVFRDWBHALUYEHQKHR5SLDRBAFP2P4\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-47/CC-MAIN-2019-47_segments_1573496668539.45_warc_CC-MAIN-20191114205415-20191114233415-00177.warc.gz\"}"}