ccc112b / wp

課程:網頁設計 -- 筆記、習題與報告
4 stars 63 forks source link

作業4:JavaScript 練習 2 #13

Open ccckmit opened 3 months ago

ccckmit commented 3 months ago
  1. 請寫一個 min(a,b) 函數傳回 a, b 裡較小的那個數字
  2. 請寫一個 arrayMin(a) 函數傳回陣列 a 裡最小的那個數字
  3. 請寫一個 filter(a, f) 函數可以根據 f 成功或失敗過濾掉那些不合的內容
    • 例如 filter([1,2,3,4], function (x) { return x%2 == 1; }) 會傳回 [1,3]
  4. 請寫一個函數 weekday(str) 可以把星期幾的英文轉換成數字(0,1,2,3,4,5,6) (Sunday 是 0)
  5. 請寫一個函數 countChar(str) 可以算出一個字串中,每個字出現幾次。
    • 例如: “aabccadeaac" => { a: 5, b:1, c:3, d:1, e:1}
  6. 寫一個函數 gcd(a,b) 傳回 a, b 兩數字的最大公因數。
  7. 寫一個函數 lcm(a,b) 傳回 a, b 兩數字的最小公倍數。
  8. 請寫一個函數 gradient(f, p) 可以計算 f 在 p 點的梯度
h = 0.01

# 我們想找函數 f 的最低點
def f(p):
    [x,y] = p
    return x * x + y * y

# df(f, p, k) 為函數 f 對變數 k 的偏微分: df / dp[k]
# 例如在上述 f 範例中 k=0, df/dx, k=1, df/dy
def df(f, p, k):
    p1 = p.copy()
    p1[k] += h
    return (f(p1) - f(p)) / h

# 函數 f 在點 p 上的梯度
def grad(f, p):
    gp = p.copy()
    for k in range(len(p)):
        gp[k] = df(f, p, k)
    return gp

[x,y] = [1,3]
print('x=', x, 'y=', y)
print('df(f(x,y), 0) = ', df(f, [x, y], 0))
print('df(f(x,y), 1) = ', df(f, [x, y], 1))
print('grad(f)=', grad(f, [x,y]))

最後一題的解答: gradient.js

延伸解答: 梯度下降法 gd.js

wakaba0972 commented 3 months ago

吳秉昭, 111211543

edwimtiongyuanxie commented 3 months ago

张源熙 111210550

https://github.com/edwimtiongyuanxie/wp/tree/master/js

第5,8题使用chatgpt

shain120 commented 3 months ago

黃冠勝111210540

codewhight commented 3 months ago

林彥廷 111210510 https://github.com/codewhight/wp/tree/master/JavaScript/HW2 第五題 參考chatgpt 第八題參考解答

peterwang0329 commented 3 months ago

汪章貴 111210513 https://github.com/peterwang0329/wp/tree/master/js/hw4

taitaiwu commented 3 months ago

吳佳泰 111210520

第三題與第五題使用Copilot來debug 第八題參考解答

C10H8Nai commented 3 months ago

林瑋哲 110910112

Q8用參考答案

tonytomtody commented 3 months ago

蔡瑞哲 111210504 https://github.com/tonytomtody/wp/tree/master/js2 第五題參考他人解法第八題參考解答

ChadChenYu commented 3 months ago

陳辰鈺 111210518

程式碼

linpeic commented 3 months ago

林沛欣 111210522 程式碼 第5題用ChatGpt debug 第8題 參考解答

CYR1225 commented 2 months ago

陳奕儒 111210546 https://github.com/CYR1225/HW4/tree/aa4a5e3d8f24c1ca420556833b9251394a873868/HW4

5.8題 參考GPT

1100jimjim commented 2 months ago

蘇湧竣 111210523 https://github.com/1100jimjim/wp/tree/master/%E4%BD%9C%E6%A5%AD-4 第3、5題參考chatgpt ;第八題參考解答

456-An commented 2 months ago

蘇奕安, 111110509

第八題使用Copilot

zerorezerorezero commented 2 months ago

陳盈羽 111210521 連結 3 4 5題用ChatGPT除錯 第8題參考ChatGPT和解答

HJH60 commented 2 months ago

姓名: 胡佳慧 學號: 111010141

-README

Dogcatlionz commented 1 month ago

吳昱礽 111210509

第3、4、5題參考ChatGPT,第8題參考解答

Linyowe commented 1 month ago

林右緯 111113344 https://github.com/Linyowe/wp/tree/master/JavaScript%E7%B7%B4%E7%BF%922.js

