Created
May 20, 2012 21:06
-
-
Save orangutanboy/2759535 to your computer and use it in GitHub Desktop.
133 character bowling game score calc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void c(int[]b,out int t){int n,v,i=t=0,X=10;for(;i<19;i+=2){n=b[i]+b[i+1];v=b[i+2];t+=(n<X)?n:X+v;if(b[i]>9)t+=b[i+(i>16|v<X?3:4)];}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using NUnit.Framework; | |
namespace GameTests | |
{ | |
[TestFixture] | |
public class ScorerTests | |
{ | |
[Test] | |
public void GameTests() | |
{ | |
var scorer = new Scorer(); | |
int result; | |
scorer.c(new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, out result); | |
Assert.AreEqual(0, result); | |
scorer.c(new[] { 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, out result); | |
Assert.AreEqual(10, result); | |
scorer.c(new[] { 10, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, out result); | |
Assert.AreEqual(12, result); | |
scorer.c(new[] { 10, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, out result); | |
Assert.AreEqual(14, result); | |
scorer.c(new[] { 9, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, out result); | |
Assert.AreEqual(13, result); | |
scorer.c(new[] { 9, 1, 10, 0, 10, 0, 5, 4, 10, 0, 5, 4, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, out result); | |
Assert.AreEqual(109, result); | |
scorer.c(new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 10, 10 }, out result); | |
Assert.AreEqual(30, result); | |
scorer.c(new[] { 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 10 }, out result); | |
Assert.AreEqual(300, result); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment