Jump to content

how to produce a folder, holding numbers


Eller
 Share

Recommended Posts

UK

One number, consisting of 4 digits, each from (including) 0, till 10

Each digit showing only once in this number.

Thus: Lowest 0123, highest 9876

How many numbers can one generate inside these rules?

I want to have (and understand) a script to produce these numbers, written in a folder (txt, rtf, or doc)

Can someone help?

NL

Een getal van 4 cijfers, elk van (inclusief) 0 tot 10.

Elk cijfer komt maar een keer in dat getal voor.

Laagste 0123, hoogste 9876

Hoeveel getallen kun je, binnen deze regels, genereren?

Ik zou graag een script hebben (en begrijpen) om deze getallen te produceren,

Geschreven in een bestand (txt, rtf of doc)

Iemand die me op weg kan helpen?

Link to comment
Share on other sites

  • Moderators

Eller,

I think the total is 5040 but why do you want all the values written to a file? :)

M23

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

More like brute force.

That's the first thing I thought until I got to this part. I'm leaning toward homework.

How many numbers can one generate inside these rules?

I want to have (and understand) a script to produce these numbers

Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Link to comment
Share on other sites

  • Moderators

JohnQSmith,

My thought processes went the other way: Homework until I reread the post and saw the "written" part. :)

Let us all wait and see what the OP says. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Developers

I think 5040 sounds about right and honestly doubt anybody would want this logic for brute force activity.

... maar ben ook benieuwd naar het antwoord waar je het wel voor nodig hebt.

Een script maken om dit te doen kost ongeveer 10 minute.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

Jos,

That long? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I posted earlier and got lots of help from Malkey, in a topic about master mind.

A number that had to be deduced, consisting of 4 unique digits.

When I play this "game" I was wondering, how many numbers would exist and by each given answer, how may one could strike through.

example: The number that has to be guessed/worked out is, let's say 4712 and one answers with 5384, the evaluation would then be

= = = 0 meaning:

One digit only was used, but not placed correctly.

Because the answer is given not in sequence of the digits, no one can tell which of those 4 digits is rewarded.

We figured out that, with good thinking, the number can be deduced in about 7 turns.

The "game" itself as it is now, is functional, I only wanted to get more information about the possibilities. How many options fall down with each given answer.

Making a script would take no more then 10 minutes, declared Jos. May be so.

But only for one who is familiar with all the scripting possibilties.

It would be nice, finding a book with step-to-step learning AutoIt. And it will take quite a bit more time to learn, not being a programmer myself.

I tried with 2.64 but it takes lots of time more and still is not working properly..

Link to comment
Share on other sites

  • Developers

Making a script would take no more then 10 minutes, declared Jos. May be so.

But only for one who is familiar with all the scripting possibilties.

True, you need to learn some basics about programming but you can approach this in a very simple way with something like this:

Global $Total
For $A = 0 To 9
    For $B = 0 To 9
        For $C = 0 To 9
            For $D = 0 To 9
                If Not ($A = $B Or $A = $C Or $A = $D Or $B = $C Or $B = $D Or $C = $D) Then
                    $Total += 1
                    ConsoleWrite($Total & ' = ' & $A & $B & $C & $D & @CRLF)
                EndIf
            Next
        Next
    Next
Next
There are several ways to tackle this challenge but this one should be relatively easy to understand.

There is much information available about programming but you first need to select what flavor of language you want to go for as they all have different Syntax basics.

AutoIt3 is very Basic like.

Success :)

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

Eller,

I got the answer this way: :)

#include <Array.au3>

