File tree Expand file tree Collapse file tree 3 files changed +14
-16
lines changed
source_py3/python_toolbox Expand file tree Collapse file tree 3 files changed +14
-16
lines changed Original file line number Diff line number Diff line change @@ -60,22 +60,6 @@ def abs_stirling(n, k):
6060
6161_shitfuck_cache = {}
6262
63- def get_sub_counters_counter (counter ):
64- from python_toolbox import nifty_collections
65- assert isinstance (counter , nifty_collections .FrozenCounter )
66- # d = {}
67- # for key_to_reduce, value_of_key_to_reduce in counter.items():
68-
69- # pass
70- return nifty_collections .FrozenCounter ({
71- nifty_collections .FrozenCounter (
72- {(key - (key == key_to_reduce )): value for
73- key , value in counter .items ()}
74- ): value_of_key_to_reduce
75-
76- })
77-
78-
7963def shitfuck (k , recurrence_counter ):
8064 from python_toolbox import nifty_collections
8165 from python_toolbox import cute_iter_tools
Original file line number Diff line number Diff line change 1010from .lazy_tuple import LazyTuple
1111from .frozen_dict import FrozenDict
1212from .frozen_counter import FrozenCounter
13+ from .frozen_chunk_counter import FrozenChunkCounter
1314from .default_sorted_dict import DefaultSortedDict
1415
1516from .emitting_ordered_set import EmittingOrderedSet
Original file line number Diff line number Diff line change 11# Copyright 2009-2014 Ram Rachum.,
22# This program is distributed under the MIT license.
33
4+ import collections
5+
46from python_toolbox import math_tools
57
68from .frozen_counter import FrozenCounter
@@ -18,3 +20,14 @@ def __init__(self, iterable):
1820 else :
1921 raise TypeError ('Keys to `FrozenChunkCounter` must be '
2022 'non-negative integers.' )
23+
24+ def get_sub_counters_counter (self ):
25+ sub_counters_counter = collections .Counter ()
26+ for key_to_reduce , value_of_key_to_reduce in sub_counter .items ():
27+ sub_counter = collections .Counter (sub_counter )
28+ sub_counter [key_to_reduce ] -= 1
29+ sub_counter [key_to_reduce - 1 ] += 1
30+ sub_counters_counter [FrozenChunkCounter (sub_counter )] = \
31+ value_of_key_to_reduce
32+ return FrozenCounter (sub_counters_counter )
33+
You can’t perform that action at this time.
0 commit comments