Coder Social home page Coder Social logo

b-pretest-lottery's Introduction

Lottery

This is one of the questions in BAT's pre-test.

Original question

抽抽樂總共有五種獎項, 1,2 獎各只有一個, 3 獎有 2 個,4 獎有 5 個,5 獎有 11 個,請寫出一個程式可以「隨機」的取得「不重複」的禮物, 且:

  • 1 獎中獎機率為 0.1%
  • 2 獎中獎機率為 2.3%
  • 3 獎中獎機率為 13%
  • 4 獎中獎機率為 18%
  • 5 獎中獎機率為 25%

這一題要麻煩大家不要生成隨機陣列

重點請放在抽獎這件事情上 抽獎的本質就是不重複的隨機抽取

不重複:是指禮物被抽走之後,就不能再被抽了

例如 3 獎是 3 隻 iPhone,iPhone A 被抽走了,給人了,理所當然就不能再被抽,但是,抽獎箱內還有 iPhone B 跟 iPhone C 可以抽!!

解題的方法很多種,但是,我們題目已經註明不要使用的方法就請大家不要使用~ 謝謝

Live Demo

Check out the live demo here.

b-pretest-lottery's People

Contributors

lovecamilletw avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.