Drill

ProblemsGo › logistics

Is this address complete enough to ship

easylogisticsStringsGo

The checkout refuses street-level addresses without a door number. A record has the street name and a number field that may be empty.

addressValid(street: string, doorNumber: int) → bool

Go needs a compiler and Drill does not host one yet, so this page is the reference rather than an exercise: the problem, worked examples, and the solution in full. To type it out, the same problem runs in Python.

Solve it in Python →

Where you start

func addressValid(street string, doorNumber int) bool {
	
}

Worked examples

CallResult
addressValid("Bagdat Cad no 12", 12)true
addressValid(" ", 5)false
addressValid("Kumsal Sok", 0)false
addressValid("", 12)false

Hint

Trim the street, then check the number.

Reference solution in Go
func addressValid(street string, doorNumber int) bool {
	return strings.TrimSpace(street) != "" && doorNumber > 0
}

The same problem in another language

More logistics problems in Go