Jackpotjoy

# Tag Archives: Programming

## Python & R Solution for Project Euler(Problem 004 - 006)

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99. Find the largest palindrome made from the product of two 3-digit numbers. Solution 906609 Python: , just setup a loop of combination of 2 3-digit numbers ,and test if product of them is a palindrome . def palindrome(): rlt = 0 for i in range (999, 99, -1): for j in range (999, 99, -1): prod = str(i * j); prod_rev Read more [...]

## Get All Files in a Folder in Python

We may already knew that it is common to get all items in given folder via function provided by "OS" module . file_foler = "Some_Path" os.listdir(file_foler) But ,os.listdir function will return folder and files in same time , what if we just want files in the folder ? There may be a solution that we loop over the result list and use os.path.isdir() to retrieve all files name file_foler = "Some_Path" result_list = [] for f in os.listdir(file_foler): if os.path.isdir(os.path.join(file_folder,f)): Read more [...]