Efficient Solutions for FizzBuzzWhizz games

Source: Internet
Author: User

A hot question recently (portal), seeing the discussions of Friends (Portal 1 portal 2), is scanning from 1 to 100, I want to talk about another idea.

This question can be converted into a card game for 100 people. what each person reports is what is written on the card.

Card issuance has a priority:

Those who have cards will not give them any more.

 

Assume that the three numbers are a, B, and c respectively. The priority is as follows:

It is better to calculate the minimum public multiples of less than 10, and do not need to scan from 1 to 100. It feels faster.

I made a comparison with the codes of young artists:

 

Source code (a little messy, more complex ):

Main (Test ([] s1 = str. split ([] s2 = [] {. parse (s1 []),. parse (s1 []),. parse (s1 [[] r1 = [] r2 = flag = (I =; I <; I ++ (r1 [I]! === (I =; I <; I ++ = DateTime. now-+ = (I =; I <; I ++ = DateTime. now-+ [] Test1 ([] result = [(I =; I <=; I ++-] = (I % a [] =? :) + (I % a [] =? :) + (I % a [] =? :) + (I % a []! = & I % a []! = & I % a []! = )? I. toString (): (I =; I <; I ++] * + I-] = result [I * + a []-] = [] Test2 ([] result = [(I =; I <; I ++] * + I-] = result [I * + a []-] =),], a []),], a [],], a []),], (I =; I <=; I ++ (. isNullOrEmpty (result [I--] = comp ([] result, temp, (I =; I * temp <=; I ++ (. isNullOrEmpty (result [I * temp-] = gcd (a, (a <a, (B = gcd (B, a % swap (, c = ngcd ([] a, (n =) a [gcd (a [n-], ngcd (a, n-lcm (, a * B/nlcm ([] a, (n = a [lcm (a [n-], nlcm (a, n-View Code

 

In addition, when one of the three numbers is an integer multiple of the other, you can optimize them!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.