Codeforces has introduced a third division in their competitions. Initially I though this is the place to go for “easy” stuff, as far as some of the 2nd division problems require some advanced algorithms, like combinations of graphs and months…

About 4 years ago, I wrote an article about prime numbers in Excel and their visualisation with VBA – vba-function-in-excel-to-check-prime-numbers. Pretty much, it displays the prime numbers in a 10 x N matrix, starting from 1 and finishing at N:…

Tagged with: align, bg_color, center, Excel, first column and first row of Excel is with index 0, font_color, format, matrix, prime numbers, Python, xlsxwriter

After reading the database to python from the previous post here, it is time to do the ADD data to the database. Our database is created like this:

1 2 3 4 5 |
CREATE TABLE "drummers" ( "Id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "Name" TEXT, "Band" TEXT ) |

The database has autoincremented primary key, thus we do not need…

Showing all links from a website with Python and BeautifulSoup is actually 6 lines of code – 2 to define the used libraries and 4 to do the job:

1 2 3 4 5 6 7 8 |
import urllib.request from bs4 import BeautifulSoup resp = urllib.request.urlopen("https://www.vitoshacademy.com") soup = BeautifulSoup(resp, from_encoding=resp.info().get_param('charset')) for link in soup.find_all('a', href=True): print(link['href']) |

In general, BeautifulSoup comes out of the box with beautiful…

Tagged with: BeautifulSoup4, display links, extract links to file, print links, Python, show all links

Yesterday I have spent some hours, trying to resolve one problem for shortest paths. The problem was coming from HackBulgaria and was somehow similar to these two problems here: Get the shortest path in a weighted graph with Dijkstra Dijkstra for…

Tagged with: dijkstra, dijkstra algo, dijkstra going a little crazy, Python, python algorithm dijkstra

Top