Skip to content

Commit

Permalink
Add mass_resolv.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
daedalus committed Feb 14, 2024
1 parent 7455c73 commit 97d2260
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
27 changes: 27 additions & 0 deletions branchless.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ def stringcompare(a,b):
return tmp == 0


def lowerbound(x, t):
#base = t
#l = len(t)
#while(l > 1):
# half = l >> 1
# base += (base[half -1] < x) * half
# l -= half
#return base
k = 1
l = len(t)
while k <= l:
#print(t[k])
k = (k << 1) + (t[k] < x)
#return k.bit_count(),k
#k >>= k.bit_count()
#print(bin(k))
#return t[k]
#return k.bit_count()
return k

def test():
assert(IsOdd(3) == True)
assert(IsOdd(2) == False)
Expand Down Expand Up @@ -55,3 +75,10 @@ def test():


test()

for i in range(0, 10):
k = lowerbound(i,[0,1,2,3,4,5,6,7,8,9])
print(i, k, k.bit_count())

print(lowerbound(5,[6, 3, 7, 1, 5, 8, 9, 0, 2, 4]))

23 changes: 21 additions & 2 deletions heaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def heaps(k, A):
yield A
else:
for i in range(0, k):
yield from heap(k-1, A)
yield from heaps(k-1, A)
if k & 1 == 0:
A[i],A[k-1] = A[k-1],A[i]
else:
Expand All @@ -31,5 +31,24 @@ def heaps_count_swaps(k, A):
return c


A038156 = lambda n: heaps_count_swaps(n, list(range(0,n)))
#A038156 = lambda n: heaps_count_swaps(n, list(range(0,n)))

def a(n):
m=0
L = list(range(0,n))
for p in heaps(len(L),L):
m = max(m,Permutation(p).rank())
return m


def a(n):
m=0
L = list(range(0,n))
for p in heaps(len(L),L):
m = Permutation(p).rank()
return m



print([a(n) for n in range(0,10)])

3 changes: 3 additions & 0 deletions mass_resolv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
# Author Darío Clavijo 2024
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 comments on commit 97d2260

Please sign in to comment.