2025年9月24日 星期三

Scribd

主要是研究所時期做的一些投影片,少部份是後來做的:

 https://www.scribd.com/user/21556865/davidsmc

"8 Kyu":Never visit a . . . !?特解

Never visit a . . . !?

 這題我是用暴力解的.但解了之後,看別人其實有特解,
就是直接輸出9-apple
原因在於:

1. Sum all the digits of n.

假設n 是a + 10*b + 100*c + 1000*d
Sum all the digits of n的結果是s.

s=a+b+c+d

2. Subtract the sum from n, and it is your new n.

所以 new n = n - s 

= a + 10*b + 100*c + 1000*d - (a + b + c + d)

= 9*b + 99*c + 999*d

所以一定是9的倍數。
其餘不是千位數的n類推,也是9的倍數

3. If the new n is in the list below return the associated fruit, otherwise return back to task 1.

...

9-apple

...

18-apple

...

27-apple

...

36-apple

...

45-apple

...

54-apple

...

63-apple

...

72-apple

...

81-apple

...

90-apple

91-kiwi

92-banana

93-kiwi

94-banana

95-melon

96-banana

97-melon

98-pineapple

99-apple

100-pineapple

9的倍數,相關的水果一定是apple.不會是別的。 

Swift storyboard for FitAutoTest 雜記

info.plist:

看是Ordinary.storyboard 還是 TabView.storyboard ?

在info.plist:

Main storyboard file base name (macOS): Ordinary
則是Ordinary

==========================================

實際在跑的<project_name>_<station_name>.plist

以branch B495_Pizza為例:

PlistHelper.swift:

func getStationProjectName() -> String {

        return "\(self.getProjectName())_\(self.getStationName())"

}


B44445_QT2Flow.swift:

SAP109_MBFlow.swift:

ConcurrentFlow.swift:

...

let stationProjectName = self._plistHelper!.getStationProjectName()

let testList = TestListFactory.getTestList(stationProjectName: stationProjectName)

...


TestListFactory.swift:

class TestListFactory {

    static func getTestList(stationProjectName: String) -> ITestList? {

        switch stationProjectName {

        case "B444445_QT2":

            return B444445_QT2List()

        ...

        case "B495_Pizza":

            return B495_PizzaList()

        ...

        case "B499_Pizza":

            return B499_PizzaList()

        case "Test_Pizza": // Temp 20250219

            return B495_PizzaList()

        default:

            return nil

        }

    }

}

==========================================

FitAutoTest, 找出程式GUI的start,

Ordinary.storyboard點兩下,

Start Btn0 -> Show the Connections inspector


Referencing Outlets

看到叫做startBtn0


Sent Actions

看到Ordinary Controller

dutStart0


OrdinaryController.swift:

@IBAction func dutStart0(_ sender: Any) {

        super.handleStartBtnClick(dutIndex: 0)

    }


BaseViewController.swift:

...

self.startBtnList = [startBtn0, startBtn1, startBtn2, startBtn3]


func handleStartBtnClick(dutIndex: Int){

    ...

     if self.setUIAfterStart(dutIndex: dutIndex, isAlarm: true) {

            ...

            self.startBtnList[dutIndex].isEnabled = false

            self._testflow!.testStart(startTime: startTime, allDutIndexSnMap: [dutIndex: self.snTextFieldList[dutIndex].stringValue])

            ..

    }

}


ITestFlow.swift:

protocol ITestFlow {

    ...

    func testStart(startTime: Date, allDutIndexSnMap: Dictionary<Int, String>) -> ()

}


B444445_QT2Flow.swift:

class B444445_QT2Flow : ITestFlow {

    ...

    func testStart(startTime: Date, allDutIndexSnMap: Dictionary<Int, String>) {

        ...

         for i in 0...plistTestItems.count - 1 {

            let pItem = plistTestItems[i]

            

            //add into DispatchGroup

            queue.async(group: group) {

                

                let eachfunc = testList!.testItemScript[pItem.Script]

                if eachfunc != nil {

                    ...

                    var resultItem = eachfunc!(container)

                    ...

    }

}

2025年8月7日 星期四

大杯無鹽

關羽跟張飛都掛了

劉備找孔明訴苦 劉備:「雲長魂歸故里,如今三弟也溘然長逝,真乃大悲啊」 孔明:「甜度?」

劉備:「大悲無言」

孔明:「我是問甜度,不是加不加鹽…」

Scribd

主要是研究所時期做的一些投影片,少部份是後來做的:  https://www.scribd.com/user/21556865/davidsmc