Skip to content

Commit 97d2260

Browse files
committed
Add mass_resolv.sh
1 parent 7455c73 commit 97d2260

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

branchless.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,26 @@ def stringcompare(a,b):
2626
return tmp == 0
2727

2828

29+
def lowerbound(x, t):
30+
#base = t
31+
#l = len(t)
32+
#while(l > 1):
33+
# half = l >> 1
34+
# base += (base[half -1] < x) * half
35+
# l -= half
36+
#return base
37+
k = 1
38+
l = len(t)
39+
while k <= l:
40+
#print(t[k])
41+
k = (k << 1) + (t[k] < x)
42+
#return k.bit_count(),k
43+
#k >>= k.bit_count()
44+
#print(bin(k))
45+
#return t[k]
46+
#return k.bit_count()
47+
return k
48+
2949
def test():
3050
assert(IsOdd(3) == True)
3151
assert(IsOdd(2) == False)
@@ -55,3 +75,10 @@ def test():
5575

5676

5777
test()
78+
79+
for i in range(0, 10):
80+
k = lowerbound(i,[0,1,2,3,4,5,6,7,8,9])
81+
print(i, k, k.bit_count())
82+
83+
print(lowerbound(5,[6, 3, 7, 1, 5, 8, 9, 0, 2, 4]))
84+

heaps.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def heaps(k, A):
99
yield A
1010
else:
1111
for i in range(0, k):
12-
yield from heap(k-1, A)
12+
yield from heaps(k-1, A)
1313
if k & 1 == 0:
1414
A[i],A[k-1] = A[k-1],A[i]
1515
else:
@@ -31,5 +31,24 @@ def heaps_count_swaps(k, A):
3131
return c
3232

3333

34-
A038156 = lambda n: heaps_count_swaps(n, list(range(0,n)))
34+
#A038156 = lambda n: heaps_count_swaps(n, list(range(0,n)))
35+
36+
def a(n):
37+
m=0
38+
L = list(range(0,n))
39+
for p in heaps(len(L),L):
40+
m = max(m,Permutation(p).rank())
41+
return m
42+
43+
44+
def a(n):
45+
m=0
46+
L = list(range(0,n))
47+
for p in heaps(len(L),L):
48+
m = Permutation(p).rank()
49+
return m
50+
51+
52+
53+
print([a(n) for n in range(0,10)])
3554

mass_resolv.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
# Author Darío Clavijo 2024
3+
cat $1 | nslookup | grep -e "[Name|Address]" | grep -e "#" -v | grep -e "Non" -v | grep -e "Server" -v | sed -e 's/\s//g;s/Name://g;s/Address://g;' | awk '{split($0,col1); getline; for (i=1; i<=NF; i++) print col1[i], $i}'

0 commit comments

Comments
 (0)