Skip to content

Instantly share code, notes, and snippets.

@avirajkhare00
Created April 20, 2025 18:33
Show Gist options
  • Save avirajkhare00/789b3cfa533bfde1326928be047cbc22 to your computer and use it in GitHub Desktop.
Save avirajkhare00/789b3cfa533bfde1326928be047cbc22 to your computer and use it in GitHub Desktop.
fn main() {
println!("πŸŽ‰ Baking a birthday cake for your friend! πŸŽ‚");
// Ingredients for the chaos cake
let flour = 2.5; // cups, because precision is overrated
let sugar = 1.0; // cups, sweet like your friendship
let eggs = 3; // because 2 is too few and 4 is an omelette
let butter = 0.5; // cups, for that *rich* flavor
let chaos_level = 9001; // it's over 9000!
// Step 1: Mix ingredients with enthusiasm
println!("πŸ₯„ Throwing {} cups of flour into the bowl... *poof* cloud!", flour);
println!("🍬 Dumping {} cups of sugar. Hope your friend likes cavities!", sugar);
println!("πŸ₯š Cracking {} eggs. Oops, shell bits add crunch!", eggs);
println!("🧈 Slapping in {} cups of butter. Cholesterol who?", butter);
println!("😈 Adding chaos level: {}. This cake's gonna be LEGENDARY!", chaos_level);
// Step 2: "Bake" the cake
let baking_result = bake_cake(flour, sugar, eggs, butter, chaos_level);
// Step 3: Present the masterpiece
match baking_result {
Ok(cake) => println!("πŸŽ‚ TADA! Baked a {} cake! Happy birthday, pal!", cake),
Err(oops) => println!("πŸ’₯ Disaster! {}. Guess we're ordering pizza!", oops),
}
}
fn bake_cake(flour: f32, sugar: f32, eggs: i32, butter: f32, chaos: i32) -> Result<String, String> {
// Quality control... or not
if flour <= 0.0 || sugar <= 0.0 || eggs <= 0 || butter <= 0.0 {
return Err("Missing ingredients! Did you forget to rob the pantry?".to_string());
}
if chaos > 9000 {
println!("πŸ”₯ Oven's screaming! Too much chaos, it's alive!");
return Err("Cake turned into a sentient monster! RUN!".to_string());
}
// Baking logic (totally legit)
println!("πŸ•’ Baking at 350Β°F for... uh, until it smells burnt!");
let cake_type = if chaos > 5000 {
"Cosmic Chaos Chocolate".to_string()
} else {
"Vanilla Friendship Delight".to_string()
};
Ok(cake_type)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment