Module Import alias ImportFrom alias alias Assign NameStore Call NameLoad NameLoad NameLoad FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad For NameStore NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad If CompareEq NameLoad Call NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad orelse Assign SubscriptStore NameLoad Index NameLoad NameLoad Expr Yield TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Return TupleLoad Call NameLoad NameLoad NameLoad BinOpSub NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return BinOpAdd Num Call NameLoad GeneratorExp NameLoad comprehension TupleStore NameStore NameStore Call NameLoad NameLoad Num decorator_list FunctionDef arguments args NameParam defaults body Return Call NameLoad Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Return TupleLoad Call NameLoad NameLoad NameLoad BinOpSub NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore ListComp TupleLoad NameLoad NameLoad comprehension TupleStore NameStore NameStore Call NameLoad NameLoad Return Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore ListComp TupleLoad NameLoad UnaryOpUSub NameLoad comprehension TupleStore NameStore NameStore Call NameLoad NameLoad Return Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore ListLoad ListLoad For TupleStore NameStore NameStore Call NameLoad NameLoad body If CompareEq BinOpAdd NameLoad Num Call NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr ListLoad Expr Call AttributeLoad SubscriptLoad NameLoad Index BinOpAdd NameLoad Num attr TupleLoad NameLoad BinOpSub Call NameLoad SubscriptLoad NameLoad Index NameLoad Num Assign NameStore BinOpSub Call NameLoad NameLoad Num Assign NameStore Num Assign NameStore Call NameLoad For NameStore Call NameLoad NameLoad Num Num body Assign TupleStore NameStore NameStore SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call NameLoad Call NameLoad Call NameLoad Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad If CompareGtE Call NameLoad NameLoad Call NameLoad NameLoad body Return NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad If CompareGtE Call NameLoad NameLoad Call NameLoad NameLoad body Return NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore ListComp TupleLoad NameLoad NameLoad comprehension TupleStore NameStore NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Return ListComp NameLoad comprehension TupleStore NameStore NameStore NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore ListComp TupleLoad NameLoad UnaryOpUSub NameLoad comprehension TupleStore NameStore NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Return ListComp NameLoad comprehension TupleStore NameStore NameStore NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign TupleStore NameStore NameStore Call NameLoad Call AttributeLoad NameLoad attr While CompareNotEq NameLoad Num body Expr Yield NameLoad Assign TupleStore NameStore NameStore SubscriptLoad NameLoad Index NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str Assign NameStore Dict Num Num Assign NameStore BinOpMult ListLoad TupleLoad Num Num Call NameLoad NameLoad For TupleStore NameStore TupleStore NameStore NameStore Call NameLoad NameLoad body For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body If BoolOpAnd CompareNotEq NameLoad Num CompareGtE SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Num NameLoad body Continue Assign NameStore BinOpAdd NameLoad NameLoad If BoolOpAnd CompareIn NameLoad NameLoad CompareLtE SubscriptLoad SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index NameLoad Index Num NameLoad body Continue Assign SubscriptStore NameLoad Index NameLoad NameLoad Assign NameStore TupleLoad NameLoad NameLoad If CompareGt NameLoad SubscriptLoad NameLoad Index NameLoad body Assign SubscriptStore NameLoad Index NameLoad NameLoad If NameLoad body Print TupleLoad NameLoad NameLoad NameLoad Assign NameStore Call NameLoad Call NameLoad Call NameLoad NameLoad NameLoad NameLoad Return TupleLoad ListComp SubscriptLoad NameLoad Index NameLoad comprehension NameStore NameLoad SubscriptLoad Call NameLoad Call AttributeLoad NameLoad attr Index Num decorator_list If CompareEq NameLoad Str body Import alias Expr Call AttributeLoad NameLoad attr Import alias identifier Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Num Num Num Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad BinOpMult ListLoad Num Num Print NameLoad Assign NameStore Call NameLoad NameLoad Print Str NameLoad Assign NameStore Call NameLoad NameLoad Print Str NameLoad Assign NameStore Call NameLoad NameLoad Print Str NameLoad Assign NameStore Call NameLoad NameLoad Print Str NameLoad Assign TupleStore NameStore NameStore Call NameLoad NameLoad Assign TupleStore NameStore NameStore Call NameLoad NameLoad Print Str NameLoad Assert CompareEq Call NameLoad NameLoad Call NameLoad NameLoad
N/A N/A bisect functools partial reduce N/A maximum N/A partial reduce max patience_sort N/A N/A xs N/A N/A N/A Patience sort an iterable, xs.

    This function generates a series of pairs (x, pile), where "pile"
    is the 0-based index of the pile "x" should be placed on top of.
    Elements of "xs" must be less-than comparable.
     N/A pile_tops N/A list N/A x xs N/A N/A pile N/A N/A bisect bisect_left pile_tops x N/A N/A pile N/A len pile_tops N/A N/A N/A N/A pile_tops append x N/A N/A N/A pile_tops N/A pile x N/A N/A N/A x pile N/A longest_monotonic_subseq_length N/A N/A xs N/A N/A N/A Return the length of the longest monotonic subsequence of xs, second
    return value is the difference between increasing and decreasing lengths.

    >>> longest_monotonic_subseq_length((4, 5, 1, 2, 3))
    (3, 1)
    >>> longest_monotonic_subseq_length((1, 2, 3, 5, 4))
    (4, 2)
    >>> longest_monotonic_subseq_length((1, 2, 1))
    (2, 0)
     N/A li N/A longest_increasing_subseq_length xs N/A ld N/A longest_decreasing_subseq_length xs N/A N/A N/A max li ld N/A li ld N/A longest_increasing_subseq_length N/A N/A xs N/A N/A N/A Return the length of the longest increasing subsequence of xs.

    >>> longest_increasing_subseq_length(range(3))
    3
    >>> longest_increasing_subseq_length([3, 1, 2, 0])
    2
     N/A N/A 1 N/A maximum N/A pile N/A N/A x pile N/A patience_sort xs -1 N/A longest_decreasing_subseq_length N/A N/A xs N/A N/A N/A N/A longest_increasing_subseq_length N/A reversed xs N/A longest_monotonic_subseq_length_loose N/A N/A xs N/A N/A N/A li N/A longest_increasing_subseq_length_loose xs N/A ld N/A longest_decreasing_subseq_length_loose xs N/A N/A N/A max li ld N/A li ld N/A longest_increasing_subseq_length_loose N/A N/A xs N/A N/A N/A xs N/A N/A x i N/A N/A i x N/A enumerate xs N/A N/A longest_increasing_subseq_length xs N/A longest_decreasing_subseq_length_loose N/A N/A xs N/A N/A N/A xs N/A N/A x N/A i N/A N/A i x N/A enumerate xs N/A N/A longest_decreasing_subseq_length xs N/A longest_increasing_subsequence N/A N/A xs N/A N/A N/A Return a longest increasing subsequence of xs.

    (Note that there may be more than one such subsequence.)
    >>> longest_increasing_subsequence(range(3))
    [0, 1, 2]
    >>> longest_increasing_subsequence([3, 1, 2, 0])
    [1, 2]
     N/A piles N/A N/A N/A N/A x p N/A patience_sort xs N/A N/A N/A N/A p 1 N/A len piles N/A N/A N/A N/A piles append N/A N/A N/A N/A N/A piles N/A N/A p 1 append N/A x N/A N/A len N/A piles N/A p 1 N/A npiles N/A N/A len piles 1 N/A prev 0 N/A lis N/A list N/A pile N/A range npiles 0 -1 N/A N/A N/A x prev N/A N/A piles N/A pile N/A prev N/A N/A N/A lis append x N/A N/A N/A lis reverse N/A lis N/A longest_decreasing_subsequence N/A N/A xs N/A N/A N/A 
    Wrapper that calls longest_increasing_subsequence
    >>> longest_decreasing_subsequence([23, 19, 97, 16, 37, 44, 88, 77, 26])
    [97, 88, 77, 26]
     N/A N/A list N/A reversed N/A longest_increasing_subsequence N/A reversed xs N/A longest_monotonic_subsequence N/A N/A xs N/A N/A N/A lis N/A longest_increasing_subsequence xs N/A lds N/A longest_decreasing_subsequence xs N/A N/A N/A len lis N/A len lds N/A N/A lis N/A lds N/A longest_monotonic_subsequence_loose N/A N/A xs N/A N/A N/A lis N/A longest_increasing_subsequence_loose xs N/A lds N/A longest_decreasing_subsequence_loose xs N/A N/A N/A len lis N/A len lds N/A N/A lis N/A lds N/A longest_increasing_subsequence_loose N/A N/A xs N/A N/A N/A xs N/A N/A x i N/A N/A i x N/A enumerate xs N/A ll N/A longest_increasing_subsequence xs N/A N/A x N/A N/A x i ll N/A longest_decreasing_subsequence_loose N/A N/A xs N/A N/A N/A xs N/A N/A x N/A i N/A N/A i x N/A enumerate xs N/A ll N/A longest_decreasing_subsequence xs N/A N/A x N/A N/A x i ll N/A backtracking N/A N/A a L bestsofar N/A N/A N/A 
    Start with the heaviest weight and emit index
     N/A N/A w j N/A max N/A N/A L items N/A N/A j -1 N/A N/A N/A j N/A N/A w j N/A bestsofar N/A j N/A heaviest_increasing_subsequence N/A N/A a debug N/A False N/A N/A 
    Returns the heaviest increasing subsequence for array a. Elements are (key,
    weight) pairs.

    >>> heaviest_increasing_subsequence([(3, 3), (2, 2), (1, 1), (0, 5)])
    ([(0, 5)], 5)
     N/A L N/A 0 -1 N/A bestsofar N/A N/A N/A 0 -1 N/A len a N/A N/A i N/A key weight N/A enumerate a N/A N/A N/A w j N/A N/A L items N/A N/A N/A N/A j -1 N/A N/A N/A a N/A j N/A 0 key N/A N/A N/A new_weight N/A w weight N/A N/A N/A new_weight L N/A N/A N/A a N/A N/A L N/A new_weight N/A 0 key N/A N/A N/A N/A L N/A new_weight i N/A newbest N/A new_weight j N/A N/A newbest N/A bestsofar N/A i N/A N/A N/A bestsofar N/A i newbest N/A debug N/A N/A N/A key weight bestsofar N/A tb N/A reversed N/A list N/A backtracking a L bestsofar N/A N/A N/A N/A a N/A x N/A x tb N/A N/A max N/A N/A L items N/A 0 N/A N/A N/A __name__ __main__ N/A N/A doctest N/A N/A N/A doctest testmod N/A numpy np N/A A N/A N/A N/A np random random_integers 0 10 10 N/A A N/A list A N/A B N/A zip A N/A N/A 1 10 N/A A N/A lis N/A longest_increasing_subsequence A N/A longest increasing: lis N/A lds N/A longest_decreasing_subsequence A N/A longest decreasing: lds N/A lisl N/A longest_increasing_subsequence_loose A N/A longest increasing loose: lisl N/A ldsl N/A longest_decreasing_subsequence_loose A N/A longest decreasing loose: ldsl N/A N/A his his_dd N/A heaviest_increasing_subsequence B N/A N/A hlis wts N/A zip his N/A heaviest increasing (weight 1, compare with lis): hlis N/A N/A N/A len lis N/A len his