guinness Posted March 24, 2014 Author Posted March 24, 2014 Excellent Melba23 and thanks again mikell. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
czardas Posted March 24, 2014 Posted March 24, 2014 (edited) Tricky ^^. Good call, though, czardas. Thanks! I always try to reduce a problem to its basic elements. In this case only one random number needs to be generated to achieve the same result. The user's input becomes the computer generated answer if you win. Don't you just love logic. Edited March 24, 2014 by czardas operator64 ArrayWorkshop
mikell Posted March 24, 2014 Posted March 24, 2014 (edited) Interesting "egg of Columbus" concept, but the error checking for the inputbox is still missing Another egg to do this in less than 3 lines ? Edited March 24, 2014 by mikell czardas 1
czardas Posted March 24, 2014 Posted March 24, 2014 (edited) Here ya go! I've been busy working on something else until now. : Local $s = " " & StringStripWS(InputBox("","Enter 7 numbers 1 - 49 separated by spaces"), 7) & " " MsgBox(0,"Lottery","You "&StringLeft("did not ",((Random(0,432938,1)&Random(1,943360,1)<>49*48*47*46*45*44*43)Or((UBound(StringSplit($s," "))=10)*(StringRegExp($s,"\d{3}")=0)*(StringRegExp($s,"[^ \d]|( 0+ )|(\A0+ )( 0+\z)")=0)*(StringMid($s,StringInStr($s," ",0,1),3)<50)*(StringMid($s,StringInStr($s," ",0,2),3)<50)*(StringMid($s,StringInStr($s," ",0,3),3)<50)*(StringMid($s,StringInStr($s," ",0,4),3)<50)*(StringMid($s,StringInStr($s," ",0,5),3)<50)*(StringMid($s,StringInStr($s," ",0,6),3)<50)*(StringMid($s,StringInStr($s," ",0,7),3)<50)*(StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,1),3),3)&"\b)",""))<3)*(StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,2),3),3)&"\b)",""))<3)*(StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,3),3),3)&"\b)",""))<3)*(StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,4),3),3)&"\b)",""))<3)*(StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,5),3),3)&"\b)",""))<3)*(StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,6),3),3)&"\b)",""))<3)*(StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,7),3),3)&"\b)",""))<3)=0))*8)&"win") Edited March 25, 2014 by czardas operator64 ArrayWorkshop
guinness Posted March 24, 2014 Author Posted March 24, 2014 Thanks czardas. Right now I am re-building the beta help file, but I will check later tomorrow. I have to say it's quite difficult to debug these or at least make sure it works to the specification I asked for. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Jfish Posted March 24, 2014 Posted March 24, 2014 @czardas - FYI, I think it says you win no matter what (unless I am running it wrong - which I could be). Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt
iamtheky Posted March 24, 2014 Posted March 24, 2014 post #19 wins for the ridiculous amount of education packed into 4 lines. Plus the value add of telling how many you got correct, that is quality forecasting of customer needs. ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
guinness Posted March 24, 2014 Author Posted March 24, 2014 post #19 wins for the ridiculous amount of education packed into 4 lines. Plus the value add of telling how many you got correct, that is quality forecasting of customer needs. I can't argue with that. But I will still keep it open for just one more day to see who else pops their head in. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
czardas Posted March 24, 2014 Posted March 24, 2014 (edited) @czardas - FYI, I think it says you win no matter what (unless I am running it wrong - which I could be). I updated post >#44. It is working now. 1528 characters in two lines. You can test it by changing this segment: (Random(0,432938,1)&Random(1,943360,1)<>49*48*47*46*45*44*43) to this: (Random(0,432938,1)&Random(1,943360,1)=49*48*47*46*45*44*43) followed by inputting correct numbers only separated by spaces. The only way to win is to cheat. Edit Good morning. Bugs driviing me mad. Edited March 25, 2014 by czardas operator64 ArrayWorkshop
Jfish Posted March 25, 2014 Posted March 25, 2014 (edited) @czardas - I changed the operator and get the same result (I win every time) - maybe I am doing it wrong? It returns false for a wrong answer so I switched your messages and it seems to work (at least for a false). MsgBox(0,"Lottery","You "&StringLeft("won ",(Random(1,432938,1)+Random(1,943360,1)=49*48*47*46*45*44*43)*(UBound(StringSplit($s," "))=10)*(StringRegExp($s,"\d{3}")=0)*(StringMid($s,StringInStr($s," ",0,1),3)<50)*(StringMid($s,StringInStr($s," ",0,2),3)<50)*(StringMid($s,StringInStr($s," ",0,3),3)<50)*(StringMid($s,StringInStr($s," ",0,4),3)<50)*(StringMid($s,StringInStr($s," ",0,5),3)<50)*(StringMid($s,StringInStr($s," ",0,6),3)<50)*(StringMid($s,StringInStr($s," ",0,7),3)<50)*(StringLen($s)-StringLen(StringReplace($s,StringMid($s,StringInStr($s," ",0,1)+1,2),""))<3)*(StringLen($s)-StringLen(StringReplace($s,StringMid($s,StringInStr($s," ",0,2)+1,2),""))<3)*(StringLen($s)-StringLen(StringReplace($s,StringMid($s,StringInStr($s," ",0,3)+1,2),""))<3)*(StringLen($s)-StringLen(StringReplace($s,StringMid($s,StringInStr($s," ",0,4)+1,2),""))<3)*(StringLen($s)-StringLen(StringReplace($s,StringMid($s,StringInStr($s," ",0,5)+1,2),""))<3)*(StringLen($s)-StringLen(StringReplace($s,StringMid($s,StringInStr($s," ",0,6)+1,2),""))<3)*(StringLen($s)-StringLen(StringReplace($s,StringMid($s,StringInStr($s," ",0,7)+1,2),""))<3)*8)&"did not win") Edited March 25, 2014 by Jfish Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt
czardas Posted March 25, 2014 Posted March 25, 2014 (edited) @Jfish - Type some incorrect numbers then you won't win all the time. Changing the operator is the easiest way to test the error checks. BTW use the code I just edited in post #44. Breakdown of checks: BUT I THINK IT'S STILL BROKEN, SO I WITHDRAW. Local $s = " " & StringStripWS(InputBox("","Enter 7 numbers 1 - 49 separated by spaces"), 7) & " " ConsoleWrite($s & @LF) ConsoleWrite(@LF) ConsoleWrite((StringRegExp($s,"[^ \d]|( 0+ )|(\A0+ )( 0+\z)")=0) &@LF) ConsoleWrite((UBound(StringSplit($s," "))=10) &@LF) ConsoleWrite((StringRegExp($s,"\d{3}")=0) &@LF) ConsoleWrite(@LF) ConsoleWrite((StringMid($s,StringInStr($s," ",0,1),3)<50) & @LF) ConsoleWrite((StringMid($s,StringInStr($s," ",0,2),3)<50) & @LF) ConsoleWrite((StringMid($s,StringInStr($s," ",0,3),3)<50) & @LF) ConsoleWrite((StringMid($s,StringInStr($s," ",0,4),3)<50) & @LF) ConsoleWrite((StringMid($s,StringInStr($s," ",0,5),3)<50) & @LF) ConsoleWrite((StringMid($s,StringInStr($s," ",0,6),3)<50) & @LF) ConsoleWrite((StringMid($s,StringInStr($s," ",0,7),3)<50) & @LF) ConsoleWrite(@LF) ConsoleWrite((StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,1),3),3)&"\b)",""))<3) &@LF) ConsoleWrite((StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,2),3),3)&"\b)",""))<3) &@LF) ConsoleWrite((StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,3),3),3)&"\b)",""))<3) &@LF) ConsoleWrite((StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,4),3),3)&"\b)",""))<3) &@LF) ConsoleWrite((StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,5),3),3)&"\b)",""))<3) &@LF) ConsoleWrite((StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,6),3),3)&"\b)",""))<3) &@LF) ConsoleWrite((StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,7),3),3)&"\b)",""))<3) &@LF) The problem is I can't get @Extended information from StringRegExpReplace without adding more lines. Actually I probably could fix it, but I don't have time. This was still a good learning experience. Edited March 25, 2014 by czardas operator64 ArrayWorkshop
Jfish Posted March 25, 2014 Posted March 25, 2014 @Jfish - Type some incorrect numbers then you won't win all the time. Changing the operator is the easiest way to test the error checks. BTW use the code I just edited in post #44. Breakdown of checks: BUT I THINK IT'S STILL BROKEN, SO I WITHDRAW. Local $s = " " & StringStripWS(InputBox("","Enter 7 numbers 1 - 49 separated by spaces"), 7) & " " ConsoleWrite($s & @LF) ConsoleWrite(@LF) ConsoleWrite((StringRegExp($s,"[^ \d]|( 0+ )|(\A0+ )( 0+\z)")=0) &@LF) ConsoleWrite((UBound(StringSplit($s," "))=10) &@LF) ConsoleWrite((StringRegExp($s,"\d{3}")=0) &@LF) ConsoleWrite(@LF) ConsoleWrite((StringMid($s,StringInStr($s," ",0,1),3)<50) & @LF) ConsoleWrite((StringMid($s,StringInStr($s," ",0,2),3)<50) & @LF) ConsoleWrite((StringMid($s,StringInStr($s," ",0,3),3)<50) & @LF) ConsoleWrite((StringMid($s,StringInStr($s," ",0,4),3)<50) & @LF) ConsoleWrite((StringMid($s,StringInStr($s," ",0,5),3)<50) & @LF) ConsoleWrite((StringMid($s,StringInStr($s," ",0,6),3)<50) & @LF) ConsoleWrite((StringMid($s,StringInStr($s," ",0,7),3)<50) & @LF) ConsoleWrite(@LF) ConsoleWrite((StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,1),3),3)&"\b)",""))<3) &@LF) ConsoleWrite((StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,2),3),3)&"\b)",""))<3) &@LF) ConsoleWrite((StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,3),3),3)&"\b)",""))<3) &@LF) ConsoleWrite((StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,4),3),3)&"\b)",""))<3) &@LF) ConsoleWrite((StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,5),3),3)&"\b)",""))<3) &@LF) ConsoleWrite((StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,6),3),3)&"\b)",""))<3) &@LF) ConsoleWrite((StringLen($s)-StringLen(StringRegExpReplace($s,"(\b"&StringStripWS(StringMid($s,StringInStr($s," ",0,7),3),3)&"\b)",""))<3) &@LF) The problem is I can't get @Extended information from StringRegExpReplace without adding more lines. Actually I probably could fix it, but I don't have time. This was still a good learning experience. Yes, you are right. I retested #44 and that one worked Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt
Moderators Melba23 Posted March 25, 2014 Moderators Posted March 25, 2014 Hi,Updated post #38 to indicate the number of matches. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
mikell Posted March 25, 2014 Posted March 25, 2014 post #19 wins for the ridiculous amount of education packed into 4 lines. Plus the value add of telling how many you got correct, that is quality forecasting of customer needs. I agree and personnally vote for the #19 too After all my own code - even with one line less - is nothing more than a small improvement of it czardas idea is pretty nice but I don't like the error checking giving out "you don't win"
czardas Posted March 25, 2014 Posted March 25, 2014 Thanks mikell, I have to agree with you. I think it should fail on dupkicated single digits: 1 1 etc... but should always spot duplicated double digits. I have decided to abandon it anyway. Theoretically I believe it can be done in one line with a horrible regexp pattern with the input box as the first parameter. operator64 ArrayWorkshop
jguinch Posted March 25, 2014 Posted March 25, 2014 Thanks Mikell and Boththose. For my code in #19, I took ideas in Paper, Rock, Scissors - Challenge topic, so it was ~easy~ . And Mikell managed to optimize it a lot ! I do not have as much merit as that .... Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
jguinch Posted March 25, 2014 Posted March 25, 2014 (edited) Hey hey ! Just one line ! RegExp not already optimized.. Local $tab[] = [ ",01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49", StringMid($tab[0], Random(0, 48, 1) * 3 + 2, 2), StringReplace($tab[0], "," & $tab[1], ""), StringMid($tab[2], Random(0, 47, 1) * 3 + 2, 2), StringReplace($tab[2], "," & $tab[3], ""), StringMid($tab[4], Random(0, 46, 1) * 3 + 2, 2), StringReplace($tab[4], "," & $tab[5], ""), StringMid($tab[6], Random(0, 45, 1) * 3 + 2, 2), StringReplace($tab[6], "," & $tab[7], ""), StringMid($tab[8], Random(0, 44, 1) * 3 + 2, 2), StringReplace($tab[8], "," & $tab[9], ""), StringMid($tab[10], Random(0, 43, 1) * 3 + 2, 2), StringReplace($tab[10], "," & $tab[11], ""), StringMid($tab[12], Random(0, 42, 1) * 3 + 2, 2), Number($tab[1]) & "," & Number($tab[3]) & "," & Number($tab[5]) & "," & Number($tab[7]) & "," & Number($tab[9]) & "," & Number($tab[11]) & "," & Number($tab[13]), InputBox("Lottery", "Enter your numbers from 1 to 49, separates by a comma (ex : 1,5,10,37,15,43,2)", "1,2,3,4,5,6,7", "", 500, 150) , ( StringRegExp($tab[15], "^(([1-9]|([1-4]\d)),){6}([1-9]|([1-4]\d))$") ) ? 1 : (0 * MsgBox(16, "Lottery", "You must enter 7 numbers, separate by a comma")) , (($tab[16] = 0) ? 0 : (((UBound( StringRegExp( "," & StringReplace($tab[15], ",", ",,") & "," , StringRegExpReplace($tab[15] , "(?:[^,]+,){0}([^,]+).*", ",$1,"), 3 ) ) + UBound( StringRegExp( "," & StringReplace($tab[15], ",", ",,") & "," , StringRegExpReplace($tab[15] , "(?:[^,]+,){1}([^,]+).*", ",$1,"), 3 ) ) + UBound( StringRegExp( "," & StringReplace($tab[15], ",", ",,") & "," , StringRegExpReplace($tab[15] , "(?:[^,]+,){2}([^,]+).*", ",$1,"), 3 ) ) + UBound( StringRegExp( "," & StringReplace($tab[15], ",", ",,") & "," , StringRegExpReplace($tab[15] , "(?:[^,]+,){3}([^,]+).*", ",$1,"), 3 ) ) + UBound( StringRegExp( "," & StringReplace($tab[15], ",", ",,") & "," , StringRegExpReplace($tab[15] , "(?:[^,]+,){4}([^,]+).*", ",$1,"), 3 ) ) + UBound( StringRegExp( "," & StringReplace($tab[15], ",", ",,") & "," , StringRegExpReplace($tab[15] , "(?:[^,]+,){5}([^,]+).*", ",$1,"), 3 ) ) + UBound( StringRegExp( "," & StringReplace($tab[15], ",", ",,") & "," , StringRegExpReplace($tab[15] , "(?:[^,]+,){6}([^,]+).*", ",$1,"), 3 ) ) ) = 7 ) ? 1 : 0 * MsgBox(16, "Lottery", "You cannot choose a same number more than one time") ) ) , StringRegExp("," & $tab[14] & ",", StringRegExpReplace($tab[15] , "(?:[^,]+,){0}([^,]+).*", ",$1,") ) + StringRegExp("," & $tab[14] & ",", StringRegExpReplace($tab[15] , "(?:[^,]+,){1}([^,]+).*", ",$1,") ) + StringRegExp("," & $tab[14] & ",", StringRegExpReplace($tab[15] , "(?:[^,]+,){2}([^,]+).*", ",$1,") ) + StringRegExp("," & $tab[14] & ",", StringRegExpReplace($tab[15] , "(?:[^,]+,){3}([^,]+).*", ",$1,") ) + StringRegExp("," & $tab[14] & ",", StringRegExpReplace($tab[15] , "(?:[^,]+,){4}([^,]+).*", ",$1,") ) + StringRegExp("," & $tab[14] & ",", StringRegExpReplace($tab[15] , "(?:[^,]+,){5}([^,]+).*", ",$1,") ) + StringRegExp("," & $tab[14] & ",", StringRegExpReplace($tab[15] , "(?:[^,]+,){6}([^,]+).*", ",$1,") ) , (( $tab[17] = 0 )? 0 : MsgBox(0, "", "You " & (( $tab[18] = 7 ) ? "win" : "loose" ) & @CRLF & @CRLF & "Computer choice : " & $tab[14] & @CRLF & "Your choice : " & $tab[15] & @CRLF & @CRLF & "You found " & $tab[18] & " good numbers" ) ) ] Here is a readable code : Local $tab[] = [ _ ",01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49", _ StringMid($tab[0], Random(0, 48, 1) * 3 + 2, 2), _ StringReplace($tab[0], "," & $tab[1], ""), _ StringMid($tab[2], Random(0, 47, 1) * 3 + 2, 2), _ StringReplace($tab[2], "," & $tab[3], ""), _ StringMid($tab[4], Random(0, 46, 1) * 3 + 2, 2), _ StringReplace($tab[4], "," & $tab[5], ""), _ StringMid($tab[6], Random(0, 45, 1) * 3 + 2, 2), _ StringReplace($tab[6], "," & $tab[7], ""), _ StringMid($tab[8], Random(0, 44, 1) * 3 + 2, 2), _ StringReplace($tab[8], "," & $tab[9], ""), _ StringMid($tab[10], Random(0, 43, 1) * 3 + 2, 2), _ StringReplace($tab[10], "," & $tab[11], ""), _ StringMid($tab[12], Random(0, 42, 1) * 3 + 2, 2), _ Number($tab[1]) & "," & Number($tab[3]) & "," & Number($tab[5]) & "," & Number($tab[7]) & "," & Number($tab[9]) & "," & Number($tab[11]) & "," & Number($tab[13]), _ InputBox("Lottery", "Enter your numbers from 1 to 49, separates by a comma (ex : 1,5,10,37,15,43,2)", "1,2,3,4,5,6,7", "", 500, 150) , _ ( StringRegExp($tab[15], "^(([1-9]|([1-4]\d)),){6}([1-9]|([1-4]\d))$") ) ? 1 : (0 * MsgBox(16, "Lottery", "You must enter 7 numbers, separate by a comma")) , _ (($tab[16] = 0) ? 0 : _ (((UBound( StringRegExp( "," & StringReplace($tab[15], ",", ",,") & "," , StringRegExpReplace($tab[15] , "(?:[^,]+,){0}([^,]+).*", ",$1,"), 3 ) ) + _ UBound( StringRegExp( "," & StringReplace($tab[15], ",", ",,") & "," , StringRegExpReplace($tab[15] , "(?:[^,]+,){1}([^,]+).*", ",$1,"), 3 ) ) + _ UBound( StringRegExp( "," & StringReplace($tab[15], ",", ",,") & "," , StringRegExpReplace($tab[15] , "(?:[^,]+,){2}([^,]+).*", ",$1,"), 3 ) ) + _ UBound( StringRegExp( "," & StringReplace($tab[15], ",", ",,") & "," , StringRegExpReplace($tab[15] , "(?:[^,]+,){3}([^,]+).*", ",$1,"), 3 ) ) + _ UBound( StringRegExp( "," & StringReplace($tab[15], ",", ",,") & "," , StringRegExpReplace($tab[15] , "(?:[^,]+,){4}([^,]+).*", ",$1,"), 3 ) ) + _ UBound( StringRegExp( "," & StringReplace($tab[15], ",", ",,") & "," , StringRegExpReplace($tab[15] , "(?:[^,]+,){5}([^,]+).*", ",$1,"), 3 ) ) + _ UBound( StringRegExp( "," & StringReplace($tab[15], ",", ",,") & "," , StringRegExpReplace($tab[15] , "(?:[^,]+,){6}([^,]+).*", ",$1,"), 3 ) ) ) = 7 ) ? 1 : 0 * MsgBox(16, "Lottery", "You cannot choose a same number more than one time") ) ) , _ StringRegExp("," & $tab[14] & ",", StringRegExpReplace($tab[15] , "(?:[^,]+,){0}([^,]+).*", ",$1,") ) + _ StringRegExp("," & $tab[14] & ",", StringRegExpReplace($tab[15] , "(?:[^,]+,){1}([^,]+).*", ",$1,") ) + _ StringRegExp("," & $tab[14] & ",", StringRegExpReplace($tab[15] , "(?:[^,]+,){2}([^,]+).*", ",$1,") ) + _ StringRegExp("," & $tab[14] & ",", StringRegExpReplace($tab[15] , "(?:[^,]+,){3}([^,]+).*", ",$1,") ) + _ StringRegExp("," & $tab[14] & ",", StringRegExpReplace($tab[15] , "(?:[^,]+,){4}([^,]+).*", ",$1,") ) + _ StringRegExp("," & $tab[14] & ",", StringRegExpReplace($tab[15] , "(?:[^,]+,){5}([^,]+).*", ",$1,") ) + _ StringRegExp("," & $tab[14] & ",", StringRegExpReplace($tab[15] , "(?:[^,]+,){6}([^,]+).*", ",$1,") ) , _ (( $tab[17] = 0 )? 0 : _ MsgBox(0, "", "You " & (( $tab[18] = 7 ) ? "win" : "loose" ) & @CRLF & @CRLF & "Computer choice : " & $tab[14] & @CRLF & "Your choice : " & $tab[15] & @CRLF & @CRLF & "You found " & $tab[18] & " good numbers" ) _ ) ] Edited March 26, 2014 by jguinch iamtheky and Werty 2 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
guinness Posted March 25, 2014 Author Posted March 25, 2014 Brain ache! UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
jguinch Posted March 25, 2014 Posted March 25, 2014 (edited) Yeah.. It's the same code as last time, but the while loop is replaced by an this : Local $tab[] = [ _ ",01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49", _ StringMid($tab[0], Random(0, 48, 1) * 3 + 2, 2), _ StringReplace($tab[0], "," & $tab[1], ""), _ StringMid($tab[2], Random(0, 47, 1) * 3 + 2, 2), _ StringReplace($tab[2], "," & $tab[3], ""), _ StringMid($tab[4], Random(0, 46, 1) * 3 + 2, 2), _ StringReplace($tab[4], "," & $tab[5], ""), _ StringMid($tab[6], Random(0, 45, 1) * 3 + 2, 2), _ StringReplace($tab[6], "," & $tab[7], ""), _ StringMid($tab[8], Random(0, 44, 1) * 3 + 2, 2), _ StringReplace($tab[8], "," & $tab[9], ""), _ StringMid($tab[10], Random(0, 43, 1) * 3 + 2, 2), _ StringReplace($tab[10], "," & $tab[11], ""), _ StringMid($tab[12], Random(0, 42, 1) * 3 + 2, 2), _ Number($tab[1]) & "," & Number($tab[3]) & "," & Number($tab[5]) & "," & Number($tab[7]) & "," & Number($tab[9]) & "," & Number($tab[11]) & "," & Number($tab[13]) ] Now, I'm tired... If someone as few time to optimize the rows 17 and 18 ... Edited March 26, 2014 by jguinch Jfish 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
mikell Posted March 25, 2014 Posted March 25, 2014 "How to make a loop without loop" Crazy... and wonderful mLipok 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now