Skip to content

Instantly share code, notes, and snippets.

@andrewheiss
Created August 15, 2020 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewheiss/cbb5d740ff0280442a2612bc3c67bb97 to your computer and use it in GitHub Desktop.
Save andrewheiss/cbb5d740ff0280442a2612bc3c67bb97 to your computer and use it in GitHub Desktop.
library(glue)

build_recipe <- function(g_flour, pct_water = 0.7, pct_starter = 0.25, pct_salt = 0.02) {
  actual_flour <- g_flour
  actual_water <- pct_water * g_flour
  actual_starter <- pct_starter * g_flour
  actual_salt <- pct_salt * g_flour
  
  starter_split <- actual_starter / 2
  real_flour <- actual_flour + starter_split
  real_water <- actual_water + starter_split
  real_hydration <- real_water / real_flour
  
  loaf_weight <- actual_flour + actual_water + actual_starter + actual_salt
  
  glue("{round(actual_flour, 2)}g flour\n",
       "{round(actual_water, 2)}g water\n",
       "{round(actual_starter, 2)}g starter\n",
       "{round(actual_salt, 2)}g salt\n---\n",
       "{round(pct_water * 100, 2)}% hydration ({round(real_hydration * 100, 2)}% actual)\n",
       "{round(loaf_weight, 2)}g loaf")
}

# 70% hydration
build_recipe(g_flour = 450)
#> 450g flour
#> 315g water
#> 112.5g starter
#> 9g salt
#> ---
#> 70% hydration (73.33% actual)
#> 886.5g loaf

# 80% hydration
build_recipe(g_flour = 450, pct_water = 0.8)
#> 450g flour
#> 360g water
#> 112.5g starter
#> 9g salt
#> ---
#> 80% hydration (82.22% actual)
#> 931.5g loaf

# 100% hyrdation!!!
build_recipe(g_flour = 450, pct_water = 1)
#> 450g flour
#> 450g water
#> 112.5g starter
#> 9g salt
#> ---
#> 100% hydration (100% actual)
#> 1021.5g loaf

Created on 2020-08-14 by the reprex package (v0.3.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment