A graphic sequence is a sequence of positive integers each denoting the number of edges for a node in a simple graph. For example the sequence
2 1 1 denotes a graph with 3 nodes one with 2 edges and 2 with one connection.
Not all sequences are graphic sequences. For example
2 1 is not a graphic sequence because there is no way to connect two nodes so that one of them has two edges.
You will take a sequence of integers by any reasonable method. This includes, but is not limited to, an array of integers and its size, a linked list of unsigned integers, and a vector of doubles. You may assume that there will be no zeros in the input. You may also assume the input is sorted from least to greatest or greatest to least.
You must output whether or not the sequence is a graphic sequence. A truthy value if it is a falsy value otherwise.
This is code-golf the goal is to minimize the number of bytes in your program
Sorted greatest to least
-> True 3 3 3 2 2 2 1 1 1 -> True 3 3 2 2 1 1 -> True 3 3 2 -> False 8 1 1 1 1 1 1 1 1 -> True 1 1 1 1 -> True 1 1 1 -> False 9 5 4 -> False