From 0c335cf93f0bab126d4293ae15f184b833ad9bd7 Mon Sep 17 00:00:00 2001 From: Reduan Azouaghe Date: Fri, 8 Aug 2025 10:43:56 +0200 Subject: [PATCH 1/3] Acceptance and extended criteria passed --- .DS_Store | Bin 0 -> 6148 bytes csharp-scrabble-challenge.Main/Scrabble.cs | 80 +++++++++++++++++++-- 2 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ae534439869c57de9b2d569935c6806c177da58b GIT binary patch literal 6148 zcmeHK%}N6?5T4YkTZ+(wf+q=ht=jsB;$^9N^x}#hRO)V9ba73}Zfg&vuxEWCpTy^J zCP@{ko&+s2Qzlvwd#ej>ZB$h zZgLONcJ!t5@YG)=kuoGU%D>W<2!{L6tD(gFY^-)z0_cv=*xxKYJ8kM}I)s2JG z=6&*@^phoC;D6M}g2OR9W9LU4JO-&sw7SJS<2A;)8JPiQfEk!Z2HaWYm8bFH_?egi zX5dd5pz}eZ68a8vi{|LShCUx@zDP)deY#5!N{7C~+#=4P2pfuMLxsCy2pf)e>HK_$ zxkVce!mNyW+{(h;P=r|>?b5h|@GWx73@`(q8JMxd3f2GP@9+PggLuRYFa!UJ0Z}{( zjvDw%uC`9R9MxKhdV@+re!0c>5bT&zjJ{Ngmr;$NT~Y_pcbHp53krV-7#g@?27Z-+ EH+ukFSO5S3 literal 0 HcmV?d00001 diff --git a/csharp-scrabble-challenge.Main/Scrabble.cs b/csharp-scrabble-challenge.Main/Scrabble.cs index c1ea013..66e3819 100644 --- a/csharp-scrabble-challenge.Main/Scrabble.cs +++ b/csharp-scrabble-challenge.Main/Scrabble.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.IO.Pipelines; using System.Linq; using System.Reflection.Metadata.Ecma335; +using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; @@ -9,15 +11,85 @@ namespace csharp_scrabble_challenge.Main { public class Scrabble { + private string _word; + private Dictionary _scores = new Dictionary() + { + {'a', 1}, + {'e', 1}, + {'i', 1}, + {'o', 1}, + {'u', 1}, + {'l', 1}, + {'n', 1}, + {'r', 1}, + {'s', 1}, + {'t', 1}, + {'d', 2}, + {'g', 2}, + {'b', 3}, + {'c', 3}, + {'m', 3}, + {'p', 3}, + {'f', 4}, + {'h', 4}, + {'v', 4}, + {'w', 4}, + {'y', 4}, + {'k', 5}, + {'j', 8}, + {'x', 8}, + {'q', 10}, + {'z', 10}, + }; + public Scrabble(string word) - { - //TODO: do something with the word variable + { + _word = word.ToLower(); } public int score() { - //TODO: score calculation code goes here - throw new NotImplementedException(); //TODO: Remove this line when the code has been written + if (_word.Count(f => f == '[') != _word.Count(f => f == '[')) return 0; + if (_word.Count(f => f == '{') != _word.Count(f => f == '}')) return 0; + + int result = 0; + bool isDouble = false; + bool isTripple = false; + + foreach (char c in _word) + { + if (Char.IsLetter(c)) + { + int points = _scores[c]; + + if (isDouble) points *= 2; + if (isTripple) points *= 3; + + result += points; + } + else if (c == '[') + { + isTripple = true; + } + else if (c == '{') + { + isDouble = true; + } + else if (c == ']') + { + isTripple = false; + } + else if (c == '}') + { + isDouble = false; + } + else + { + return 0; + } + } + + return result; } } } From e5f1cee23e3eda67f8a3accad244ced7866f7c88 Mon Sep 17 00:00:00 2001 From: reduan-azouaghe Date: Fri, 8 Aug 2025 10:46:30 +0200 Subject: [PATCH 2/3] Delete .DS_Store --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index ae534439869c57de9b2d569935c6806c177da58b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}N6?5T4YkTZ+(wf+q=ht=jsB;$^9N^x}#hRO)V9ba73}Zfg&vuxEWCpTy^J zCP@{ko&+s2Qzlvwd#ej>ZB$h zZgLONcJ!t5@YG)=kuoGU%D>W<2!{L6tD(gFY^-)z0_cv=*xxKYJ8kM}I)s2JG z=6&*@^phoC;D6M}g2OR9W9LU4JO-&sw7SJS<2A;)8JPiQfEk!Z2HaWYm8bFH_?egi zX5dd5pz}eZ68a8vi{|LShCUx@zDP)deY#5!N{7C~+#=4P2pfuMLxsCy2pf)e>HK_$ zxkVce!mNyW+{(h;P=r|>?b5h|@GWx73@`(q8JMxd3f2GP@9+PggLuRYFa!UJ0Z}{( zjvDw%uC`9R9MxKhdV@+re!0c>5bT&zjJ{Ngmr;$NT~Y_pcbHp53krV-7#g@?27Z-+ EH+ukFSO5S3 From 0ed7a443c714ae4077f039fbe1dc3f15e5ec4d3e Mon Sep 17 00:00:00 2001 From: reduan-azouaghe Date: Fri, 8 Aug 2025 10:46:51 +0200 Subject: [PATCH 3/3] Update .gitignore Add `.DS_Store`. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index a6576fc..de3d636 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ ## ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore +.DS_Store + # User-specific files *.rsuser *.suo