Lawrence Gimenez

cook-canton.go

Found a funny reel on Facebook titled From Coder to Cooker. The person was cooking pancit canton with the help of codes. You can watch it here.

I believe he was using C# on this one. Anyway, here’s my version in Go language.

package main

import ("fmt"; 	"time")

var boilingWaterDone, waterIsBoiling = false, true

type Step int
const (Boil Step = iota; CookNoodles; DrainWater; MixSeasoning; MixWell)

func main() {
	for {
		runStep(Boil)
		if boilingWaterDone == true {
			waterIsBoiling = true
			break
		}
	}
	if waterIsBoiling {
		runStep(CookNoodles)
		runStep(DrainWater)
		runStep(MixSeasoning)
		runStep(MixWell)
	}
}

func runStep(step Step) {
	switch step {
	case Boil:
		fmt.Println("Boiling water...")
	case CookNoodles:
		fmt.Println("Cooking noodles...")
		time.Sleep(5 * time.Minute) // Cook noodles for 5 minutes
	case DrainWater:
		fmt.Println("Drain water...")
	case MixSeasoning:
		fmt.Println("Mix seasoning...")
	case MixWell:
		fmt.Println("Mix well...")
	}
}