Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Guess My Job

a guest Apr 9th, 2020 171 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "math/rand"
  6. )
  7.  
  8. // Note: Modify these for your own
  9. const SEED = 32315233;    // Always need to change this for random result
  10. const HEADER = "最近好多人在玩,過去工作嘅……(十猜一)"
  11. const FOOTER = "猜中沒有獎勵!"
  12. const CORRECT_ITEM = "遊戲開發員"
  13. const OPTION_SIZE = 10;
  14.  
  15. func getRandomItems(size int) []string {
  16.     var fullList = []string {
  17.         "飛機維修員",
  18.        "中西式廚師助理",
  19.        "水吧技術員",
  20.        "高級餐飲服務員",
  21.        "遊戲測試員",
  22.        "遊戲營運執行員",
  23.        "送貨司機",
  24.        "晚間酒樓清潔員",
  25.        "攻略編輯員",
  26.        "遊戲設計",
  27.        "誌出版員",
  28.        "高級西餐侍應",
  29.        "補習老師",
  30.        "電腦維修員",
  31.        "遊戲店務員",
  32.        "小型高卡車手",
  33.        "裝修工人",
  34.        "剪片技術員",
  35.        "配音員",
  36.        "展覽裝置員",
  37.     };
  38.  
  39.     return shuffleList(fullList)[0:size];
  40. }
  41.  
  42.  
  43. func swap(a, b string) (string, string) {
  44.     return b, a
  45. }
  46.  
  47. func shuffleList(inputList []string) []string {
  48.     var arraySize = len(inputList)
  49.  
  50.     // rand.Seed(SEED)
  51.     rand := rand.New(rand.NewSource(SEED))
  52.  
  53.     for i :=0; i<30; i++ {
  54.         var pos1 = rand.Intn(arraySize)
  55.         var pos2 = rand.Intn(arraySize)
  56.  
  57.         inputList[pos1], inputList[pos2] = swap(inputList[pos1], inputList[pos2])
  58.     }
  59.  
  60.     return inputList;
  61. }
  62.  
  63.  
  64.  
  65. func getShuffleItems(correctItem string, size int) []string {
  66.     var itemList = getRandomItems(size-1);
  67.  
  68.     itemList = append(itemList, correctItem);
  69.  
  70.     return shuffleList(itemList);
  71. }
  72.  
  73.  
  74. func main() {
  75.  
  76.  
  77.     var itemList = getShuffleItems(CORRECT_ITEM, OPTION_SIZE)
  78.  
  79.     fmt.Println(HEADER + "\n")
  80.  
  81.     for i, item := range itemList {
  82.         fmt.Printf("%d: %s\n", (i + 1), item)
  83.     }
  84.  
  85.     fmt.Println("\n" + FOOTER)
  86. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top