Avoid the fall of your city
Your city is modeled by several gauges :
- gold
- wheat
| import Test.Hspec | |
| main = hspec $ do | |
| describe "fizbuzz" $ do | |
| it "returns a number string when given a number" $ do | |
| fb 1 `shouldBe` "1" | |
| fb 2 `shouldBe` "2" | |
| fb 4 `shouldBe` "4" | |
| it "returns 'fizz' when given a multiple of 3" $ do | |
| fb 3 `shouldBe` "fizz" |
| describe "Insurance Bonus system" $ do | |
| describe "evolution without accident" $ do | |
| it "starts at 100 for new drivers" $ | |
| bonus new `shouldBe` 100 | |
| it "after each year without accident, it decreases by 5%" $ do | |
| bonus (new >- Year) `shouldBe` 95 | |
| bonus (new >- Year >- Year) `shouldBe` 90 | |
| bonus (years 5) `shouldBe` 76 | |
| it "never goes under 50%" $ do | |
| bonus (caped) `shouldBe` 50 |
| import Test.Hspec | |
| main = hspec $ do | |
| describe "tree fold" $ | |
| it "works!" $ | |
| visit (Branch | |
| -- / \ | |
| (Node "h") (Branch | |
| -- / \ | |
| (Branch -- \ |
| import Test.Hspec | |
| main = hspec $ do | |
| describe "fizbuzz" $ do | |
| it "1 gives 1" $ do | |
| fizzBuzz 1 `shouldBe` "1" | |
| it "2 gives 2" $ do | |
| fizzBuzz 2 `shouldBe` "2" | |
| it "3 gives fizz" $ do | |
| fizzBuzz 3 `shouldBe` "fizz" |
| # Let's start with an easy challenge... Hundreds of visitors shop inside a shopping mall . | |
| # The aim of this challenge is to determine how many people are present in the shopping mall | |
| # at a given point in time. | |
| # | |
| # Data | |
| # | |
| # Input |
| from unittest import TestCase | |
| class Anything: | |
| def __eq__(self, other): | |
| return True | |
| def __ne__(self, other): | |
| return False |
| event_reaction_map = {} | |
| def apply_effects_of(event): | |
| if event in event_reaction_map: | |
| for reaction in event_reaction_map[event]: | |
| reaction() | |
| def react_to(event): |
| event_reaction_map = {} | |
| def apply_events_triggered_by(event): | |
| if event in event_reaction_map: | |
| for reaction in event_reaction_map[event]: | |
| reaction() | |
| def react_to(event): |
| import random | |
| city = {"gold" : 5, | |
| "food" : 5, | |
| "health" : 5, | |
| "civilians" : 5, | |
| "army" : 5} | |
| def hasFallen (city) : | |
| def militaryPutsch(city): |