Code Logo

Coffee Prep Checker

Published at19 Apr 2026
Logic & Conditionals Easy 15 views
Like0

Given the number of coffee beans in grams and the amount of water in milliliters, determine if there are enough beans to brew a standard cup of coffee. A standard cup requires at least 15 grams of beans. If the beans are sufficient, return true; otherwise return false.

For example, with 20g beans and any amount of water, return true. With 10g beans, return false regardless of water amount. With exactly 15g beans, return true.

This problem teaches threshold comparison — checking if a value meets or exceeds a minimum requirement. This pattern is used in inventory management, quality control, and resource allocation.

The solution simply compares the bean amount to the 15-gram threshold. If beans >= 15, there is enough for a standard cup. The water amount is provided for context but does not affect the result — the limiting factor is the beans.

Edge cases include zero beans (false), exactly 15 beans (true), and large amounts of beans (true). The water parameter is ignored in the logic.

Learn about our pseudocode specification
Guide

Algorithm Flow

Recommendation Algorithm Flow for Coffee Prep Checker
Recommendation Algorithm Flow for Coffee Prep Checker

Solution Approach

Compare the bean amount to the 15-gram minimum threshold and return the boolean result.

function canBrew(beans, water)
  return beans >= 15

Return the result of beans >= 15. This produces true when the available beans meet or exceed the 15-gram minimum required for a standard cup of coffee. The water amount is provided as a parameter for real-world context but does not affect the brewing decision in this simplified version.

Time complexity is O(1), space complexity is O(1).

Best Answers

Pseudocode - Approach 1
program coffee_prep
dictionary
   weight: integer
algorithm
   input(weight)
   if weight >= 15 then
      output("READY")
   else
      output("NOT ENOUGH")
   endif
endprogram