cindycallista commented 1 month ago

楊莉思 111210555 https://github.com/cindycallista/wp/tree/master/HW_4 第八題參考解答, 梯度下降法

Jonathan-es commented 1 month ago

陳家盛 111210554

https://github.com/Jonathan-es/wp/tree/master/hw4 3 和 8 ,使用 ChatGPT

Erkmrcl17 commented 1 month ago

李麗恩 111210559

https://github.com/Erkmrcl17/wp/tree/master/HW

Q8 參考Chat GPT

Logan910115 commented 3 weeks ago

羅德耕 110910560 https://github.com/Logan910115/wp/tree/master/HW4

參考GPT

Rafu2102 commented 3 weeks ago

林明昌 111210534 https://github.com/Rafu2102/wp/tree/master/js/HW4 老師抱歉我數學不太好 第3、7、8題是參考chatgpt做的

emperoy commented 3 weeks ago

羅翊宸 111110513 https://github.com/emperoy/wp/tree/master/js/hw4 Q8參考範例

Yu0618 commented 2 weeks ago

李蕙妤 111210519 https://github.com/Yu0618/wp/tree/master/html/hw4 第8題參考解答

yawem0525 commented 2 weeks ago

張雅雯 111210539 https://github.com/yawem0525/wp/tree/master/HW4 第八題參考chatgpt

yunuun commented 2 weeks ago

黃湘芸 111210514 https://github.com/yunuun/wp/tree/master/hw4 第3、5題參考chatgpt 第8題參考老師解答

Vanh3ll commented 2 weeks ago

卓孝偉 111210551 https://github.com/Vanh3ll/wp/tree/master/HW4

6,7 題用ChatGPT除錯 第8題參考ChatGPT解答

Kumaaaaaaaaaaaakuaaaaa commented 2 weeks ago

吳畇蓁

111210240

程式碼 : https://github.com/Kumaaaaaaaaaaaakuaaaaa/wp/blob/master/hw4

jerry92916 commented 2 weeks ago

陳宏傑 111210529 https://github.com/jerry92916/wp/tree/master/HW4

Sakuraebi128 commented 2 weeks ago

黃瓘閎 111210541 https://github.com/Sakuraebi128/wp/tree/master/Hw4 第3、5題參考chatgpt,第8題參考解答。

shanghua1002 commented 2 weeks ago

吳尚樺111210505 程式碼

Raylee123321 commented 2 weeks ago

李詠睿 111210508 code

Kumaaaaaaaaaaaakuaaaaa commented 2 weeks ago

吳畇蓁

111210240

程式碼 : https://github.com/Kumaaaaaaaaaaaakuaaaaa/wp/blob/master/hw4

hmzhen12 commented 2 weeks ago

胡眉真 111210548

程式碼: https://github.com/hmzhen12/wp/tree/master/HW4

第3題和 第8題 ,使用 ChatGPT

110910234 commented 2 weeks ago

莊宸維 110910234 https://github.com/110910234/wp/tree/master/hw4 參考GPT

daibao87 commented 2 weeks ago

林育民 111210507 https://github.com/daibao87/daibao87.github.io/tree/main/hw4 第八參考老師解答

VinsOrl commented 1 week ago

林新興 111210556 https://github.com/VinsOrl/wp/tree/master/HW4 參考GPT,stack overflow

yiting0418 commented 1 week ago

陳翊庭 111210512 https://github.com/yiting0418/wp/tree/master/hw4

Micha1lyu commented 1 week ago

余宸安 111210543 https://github.com/Micha1lyu/wp/tree/master/js/hw4 第3、5題參考chatgpt 第4題參考講義month.js 第8題參考解答

Kabocha0918 commented 1 week ago

曾俊諭 111210506 https://github.com/Kabocha0918/wp/tree/master/html/work4

julianalidya commented 1 week ago

林小蓮 111210552 https://github.com/julianalidya/wp/tree/master/HW%204

LainGH0601 commented 1 week ago

王莉允 111010144 https://github.com/LainGH0601/wp/tree/master/homework/HOMEWORK4

W100552733w commented 1 week ago

葉俊成 111210544 https://github.com/W100552733w/W100.github/tree/main/hw4

CH623 commented 1 week ago

趙興華 111210515 https://github.com/CH623/wp/tree/master/js/HW4

Erhashh commented 1 week ago

安吉斯 111210563 https://github.com/Erhashh/wp/tree/master/hw4 使用 ChatGPT