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
| Mapper.CreateMap<List<ObjectId>, List<string>>().ConvertUsing(o => o.Select(os => os.ToString()).ToList()); | |
| Mapper.CreateMap<List<string>, List<ObjectId>>().ConvertUsing(o => o.Select(os => ObjectId.Parse(os)).ToList()); | |
| Mapper.CreateMap<ObjectId, string>().ConvertUsing(o => o.ToString()); | |
| Mapper.CreateMap<string, ObjectId>().ConvertUsing(s => ObjectId.Parse(s)); |
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.Linq; | |
| using NUnit.Framework; | |
| namespace Alexw.Katas.BinarySearch | |
| { | |
| public class BinarySearchTests | |
| { | |
| private static readonly DataItem[] Items = | |
| { |
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
| function binSearch(arr, toSearch) { | |
| var lowerBound = 0, upperBound = arr.length -1; | |
| while(true) { | |
| var index = Math.floor((upperBound - lowerBound) / 2 + lowerBound); | |
| var current = arr[index]; | |
| if(current === toSearch) return index; | |
| if(current > toSearch) { |
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
| function bowlingScore(frames) { | |
| const rolls = frames.split("").filter(function(value, index) { return value != " " }); | |
| var frames = getFramesFromRolls(rolls); | |
| var score = calculateScoreFromFrames(rolls, frames); | |
| return score; | |
| } | |
| function getFramesFromRolls(rolls) { | |
| if (rolls === undefined || rolls.length == 0) { return []; } |
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
| <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous"> | |
| <div class="editor"> | |
| <h2>Input</h2> | |
| <textarea id="editor" name="input-textarea" onchange="update(this)" placeholder="Try ^6hello world"> | |
| </textarea> | |
| <ul class="examples"> | |
| <li><button type="button" onClick="window.rainbow()">Rainbow</button> | |
| </ul> | |
| </div> |
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
| // guiding principles | |
| // 1. to think in command / query separation - there are commands and there are queries | |
| // strict CQRS recommends that commands do not return results apart from creation which returns an ID | |
| // I can agree with that at a repo events level but not sure about command handlers however that does work here | |
| // Useful links | |
| // https://github.com/gregoryyoung/m-r/blob/master/SimpleCQRS/CommandHandlers.cs | |
| interface ICommandHandler<Command, ResultType> { | |
| // you don't really need this interface but I am enforcing command handler shapes with it |
OlderNewer