diff options
| author | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2024-08-07 09:56:50 +0100 |
|---|---|---|
| committer | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2024-08-07 09:56:50 +0100 |
| commit | 94b9145b09c9801d2400771d37e7a7ee85dacfda (patch) | |
| tree | 5fbcc46085ec932ac57456b40e865d0603c39910 | |
| parent | 8e595373b239918114db8050c33eed2e6f52d0a1 (diff) | |
| download | perlweeklychallenge-club-94b9145b09c9801d2400771d37e7a7ee85dacfda.tar.gz perlweeklychallenge-club-94b9145b09c9801d2400771d37e7a7ee85dacfda.tar.bz2 perlweeklychallenge-club-94b9145b09c9801d2400771d37e7a7ee85dacfda.zip | |
- Added solutions by Robbie Hatley.
- Added solutions by Packy Anderson.
- Added solutions by Eric Cheung.
24 files changed, 2395 insertions, 2248 deletions
diff --git a/challenge-281/eric-cheung/python/ch-1.py b/challenge-281/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..22bdbb6e1b --- /dev/null +++ b/challenge-281/eric-cheung/python/ch-1.py @@ -0,0 +1,15 @@ +
+arrX_Coor = ["a", "b", "c", "d", "e", "f", "g", "h"]
+arrY_Coor = [nLoop for nLoop in range(1, 9)]
+
+## print (arrX_Coor)
+## print (arrY_Coor)
+
+## strCoord = "d3" ## Example 1
+## strCoord = "g5" ## Example 2
+strCoord = "e6" ## Example 3
+
+## Ref.
+## True: Light
+## False: Dark
+print (arrX_Coor.index(strCoord[0]) % 2 == 1 or arrY_Coor.index(int(strCoord[1])) % 2 == 1)
diff --git a/challenge-281/eric-cheung/python/ch-2.py b/challenge-281/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..d665d4e730 --- /dev/null +++ b/challenge-281/eric-cheung/python/ch-2.py @@ -0,0 +1,113 @@ +
+## Ref.
+## https://www.geeksforgeeks.org/minimum-steps-reach-target-knight-set-2/
+
+## Min Steps For A Knight to Reach Target Position
+
+## Initialize the Matrix
+arrKnightMove = [[0 for nRowLoop in range(8)] for nColLoop in range(8)]
+
+## Size of Chess Board nBoardSize * nBoardSize
+nBoardSize = 8
+
+arrX_Coor = ["a", "b", "c", "d", "e", "f", "g", "h"]
+arrY_Coor = [str(nLoop) for nLoop in range(1, 9)]
+
+def GetStepMove (nStartPos_X, nStartPos_Y, nTargetPos_X, nTargetPos_Y):
+
+ ## Exception
+ ## These are the four corner points
+ ## for which the minimum steps is 4
+
+ if nStartPos_X == 1 and nStartPos_Y == 1 and nTargetPos_X == 2 and nTargetPos_Y == 2 or nStartPos_X == 2 and nStartPos_Y == 2 and nTargetPos_X == 1 and nTargetPos_Y == 1:
+ return 4
+
+ if nStartPos_X == 1 and nStartPos_Y == nBoardSize and nTargetPos_X == 2 and nTargetPos_Y == nBoardSize - 1 or nStartPos_X == 2 and nStartPos_Y == nBoardSize - 1 and nTargetPos_X == 1 and nTargetPos_Y == nBoardSize:
+ return 4
+
+ if nStartPos_X == nBoardSize and nStartPos_Y == 1 and nTargetPos_X == nBoardSize - 1 and nTargetPos_Y == 2 or nStartPos_X == nBoardSize - 1 and nStartPos_Y == 2 and nTargetPos_X == nBoardSize and nTargetPos_Y == 1:
+ return 4
+
+ if nStartPos_X == nBoardSize and nStartPos_Y == nBoardSize and nTargetPos_X == nBoardSize - 1 and nTargetPos_Y == nBoardSize - 1 or nStartPos_X == nBoardSize - 1 and nStartPos_Y == nBoardSize - 1 and nTargetPos_X == nBoardSize and nTargetPos_Y == nBoardSize:
+ return 4
+
+ ## If Knight is on the target, position return 0
+ if nStartPos_X == nTargetPos_X and nStartPos_Y == nTargetPos_Y:
+ return arrKnightMove[0][0]
+
+ ## If already calculated, then return that value. Take absolute difference
+ nAbsDiff_X = abs(nStartPos_X - nTargetPos_X)
+ nAbsDiff_Y = abs(nStartPos_Y - nTargetPos_Y)
+
+ if arrKnightMove[nAbsDiff_X][nAbsDiff_Y] != 0:
+ return arrKnightMove[nAbsDiff_X][nAbsDiff_Y]
+
+ ## There will be two distinct positions
+ ## from the knight towards a target
+ ## if the target is in same row or column
+ ## as of knight then there can be four
+ ## positions towards the target but in that
+ ## two would be the same and the other two
+ ## would be the same.
+ nInterPos_01_X, nInterPos_01_Y, nInterPos_02_X, nInterPos_02_Y = 0, 0, 0, 0
+
+ ## (nInterPos_01_X, nInterPos_01_Y) and (nInterPos_02_X, nInterPos_02_Y) are two positions.
+ ## these can be different according to situation.
+ ## From position of knight, the chess board can be
+ ## divided into four blocks i.e.. N-E, E-S, S-W, W-N
+ if nStartPos_X <= nTargetPos_X:
+ nInterPos_01_X = nStartPos_X + 2
+ nInterPos_02_X = nStartPos_X + 1
+ else:
+ nInterPos_01_X = nStartPos_X - 2
+ nInterPos_02_X = nStartPos_X - 1
+
+ if nStartPos_Y <= nTargetPos_Y:
+ nInterPos_01_Y = nStartPos_Y + 1
+ nInterPos_02_Y = nStartPos_Y + 2
+ else:
+ nInterPos_01_Y = nStartPos_Y - 1
+ nInterPos_02_Y = nStartPos_Y - 2
+
+ ## Answer will be, 1 + minimum of steps
+ ## required from (nInterPos_01_X, nInterPos_01_Y) and (nInterPos_02_X, nInterPos_02_Y)
+ arrKnightMove[nAbsDiff_X][nAbsDiff_Y] = min(GetStepMove(nInterPos_01_X, nInterPos_01_Y, nTargetPos_X, nTargetPos_Y), GetStepMove(nInterPos_02_X, nInterPos_02_Y, nTargetPos_X, nTargetPos_Y)) + 1
+
+ ## exchanging the coordinates nStartPos_X with nStartPos_Y of both
+ ## knight and target will result in same answer
+ arrKnightMove[nAbsDiff_Y][nAbsDiff_X] = arrKnightMove[nAbsDiff_X][nAbsDiff_Y]
+
+ return arrKnightMove[nAbsDiff_X][nAbsDiff_Y]
+
+
+## Driver Code
+if __name__ == "__main__":
+
+ ## (nStartPos_X, nStartPos_Y) coordinate of the Knight Position
+ ## (nTargetPos_X, nTargetPos_Y) coordinate of the Target Position
+
+ ## Example 1
+ ## strStartPos = "g2"
+ ## strTargetPos = "a8"
+
+ ## Example 2
+ strStartPos = "g2"
+ strTargetPos = "h2"
+
+ nStartPos_X = arrX_Coor.index(strStartPos[0]) + 1
+ nStartPos_Y = arrY_Coor.index(strStartPos[1]) + 1
+
+ nTargetPos_X = arrX_Coor.index(strTargetPos[0]) + 1
+ nTargetPos_Y = arrY_Coor.index(strTargetPos[1]) + 1
+
+ ## arrKnightMove[a][b], here a, b is the difference of
+ ## nStartPos_X & nTargetPos_X and nStartPos_Y & nTargetPos_Y respectively
+ arrKnightMove[1][0] = 3
+ arrKnightMove[0][1] = 3
+ arrKnightMove[1][1] = 2
+ arrKnightMove[2][0] = 2
+ arrKnightMove[0][2] = 2
+ arrKnightMove[2][1] = 1
+ arrKnightMove[1][2] = 1
+
+ print (GetStepMove(nStartPos_X, nStartPos_Y, nTargetPos_X, nTargetPos_Y))
diff --git a/stats/pwc-current.json b/stats/pwc-current.json index af688e0780..7ff509be34 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,7 +1,141 @@ { + "tooltip" : { + "followPointer" : 1, + "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", + "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>" + }, + "series" : [ + { + "name" : "The Weekly Challenge - 281", + "colorByPoint" : 1, + "data" : [ + { + "name" : "Alexander Karelas", + "drilldown" : "Alexander Karelas", + "y" : 2 + }, + { + "drilldown" : "Dave Jacoby", + "name" : "Dave Jacoby", + "y" : 3 + }, + { + "drilldown" : "David Ferrone", + "y" : 2, + "name" : "David Ferrone" + }, + { + "y" : 2, + "drilldown" : "E. Choroba", + "name" : "E. Choroba" + }, + { + "name" : "Feng Chang", + "drilldown" : "Feng Chang", + "y" : 2 + }, + { + "y" : 2, + "drilldown" : "Jan Krnavek", + "name" : "Jan Krnavek" + }, + { + "y" : 2, + "drilldown" : "Kjetil Skotheim", + "name" : "Kjetil Skotheim" + }, + { + "drilldown" : "Laurent Rosenfeld", + "name" : "Laurent Rosenfeld", + "y" : 3 + }, + { + "drilldown" : "Mariano Ortega", + "name" : "Mariano Ortega", + "y" : 2 + }, + { + "drilldown" : "Mark Anderson", + "name" : "Mark Anderson", + "y" : 2 + }, + { + "y" : 5, + "drilldown" : "Packy Anderson", + "name" : "Packy Anderson" + }, + { + "drilldown" : "Peter Campbell Smith", + "y" : 3, + "name" : "Peter Campbell Smith" + }, + { + "drilldown" : "Peter Meszaros", + "name" : "Peter Meszaros", + "y" : 2 + }, + { + "y" : 3, + "drilldown" : "Robbie Hatley", + "name" : "Robbie Hatley" + }, + { + "y" : 4, + "drilldown" : "Roger Bell_West", + "name" : "Roger Bell_West" + }, + { + "drilldown" : "Thomas Kohler", + "name" : "Thomas Kohler", + "y" : 4 + }, + { + "drilldown" : "Ulrich Rieke", + "y" : 4, + "name" : "Ulrich Rieke" + }, + { + "drilldown" : "W. Luis Mochan", + "y" : 3, + "name" : "W. Luis Mochan" + }, + { + "drilldown" : "Wanderdoc", + "name" : "Wanderdoc", + "y" : 2 + } + ] + } + ], + "xAxis" : { + "type" : "category" + }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } + }, "title" : { "text" : "The Weekly Challenge - 281" }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "legend" : { + "enabled" : 0 + }, + "subtitle" : { + "text" : "[Champions: 19] Last updated at 2024-08-07 08:56:24 GMT" + }, + "chart" : { + "type" : "column" + }, "drilldown" : { "series" : [ { @@ -11,10 +145,12 @@ 2 ] ], - "id" : "Alexander Karelas", - "name" : "Alexander Karelas" + "name" : "Alexander Karelas", + "id" : "Alexander Karelas" }, { + "name" : "Dave Jacoby", + "id" : "Dave Jacoby", "data" : [ [ "Perl", @@ -24,62 +160,59 @@ "Blog", 1 ] - ], - "id" : "Dave Jacoby", - "name" : "Dave Jacoby" + ] }, { + "name" : "David Ferrone", "id" : "David Ferrone", "data" : [ [ "Perl", 2 ] - ], - "name" : "David Ferrone" + ] }, { "name" : "E. Choroba", + "id" : "E. Choroba", "data" : [ [ "Perl", 2 ] - ], - "id" : "E. Choroba" + ] }, { + "name" : "Feng Chang", + "id" : "Feng Chang", "data" : [ [ "Raku", 2 ] - ], - "name" : "Feng Chang", - "id" : "Feng Chang" + ] }, { - "name" : "Jan Krnavek", "data" : [ [ "Raku", 2 ] ], + "name" : "Jan Krnavek", "id" : "Jan Krnavek" }, { + "name" : "Kjetil Skotheim", + "id" : "Kjetil Skotheim", "data" : [ [ "Perl", 2 ] - ], - "name" : "Kjetil Skotheim", - "id" : "Kjetil Skotheim" + ] }, { - "id" : "Laurent Rosenfeld", "data" : [ [ "Perl", @@ -94,30 +227,30 @@ 1 ] ], + "id" : "Laurent Rosenfeld", "name" : "Laurent Rosenfeld" }, { - "id" : "Mariano Ortega", "data" : [ [ "Perl", 2 ] ], + "id" : "Mariano Ortega", "name" : "Mariano Ortega" }, { "name" : "Mark Anderson", + "id" : "Mark Anderson", "data" : [ [ "Raku", 2 ] - ], - "id" : "Mark Anderson" + ] }, { - "id" : "Packy Anderson", "data" : [ [ "Perl", @@ -132,10 +265,10 @@ 1 ] ], - "name" : "Packy Anderson" + "name" : "Packy Anderson", + "id" : "Packy Anderson" }, { - "name" : "Peter Campbell Smith", "data" : [ [ "Perl", @@ -146,20 +279,34 @@ 1 ] ], + "name" : "Peter Campbell Smith", "id" : "Peter Campbell Smith" }, { - "name" : "Peter Meszaros", "data" : [ [ "Perl", 2 ] ], - "id" : "Peter Meszaros" + "id" : "Peter Meszaros", + "name" : "Peter Meszaros" + }, + { + "name" : "Robbie Hatley", + "id" : "Robbie Hatley", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] }, { - "id" : "Roger Bell_West", "data" : [ [ "Perl", @@ -170,10 +317,10 @@ 2 ] ], - "name" : "Roger Bell_West" + "name" : "Roger Bell_West", + "id" : "Roger Bell_West" }, { - "name" : "Thomas Kohler", "data" : [ [ "Perl", @@ -184,9 +331,11 @@ 2 ] ], - "id" : "Thomas Kohler" + "id" : "Thomas Kohler", + "name" : "Thomas Kohler" }, { + "name" : "Ulrich Rieke", "id" : "Ulrich Rieke", "data" : [ [ @@ -197,11 +346,9 @@ "Raku", 2 ] - ], - "name" : "Ulrich Rieke" + ] }, { - "id" : "W. Luis Mochan", "data" : [ [ "Perl", @@ -212,147 +359,19 @@ 1 ] ], + "id" : "W. Luis Mochan", "name" : "W. Luis Mochan" }, { + "id" : "Wanderdoc", + "name" : "Wanderdoc", "data" : [ [ "Perl", 2 ] - ], - "id" : "Wanderdoc", - "name" : "Wanderdoc" + ] } ] - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "subtitle" : { - "text" : "[Champions: 18] Last updated at 2024-08-06 22:29:23 GMT" - }, - "series" : [ - { - "data" : [ - { - "y" : 2, - "drilldown" : "Alexander Karelas", - "name" : "Alexander Karelas" - }, - { - "name" : "Dave Jacoby", - "drilldown" : "Dave Jacoby", - "y" : 3 - }, - { - "y" : 2, - "drilldown" : "David Ferrone", - "name" : "David Ferrone" - }, - { - "y" : 2, - "name" : "E. Choroba", - "drilldown" : "E. Choroba" - }, - { - "drilldown" : "Feng Chang", - "name" : "Feng Chang", - "y" : 2 - }, - { - "y" : 2, - "drilldown" : "Jan Krnavek", - "name" : "Jan Krnavek" - }, - { - "drilldown" : "Kjetil Skotheim", - "name" : "Kjetil Skotheim", - "y" : 2 - }, - { - "name" : "Laurent Rosenfeld", - "drilldown" : "Laurent Rosenfeld", - "y" : 3 - }, - { - "name" : "Mariano Ortega", - "drilldown" : "Mariano Ortega", - "y" : 2 - }, - { - "name" : "Mark Anderson", - "drilldown" : "Mark Anderson", - "y" : 2 - }, - { - "y" : 5, - "drilldown" : "Packy Anderson", - "name" : "Packy Anderson" - }, - { - "drilldown" : "Peter Campbell Smith", - "name" : "Peter Campbell Smith", - "y" : 3 - }, - { - "y" : 2, - "name" : "Peter Meszaros", - "drilldown" : "Peter Meszaros" - }, - { - "y" : 4, - "drilldown" : "Roger Bell_West", - "name" : "Roger Bell_West" - }, - { - "y" : 4, - "name" : "Thomas Kohler", - "drilldown" : "Thomas Kohler" - }, - { - "drilldown" : "Ulrich Rieke", - "name" : "Ulrich Rieke", - "y" : 4 - }, - { - "y" : 3, - "name" : "W. Luis Mochan", - "drilldown" : "W. Luis Mochan" - }, - { - "drilldown" : "Wanderdoc", - "name" : "Wanderdoc", - "y" : 2 - } - ], - "name" : "The Weekly Challenge - 281", - "colorByPoint" : 1 - } - ], - "chart" : { - "type" : "column" - }, - "plotOptions" : { - "series" : { - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - }, - "borderWidth" : 0 - } - }, - "legend" : { - "enabled" : 0 - }, - "xAxis" : { - "type" : "category" - }, - "tooltip" : { - "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", - "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", - "followPointer" : 1 } } diff --git a/stats/pwc-language-breakdown-2019.json b/stats/pwc-language-breakdown-2019.json index 8e542545fd..10f2296e38 100644 --- a/stats/pwc-language-breakdown-2019.json +++ b/stats/pwc-language-breakdown-2019.json @@ -1,240 +1,17 @@ { - "plotOptions" : { - "series" : { - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - }, - "borderWidth" : 0 - } + "subtitle" : { + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2024-08-07 08:56:24 GMT" + }, + "legend" : { + "enabled" : "false" }, "chart" : { "type" : "column" }, - "series" : [ - { - "colorByPoint" : "true", - "name" : "The Weekly Challenge Languages", - "data" : [ - { - "drilldown" : "041", - "name" : "041", - "y" : 80 - }, - { - "y" : 77, - "drilldown" : "040", - "name" : "040" - }, - { - "name" : "039", - "drilldown" : "039", - "y" : 68 - }, - { - "drilldown" : "038", - "name" : "038", - "y" : 74 - }, - { - "y" : 70, - "name" : "037", - "drilldown" : "037" - }, - { - "y" : 70, - "drilldown" : "036", - "name" : "036" - }, - { - "name" : "035", - "drilldown" : "035", - "y" : 68 - }, - { - "drilldown" : "034", - "name" : "034", - "y" : 70 - }, - { - "y" : 113, - "drilldown" : "033", - "name" : "033" - }, - { - "drilldown" : "032", - "name" : "032", - "y" : 97 - }, - { - "name" : "031", - "drilldown" : "031", - "y" : 93 - }, - { - "drilldown" : "030", - "name" : "030", - "y" : 120 - }, - { - "y" : 83, - "drilldown" : "029", - "name" : "029" - }, - { - "name" : "028", - "drilldown" : "028", - "y" : 82 - }, - { - "y" : 64, - "name" : "027", - "drilldown" : "027" - }, - { - "name" : "026", - "drilldown" : "026", - "y" : 75 - }, - { - "drilldown" : "025", - "name" : "025", - "y" : 62 - }, - { - "name" : "024", - "drilldown" : "024", - "y" : 77 - }, - { - "name" : "023", - "drilldown" : "023", - "y" : 88 - }, - { - "y" : 72, - "drilldown" : "022", - "name" : "022" - }, - { - "drilldown" : "021", - "name" : "021", - "y" : 72 - }, - { - "y" : 100, - "drilldown" : "020", - "name" : "020" - }, - { - "drilldown" : "019", - "name" : "019", - "y" : 101 - }, - { - "y" : 82, - "drilldown" : "018", - "name" : "018" - }, - { - "y" : 83, - "drilldown" : "017", - "name" : "017" - }, - { - "drilldown" : "016", - "name" : "016", - "y" : 75 - }, - { - "name" : "015", - "drilldown" : "015", - "y" : 95 - }, - { - "y" : 98, - "name" : "014", - "drilldown" : "014" - }, - { - "y" : 85, - "drilldown" : "013", - "name" : "013" - }, - { - "y" : 90, - "name" : "012", - "drilldown" : "012" - }, - { - "drilldown" : "011", - "name" : "011", - "y" : 86 - }, - { - "y" : 69, - "name" : "010", - "drilldown" : "010" - }, - { - "y" : 79, - "name" : "009", - "drilldown" : "009" - }, - { - "name" : "008", - "drilldown" : "008", - "y" : 82 - }, - { - "y" : 71, - "drilldown" : "007", - "name" : "007" - }, - { - "name" : "006", - "drilldown" : "006", - "y" : 63 - }, - { - "drilldown" : "005", - "name" : "005", - "y" : 82 - }, - { - "name" : "004", - "drilldown" : "004", - "y" : 106 - }, - { - "y" : 91, - "name" : "003", - "drilldown" : "003" - }, - { - "drilldown" : "002", - "name" : "002", - "y" : 133 - }, - { - "y" : 165, - "drilldown" : "001", - "name" : "001" - } - ] - } - ], - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2024-08-06 22:29:23 GMT" - }, "drilldown" : { "series" : [ { + "name" : "041", "id" : "041", "data" : [ [ @@ -249,10 +26,10 @@ "Blog", 9 ] - ], - "name" : "041" + ] }, { + "id" : "040", "name" : "040", "data" : [ [ @@ -267,8 +44,7 @@ "Blog", 10 ] - ], - "id" : "040" + ] }, { "data" : [ @@ -289,6 +65,8 @@ "id" : "039" }, { + "name" : "038", + "id" : "038", "data" : [ [ "Perl", @@ -302,12 +80,9 @@ "Blog", 12 ] - ], - "name" : "038", - "id" : "038" + ] }, { - "id" : "037", "data" : [ [ "Perl", @@ -322,9 +97,11 @@ 9 ] ], + "id" : "037", "name" : "037" }, { + "id" : "036", "name" : "036", "data" : [ [ @@ -339,8 +116,7 @@ |