; Here are the 9 digits:
Global $aArray[10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
; And here are the possible combinations - I get 210
$aCombo = _ArrayCombinations($aArray, 4)
_ArrayDisplay($aCombo)

; Each of those 4 separate digits can be combined in several ways - let us see how many
Global $aArray[4] = [0, 1, 2, 3]
; I get 24
$aCombo = _ArrayPermute($aArray)
_ArrayDisplay($aCombo)

; Each of the combinations can be permuted 24 ways
; So the total is 210 x 24 = 5040

Pretty easy to loop through the first array and Permute each Combination if you want them all. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanx to both of you. I'll study these examples.

The one Jos gave, looks elementary and easier to understand, so I will start with that one,

@Jos:

Ik heb destijds al eens gevraagd of er niet een AutoIt boekwerkje bestond. De mogelijkheden ten opzichte van de versie 2.64 zijn zoveel gecompliceerder dat je daar zonder hulp niet uitkomt en ik ben er van overtuigd dat meer mensen aardigheid zouden vinden in scripting als de opstap wat te behappen zou zijn.

@Melba:

As I stated to Jos, I used version 2.64 in the passed, but the possibilities in version3 are far more complex.

Working with arrays may look simple to one who is more or less familiar with programming languages, but for a beginner it is a new world.

It's a pitty that opearting systems now adays are that easy to use, that now one uses his brains no more.

The computer is supposed to understand the human brain and it sure reaches that point.

Trouble begins as soon as the user does not understand the computers "brain".

Give me time...............

Link to comment
Share on other sites

  • Developers

I honestly believe that Autoit3 is a lot easier to learn and much more readable to start your programming with and don't let the number of extra functions/UDF's overwhelm you.

Programming is much about "trail and error" too. just start with simple things and expand on that.

It will take time but will be easier as you progress.

I tried to write the above snippet with basic logic in mind so study it and make sure you understand it, only then you will progress.

Enjoy,

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Eller,

I recently wrote a version of what you are talking about, however, we called the game "Bagels". Each position of the guess had three possible outcomes, Fermi = right number in the right position, Pico = right number in the wrong position and Bagels = guessed digit does not exist in the number.

What use is this list that you want as pertains to this game?

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

@kylomas

As i told before, I was curious about the possible range and want to show how many number fall out on each given evaluation.

The game you discribe is the same we play over here and it was well known as Master Mind (4 colored pins)

It doesnot serve any pratical use, except a demonstration of the game itself.

@jos

In order to make the answers readable for other visitors as well, I will write in English, including the faults I make, being English not my native language.

The script you wrote, indeed is easy to understand and should work just fine.

Except: Where do I see the output? ConsoleWrite...

The helpfile does not give much of an answer. "readable with editors who can read stream out....... "

I tried to start the script from within the editor, but can't find any outcome.

@melba

For experienced writers your script is pretty short and also provides a list.

Honestly I have to guess about the lines and their meaning.

It looks, how do I put it.. understandable, but since the results are not correct, I try to figure out where it goes wrong.

There are lot of gaps between the lines on which numbers can be (should be) placed, that meet the conditions.

I made a very short list to show what I mean.

[13]|0139

0142

0143

[14]|0145

[15]|0146

[16]|0147

[17]|0148

[18]|0149

0152

0153

0154

[19]|0156

The conditions were that no digit should apear more than once. Between 18 and 19 it leaves three options unused...

And so on, tiil the end.

Link to comment
Share on other sites

  • Developers

I used ConsoleWrite so you can copy it into SciTE and simply hit F5 for Run.

I would advice to install the Full SciTE4AutoIt3 installer as well that comes with several tools and makes your life easier. (Link in my Sig)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

@jos

Yep. found it. I had SciTE may be not the most recent one (timestamp 16-04-2010, size: 687, 104 kb)

I ran the script, but the window was reduced so I did not notice the list that scrolled "down under"

Tnx!

(I call it a day... 2305 bed calls!)

Link to comment
Share on other sites

  • Moderators

Eller,

Here is a more comprehensive and commented script: ;)

#include <Array.au3>

; Create an array to hold the results
Global $aResult[5041] = [5040]

; Determine all possible combinations of 4 digits
Global $aCombArray[10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
$aCombo = _ArrayCombinations($aCombArray, 4)

; This sets the entry location for the next element in the $aReult array
$iIndex = 0

; We loop through the combinations and see what permutations we can get
For $i = 1 To $aCombo[0]

    ; Separate the 4 digits
    $aSplit = StringSplit($aCombo[$i], "")
    ; And put theminto an array
    Global $aPermArray[4] = [$aSplit[1], $aSplit[2], $aSplit[3], $aSplit[4]]
    ; To get the permutations
    $aPerm = _ArrayPermute($aPermArray)
    ; Now add these permutatiosn to the result array
    For $j = 1 To $aPerm[0]
        ; Increase the index count
        $iIndex += 1
        ; And put this permutation into the array
        $aResult[$iIndex] = $aPerm[$j]
    Next

Next

; And look at the result
_ArrayDisplay($aResult)

Please ask if you have any questions. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

@Melba

Number of results set to max 5040.

How did you establish this max? Any arithmetic formula?

It looks a bit as if the combinations are found at random.

There is no logical numeric order in the list of results.

I have to try the lines and change values to see if I can get to understand what they do.

As for now it comes to me like magic.

A number of expressions I do understand, since I had a script from Malkey, using similar routines.

So: Tnx so far, I have some studiing to do…..

I think I try to set up a similar script and make it run.

Wish me luck….

Link to comment
Share on other sites

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

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...