Moscow Puzzles 89: Siskin and Thrush

Posted on Sat 30 October 2021 in tech • Tagged with programming, moscow puzzles, python

Moscow Puzzles #89

Siskin and Thrush

class birdcage:
"""
Moscow Puzzles 89 - Siskin and Thrush:
At the end of summer camp the children decided to free the 20 birds they caught.
Line up the cages in a row, counting from left to right, open each fifth cage with a bird in it.
You may take the last two birds to the city. The children wanted to take Siskin and Thrush.
Which cages should contain them?
"""
N = 20
SKIP = 5
def __init__(self):
self.cage = [False] * self.N
self.visited = set()
self.total = set()
for i in range(1, self.N+1):
self.total.add(i)
def iterate(self, pos):
pos += 1
if pos == self.N+1:
pos = 1
while pos in self.visited:
pos += 1
if pos == self.N+1:
pos = 1
return pos
def skip_count(self):
pos = 0
skcount = 0
while len(self.visited) < self.N - 2:
if skcount < self.SKIP:
skcount += 1
pos = self.iterate(pos)
else:
self.visited.add(pos)
skcount = 0
return self.total - self.visited;
if __name__ == '__main__':
cage = birdcage()
closed = cage.skip_count()
print(closed)

C++ Functional Programming?

Posted on Wed 27 October 2021 in tech • Tagged with programming, c++, go, python, java

cpp

C++ programmers should explore functional languages. Experience with modern programming idioms can improve ones ability to write modern C++.


dnsmasq adblock fetcher using python

Posted on Wed 23 December 2020 in tech • Tagged with programming, python, adblocker

If you are using Pi Hole or Unifi Edgerouter for Ad Blocking via a host file, check out fetch_blocker. This is a straightforward python script to pull the Steven Black Hosts consolidated adblocker list and convert it to dnsmasq format.


Post an order on Binance using Python

Posted on Sat 19 December 2020 in tech • Tagged with programming, python, tech, bitcoin, tutorial, crypto

Tutorial: Post an order on Binance using Python


Continue reading

Using python3?

Posted on Mon 27 April 2020 in tech • Tagged with programming, python

It seems terrifying. 😱 Is it really so wrong?!? #python3 #Luddite