public void Day3_Should_Calculate_Sum2_part2() { SpiralGridModel gridModel = new SpiralGridModel(); NumberModel number = gridModel.CalculateWhenSumOvverridesValue(289326); Assert.AreEqual(1, number.Sum); }
public HexadecimalNumber(string input) { var number = new NumberModel(input, Base); IntegerPart = number.IntegerPart; FloatPart = number.FloatPart; }
/// <summary> /// 系统底层使用 /// </summary> /// <returns></returns> public List <NumberModel> GetALL() { List <NumberModel> numbers = new List <NumberModel>(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { for (int k = 0; k < 10; k++) { for (int l = 0; l < 10; l++) { for (int z = 0; z < 10; z++) { NumberModel number = new NumberModel(); number.N1 = i; number.N2 = j; number.N3 = k; number.N4 = l; number.N5 = z; numbers.Add(number); } } } } } return(numbers); }
public ActionResult MainView(NumberModel nm) { int intTemp = int.Parse(nm.number); double doubleTemp = double.Parse(nm.number); nm.square = doubleTemp * doubleTemp; nm.cube = doubleTemp * doubleTemp * doubleTemp; //factorial nm.factorial = 1; for (int i = 0; i < intTemp; i++) { nm.factorial *= (i + 1); } //check if number is a prime nm.isPrime = true; if (intTemp % 2 == 0) { nm.isPrime = false; } for (int i = 3; i < intTemp / 2 + 1; i += 2) { if (intTemp % i == 0) { nm.isPrime = false; } } return(View(nm)); }
/* * 0,1,2,3,4,5,6,7,8,9,0,1 * 9后面是0 * 0后面是1 */ /// <summary> /// 处理完毕 /// </summary> /// <param name="shouwei"></param> /// <param name="is09"></param> /// <param name="numberModels"></param> public static void 无序4连(bool shouwei, bool is09, ref List <NumberModel> numberModels) { foreach (var item in AllNumer.GetAllNumer()) { NumberModel number = Sort(item); string ruleN = "0123456789"; string ruleS = "0123456789012"; if (ruleN.IndexOf(number.GetString()) >= 0) { Add(item, ref numberModels); } if (shouwei) { if (number.N1 == number.N4 - 1 && number.N2 == item.N1 - 1 && number.N3 == item.N2 - 1) { Add(item, ref numberModels); } } if (is09) { if (ruleS.IndexOf(number.GetString()) >= 0 || ruleS.IndexOf(item.GetString()) >= 0) { Add(item, ref numberModels); } } } }
public static void NonMatchNums() { List <string> getApiNums = NumberModel.LoadNumber(); //List<int> numRange = new List<int>(); List <int> apiNums = new List <int>(); foreach (string item in getApiNums) { int num = int.Parse(item); apiNums.Add(num); } for (int i = 0; i < 8; i++) { numRange.Add(i); } for (int i = 0; i < apiNums.Count; i++) { for (int j = 0; j < numRange.Count; j++) { if (apiNums[i] == numRange[j]) { numRange.RemoveAt(j); } } } nonMatchRangeExist = true; RanHint(); }
/// <summary> /// 上期开的号码本期中一个没有 /// </summary> /// <param name="numberModel"></param> /// <param name="item"></param> /// <returns></returns> private static bool CheckHisAllNot(NumberModel numberModel, NumberModel item) { if (item.N1 != numberModel.N1 && item.N1 != numberModel.N2 && item.N1 != numberModel.N3 && item.N1 != numberModel.N4 && item.N1 != numberModel.N5) { return(false); } if (item.N2 != numberModel.N1 && item.N2 != numberModel.N2 && item.N2 != numberModel.N3 && item.N2 != numberModel.N4 && item.N2 != numberModel.N5) { return(false); } if (item.N3 != numberModel.N1 && item.N3 != numberModel.N2 && item.N3 != numberModel.N3 && item.N3 != numberModel.N4 && item.N3 != numberModel.N5) { return(false); } if (item.N4 != numberModel.N1 && item.N4 != numberModel.N2 && item.N4 != numberModel.N3 && item.N4 != numberModel.N4 && item.N4 != numberModel.N5) { return(false); } if (item.N5 != numberModel.N1 && item.N5 != numberModel.N2 && item.N5 != numberModel.N3 && item.N5 != numberModel.N4 && item.N5 != numberModel.N5) { return(false); } return(true); }
public static void Huice() { DateTime stardate = DateTime.Today.AddDays(-3); CPQaunt.DataAccess.Tcp_HiscodeCollection collection = new CPQaunt.DataAccess.Tcp_HiscodeCollection(); collection.ListByDate(stardate, DateTime.Today.AddDays(1)); for (int i = 0; i < collection.DataTable.Rows.Count; i++) { NumberModel number = new NumberModel(); string[] sl = collection.DataTable.Rows[i]["opencode"].ToString().Split(','); number.N1 = int.Parse(sl[0]); number.N2 = int.Parse(sl[1]); number.N3 = int.Parse(sl[2]); number.N4 = int.Parse(sl[3]); number.N5 = int.Parse(sl[4]); if (number.N1 != 3 && number.N2 != 3 && number.N3 != 3 && number.N4 != 3 && number.N5 != 3) { if (number.N1 != 6 && number.N2 != 6 && number.N3 != 6 && number.N4 != 6 && number.N5 != 6) { if (number.N1 != 9 && number.N2 != 9 && number.N3 != 9 && number.N4 != 9 && number.N5 != 9) { winnercount = winnercount + 1; yingliamount = yingliamount + 950; } } } failcount = failcount + 1; xiazhuamount = xiazhuamount + 168; Console.WriteLine("总下注:" + collection.DataTable.Rows.Count + "-----没中:" + failcount + "---中了" + winnercount + "-----总收益:" + yingliamount + " -----总下注" + xiazhuamount); } }
/// <summary> /// Initializes a new instance of the <see cref="NumberViewModel" /> class. /// </summary> /// <param name="model">The model.</param> /// <param name="dispatchService">The dispatch service.</param> public NumberViewModel(NumberModel model, IDispatchService dispatchService) { _dispatchService = dispatchService; Model = model; Model.PropertyChanged += ModelOnPropertyChanged; }
public BinaryNumber(string input) { var number = new NumberModel(input, Base); IntegerPart = number.IntegerPart; FloatPart = number.FloatPart; }
private static void Add(NumberModel item, ref List <NumberModel> numberModels) { if (numberModels.Count(S => S.N1 == item.N1 && S.N2 == item.N2 && S.N3 == item.N3 && S.N4 == item.N4) == 0) { numberModels.Add(item); } }
/// <summary> /// 是否全是大数 /// </summary> /// <param name="lastnumber"></param> /// <returns></returns> public static bool CheckSmall(NumberModel lastnumber) { if (lastnumber.N1 >= 5 && lastnumber.N2 >= 5 && lastnumber.N3 >= 5 && lastnumber.N4 >= 5 && lastnumber.N5 >= 5) { return(true); } return(false); }
/// <summary> /// 是否全是小数 /// </summary> /// <param name="lastnumber"></param> /// <returns></returns> public static bool CheckBig(NumberModel lastnumber) { if (lastnumber.N1 < 5 && lastnumber.N2 < 5 && lastnumber.N3 < 5 && lastnumber.N4 < 5 && lastnumber.N5 < 5) { return(true); } return(false); }
/// <summary> /// 是否全是奇数 /// </summary> /// <param name="lastnumber"></param> /// <returns></returns> public static bool ChecNotkOdd(NumberModel lastnumber) { if (!IsOdd(lastnumber.N1) && !IsOdd(lastnumber.N2) && !IsOdd(lastnumber.N3) && !IsOdd(lastnumber.N4) && !IsOdd(lastnumber.N5)) { return(true); } return(false); }
public IHttpActionResult JoinGame(int id, [FromBody] NumberModel numberModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var currentUserId = this.User.Identity.GetUserId(); var currentUser = this.Data.Users.Find(currentUserId); var game = this.Data.Games.Find(id); if (game == null || game.State != GameState.WaitingForOpponent) { return(BadRequest("Invalid game")); } if (game.RedUser.Id == currentUser.Id) { return(BadRequest("User cannot join their own games")); } var isRedInTurn = rand.Next() % 2 == 0; game.State = (isRedInTurn) ? GameState.RedInTurn : GameState.BlueInTurn; game.BlueUser = currentUser; game.BlueUserNumber = int.Parse(numberModel.Number); this.Data.Games.Update(game); this.Data.SaveChanges(); var nextTurnnotification = new Notification() { Message = string.Format(NextTurnNotificationFormat, game.Name), DateCreated = DateTime.Now, NotificationState = NotificationState.Unread, NotificationType = NotificationType.YourTurn, User = isRedInTurn ? game.RedUser : game.BlueUser, Game = game }; this.Data.Notifications.Add(nextTurnnotification); var notification = new Notification() { Message = string.Format(GameJoinedMessageFormat, currentUser.UserName, game.Name), DateCreated = DateTime.Now, Game = game, NotificationType = NotificationType.GameJoined, NotificationState = NotificationState.Unread, User = game.RedUser }; this.Data.Notifications.Add(notification); this.Data.SaveChanges(); return(Ok("Game joined")); }
public void Day3_Should_find_Position2_part1() { SpiralGridModel gridModel = new SpiralGridModel(); NumberModel number = gridModel.FindPosition(1024); //List<NumberModel> numberList = gridModel.FindPosition(1024); int steps = gridModel.GetDistance(number); Assert.AreEqual(31, steps); }
public async Task <ActionResult <NumberModel[]> > AddOrUpdate([FromBody] NumberModel model) { if (model == null || string.IsNullOrEmpty(model.Id)) { return(BadRequest("Number not posted")); } await numberService.AddOrUpdate(model); return(Ok(Get())); }
public IActionResult Index() { var numbers = _numberRepository.GetAll(); var model = new NumberModel { Numbers = numbers }; Response.Headers.Add("Refresh", "5"); return(View(model)); }
public Task AddWorkItem(IBotContext context) { //switch var message = context.Request.AsMessageActivity(); if (context.State.ConversationProperties["currentState"] == null) { context.Reply("Enter customerid:"); context.State.ConversationProperties["currentState"] = "customerId"; return(Task.CompletedTask); } switch (context.State.ConversationProperties["currentState"]) { case "customerId": context.State.ConversationProperties["customerId"] = message.Text; context.Reply("Enter description:"); context.State.ConversationProperties["currentState"] = "description"; break; case "description": context.State.ConversationProperties["description"] = message.Text; context.Reply("Enter work hours:"); context.State.ConversationProperties["currentState"] = "hours"; break; case "hours": context.State.ConversationProperties["hours"] = message.Text; // Recognize number NumberModel numberModel = (NumberModel)NumberRecognizer.Instance.GetNumberModel(Culture.English); var result = numberModel.Parse(context.Request.AsMessageActivity().Text); if (result.Count > 0 && long.TryParse(result[0].Resolution.Values.FirstOrDefault().ToString(), out long n)) { context.Reply($"You entered: {n}"); context.Reply("Enter attachment:"); context.State.ConversationProperties["currentState"] = "attachment"; } else { context.Reply("Invalid number. Enter an integer."); } break; default: // Once you completed your steps context.State.ConversationProperties["currentIntent"] = null; break; } return(Task.CompletedTask); }
public NumberModel ConvertNumberToString(string startingNumber) { char[] array = startingNumber.Split(".")[0].ToCharArray(); var numberModel = new NumberModel(); var number = Convert.ToInt32(startingNumber.Split(".")[0]); if (number >= 1000) { var result = (number - (number % 1000)) / 1000; numberModel.NumberString = $"{digits[result - 1]} {columns[0]} "; number = number % 1000; } if (number >= 100) { var result = (number - (number % 100)) / 100; numberModel.NumberString += $"{digits[result - 1]} {columns[1]} "; number = number % 100; } if (number >= 20) { var result = (number - (number % 10)) / 10; numberModel.NumberString += $"{tens[result - 2]}"; number = number % 10; if (number != 0) { numberModel.NumberString += $"-{digits[number - 1]} "; } } else { var result = (number - (number % 10)) / 10; numberModel.NumberString += $"{digits[number - 1]} "; } if (startingNumber.Contains(".")) { cents = startingNumber.Split(".")[1]; } if (cents == "" || cents == null) { cents = "00"; } char[] cap = numberModel.NumberString.ToCharArray(); cap[0] = char.ToUpper(cap[0]); numberModel.NumberString = new string(cap); numberModel.NumberString += $" and {cents}/100 dollars"; return(numberModel); }
public void Should_serialize_nullable_int_to_number() { // Given var model = new NumberModel { SomeNullableInt = 42 }; // When var result = SimpleJson.SerializeObject(model); // Then result.ShouldEqual("{\"SomeNullableInt\":42}"); }
//Method to compile user and computer number combinations. Unlock Button directs to this class. public async Task SetCombNums(List <int> inputNums) { //sets user combination input List <string> apiNums = new List <string>(); List <int> userNums = inputNums; //Initiates Number Model to call API for random combination //NumberModel nm = new NumberModel(); apiNums = NumberModel.LoadNumber(); await CombCheck.RunCheck(apiNums, userNums); }
public NumberModel GetRandomNumbers() { Random random = new Random(); NumberModel numberObject = new NumberModel { RandomNumber1 = random.Next(-500, 5000), RandomNumber2 = random.Next(-500, 5000), RandomNumber3 = random.Next(-500, 5000), }; return(numberObject); }
public void Hexadecimal_Float_Dot_Separated_Test() { INumber number = new NumberModel("AD.FD", 16); number.IntegerPart.Should().Be("AD"); number.FloatPart.Should().Be("FD"); number.Base.Should().Be(16); number = new HexadecimalNumber("AD.FD"); number.IntegerPart.Should().Be("AD"); number.FloatPart.Should().Be("FD"); number.Base.Should().Be(16); }
public void IndexPostTestFibonacciNumbers() { var model = new NumberModel(); var calc = new CalcNumberSequence(); var controller = new HomeController(); model.Number = 6; var viewResult = controller.Index(model) as PartialViewResult; var outputModel = (NumberModel)viewResult.ViewData.Model; var result = outputModel.FibonacciNumbers; Assert.AreEqual("0,1,1,2,3,5", result); }
public void IndexPostTestSubstitutedNumbers() { var model = new NumberModel(); var calc = new CalcNumberSequence(); var controller = new HomeController(); model.Number = 15; var viewResult = controller.Index(model) as PartialViewResult; var outputModel = (NumberModel)viewResult.ViewData.Model; var result = outputModel.SubstitutedNumbers; Assert.AreEqual("1,2,C,4,E,C,7,8,C,E,11,C,13,14,Z", result); }
static void Main(string[] args) { SpiralGridModel gridModel = new SpiralGridModel(); Console.WriteLine("created gridmodel"); NumberModel number = gridModel.FindPosition(289326); Console.WriteLine("Done findPosition"); int steps = gridModel.GetDistance(number); Console.WriteLine(steps); Console.ReadKey(); }
public void Binary_Regular_Float_Dot_Separated_Test() { INumber number = new NumberModel("100101.010101", 2); number.IntegerPart.Should().Be("100101"); number.FloatPart.Should().Be("010101"); number.Base.Should().Be(2); number = new BinaryNumber("100101.010101"); number.IntegerPart.Should().Be("100101"); number.FloatPart.Should().Be("010101"); number.Base.Should().Be(2); }
public void Decimal_Float_Dot_Separated_Test() { INumber number = new NumberModel("123.456", 10); number.IntegerPart.Should().Be("123"); number.FloatPart.Should().Be("456"); number.Base.Should().Be(10); number = new DecimalNumber("123.456"); number.IntegerPart.Should().Be("123"); number.FloatPart.Should().Be("456"); number.Base.Should().Be(10); }
public void Day3_Should_find_Position4_part1() { SpiralGridModel gridModel = new SpiralGridModel(); NumberModel number = gridModel.FindPosition(1); //List<NumberModel> numberList = gridModel.FindPosition(12, Number); //NumberModel number = numberList[numberList.Count - 1]; Assert.AreEqual(0, number.X_position); Assert.AreEqual(0, number.Y_position); int steps = gridModel.GetDistance(number); Assert.AreEqual(0, steps); }
public void IndexPost() { HomeController controller = new HomeController(); NumberModel request = new NumberModel(); request.Number = "123.45"; ViewResult result = controller.Index(request) as ViewResult; NumberModel response = (NumberModel) result.Model; Assert.AreEqual("123.45", response.Number); Assert.AreEqual("One Hundred and Twenty Three Dollars and Fourty Five Cents", response.TransformedNumber); Assert.IsFalse(controller.ModelState.ContainsKey("Number")); }
public void IndexPostNegative() { HomeController controller = new HomeController(); NumberModel request = new NumberModel(); request.Number = "-123.45"; ViewResult result = controller.Index(request) as ViewResult; NumberModel response = (NumberModel)result.Model; Assert.AreEqual("-123.45", response.Number); Assert.IsNull(response.TransformedNumber); Assert.IsTrue(controller.ViewData.ModelState.ContainsKey("Number")); }