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
| type Direction = Up | Right | Down | Left | |
| type State = { map: Map<int * int, int>; pos: (int * int); dir: Direction; } | |
| let manhattanDist x y = (fun (a, b) (c, d) -> abs (a - c) + abs (b - d)) x y | |
| let initState = | |
| { map = Map.empty<int * int, int> |> Map.add (0, 0) 1 | |
| pos = (0, 1) | |
| dir = Up } |
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
| type State = Group | Garbage | Cancel | |
| type StateContainer = { state : State; level : int; score : int; garbage : int } | |
| let solve stream = | |
| stream | |
| |> Seq.fold (fun current c -> | |
| match (current.state, c) with | |
| | Group, '{' -> { current with state = Group; level = current.level + 1 } | |
| | Group, '<' -> { current with state = Garbage } | |
| | Group, '}' -> { current with level = current.level - 1; score = current.score + current.level; } |
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 Microsoft.AspNetCore.Mvc; | |
| namespace Sorting.SnakeCase.Controllers | |
| { | |
| public class SnakeCaseTestController : Controller | |
| { | |
| [Route("users")] | |
| [HttpGet] | |
| public IActionResult GetUser(string userName, string firstName, string lastName) | |
| { |
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
| public void ConfigureServices(IServiceCollection services) | |
| { | |
| services | |
| .AddMvc(options => | |
| { | |
| options.ValueProviderFactories.Add(new SnakeCaseQueryValueProviderFactory()); | |
| }) | |
| .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver | |
| { | |
| NamingStrategy = new SnakeCaseNamingStrategy() |
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
| public void ConfigureServices(IServiceCollection services) | |
| { | |
| services | |
| .AddMvc(); | |
| .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver | |
| { | |
| NamingStrategy = new SnakeCaseNamingStrategy() | |
| }); | |
| } |
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.Globalization; | |
| using System.Threading.Tasks; | |
| using Microsoft.AspNetCore.Mvc.ModelBinding; | |
| namespace Sorting.SnakeCase.Http.Mvc.ModelBinding | |
| { | |
| public class SnakeCaseQueryValueProviderFactory : IValueProviderFactory | |
| { |
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.Globalization; | |
| using Microsoft.AspNetCore.Mvc.ModelBinding; | |
| using Microsoft.AspNetCore.Http; | |
| using Sorting.SnakeCase.Extensions; | |
| namespace Sorting.SnakeCase.Http.Mvc.ModelBinding | |
| { | |
| public class SnakeCaseQueryValueProvider : QueryStringValueProvider, IValueProvider |
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.Text; | |
| namespace Sorting.SnakeCase.Utilities | |
| { | |
| public static class StringExtensions | |
| { | |
| public static string ToSnakeCase(this string s) | |
| { | |
| if (string.IsNullOrWhiteSpace(s)) | |
| { |