Karsten Johansson<p>WARNING: Awesome code follows</p><p>I just read there is a more accurate way to calculate a dog's age in human years than simply multiplying by 7 (which does produce a lot of oddities, especially when it comes to dogs giving birth at "7" years old lol). The progression through the first, second and then subsequent years are handled in a manner that is much closer to how dogs typically age compared to humans.</p><p>Here are <a href="https://infosec.exchange/tags/lisp" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>lisp</span></a> and <a href="https://infosec.exchange/tags/python" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>python</span></a> functions demonstrating the new calculations. Feel free to use them as you wish. Especially if you have one or more dogs.</p><p>Feel free to improve or comment on the code in the comments or elsewhere. I always post these kinds of functions for conversation and community, I'm just learning python, so don't bark too loudly.</p><p>The formats are:</p><p>(dogs-age years months)<br>and<br>dogs_age(years, months)</p><p>There is no error checking, so use zeros when necessary.</p><p>Don't be strangers. Shake a paw!</p><p><a href="https://infosec.exchange/tags/commonlisp" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>commonlisp</span></a> </p><p>(defun dogs-age (years months)<br> "Calculate the human age equivalent of a dog given its age in years and months."<br> (let ((human-age 0))<br> (cond<br> ((< years 1)<br> (setq human-age (* (/ months 12.0) 15)))<br> ((= years 1)<br> (setq human-age (+ 15 (* (/ months 12.0) 9))))<br> ((>= years 2)<br> (setq human-age (+ 15 9<br> (* (- years 2) 5)<br> (* (/ months 12.0) 5)))))<br> human-age))</p><p><a href="https://infosec.exchange/tags/python3" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>python3</span></a> </p><p>def dogs_age(years, months):<br> """<br> Calculate the human age equivalent of a dog given its age in years and months.<br> """<br> if years < 1:<br> human_age = months * (15 / 12)<br> elif years == 1:<br> human_age = 15 + months * (9 / 12)<br> else:<br> human_age = 15 + 9 + (years - 2) * 5 + months * (5 / 12)</p><p>return human_age</p> <p>Hey, <span class="h-card" translate="no"><a href="https://social.sdf.org/@praetor" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>praetor</span></a></span> you might be interestd in this, even if it isn't about cats. If you change the subsequent years from 5 to 4, it'll work for cats just the same, apparently. :ablobdj: </p><p><a href="https://infosec.exchange/tags/dog" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>dog</span></a> <a href="https://infosec.exchange/tags/dogs" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>dogs</span></a> <a href="https://infosec.exchange/tags/dogsofmastodon" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>dogsofmastodon</span></a> <a href="https://infosec.exchange/tags/mondog" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>mondog</span></a></p>