GO Solution For UVa 10871 - Primed Subsequence. In this post we will see how we can solve this challenge in GoLang for UVa Online Judge.

Problem Description

Given a sequence of positive integers of length n, we define a primed subsequence as a consecutive subsequence of length at least two that sums to a prime number greater than or equal to two.

For example, given the sequence:

3 5 6 3 8

There are two primed subsequences of length 2 (5 + 6 = 11 and

...

You can find the full details of the problem Primed Subsequence at UVa Online Judge

Sample Input

3
5 3 5 6 3 8
5 6 4 5 4 12
21 15 17 16 32 28 22 26 30 34 29 31 20 24 18 33 35 25 27 23 19 21

Sample Output

Shortest primed subsequence is length 2: 5 6
Shortest primed subsequence is length 3: 4 5 4
This sequence is anti-primed.

Solution: Please check the main.go snippet for the solution.

Solution originally posted at: Github by @codingsince1985