Sign in to follow this  
Followers 0
face

multiply numbers on a list by 2, 3, 4 etc

20 posts in this topic

how can i multiply numbers in a text file 92 by 92 and each time by a different amount

eg:

1

2

3

...

92

multiplied by 2

93

94

95

...

184

multipiled by 3 on the same list

so every time every 92 numbers a different factor multiplies the numbers until line 26000

Share this post


Link to post
Share on other sites



Using nested For/Next loops?

Not clear by what you mean by "multiply numbers in a text file 92 by 92".

Can you post what code you have so far?  It would make helping you a lot easier.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

i have a list for 92 numbers that repeat

here's an example with 4 numbers that repeat twice (same order)

 

22

45

2

91

22

45

2

91

i need to multiply the 4 numbers and everytime they repeat the multiplier goes +1

heres a eg: result, first repeat multiplied by 2 and then by 3 (2+1) and so on

44

90

4

182

66

135

6

273

so basically its the same numbers (22, 45, 2, 91) that repeat but multiply by 2, 3,4 ,5, ...

Edited by face

Share this post


Link to post
Share on other sites

A little bit clearer.

Read up on FileReadLine, While/Wend, and For/Next in the help file.  If you get stuck, post the code that you were able to put together, and we can try to get you past your hurdles.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

#include <File.au3>
$file = @DesktopDir & "\temp.txt"
Local $array[1]
_FileReadToArray($file,$array)

$iMultiplier = 2
For $i = 1 To UBound($array)-1
    $return = $array[$i] * $iMultiplier
    ConsoleWrite($return & @CRLF)
    If IsInt($i/4) Then $iMultiplier+=1
Next

oops, misread your second one...you can instead do this....will loop through the records, and multiply by 1 (basically copy the initial 96), then enumerate the multiplier continually (after looping through the file each time), until line 26000 is reached:

#include <File.au3>
$file = @DesktopDir & "\temp.txt"
$file_output = @DesktopDir & "\output.txt"

Local $array[1]
_FileReadToArray($file,$array)
_FileCreate($file_output)
$hOutput = FileOpen($file_output,2)
$iMultiplier = 1
$iCounter = 1
While True
    For $i = 1 To UBound($array)-1
        If $iCounter > 26000 Then ExitLoop 2
        FileWriteLine($hOutput, $array[$i] * $iMultiplier)
        $iCounter += 1
    Next
    $iMultiplier += 1
WEnd

FileClose($hOutput)

If you don't need the initial copy to the file (multiply times 1) then set $iMultiplier = 2, instead of 1

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

thanks a lot

can you make it so i don't modify the $iMultiplier manually, after each 92 numbers it doesn't go +1 by itself

Share this post


Link to post
Share on other sites

Another solution

 

#include <File.au3>
#include <Array.au3>
dim $array

_FileReadToArray(@ScriptDir & "\numbers.txt",$array)
_ArrayDelete($array,0)
_ArrayDisplay($array)

;loop through array to find last unique element in seriesrepeat
$index_of_last_unique_element = 0
for $x = 1 to UBound($array)-1
    if $array[0] = $array[$x] Then
        $index_of_last_unique_element = $x-1
        ExitLoop
    EndIf
Next

$multiplier = 2
for $x = 0 to UBound($array)-1
    if $array[$x] * $multiplier <= 2600 Then
        $array[$x] *= $multiplier
    Else
        ExitLoop
    EndIf
    if $x <> 0 and mod($x,$index_of_last_unique_element) = 0 then
        $multiplier += 1
    EndIf
Next

_ArrayDisplay($array,"Finished")

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Jaberwocky, I already have proven that I 'can'; in fact, I 'will' continue to help.

I like to answer those posts that require logical solutions.  He may not learn anything, and will post more similar questions, and I will answer those as well.  I'm in it for the puzzles, not your affirmations.

If you want to enumerate the multiplier every 96 numbers, do this:

#include <File.au3>
$file = @DesktopDir & "\temp.txt"
$file_output = @DesktopDir & "\output.txt"

