Last active
          November 9, 2015 01:49 
        
      - 
      
- 
        Save mathias-brandewinder/3f8ab7fcda99e73ad38a to your computer and use it in GitHub Desktop. 
    Wonderland katas
  
        
  
    
      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
    
  
  
    
  | (def suits [:spade :club :diamond :heart]) | |
| (def ranks [2 3 4 5 6 7 8 9 10 :jack :queen :king :ace]) | 
  
    
      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 Suit = | |
| | Spade | |
| | Club | |
| | Diamond | |
| | Heart | |
| type Rank = | |
| | Value of int | |
| | Jack | |
| | Queen | |
| | King | |
| | Ace | |
| type Card = Suit * Rank | 
  
    
      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
    
  
  
    
  | (def start-pos [[[:fox :goose :corn :you] [:boat] []]]) | 
  
    
      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 Location = | |
| | LeftBank | |
| | RightBank | |
| | Boat | |
| type Positions = { | |
| Fox: Location | |
| Goose: Location | |
| Corn: Location | |
| You: Location } | 
  
    
      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
    
  
  
    
  | let encode key message = "encodeme" | |
| encode "scones" "meetmebythetree" = "egsgqwtahuiljgs" | 
  
    
      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
    
  
  
    
  | val encode : key:Keyword -> message:Message -> Message | 
  
    
      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
    
  
  
    
  | Test failed: | |
| encode "vigilance" "meetmeontuesdayeveningatseven" = "hmkbxebpxpmyllyrxiiqtoltfgzzv" | |
| "encodeme" = "hmkbxebpxpmyllyrxiiqtoltfgzzv" | |
| false | |
| Test failed: | |
| encode "scones" "meetmebythetree" = "egsgqwtahuiljgs" | |
| "encodeme" = "egsgqwtahuiljgs" | |
| false | 
  
    
      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
    
  
  
    
  | #r @"../packages/Unquote/lib/net45/Unquote.dll" | |
| open Swensen.Unquote | |
| let tests () = | |
| // verify encoding | |
| test <@ encode "vigilance" "meetmeontuesdayeveningatseven" = "hmkbxebpxpmyllyrxiiqtoltfgzzv" @> | |
| test <@ encode "scones" "meetmebythetree" = "egsgqwtahuiljgs" @> | |
| // run the tests | |
| tests () | 
  
    
      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
    
  
  
    
  | let gooseIsSafe positions = | |
| (positions.Goose <> positions.Fox) | |
| || (positions.Goose = positions.You) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment