CP2020-40923218

  • Home
    • Site Map
    • reveal
    • blog
  • 首頁
  • 關於更新
    • 十月份更新
    • 十一月更新
    • 十二月更新
    • 一月份更新
  • 心得
  • 課程內容(HW1)
    • Customer Relations
    • Overview
    • Operational Procedures
      • Customer Service Key Principles
    • Effective Listening
      • Listening skills
    • Taking Ownership
      • Apologizing When Appropriate
      • Show Empathy
    • Remain Courteous and Professional
      • Timeliness
      • Keeping the Customer Informed
    • Problem Resolution and Follow-Up
    • Proper Treatment of a Customer’s Property
    • Putting it All Together
  • 課程內容(HW2)
    • 作業之一(分組數列)
    • 作業之二(是否有加退選)
    • 作業之三()
  • 課程內容(HW3)
    • 19題
    • 25題
      • 猜數字測試
    • 26題
  • 網頁來自Github
    • 運作原理
猜數字測試 << Previous Next >> 網頁來自Github

26題

(完成度60%)

def checkGrid(grid):
 
    for x in range(0,3):
        row = set([grid[x][0],grid[x][1],grid[x][2]])
        if len(row) == 1 and grid[x][0] != 0:
            return grid[x][0]

    for x in range(0,3):
        column = set([grid[0][x],grid[1][x],grid[2][x]])
        if len(column) == 1 and grid[0][x] != 0:
            return grid[0][x]

    diag1 = set([grid[0][0],grid[1][1],grid[2][2]])
    diag2 = set([grid[0][2],grid[1][1],grid[2][0]])
    if len(diag1) == 1 or len(diag2) == 1 and grid[1][1] != 0:
        return grid[1][1]

    return 0

winner_is_2 = [
[2, 2, 0],
	[2, 1, 0],
	[2, 1, 1]]
winner_is_1 = [
[1, 2, 0],
	[2, 1, 0],
	[2, 1, 1]]

winner_is_also_1 = [
[0, 1, 0],
	[2, 1, 0],
	[2, 1, 1]]

no_winner = [
[1, 2, 0],
	[2, 1, 0],
	[2, 1, 2]]

also_no_winner = [
[1, 2, 0],
	[2, 1, 0],
	[2, 1, 0]]

print(checkGrid(winner_is_2))

心得:這題我到目前我還沒有理解,我需要花點時間來爬文,就現在來說,我要研究這串程式究竟在說什麼。

備註:kaggle我這裡沒有跑,我不確定跑起來是否有問題。

結果:

>y:\python38\pythonw.exe -u "26題.py"
2
>Exit code: 0

猜數字測試 << Previous Next >> 網頁來自Github

Copyright © All rights reserved | This template is made with by Colorlib