What time can I drive after drinking? - MATLAB Cody - MATLAB Central

Problem 44939. What time can I drive after drinking?

Difficulty:Rate

At T o'clock, after a hard day of Matlab, I immediately start drinking and treat myself to N pints of tasty beer. Each beer I drink has 3 standard units (strong beer - ~5.2%) and my body processes 1 unit of alcohol each hour (the average). Assume all beer is consumed instantly.

In England the legal limit for driving is approximately 2 units of alcohol in your blood, assuming this at what time can I legally drive again?

The input N is number of beers drank and T the time I start drinking (as a 24 hour integer). The output H is the hour I may drive again (24 hour integer) and the output Y is how many days (where 0 is the same day, 1 is the following day etc).

E.g. If I drink 1 beer (N=1) at 7 pm (T=19), 1 of the units will be processed in 1 hour and I can 'safely' drive with 2 units in my blood. The output is D=0, H=20.

https://www.nhs.uk/common-health-questions/lifestyle/how-long-does-alcohol-stay-in-your-blood/

Solution Stats

80.0% Correct | 20.0% Incorrect
Last Solution submitted on Aug 27, 2024

Problem Comments

Solution Comments

Show comments
R2025a Pre-release highlights
This topic is for discussing highlights to the current R2025a Pre-release.
13
5

Problem Recent Solvers19

Suggested Problems

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page