Skip to content

Latest commit

 

History

History
executable file
·
87 lines (60 loc) · 1.83 KB

tournament-doc.md

File metadata and controls

executable file
·
87 lines (60 loc) · 1.83 KB

tournament

import "tournament"

Index

func Tally

func Tally(reader io.Reader, writer io.Writer) error

Tally returns the results of a small football competition.

Example

package main

import (
	"bytes"
	"strings"
)

var input string = `
Allegoric Alaskans;Blithering Badgers;win
Devastating Donkeys;Courageous Californians;draw
Devastating Donkeys;Allegoric Alaskans;win
Courageous Californians;Blithering Badgers;loss
Blithering Badgers;Devastating Donkeys;loss
Allegoric Alaskans;Courageous Californians;win
`[1:] // [1:] = strip initial readability newline

func main() {
	debug = true

	reader := strings.NewReader(input)
	var buffer bytes.Buffer

	Tally(reader, &buffer)
}

Output

Team                           | MP |  W |  D |  L |  P
Devastating Donkeys            |  3 |  2 |  1 |  0 |  7
Allegoric Alaskans             |  3 |  2 |  0 |  1 |  6
Blithering Badgers             |  3 |  1 |  0 |  2 |  3
Courageous Californians        |  3 |  0 |  1 |  2 |  1

type Team

Team struct holds a team's tournament information.

type Team struct {
    // contains filtered or unexported fields
}

type Teams

Teams map holds a collection of Team structs for a single tournament.

type Teams map[string]Team

Generated by gomarkdoc