首页 > 编程语言 >python3 使用位图排序

python3 使用位图排序

时间:2022-10-26 16:45:06浏览次数:52  
标签:15 bm BitMap tostring 使用 print 排序 python3

代码

from bitmap import BitMap

a=[1,5,3,4,7,8,15,6,9]
print(a)

bm=BitMap(max(a))
#print(dir(bm))

print(bm.tostring())
for i in a:
    bm.set(i)
    print(bm.tostring())

print(bm.nonzero())

执行

% python3 1.py
[1, 5, 3, 4, 7, 8, 15, 6, 9]
0000000000000000
0000000000000010
0000000000100010
0000000000101010
0000000000111010
0000000010111010
0000000110111010
1000000110111010
1000000111111010
1000001111111010
[1, 3, 4, 5, 6, 7, 8, 9, 15]

标签:15,bm,BitMap,tostring,使用,print,排序,python3
From: https://www.cnblogs.com/dewan/p/16828961.html

相关文章