Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "bufio"
- "os"
- )
- func main() {
- var voucherAmount, ticketPurchased, otherPurchased int
- fmt.Scanln(&voucherAmount)
- scanner := bufio.NewScanner(os.Stdin)
- for {
- scanner.Scan()
- command := scanner.Text()
- if command == "End" {
- break
- }
- voucherAmount -= int(command[0])
- if voucherAmount < 0 {
- break
- }
- if (len(command) > 8) {
- voucherAmount -= int(command[1])
- if voucherAmount < 0 {
- break
- }
- ticketPurchased++
- } else {
- otherPurchased++
- }
- }
- fmt.Println(ticketPurchased)
- fmt.Println(otherPurchased)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement