Skip to main content

Posts

highres - A python package to download high resolution images using Google Search by Image feature

highres A python package to download high resolution image using Google Search by Image feature Prerequisites: Instructions are below Python with pip selenium package A browser with Webdriver Install selenium via pip pip install selenium   Webdriver Setup Click and download the driver from their official websites. Chrome Firefox Edge Add webdriver folder path to System path Add downloaded driver folder path to System path. Todo Now, before we start coding, lets break down our goal into smaller components. Set up Code for: Input & Output folders Identify image files in a folder. Detect browser and launch Navigate and use Google's 'Search by Image' Download image based on it's URL and save in a folder Create a pip package Code for Input & Output folders Nomally we can simply use string variable to store paths, but using Path from pathlib is OS neutral and has many useful features....
Recent posts

Genetic Algorithm - Travelling Salesman with Julia

  Genetic Algorithm Genetic algorithm (GA) is a type of algorithm inspired by the process of natural selection to generate high-quality solutions to problems, which otherwise would be too difficult to solve. Travelling Salesman Problem Travelling Salesman Problem or TSP for short, is a infamous problem where a travelling sales person has to travel various cities with known distance and return to the origin city in the shortest time/path possible. Like below, each circle is a city and blue line is a route, visiting them. Why not brute-force ?? Okay, lets try to brute force to solve the problem. for starters lets take 5 cities, i.e., we have to calculate 5! , i.e., 120 routes to ensure we got the shortest path. Now, if we are to do that for 50 cities, 5! = 120 10! = 3628800 15! = 1307674368000 20! = 2432902008176640000 50! = 30414093201713378043612608166064768844377641568960512000000000000 We can see how brute forcing our way is ...

Tron game - Combinatorial search

About Tron game: Tron is a two player game based on the popular movie Tron. The objective of the game is to cut off players movement through each others motorbikes that leave a wall behind them as they move. Like this: I came across this question in Hackerrank , where our programs will read the players position at each turn and will decide the movement, by printing one of (LEFT, RIGHT, UP, DOWN) to the console, and we can see the result visually. Before we go further, I should tell you that the solution below is a naive and basic approach (scored 36/50) and there are a lot of algorithms available that provide better results. Now the input we get are: player's turn bot player's current positions the whole grid (15x15) values Input is: r 4 3 5 13 ############### #-rr--------gg# #-rr--------gg# #-rr--------gg# #-rr--------gg# #-r---------g-# #-r---------gg# #rr----------g# #-------------# #-------------# #-------------# #-------------# #-------------# #---...