# SAM's note ### Michelle's new choice: https://24h.pchome.com.tw/prod/DHAFL8-A900B4WIF?fq=/S/DHAFK8 ### RESTful API with Laravel: Build a Real API with Laravel https://www.udemy.com/course/restful-api-with-laravel-php-homestead-passport-hateoas/ ### Web Application & Software Architecture 101 https://www.educative.io/courses/web-application-software-architecture-101 ### Leetcode problem categories https://cspiration.com/leetcodeClassification ### 專欄文章:Python Tutorial https://openhome.cc/Gossip/CodeData/PythonTutorial/ # 程式練習 ### h3howhow problems 題目:最簡分數計算 設計說明: 請撰寫一程式,讓使用者輸入的兩個分數,分別是m/n和y/x(m,n,y,x皆為整數)計算m/n+y/x,並以最簡分數呈現。 範例輸入: 輸入第一個分數的分子分母:5,6 輸入第二個分數的分子分母:3,10 範例輸出: 5/6+3/10=17/15 ```python= ######Michelle###### def gcd(a,b): if b == 0: return a else: return gcd(b,a%b) def fracadd(x,y,w,z): mole = x*z+w*y deno = y*z mole1 = int(mole/gcd(mole,deno)) deno1 = int(deno/gcd(mole,deno)) return str(mole1)+"/"+str(deno1) x,y = input("請輸入第一個分數:").split(",") x = int(x) y = int(y) w,z = input("請輸入第二個分數:").split(",") w = int(w) z = int(z) print(x,"/",y,"+",w,"/",z,"=",fracadd(x,y,w,z)) ``` # LeetCode Problems ## 4/26題目: Given an integer n, return a list of all simplified fractions between 0 and 1 (exclusive) such that the denominator is less-than-or-equal-to n. The fractions can be in any order. Example 1: Input: n = 2 Output: ["1/2"] Explanation: "1/2" is the only unique fraction with a denominator less-than-or-equal-to 2. Example 2: Input: n = 3 Output: ["1/2","1/3","2/3"] Example 3: Input: n = 4 Output: ["1/2","1/3","1/4","2/3","3/4"] Explanation: "2/4" is not a simplified fraction because it can be simplified to "1/2". Example 4: Input: n = 1 Output: [] Constraints: 1 <= n <= 100 ```python= ######Michelle###### def gcd(x,y): if y == 0: return x else: return gcd(y,x%y) anslist = list() num = int(input("請輸入1到100:")) for i in range(1,num+1): for j in range(1,i): if gcd(i,j) == 1: frac = str(j)+"/"+str(i) anslist.append(frac) print(anslist)