aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-143/eric-cheung/excel-vba/Challenge_143.xlsmbin0 -> 27321 bytes
-rwxr-xr-xchallenge-143/eric-cheung/excel-vba/ch-2.bas55
-rwxr-xr-xchallenge-143/eric-cheung/python/ch-1.py9
3 files changed, 64 insertions, 0 deletions
diff --git a/challenge-143/eric-cheung/excel-vba/Challenge_143.xlsm b/challenge-143/eric-cheung/excel-vba/Challenge_143.xlsm
new file mode 100755
index 0000000000..895a479b7d
--- /dev/null
+++ b/challenge-143/eric-cheung/excel-vba/Challenge_143.xlsm
Binary files differ
diff --git a/challenge-143/eric-cheung/excel-vba/ch-2.bas b/challenge-143/eric-cheung/excel-vba/ch-2.bas
new file mode 100755
index 0000000000..101b9bea72
--- /dev/null
+++ b/challenge-143/eric-cheung/excel-vba/ch-2.bas
@@ -0,0 +1,55 @@
+Attribute VB_Name = "ModTask_02"
+Option Explicit
+
+Public Const strMyTitle As String = "Eric Cheung"
+
+Sub Task_02() '' Stealthy Number
+
+ '' Const nInpuNum As Integer = 36 '' Example 1
+ '' Const nInpuNum As Integer = 12 '' Example 2
+ Const nInpuNum As Integer = 6 '' Example 3
+
+ Dim nLoop As Integer, nSubLoop As Integer, nCnt As Integer
+ Dim bIsPrime As Boolean
+
+ Dim nFactorArr_01() As Integer, nFactorArr_02()
+
+ ReDim nFactorArr_01(1 To 1)
+ ReDim nFactorArr_02(1 To 1)
+
+ nCnt = 1
+ nFactorArr_01(1) = 1: nFactorArr_02(1) = nInpuNum
+
+ bIsPrime = True
+ For nLoop = 2 To Sqr(nInpuNum)
+ If nInpuNum Mod nLoop = 0 Then
+ bIsPrime = False
+
+ nCnt = nCnt + 1
+ ReDim Preserve nFactorArr_01(1 To nCnt)
+ ReDim Preserve nFactorArr_02(1 To nCnt)
+
+ nFactorArr_01(nCnt) = nLoop
+ nFactorArr_02(nCnt) = nInpuNum / nLoop
+ End If
+ Next nLoop
+
+ If bIsPrime Then
+ MsgBox 0, vbOKOnly, strMyTitle
+ Exit Sub
+ End If
+
+ For nLoop = LBound(nFactorArr_01) To UBound(nFactorArr_01) - 1
+ For nSubLoop = nLoop + 1 To UBound(nFactorArr_01)
+ If Abs(nFactorArr_01(nLoop) + nFactorArr_02(nLoop) - nFactorArr_01(nSubLoop) - nFactorArr_02(nSubLoop)) = 1 Then
+ MsgBox 1, vbOKOnly, strMyTitle
+ Exit Sub
+ End If
+ Next nSubLoop
+ Next nLoop
+
+ MsgBox 0, vbOKOnly, strMyTitle
+
+End Sub
+
+
diff --git a/challenge-143/eric-cheung/python/ch-1.py b/challenge-143/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..4820b6c769
--- /dev/null
+++ b/challenge-143/eric-cheung/python/ch-1.py
@@ -0,0 +1,9 @@
+## Calculator
+import os
+
+strMathExpr = "10 + 20 - 5" ## Example 1
+## strMathExpr = "(10 + 20 - 5) * 2" ## Example 2
+
+print (strMathExpr + " = " + str(eval(strMathExpr)))
+
+os.system("pause")