Local $array[1]
_FileReadToArray($file,$array)
_FileCreate($file_output)
$hOutput = FileOpen($file_output,2)
$iMultiplier = 1
$iCounter = 1
While True
    For $i = 1 To 96
        FileWriteLine($hOutput, $array[$iCounter] * $iMultiplier)
        $iCounter += 1
    Next
    $iMultiplier += 1
WEnd

FileClose($hOutput)

This assumes your file already has the 26000 lines, with repeating integers.  Let me know if that's not the case.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

i get and error message 

 

thanks again

Edited by face

Share this post


Link to post
Share on other sites

That's helpful. What is the error message, are we supposed to guess?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

oops, need to put in a check that $iCounter is not over ubound of the array

If $iCounter < Ubound($array) Then...

If $iCounter is above or equal, then you need to force the scripts exit (exit command)

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

this what you wrote works 

#include <File.au3>
$file = @DesktopDir & "\temp.txt"
$file_output = @DesktopDir & "\output.txt"

Local $array[1]
_FileReadToArray($file,$array)
_FileCreate($file_output)
$hOutput = FileOpen($file_output,2)
$iMultiplier = 2
$iCounter = 1
While True
    For $i = 1 To UBound($array)-1
        If $iCounter > 92 Then ExitLoop 2
        FileWriteLine($hOutput, $array[$i] * $iMultiplier)
        $iCounter += 1
    Next
    $iMultiplier += 2
WEnd

FileClose($hOutput)

but i need "$iMultiplier += 2" to go +1 every 92 multiplied numbers

Share this post


Link to post
Share on other sites

Then change it


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Unless the game is Math Blaster this is very clearly not game automation.  It might be tracking weapon stats or even forecasting future attributes, but a script that multiplies every value in an array by $x should be of no concern, even if he said "i use this for hacking and game automation and circumventing authentication."


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Actually the rules clearly state that no game automation in any way whatsoever shall be discussed.  So if this is indeed for a game then it should be dealt with by a moderator as that moderator sees fit to deal with it.

1. Do not ask for help with AutoIt scripts, post links to, or start discussion topics on the following subjects:

    Malware of any form - trojan, virus, keylogger, spam tool, "joke/spoof" script, etc.
    Bypassing of security measures - log-in and security dialogs, CAPTCHAs, anti-bot agents, software activation, etc.
    Automation of software/sites contrary to their EULA (see Reporting bullet below).
    Launching, automation or script interaction with games or game servers, regardless of the game.
    Running or injecting any code (in any form) intended to alter the original functionality of another process.
    Decompilation of AutoIt scripts or details of decompiler software.

This list is non-exhaustive - the Moderating team reserve the right to close any thread that they feel is contrary to the ethos of the forum.

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Jaberwocky, I already have proven that I 'can'; in fact, I 'will' continue to help.

I like to answer those posts that require logical solutions.  He may not learn anything, and will post more similar questions, and I will answer those as well.  I'm in it for the puzzles, not your affirmations.

 

No one said you couldn't or should not help.  However, what you are providing isn't help.  In my short time on these forums I've gathered that the consensus of this forum by people smarter and more experienced than me is that it is pointless to just give outright solutions without the OP doing anything on their part.  You're not helping AutoIt in any way.  Rather you're only helping only your self.  If you need to solve puzzles I'm sure that you can find plenty of your own solve.  Unless you can't?

Edited by jaberwocky6669

Share this post


Link to post
Share on other sites

Hi,

The script in question merely manipulates a text file on the Desktop - as such I see nothing wrong with it. The script itself does not interact with a game - which is the litmus test as set out in the Forum rules.

boththose suggested that this thread would be legal:

 

even if he said "i use this for hacking and game automation and circumventing authentication."

In fact it would be quite the opposite. If someone openly admits that they are seeking help for something prohibited by the Forum rules then the thread is automatically "out-of-bounds" as we are not prepared to assist anyone to circumvent the rules if that is their stated aim - even if the proximate problem is not specifically game-related. People might like to read my final post in this thread. ;)

I hope that is clear. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

i said the script would be of no concern (which it really wouldn't)...forum legality of intent notwithstanding.


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
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
Sign in to follow this  
Followers 0