Skip to content

Commit 3266009

Browse files
committed
-
1 parent b5da6bf commit 3266009

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

source_py3/python_toolbox/math_tools/sequences.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff 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-
7963
def shitfuck(k, recurrence_counter):
8064
from python_toolbox import nifty_collections
8165
from python_toolbox import cute_iter_tools

source_py3/python_toolbox/nifty_collections/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from .lazy_tuple import LazyTuple
1111
from .frozen_dict import FrozenDict
1212
from .frozen_counter import FrozenCounter
13+
from .frozen_chunk_counter import FrozenChunkCounter
1314
from .default_sorted_dict import DefaultSortedDict
1415

1516
from .emitting_ordered_set import EmittingOrderedSet

source_py3/python_toolbox/nifty_collections/frozen_chunk_counter.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright 2009-2014 Ram Rachum.,
22
# This program is distributed under the MIT license.
33

4+
import collections
5+
46
from python_toolbox import math_tools
57

68
from .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+

0 commit comments

Comments
 (0)