spudw2k Posted April 18, 2021 Share Posted April 18, 2021 (edited) I know fizzbuzz has been mentioned a few times in the forum; I just saw a Youtube video from Tom Scott about it. I paused the video before he discussed his solution and came up with my own first. My first version already had some modularity in mind, but I decided to go further and make one with maximal modularity in mind--multiple words and multiple round conditions. To keep things simple, the only requirement is that the words and rounds have to be defined in such a way that the expected order is correct (word order and round order). It was a simple but fun exercise. Here is the video if anyone is interested: Spoiler And here is my solution: Spoiler Const Enum $UBOUND_ROWS = 1, $UBOUND_COLUMNS ;Constants for UBOUND function parameters Const $VERBSANDROUNDS = [["Fizz", 3],["Buzz", 5],["Pop", 9, 11]] ;Verb List - Two-Dimension Array Const $ROUNDS = 100, $VERBWORD = 0, $VERBS= UBound($VERBSANDROUNDS,$UBOUND_ROWS) - 1, $VERBROUNDS = UBound($VERBSANDROUNDS, $UBOUND_COLUMNS) - 1 ;Other Constants For $iRound = 1 to $ROUNDS ;For each round Local $sRoundOutput = "" ;Initialize blank string For $iVerb = 0 To $VERBS ;For each Verb Word For $iVerbRound = 1 To $VERBROUNDS ;For each Verb Round to Evaluate If Not Mod($iRound, $VERBSANDROUNDS[$iVerb][$iVerbRound]) Then $sRoundOutput &= $VERBSANDROUNDS[$iVerb][$VERBWORD] ;If Round is Divisble by Verb Round, append Verb Word to string Next Next If Not $sRoundOutput Then $sRoundOutput = $iRound ;If string is blank (no verb words) set string value to round number ConsoleWrite($sRoundOutput & @CRLF) ;Output string Next Edited April 21, 2021 by spudw2k made the solution code more meaningful / readable Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!Register a new account
Already have an account? Sign in here.Sign In Now