Created
July 1, 2016 15:54
-
-
Save stackia/664fe5eb134fa4ec90e00543217bc320 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace ConsoleApplication4 | |
{ | |
public static class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
// 见 Decode 方法 | |
} | |
public static List<ResultItem> Decode(string mode, string input) | |
{ | |
Func<string, List<ResultItem>> process = a => | |
{ | |
var cc = new List<ResultItem>(); | |
Func<char, int> ee = | |
aa => aa >= '0' && '9' >= aa ? int.Parse(aa.ToString()) : aa - 'a' + 10; | |
Func<string, int, ResultItem> ff = (aaa, bbb) => | |
{ | |
var ccc = ee(aaa[bbb]); | |
var ddd = ee(aaa[bbb + 1]); | |
ddd = 15 & ddd; | |
var fff = (12 & ccc) >> 2; | |
var ggg = (2 & ccc) > 0; | |
var hhh = (1 & ccc) > 0; | |
return new ResultItem | |
{ | |
Value = ddd, | |
Winner = fff, | |
PlayerPair = ggg, | |
BankerPair = hhh | |
}; | |
}; | |
var gg = 0; | |
for (; gg < a.Length - 1; gg += 2) | |
{ | |
var bb = ff(a, gg); | |
if (bb.Winner != 3) cc.Add(bb); | |
else cc = new List<ResultItem>(); | |
} | |
return cc; | |
}; | |
if (string.IsNullOrEmpty(mode) || string.IsNullOrEmpty(input)) return new List<ResultItem>(); | |
switch (mode) | |
{ | |
case "7bal": | |
case "bal": | |
return process(input); | |
case "rol": | |
case "rofl": | |
return input.Split(';').Select(s => new ResultItem | |
{ | |
Result = s | |
}).ToList(); | |
default: | |
throw new NotSupportedException(mode); | |
} | |
} | |
public class ResultItem | |
{ | |
public bool BankerPair { get; set; } | |
public bool PlayerPair { get; set; } | |
public int Value { get; set; } | |
public int Winner { get; set; } | |
public string Result { get; set; } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment