Advertisement
tabvn

Untitled

Apr 12th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.81 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "encoding/json"
  5.     "fmt"
  6.     "io/ioutil"
  7.     "os"
  8. )
  9.  
  10. type Test struct {
  11.     Input  string `json:"input"`
  12.     Expect string `json:"expect"`
  13. }
  14.  
  15. func (t Test) toString() string {
  16.     bytes, err := json.Marshal(t)
  17.     if err != nil {
  18.         fmt.Println(err.Error())
  19.         os.Exit(1)
  20.     }
  21.     return string(bytes)
  22. }
  23.  
  24. func solve() []Test {
  25.     Tests := make([]Test, 3)
  26.  
  27.     f := []byte{47, 116, 101, 115, 116, 115, 46, 106, 115, 111, 110}
  28.     raw, err := ioutil.ReadFile(string(f))
  29.     if err != nil {
  30.         fmt.Println(err.Error())
  31.         os.Exit(1)
  32.     }
  33.     json.Unmarshal(raw, &Tests)
  34.     return Tests
  35. }
  36.  
  37. func main() {
  38.  
  39.     text, _ := ioutil.ReadAll(os.Stdin)
  40.     input := string(text)
  41.  
  42.     Tests := solve()
  43.  
  44.     var m = make(map[string]string)
  45.  
  46.     for _, t := range Tests {
  47.         m[t.Input] = t.Expect
  48.     }
  49.  
  50.     fmt.Println(m[input])
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement