diff options
| -rwxr-xr-x | challenge-145/eric-cheung/excel-vba/Challenge_145.xlsm | bin | 0 -> 26797 bytes | |||
| -rwxr-xr-x | challenge-145/eric-cheung/excel-vba/ch-1.bas | 31 | ||||
| -rwxr-xr-x | challenge-145/eric-cheung/python/ch-2.py | 148 | ||||
| -rw-r--r-- | stats/pwc-current.json | 128 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 68 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 956 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 732 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 100 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 110 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 112 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 34 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 30 | ||||
| -rw-r--r-- | stats/pwc-summary-241-270.json | 24 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 106 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 36 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 116 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 38 |
17 files changed, 1474 insertions, 1295 deletions
diff --git a/challenge-145/eric-cheung/excel-vba/Challenge_145.xlsm b/challenge-145/eric-cheung/excel-vba/Challenge_145.xlsm Binary files differnew file mode 100755 index 0000000000..67327b18b0 --- /dev/null +++ b/challenge-145/eric-cheung/excel-vba/Challenge_145.xlsm diff --git a/challenge-145/eric-cheung/excel-vba/ch-1.bas b/challenge-145/eric-cheung/excel-vba/ch-1.bas new file mode 100755 index 0000000000..c29c9b6a07 --- /dev/null +++ b/challenge-145/eric-cheung/excel-vba/ch-1.bas @@ -0,0 +1,31 @@ +Attribute VB_Name = "ModTask_01"
+Option Explicit
+
+Public Const strMyTitle As String = "Eric Cheung"
+
+Sub Task_01()
+'' Dot Product
+
+ Dim strMsg As String
+
+ Dim dArr_A() As Variant, dArr_B() As Variant
+ Dim nLoop As Integer
+ Dim dSum As Double
+
+ dArr_A = Array(1, 2, 3)
+ dArr_B = Array(4, 5, 6)
+
+ If UBound(dArr_A) - LBound(dArr_A) <> UBound(dArr_B) - LBound(dArr_B) Then
+ strMsg = "Inconsistent Array Size"
+ Exit Sub
+ End If
+
+ For nLoop = LBound(dArr_A) To UBound(dArr_A)
+ dSum = dSum + dArr_A(nLoop) * dArr_B(nLoop)
+ Next nLoop
+
+ MsgBox dSum, vbOKOnly, strMyTitle
+
+End Sub
+
+
diff --git a/challenge-145/eric-cheung/python/ch-2.py b/challenge-145/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..5d4276b2e6 --- /dev/null +++ b/challenge-145/eric-cheung/python/ch-2.py @@ -0,0 +1,148 @@ +import logging
+
+## Credit:
+## https://gist.github.com/shubham2508/9188707973e9a758c0edefe577c0da20
+
+## Remarks:
+## https://stackoverflow.com/questions/2802726/putting-a-simple-if-then-else-statement-on-one-line
+## https://en.wikipedia.org/wiki/%3F:#Python
+
+## Links Used:
+## http://adilet.org/blog/palindromic-tree/
+## https://medium.com/@alessiopiergiacomi/eertree-or-palindromic-tree-82453e75025b
+## It solves the problem in O(n)
+
+class PalindromicNode:
+ def __init__(self, start = 0, end = 0):
+ self.start = start
+ self.end = end
+ self.len = end - start + 1
+ self.insertionEdge = [0] * 26
+ self.suffixLink = None
+
+ ## Optional Attribute
+ self.count = 1 ## Stores number of times this palindrome was repeated
+ self.num_of_suffix_links = 1 ## stores number of suffix link till imaginary node
+
+ def increment_count(self):
+ self.count = self.count + 1
+
+class PalindromicTree:
+ def __init__(self, value):
+ self.emptyNode = PalindromicNode()
+ self.imaginaryNode = PalindromicNode()
+ self.tree = []
+ self.string = value
+ self.total_palindromes = 0
+ self.distinct_palindromes = 0
+ self.emptyNode.suffixLink = self.imaginaryNode
+ self.imaginaryNode.suffixLink = self.imaginaryNode
+ self.imaginaryNode.len = -1
+ self.emptyNode.len = 0
+
+ self.current_suffix = self.imaginaryNode
+
+ def insert_letter(self, curr_ind, character):
+ chr_index = ord(character) - 97
+ new_node = None
+ curr_suffix = self.current_suffix
+
+ if curr_suffix.len > 0:
+ logging.debug(f'\n curr_suffix is : {self.string[curr_suffix.start:curr_suffix.end + 1]}')
+
+ while curr_suffix:
+ curr_start = curr_ind if curr_suffix.len == -1 else curr_ind - curr_suffix.len - 1
+
+ if curr_start >= 0 and self.string[curr_start] == character:
+ if not curr_suffix.insertionEdge[chr_index]:
+ new_node = PalindromicNode(start = curr_start, end = curr_ind)
+ logging.info(f' new_node starts from: {new_node.start} ends at: {new_node.end}')
+ curr_suffix.insertionEdge[chr_index] = new_node
+ self.distinct_palindromes = self.distinct_palindromes + 1
+
+ break
+ else:
+ new_node = curr_suffix.insertionEdge[chr_index]
+ self.total_palindromes = self.total_palindromes + new_node.num_of_suffix_links
+ new_node.increment_count()
+ self.current_suffix = new_node
+ logging.info(f' new_node is already present: {self.string[new_node.start:new_node.end + 1]}')
+ logging.debug(f' Palindromes til now: {self.total_palindromes}')
+
+ return
+
+ curr_suffix = curr_suffix.suffixLink
+
+ self.tree.append(new_node)
+ self.current_suffix = new_node
+
+ if new_node.start == new_node.end:
+ new_node.suffixLink = self.emptyNode
+ self.total_palindromes += new_node.num_of_suffix_links
+ logging.debug(f' Palindromes til now: {self.total_palindromes}')
+ return
+
+ curr_suffix = curr_suffix.suffixLink
+
+ while True:
+ curr_start = curr_ind if curr_suffix.len == -1 else curr_ind - curr_suffix.len - 1
+
+ if curr_start >= 0 and self.string[curr_start] == character:
+ new_node.suffixLink = curr_suffix.insertionEdge[chr_index]
+ new_node.num_of_suffix_links = new_node.num_of_suffix_links + new_node.suffixLink.num_of_suffix_links
+ self.total_palindromes = self.total_palindromes + new_node.num_of_suffix_links
+
+ logging.debug(f' new_node suffix link is : {self.string[new_node.suffixLink.start:new_node.suffixLink.end + 1]}')
+
+ break
+
+ curr_suffix = curr_suffix.suffixLink
+
+ logging.debug(f' Palindromes til now: {self.total_palindromes}')
+
+ def get_number_of_occurrence_of_sub_palindromes(self):
+
+ total_len = len(self.tree)
+
+ for j in range(total_len - 1, -1, -1):
+ self.tree[j].suffixLink.count = self.tree[j].suffixLink.count + self.tree[j].count
+
+ total_palindromes = 0
+
+ for treeNode in self.tree:
+ start, end, count = treeNode.start, treeNode.end, treeNode.count
+ logging.critical(f' Palindrome is {self.string[start:end + 1]} number of times: {count} ')
+ total_palindromes += count
+
+ logging.critical(f' Total number of palindromes: {total_palindromes} ')
+
+
+if __name__ == "__main__":
+
+ ## Example 1:
+ ## string = "redivider"
+
+ ## Example 2:
+ ## string = "deific"
+
+ ## Example 3:
+ ## string = "rotors"
+
+ ## Example 4:
+ ## string = "challenge"
+
+ ## Example 5:
+ ## string = "champion"
+
+ ## Example 6:
+ string = "christmas"
+
+ logging.basicConfig(level = logging.INFO)
+ palindromicTree = PalindromicTree(string)
+ for index, ch in enumerate(string):
+ palindromicTree.insert_letter(index, ch)
+
+ logging.critical(f' Total number of palindromes: {palindromicTree.total_palindromes} ')
+ logging.critical(f' Total number of distinct palindromes: {palindromicTree.distinct_palindromes}')
+
+ palindromicTree.get_number_of_occurrence_of_sub_palindromes()
diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 2998234038..cbf95f0533 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,64 +1,60 @@ { - "title" : { - "text" : "The Weekly Challenge - 145" - }, - "legend" : { - "enabled" : 0 + "subtitle" : { + "text" : "[Champions: 11] Last updated at 2021-12-28 13:55:46 GMT" }, "tooltip" : { + "followPointer" : 1, "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", - "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", - "followPointer" : 1 + "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>" }, "series" : [ { - "name" : "The Weekly Challenge - 145", "colorByPoint" : 1, "data" : [ { - "drilldown" : "Andrew Shitov", + "name" : "Andrew Shitov", "y" : 1, - "name" : "Andrew Shitov" + "drilldown" : "Andrew Shitov" }, { "drilldown" : "Dave Jacoby", - "name" : "Dave Jacoby", - "y" : 3 + "y" : 3, + "name" : "Dave Jacoby" }, { "drilldown" : "Laurent Rosenfeld", - "name" : "Laurent Rosenfeld", - "y" : 3 + "y" : 3, + "name" : "Laurent Rosenfeld" }, { - "name" : "Mark Anderson", + "drilldown" : "Mark Anderson", "y" : 1, - "drilldown" : "Mark Anderson" + "name" : "Mark Anderson" }, { - "name" : "Mohammad S Anwar", + "drilldown" : "Mohammad S Anwar", "y" : 1, - "drilldown" : "Mohammad S Anwar" + "name" : "Mohammad S Anwar" }, { + "drilldown" : "Olivier Delouya", "name" : "Olivier Delouya", - "y" : 1, - "drilldown" : "Olivier Delouya" + "y" : 1 }, { "drilldown" : "Paulo Custodio", - "y" : 2, - "name" : "Paulo Custodio" + "name" : "Paulo Custodio", + "y" : 2 }, { - "drilldown" : "Peter Campbell Smith", "y" : 3, - "name" : "Peter Campbell Smith" + "name" : "Peter Campbell Smith", + "drilldown" : "Peter Campbell Smith" }, { + "drilldown" : "Robert DiCicco", "name" : "Robert DiCicco", - "y" : 2, - "drilldown" : "Robert DiCicco" + "y" : 2 }, { "y" : 5, @@ -70,37 +66,29 @@ "y" : 3, "drilldown" : "W. Luis Mochan" } - ] + ], + "name" : "The Weekly Challenge - 145" } ], - "subtitle" : { - "text" : "[Champions: 11] Last updated at 2021-12-28 13:42:53 GMT" + "title" : { + "text" : "The Weekly Challenge - 145" }, "chart" : { "type" : "column" }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "xAxis" : { - "type" : "category" - }, "drilldown" : { "series" : [ { - "name" : "Andrew Shitov", - "id" : "Andrew Shitov", "data" : [ [ "Raku", 1 ] - ] + ], + "id" : "Andrew Shitov", + "name" : "Andrew Shitov" }, { - "id" : "Dave Jacoby", "name" : "Dave Jacoby", "data" : [ [ @@ -111,10 +99,10 @@ "Blog", 1 ] - ] + ], + "id" : "Dave Jacoby" }, { - "id" : "Laurent Rosenfeld", "name" : "Laurent Rosenfeld", "data" : [ [ @@ -129,37 +117,38 @@ "Blog", 1 ] - ] + ], + "id" : "Laurent Rosenfeld" }, { - "name" : "Mark Anderson", "id" : "Mark Anderson", "data" : [ [ "Raku", 1 ] - ] + ], + "name" : "Mark Anderson" }, { + "name" : "Mohammad S Anwar", + "id" : "Mohammad S Anwar", "data" : [ [ "Perl", 1 ] - ], - "id" : "Mohammad S Anwar", - "name" : "Mohammad S Anwar" + ] }, { - "name" : "Olivier Delouya", "id" : "Olivier Delouya", "data" : [ [ "Perl", 1 ] - ] + ], + "name" : "Olivier Delouya" }, { "data" : [ @@ -168,10 +157,11 @@ 2 ] ], - "name" : "Paulo Custodio", - "id" : "Paulo Custodio" + "id" : "Paulo Custodio", + "name" : "Paulo Custodio" }, { + "name" : "Peter Campbell Smith", "data" : [ [ "Perl", @@ -182,20 +172,21 @@ 1 ] ], - "id" : "Peter Campbell Smith", - "name" : "Peter Campbell Smith" + "id" : "Peter Campbell Smith" }, { + "name" : "Robert DiCicco", + "id" : "Robert DiCicco", "data" : [ [ "Perl", 2 ] - ], - "id" : "Robert DiCicco", - "name" : "Robert DiCicco" + ] }, { + "name" : "Roger Bell_West", + "id" : "Roger Bell_West", "data" : [ [ "Perl", @@ -209,11 +200,10 @@ "Blog", 1 ] - ], - "name" : "Roger Bell_West", - "id" : "Roger Bell_West" + ] }, { + "name" : "W. Luis Mochan", "data" : [ [ "Perl", @@ -224,18 +214,28 @@ 1 ] ], - "name" : "W. Luis Mochan", "id" : "W. Luis Mochan" } ] }, + "legend" : { + "enabled" : 0 + }, "plotOptions" : { "series" : { - "borderWidth" : 0, "dataLabels" : { "format" : "{point.y}", "enabled" : 1 - } + }, + "borderWidth" : 0 + } + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" } + }, + "xAxis" : { + "type" : "category" } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 0f7e3a6828..6cd224c505 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,20 +1,45 @@ { + "yAxis" : { + "min" : 0, + "title" : { + "text" : null + } + }, + "xAxis" : { + "labels" : { + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + } + }, + "type" : "category" + }, + "legend" : { + "enabled" : "false" + }, + "chart" : { + "type" : "column" + }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, "subtitle" : { - "text" : "Last updated at 2021-12-28 13:42:53 GMT" + "text" : "Last updated at 2021-12-28 13:55:46 GMT" }, "series" : [ { + "name" : "Contributions", "dataLabels" : { "color" : "#FFFFFF", - "rotation" : -90, - "format" : "{point.y:.0f}", - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - }, "enabled" : "true", "y" : 10, - "align" : "right" + "align" : "right", + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + }, + "rotation" : -90, + "format" : "{point.y:.0f}" }, "data" : [ [ @@ -29,35 +54,10 @@ "Raku", 4194 ] - ], - "name" : "Contributions" + ] } ], - "legend" : { - "enabled" : "false" - }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" - }, "title" : { "text" : "The Weekly Challenge Contributions [2019 - 2021]" - }, - "xAxis" : { - "labels" : { - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - } - }, - "type" : "category" - }, - "yAxis" : { - "title" : { - "text" : null - }, - "min" : 0 - }, - "chart" : { - "type" : "column" } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 819d3b70ca..5fda562c7d 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,7 +1,32 @@ { + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "xAxis" : { + "type" : "category" + }, + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + } + } + }, + "legend" : { + "enabled" : "false" + }, + "chart" : { + "type" : "column" + }, "drilldown" : { "series" : [ { + "name" : "001", + "id" : "001", "data" : [ [ "Perl", @@ -15,11 +40,11 @@ "Blog", 11 ] - ], - "name" : "001", - "id" : "001" + ] }, { + "name" : "002", + "id" : "002", "data" : [ [ "Perl", @@ -33,12 +58,9 @@ "Blog", 10 ] - ], - "id" : "002", - "name" : "002" + ] }, { - "name" : "003", "id" : "003", "data" : [ [ @@ -53,7 +75,8 @@ "Blog", 9 ] - ] + ], + "name" : "003" }, { "name" : "004", @@ -74,7 +97,6 @@ ] }, { - "id" : "005", "name" : "005", "data" : [ [ @@ -89,10 +111,10 @@ "Blog", 12 ] - ] + ], + "id" : "005" }, { - "name" : "006", "id" : "006", "data" : [ [ @@ -107,10 +129,10 @@ "Blog", 7 ] - ] + ], + "name" : "006" }, { - "name" : "007", "id" : "007", "data" : [ [ @@ -125,7 +147,8 @@ "Blog", 10 ] - ] + ], + "name" : "007" }, { "data" : [ @@ -164,6 +187,8 @@ ] }, { + "name" : "010", + "id" : "010", "data" : [ [ "Perl", @@ -177,11 +202,11 @@ "Blog", 11 ] - ], - "name" : "010", - "id" : "010" + ] }, { + "name" : "011", + "id" : "011", "data" : [ [ "Perl", @@ -195,11 +220,10 @@ "Blog", 10 ] - ], - "name" : "011", - "id" : "011" + ] }, { + "id" : "012", "data" : [ [ "Perl", @@ -214,7 +238,6 @@ 11 ] ], - "id" : "012", "name" : "012" }, { @@ -254,8 +277,6 @@ "name" : "014" }, { - "name" : "015", - "id" : "015", "data" : [ [ "Perl", @@ -269,9 +290,12 @@ "Blog", 15 ] - ] + ], + "id" : "015", + "name" : "015" }, { + "name" : "016", "data" : [ [ "Perl", @@ -286,11 +310,9 @@ 12 ] ], - "id" : "016", - "name" : "016" + "id" : "016" }, { - "id" : "017", "name" : "017", "data" : [ [ @@ -305,9 +327,12 @@ "Blog", 12 ] - ] + ], + "id" : "017" }, { + "name" : "018", + "id" : "018", "data" : [ [ "Perl", @@ -321,13 +346,9 @@ "Blog", 14 ] - ], - "name" : "018", - "id" : "018" + ] }, { - "id" : "019", - "name" : "019", "data" : [ [ "Perl", @@ -341,7 +362,9 @@ "Blog", 13 ] - ] + ], + "id" : "019", + "name" : "019" }, { "name" : "020", @@ -363,7 +386,6 @@ }, { "name" : "021", - "id" : "021", "data" : [ [ "Perl", @@ -377,7 +399,8 @@ "Blog", 10 ] - ] + ], + "id" : "021" }, { "data" : [ @@ -430,8 +453,8 @@ 11 ] ], - "name" : "024", - "id" : "024" + "id" : "024", + "name" : "024" }, { "data" : [ @@ -448,11 +471,10 @@ 12 ] ], - "name" : "025", - "id" : "025" + "id" : "025", + "name" : "025" }, { - "id" : "026", "name" : "026", "data" : [ [ @@ -467,9 +489,12 @@ "Blog", 10 ] - ] + ], + "id" : "026" }, { + "name" : "027", + "id" : "027", "data" : [ [ "Perl", @@ -483,11 +508,10 @@ "Blog", 9 ] - ], - "name" : "027", - "id" : "027" + ] }, { + "name" : "028", "data" : [ [ "Perl", @@ -502,10 +526,10 @@ 9 ] ], - "name" : "028", "id" : "028" }, { + "id" : "029", "data" : [ [ "Perl", @@ -520,12 +544,9 @@ 12 ] ], - "id" : "029", "name" : "029" }, { - "name" : "030", - "id" : "030", "data" : [ [ "Perl", @@ -539,9 +560,12 @@ "Blog", 10 ] - ] + ], + "id" : "030", + "name" : "030" }, { + "name" : "031", "data" : [ [ "Perl", @@ -556,10 +580,11 @@ 9 ] ], - "name" : "031", "id" : "031" }, { + "name" : "032", + "id" : "032", "data" : [ [ "Perl", @@ -573,13 +598,11 @@ "Blog", 10 ] - ], - "id" : "032", - "name" : "032" + ] }, { - "id" : "033", "name" : "033", + "id" : "033", "data" : [ [ "Perl", @@ -610,12 +633,10 @@ 11 ] ], - "name" : "034", - "id" : "034" + "id" : "034", + "name" : "034" }, { - "id" : "035", - "name" : "035", "data" : [ [ "Perl", @@ -629,7 +650,9 @@ "Blog", 9 ] - ] + ], + "id" : "035", + "name" : "035" }, { "data" : [ @@ -651,7 +674,6 @@ }, { "id" : "037", - "name" : "037", "data" : [ [ "Perl", @@ -665,9 +687,11 @@ "Blog", 9 ] - ] + ], + "name" : "037" }, { + "name" : "038", "data" : [ [ "Perl", @@ -682,7 +706,6 @@ 12 ] ], - "name" : "038", "id" : "038" }, { @@ -722,7 +745,6 @@ "name" : "040" }, { - "id" : "041", "name" : "041", "data" : [ [ @@ -737,11 +759,11 @@ "Blog", 9 ] - ] + ], + "id" : "041" }, { "name" : "042", - "id" : "042", "data" : [ [ "Perl", @@ -755,11 +777,10 @@ "Blog", 11 ] - ] + ], + "id" : "042" }, { - "name" : "043", - "id" : "043", "data" : [ [ "Perl", @@ -773,10 +794,11 @@ "Blog", 11 ] - ] + ], + "id" : "043", + "name" : "043" }, { - "id" : "044", "name" : "044", "data" : [ [ @@ -791,7 +813,8 @@ "Blog", 11 ] - ] + ], + "id" : "044" }, { "name" : "045", @@ -812,6 +835,8 @@ ] }, { + "name" : "046", + "id" : "046", "data" : [ [ "Perl", @@ -825,11 +850,10 @@ "Blog", 10 ] - ], - "name" : "046", - "id" : "046" + ] }, { + "name" : "047", "data" : [ [ "Perl", @@ -844,8 +868,7 @@ 10 ] ], - "id" : "047", - "name" : "047" + "id" : "047" }, { "name" : "048", @@ -866,6 +889,8 @@ ] }, { + "name" : "049", + "id" : "049", "data" : [ [ "Perl", @@ -879,13 +904,10 @@ |
