Spoiler
Solve Installment Problems, Currently only solves for The equal repayment installment
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
a =
b =
c =
d =
e =
random, a, 1, 1000 ; Amount
a := a * 100 ; Amount
random, b, 1, 2
if (b=1)
b := "due in"
else
b := "taken as debt in"
random, e, 1, 20 ; Rate of interest
SetFormat, float, 6.2
e := e * 2.5 ;; Rate of interest
random, d, 1, 2 ; SI or CI
if (d=1) ; SI or CI
d := "Simple Interest" ; SI or CI
else
d := "Compound Interest" ; SI or CI
Random, c, 1, 10
;`nTo know the final answer press ONLY press f1,
;TrayTip, TIPS, To get a detailed solution to the above question press OK`nTo make the script generate another question press f2`nTo exit this application press f3
MsgBox What equal installment will repay an amount of %a% %b% %c% years where in the rate of interest is %e% yearly and interest is being calculated as per %d%`n`nTo get a detailed solution to the above question press OK`nTo make the script generate another question press f2`nTo exit this App press f3`nTo load again double click the icon of the script where it is downloaded
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/*
Gui, Add, Text, section, what equal instalment will repay an amount of:
Gui, Add, Edit, ys Va
Gui, Add, DropDownList, xm vB, due in||taken as debt
Gui, Add, Text, xm section, in years (enter number of instalments):
Gui, Add, Edit, ys VC
Gui, Add, Text, xm section, when interest is calculated at :
Gui, Add, DropDownList, ys vD, Simple Interest||Compound Interest
Gui, Add, Text, xm section, at the interest rate as per year:
Gui, Add, Edit, ys VE
Gui, Add, Button, Default, OK
gui, show
return
GuiClose:
ButtonOK:
Gui, Submit
*/
;;;;;;;;;;;;;;;;;;;;;;calculating the AP Part;;;;;;;;;;;;
K := C - 1, index := 0
loop, %c%
{
index := A_index + index
qq := k - A_index + 1
sol .= "Value of " A_index " installment ( paid at the end of " A_index " year , ) at the end of " c " years is X+X" "*" e "*" qq "/100 (interest)" "`r`n"
;;;;;;;;;;;;; in reverse order as opposed to above ;;;;;;;;;;;;;;;
l := k - A_index + 1
ssol .= "+" l
ssol2 .= ssol "`n"
}
K := C - 1, index := 0
loop, %K%
{
;msgbox %index%
;sol .= A_index "+" index "`r`n"
index := A_index + index
;sol .= A_index "+" index "`r`n"
;msgbox, %sol%
}
loop, %c%
{
l := C - A_index
AP .= "+" l
}
;msgbox, %sol% `n`n Total value of all the installments is %c%*X + X*%index%*%e%/100, which is equal to %a% `n`n` which gives the answer as %a%/%index%
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if ( ( B = "due in" ) and ( D = "Simple Interest" ) )
{
d_part := ( index * E ) / 100
divisor := c + d_part
ans := A / divisor
;msgbox, %sol% `n`n Total value of all the installments is %c%*X + X*%e%(%AP%)*%index%/100, which is equal to %a% `n`n` which gives X = %a%/%divisor% `n`n ANS which is X = %ans% `n`n`namount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS which is `n%ans%
msgbox, %sol% `n`n Total value of all the installments is %c%*X + X*%e%(%AP%)/100, which is equal to %a% `n`n` which gives X = %a%/%divisor% `n`n ANS which is X = %ans% `n`n`namount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS which is `n%ans%
;msgbox, Total value of all the installments is %c%*X + X*%e%(%AP%)/100, which is equal to %a% `n`n` which gives X = %a%/%divisor% `n`n ANS which is X = %ans% `n`n`namount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS which is `n%ans%
;msgbox, amount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS is `n%ans%
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if ( ( B = "taken as debt in" ) and ( D = "Simple Interest" ) )
{
d_part := ( index * E ) / 100
divisor := c + d_part
A1 := A + ( A * C * ( E/100 ) )
ans := A1 / divisor
;msgbox, amount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS is `n%ans%
;msgbox, %sol% `n`n Total value of all the installments is %c%*X + X*%e%*%index%/100,`n`n` And the value of money taken as debt at the end of %c% years is %a% + %A% * %C% * ( %E%/100 ) = %a1%`n`n which gives X = %a1%/%divisor% `n`n ANS which is X = %ans% `n`n`namount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS which is `n%ans%
msgbox, %sol% `n`n Total value of all the installments is %c%*X + X*%e%(%AP%)/100,`n`n` And the value of money taken as debt at the end of %c% years is %a% + %A% * %C% * ( %E%/100 ) = %a1%`n`n which gives X = %a1%/%divisor% `n`n ANS which is X = %ans% `n`n`namount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS which is `n%ans%
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if ( ( B = "due in" ) and ( D = "Compound Interest" ) )
{
k2 := C - 1
index2 := 0
loop, %k2%
{
index2 := ( 1 + ( E / 100 ) )**( A_index ) + index2
m0 := 1
m%A_index% := ( 1 + ( E / 100 ) )**( A_index )
}
loop, %C%
{
nn := c - A_index
mm .= "Value of " A_index " installment (at the end of " c " years) is X * ( 1 + ( " E " / 100 ) )^ " nn " = X * " m%nn% "`n"
;msgbox, %mm%
}
index2 := index2 + 1
ans := A / index2
;msgbox, Amount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS is `n%ans%
msgbox, %mm% `nTotalling the above we get X * %index2% Which is equal to %a%`nX * %index2% = %a%`n`nX = %ans%`n`n`n`nAmount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS is `n%ans%
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if ( ( B = "taken as debt in" ) and ( D = "Compound Interest" ) )
{
k2 := C - 1
index2 := 0
loop, %k2%
{
index2 := ( 1 + ( E / 100 ) )**( A_index ) + index2
m0 := 1
m%A_index% := ( 1 + ( E / 100 ) )**( A_index )
}
loop, %C%
{
nn := c - A_index
mm .= "Value of " A_index " installment (at the end of " c " years) is X * ( 1 + ( " E " / 100 ) )^ " nn " = X * " m%nn% "`n"
;msgbox, %mm%
}
index2 := index2 + 1
A1 := A * ( 1 + ( E / 100 ) )**C
ans := A1 / index2
;msgbox, amount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS is `n%ans%
msgbox, %mm% `nTotalling the above we get X * %index2% `n`nAnd the value of money taken as debt at the end of %c% years is %A% * ( 1 + ( %E% / 100 ) )**%C% = %a1% `n`nX * %index2% = %a1%`n`nX = %ans%`n`n`n`nAmount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS is `n%ans%
}
return
;f1::MsgBox %ans%
f2::reload
f3::exitapp
Spoiler
Quadratic Equation SolverCode: Select all
Gui, Add, Text, section, what equal instalment will repay an amount of:
Gui, Add, Edit, ys Va
Gui, Add, DropDownList, xm vB, due in||taken as debt
Gui, Add, Text, xm section, in years (enter number of instalments):
Gui, Add, Edit, ys VC
Gui, Add, Text, xm section, when interest is calculated at :
Gui, Add, DropDownList, ys vD, Simple Interest||Compound Interest
Gui, Add, Text, xm section, at the interest rate as per year:
Gui, Add, Edit, ys VE
Gui, Add, Button, Default, OK
gui, show
return
GuiClose:
ButtonOK:
Gui, Submit
;;;;;;;;;;;;;;;;;;;;;;calculating the AP Part;;;;;;;;;;;;
K := C - 1, index := 0
loop, %c%
{
index := A_index + index
qq := k - A_index + 1
sol .= "Value of " A_index " installment ( paid at the end of " A_index " year , ) at the end of " c " years is X+X" "*" e "*" qq "/100 (interest)" "`r`n"
;;;;;;;;;;;;; in reverse order as opposed to above ;;;;;;;;;;;;;;;
l := k - A_index + 1
ssol .= "+" l
ssol2 .= ssol "`n"
}
K := C - 1, index := 0
loop, %K%
{
;msgbox %index%
;sol .= A_index "+" index "`r`n"
index := A_index + index
;sol .= A_index "+" index "`r`n"
;msgbox, %sol%
}
loop, %c%
{
l := C - A_index
AP .= "+" l
}
;msgbox, %sol% `n`n Total value of all the installments is %c%*X + X*%index%*%e%/100, which is equal to %a% `n`n` which gives the answer as %a%/%index%
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if ( ( B = "due in" ) and ( D = "Simple Interest" ) )
{
d_part := ( index * E ) / 100
divisor := c + d_part
ans := A / divisor
;msgbox, %sol% `n`n Total value of all the installments is %c%*X + X*%e%(%AP%)*%index%/100, which is equal to %a% `n`n` which gives X = %a%/%divisor% `n`n ANS which is X = %ans% `n`n`namount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS which is `n%ans%
msgbox, %sol% `n`n Total value of all the installments is %c%*X + X*%e%(%AP%)/100, which is equal to %a% `n`n` which gives X = %a%/%divisor% `n`n ANS which is X = %ans% `n`n`namount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS which is `n%ans%
;msgbox, Total value of all the installments is %c%*X + X*%e%(%AP%)/100, which is equal to %a% `n`n` which gives X = %a%/%divisor% `n`n ANS which is X = %ans% `n`n`namount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS which is `n%ans%
;msgbox, amount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS is `n%ans%
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if ( ( B = "taken as debt" ) and ( D = "Simple Interest" ) )
{
d_part := ( index * E ) / 100
divisor := c + d_part
A1 := A + ( A * C * ( E/100 ) )
ans := A1 / divisor
;msgbox, amount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS is `n%ans%
;msgbox, %sol% `n`n Total value of all the installments is %c%*X + X*%e%*%index%/100,`n`n` And the value of money taken as debt at the end of %c% years is %a% + %A% * %C% * ( %E%/100 ) = %a1%`n`n which gives X = %a1%/%divisor% `n`n ANS which is X = %ans% `n`n`namount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS which is `n%ans%
msgbox, %sol% `n`n Total value of all the installments is %c%*X + X*%e%(%AP%)/100,`n`n` And the value of money taken as debt at the end of %c% years is %a% + %A% * %C% * ( %E%/100 ) = %a1%`n`n which gives X = %a1%/%divisor% `n`n ANS which is X = %ans% `n`n`namount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS which is `n%ans%
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if ( ( B = "due in" ) and ( D = "Compound Interest" ) )
{
k2 := C - 1
index2 := 0
loop, %k2%
{
index2 := ( 1 + ( E / 100 ) )**( A_index ) + index2
m0 := 1
m%A_index% := ( 1 + ( E / 100 ) )**( A_index )
}
loop, %C%
{
nn := c - A_index
mm .= "Value of " A_index " installment (at the end of " c " years) is X * ( 1 + ( " E " / 100 ) )^ " nn " = X * " m%nn% "`n"
;msgbox, %mm%
}
index2 := index2 + 1
ans := A / index2
;msgbox, Amount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS is `n%ans%
msgbox, %mm% `nTotalling the above we get X * %index2% Which is equal to %a%`nX * %index2% = %a%`n`nX = %ans%`n`n`n`nAmount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS is `n%ans%
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if ( ( B = "taken as debt" ) and ( D = "Compound Interest" ) )
{
k2 := C - 1
index2 := 0
loop, %k2%
{
index2 := ( 1 + ( E / 100 ) )**( A_index ) + index2
m0 := 1
m%A_index% := ( 1 + ( E / 100 ) )**( A_index )
}
loop, %C%
{
nn := c - A_index
mm .= "Value of " A_index " installment (at the end of " c " years) is X * ( 1 + ( " E " / 100 ) )^ " nn " = X * " m%nn% "`n"
;msgbox, %mm%
}
index2 := index2 + 1
A1 := A * ( 1 + ( E / 100 ) )**C
ans := A1 / index2
;msgbox, amount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS is `n%ans%
msgbox, %mm% `nTotalling the above we get X * %index2% `n`nAnd the value of money taken as debt at the end of %c% years is %A% * ( 1 + ( %E% / 100 ) )**%C% = %a1% `n`nX * %index2% = %a1%`n`nX = %ans%`n`n`n`nAmount is %a% `n ( %b% )`n to be repayed in %c% years `n @ %d% `n rate of interest being %e%`n *****************`n`n`nANS is `n%ans%
}
f1::Reload
f2::exitapp
Spoiler
Factors Of A NumberCode: Select all
/*
InputBox, A, QUADRATIC EQUATION SOLVER, please enter A or the coefficient of xsquare, , 270, 150
InputBox, B, QUADRATIC EQUATION SOLVER, please enter B or the coefficient of x, , 270, 150
InputBox, C, QUADRATIC EQUATION SOLVER, please enter C or the constant term which is on the LHS, , 270, 150
discriminant := B * B - 4 * A * C
msgbox, discriminant is %discriminant%
if discriminant < 0
{
discriminant := Abs(discriminant)
discriminant := Sqrt(discriminant)
msgbox imaginery roots!
k := 2 * A
msgbox the roots are (-%B% + i%discriminant%)/%k% `n (-%B% - i%discriminant%)/%k%
}
else
{
root1 := (-B + Sqrt(discriminant)) / (2 * A)
root2 := (-B - Sqrt(discriminant)) / (2 * A)
msgbox the roots are `n %root1% and `n%root2%
}
*/
gui, add, text, section center, QUADRATIC EQUATION SOLVER
gui, add, text, section, please enter A or the coefficient of x square: ; Save this control's position and start a new section.
gui, add, text,, please enter B or the coefficient of x:
gui, add, text,, please enter C or the constant term which is on the LHS:
gui, add, edit, ys vA ; Start a new column within this section.
gui, add, edit, vB
gui, add, edit, vC
Gui, Add, Button, section xm default, SUBMIT
;Gui, Add, Button, ys default, A
;Gui, Add, Button, ys default, B
;Gui, Add, Button, ys default, OnlyA
;Gui, Add, Button, ys default, onlyB
;Gui, Add, Button, ys default, Both
;Gui, Add, Button, ys default, None
Gui, Show,, Simple Input Example
return
ButtonSUBMIT:
Gui, Submit
discriminant := B * B - 4 * A * C
msgbox, discriminant is %discriminant%
if discriminant < 0
{
discriminant := Abs(discriminant)
discriminant := Sqrt(discriminant)
msgbox imaginery roots!
k := 2 * A
msgbox the roots are `n`n(-%B% + i%discriminant%)/%k% `n (-%B% - i%discriminant%)/%k%
}
else
{
root1 := (-B + Sqrt(discriminant)) / (2 * A)
root2 := (-B - Sqrt(discriminant)) / (2 * A)
root11 := (-B + "_/"(discriminant)) / (2 * A)
root22 := (-B - "_/"(discriminant)) / (2 * A)
msgbox the roots are `n %root1% `n and `n%root2%
}
return
f1::Reload
f2::exitapp
Spoiler
Time and Work by GeekDude
Code: Select all
#persistent
;f1::
;FileDelete, C:\Documents and Settings\JYOTI\Desktop\New Text document.txt
InputBox, UserInput, CHECKING WHETHER A NUMBER IS PRIME OR NOT, ENTER ANY NATURAL NUMBER, , 320, 120
k = 2
label1:
Var := mod(userinput, k)
if var = 0
{
;FileAppend, %k%`n, C:\Documents and Settings\JYOTI\Desktop\New Text document.txt
kks .= k "`r`n"
}
k := k + 1
;if ( k = floor(Sqrt(UserInput)) + 1 )
if ( k = (UserInput//2) + 1 )
{
;msgbox %userinput% is a prime no.
; FileRead, Contents, C:\Documents and Settings\JYOTI\Desktop\New Text document.txt
;msgbox %contents%
msgbox %kks%
exitapp
}
goto, label1
Spoiler
Massive Human Multiplier by FrozenthiaCode: Select all
InputBox, UserInput, Working Together Calculator, If person 1 does the job in 9 time units`,person 2 in 4 time units`, enter "9+4" and so on for more,, 320, 140
MsgBox, % Working(UserInput)
return
Working(UInput) ; Made by GeekDude. Input "N+N+N", "-N+N", "N+N-N", etc
{
MsgBox, % "Rate of doing work is " RegExReplace(UInput, "([\-\+]?)(\d+)", "$11/$2")
Nums := RegExReplace(UInput, "\+?(\-?\d+)", "$1`,") ; Makes -3+4-5 into "-3,4,-5,"
StringTrimRight, Nums, Nums, 1 ; Fixes it so it is just "-3,4,5"
StringSplit, Num, Nums, `, ; Splits it into it's individual parts, seperated by the commas
LCM := Num1
Loop, % Num0 - 1
Index := A_Index+1, LCM := LCM(LCM, Num%Index%) ; Calculate the LCM of all the numbers
Adds := Round(LCM/Num1)
Loop, % Num0 - 1
Index := A_Index+1, Adds .= "+" Round(LCM/Num%Index%) ; Divide the LCM by each number
; Comes out looking like this "-3+4+-5"
StringReplace, Adds, Adds, +-, -, All ; Make it look like "-3+4-5"
MsgBox, % "LCM of " Nums " is " LCM ", So the equation becomes (" Adds ")/" LCM
Sum := Round(LCM/Num1)
Loop, % Num0 - 1
Index := A_Index+1, Sum += Round(LCM/Num%Index%) ; Calculate the sum of all the numbers
MsgBox, % "So the work would be completed in reciprocal of " Sum "/" LCM " which is " LCM "/" Sum " time units"
return LCM/Sum
}
LCM(Number1, Number2) { ; Least Common Multiple: not made by GeekDude
If (Number1 = 0 || Number2 = 0)
Return
Var := Number1 * Number2
While, Number2
Num := Number2, Number2 := Mod(Number1,Number2), Number1 := Num
Return, Var // Number1
}
Spoiler
LCM
Code: Select all
Gui, Add, Edit, w780 vEdit gMult,
Gui, Add, Edit, w780 vEdit2 gMult,
Gui, Add, Edit, w780 vEdit3 Readonly,
Gui, Add, Edit, w780 h600 Readonly vEdit4,
Gui, Show, w800
Mult:
GuiControlGet, Number,, Edit
GuiControlGet, Number2,, Edit2
GuiControl,, Edit3, % HumanMultiplication(Number, Number2, True)
GuiControl,, Edit4, % Demonstration
Return
HumanMultiplication(Number1, Number2, AddCommas = False)
{
If Number1 is integer
Number1 := "" Number1 ""
If Number2 is integer
Number2 := "" Number2 ""
Global Demonstration
Demonstration := ""
Negatives := 0
If (SubStr(Number1, 1, 1) = "-")
{
Negatives++
StringTrimLeft, Number1, Number1, 1
}
If (SubStr(Number2, 1, 1) = "-")
{
Negatives++
StringTrimLeft, Number2, Number2, 1
}
If (RegExMatch(Number1, "[^0-9]", Match) > 0)
Return "Parameter one was not a number."
If (RegExMatch(Number2, "[^0-9]", Match) > 0)
Return "Parameter two was not a number."
Carry := 0
If (StrLen(Number1) > StrLen(Number2)) or (StrLen(Number1) = StrLen(Number2))
{
TopNumber := Number1
BottomNumber := Number2
}
Else if (StrLen(Number2) > StrLen(Number1))
{
TopNumber := Number2
BottomNumber := Number1
}
Loop, Parse, TopNumber
rTopNumber .= SubStr(TopNumber, StrLen(TopNumber) - (A_Index - 1), 1)
Loop, Parse, BottomNumber
rBottomNumber .= SubStr(BottomNumber, StrLen(BottomNumber) - (A_Index - 1), 1)
Loop, Parse, rBottomNumber
{
SubIndex := A_Index
Loop, Parse, rTopNumber
{
DigitToMult := SubStr(rBottomNumber, SubIndex, 1)
SmallAnswer := DigitToMult * A_LoopField + Carry
AddToLine .= SubStr(SmallAnswer, strLen(SmallAnswer), 1) ","
If (strLen(SmallAnswer) > 1)
Carry := SubStr(SmallAnswer, 1, strLen(SmallAnswer) - 1)
else
Carry := 0
}
If (Carry > 0)
{
AddToLine := AddToLine . Carry
Carry := 0
}
AddToLine := RegExReplace(AddToLine, "\,", "")
Loop, Parse, AddToLine
Line%SubIndex% .= SubStr(AddToLine, StrLen(AddToLine) - (A_Index - 1), 1)
AddToLine := ""
}
Padding := 0
Loop, %SubIndex%
{
AddIndex := A_Index
AddZeroAmount := A_Index - 1
Loop, %AddZeroAmount%
Line%AddIndex% .= "0"
If (strLen(Line%A_Index%) > Padding)
Padding := strLen(Line%A_Index%)
}
Loop, %SubIndex%
{
PadIndex := A_Index
If (strLen(Line%A_Index%) < Padding)
{
PadAmount := Padding - strLen(Line%A_Index%)
Loop, %PadAmount%
Line%PadIndex% := "0" . Line%PadIndex%
}
Demonstration .= ";" Line%PadIndex% "`n"
}
Carry := 0
AddCol := 0
Loop, %Padding%
{
Col := A_Index - 1
AddCol := 0
Loop, %SubIndex%
{
AddCol += SubStr(Line%A_Index%, StrLen(Line%A_Index%) - Col, 1)
}
AddCol := AddCol + Carry
rFinalLine .= SubStr(AddCol, StrLen(AddCol), 1)
If (strLen(AddCol) > 1)
Carry := SubStr(AddCol, 1, StrLen(AddCol) - 1)
else
Carry := 0
}
If (Carry > 0)
rFinalLine .= Carry
Loop, Parse, rFinalLine
Answer .= SubStr(rFinalLine, strLen(rFinalLine) - (A_Index - 1), 1)
If (AddCommas = True)
{
StringSplit, d, Answer, .
Loop, % StrLen(d1)
x := SubStr(d1, 1 - A_Index, 1), c := x . (A_Index > 1 && !Mod(A_Index - 1, 3) ? "," : "") . c
newAnswer := c . (d0 = 2 ? "." d2 : "")
If (Negatives = 1)
newAnswer := "-" . newAnswer
return newAnswer
}
If (Negatives = 1)
Answer := "-" . Answer
Return Answer
}
Spoiler
WeekDay On Any date (without using any built-in thing, i.e. it merely calculates the No. of ODD days and tells the Day).Though the final result is verified the comments needs to be more elaborative.
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Gui, Add, Text, section, Would you like to Practise OR Would you like to solve a question
Gui, Add, DropDownList, xm vB111, PRACTICE||SOLVE A QUESTION
Gui, Add, Button, Default, OKAY
gui, show
return
GuiClose:
ButtonOKAY:
Gui, Submit
if (B111 = "PRACTICE")
goto, Practise
else
goto, solveaquestion
practise:
Random, z, 1, 10
loop, %z%
{
Random, y, 1, 100
string .= y . ","
}
StringTrimRight, string, string, 1
msg = find the LCM of
MsgBox, %msg%`n%string%
z =
stringsplit, k , string, `,
if (k0 = 2)
{
l1 := k1 > k2 ? k1 : k2
l2 := k1 < k2 ? k1 : k2
loop,
{
l1 := l1 * A_index
if ( mod(l1, l2) = 0 )
break
L1 := floor(L1/A_index)
}
MsgBox LCM is %l1%
exitapp
}
else
{
l1 := k1 > k2 ? k1 : k2
l2 := k1 < k2 ? k1 : k2
loop, % k0 - 1
{
m := A_index + 1
position := k%m%
l2 := l1 < position ? l1 : position
l1 := position > l1 ? position : l1
loop,
{
l1 := l1 * A_index
if ( mod(l1, l2) = 0 )
break
L1 := floor(L1/A_index)
}
}
time1 := A_TickCount - time
MsgBox LCM is %l1%
}
return
;;;;;;;;;;;to solve a question;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
solveaquestion:
InputBox, string, Enter no.s separated by commas whose LCM is sought, LCM least common multiple
stringsplit, k , string, `,
if (k0 = 2)
{
l1 := k1 > k2 ? k1 : k2
l2 := k1 < k2 ? k1 : k2
loop,
{
l1 := l1 * A_index
if ( mod(l1, l2) = 0 )
break
L1 := floor(L1/A_index)
}
MsgBox LCM is %l1%
exitapp
}
else
{
l1 := k1 > k2 ? k1 : k2
l2 := k1 < k2 ? k1 : k2
loop, % k0 - 1
{
m := A_index + 1
position := k%m%
l2 := l1 < position ? l1 : position
l1 := position > l1 ? position : l1
loop,
{
l1 := l1 * A_index
if ( mod(l1, l2) = 0 )
break
L1 := floor(L1/A_index)
}
}
time1 := A_TickCount - time
MsgBox LCM is %l1%
}
return
Spoiler
GCD or HCF
Code: Select all
; n is month
; K IS date
InputBox, UserInput, date, enter date in the format 01012001 that is datemonthyear to get weekday for that date, , 220, 170
;finding year
Var1 := mod(userinput, 10000)
msgbox year is %var1%
w := mod(var1, 100)
;finding month
m := userinput - var1
var2 := m //= 10000
n := mod(var2, 100)
msgbox month is %n%
;finding date
k := userinput //= 1000000
msgbox date is %k%
;calculating number of odd days
;checkLP
b := var1 - 1
a := mod(b, 400)
if a = 0
{
msgbox the year %var1% is a year with 28 days in feb with zero odd days in previous years
; if date is jan in a year multiple of 400
if n = 1
{
days := k
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 2
{
days := 31 + k
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 3
{
days := 31 + 28 + k
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 4
{
days := 31 + 28 + 31 + k
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 5
{
days := 31 + 28 + 31 + 30 + k
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 6
{
days := 31 + 28 + 31 + 30 + 31 + k
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 7
{
days := 31 + 28 + 31 + 30 + 31 + 30 + k
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 8
{
days := 31 + 28 + 31 + 30 + 31 + 30 + 31 + k
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 9
{
days := 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + k
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 10
{
days := 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + k
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 11
{
days := 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + k
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 12
{
days := 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + k
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
}
}
}
}
}
}
}
}
}
}
}
}
else
{
if w = 0
{
msgbox %var1% not a leap year
Z := var1 - 1
MSGBOX %Z%
Y := Z // 4
MSGBOX %Y%
U := Z // 100
X1 := Z // 400
MSGBOX %X1%
;ODD DAYS IN YEARS PRECEEDING IF THE CURRENT ONE IS NOT A LEAP YEAR
V := Z + Y - u + X1
ODDDAYSINYEARS := MOD(V, 7)
MSGBOX ODDDAYS IN YEARS PRECEEDING the year(non leap year) input by user is %ODDDAYSINYEARS%
if n = 1
{
days := k + ODDDAYSINYEARS
msgbox %days% odd days to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 2
{
days := 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 3
{
days := 31 + 28 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 4
{
days := 31 + 28 + 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 5
{
days := 31 + 28 + 31 + 30 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 6
{
days := 31 + 28 + 31 + 30 + 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 7
{
days := 31 + 28 + 31 + 30 + 31 + 30 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 8
{
days := 31 + 28 + 31 + 30 + 31 + 30 + 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 9
{
days := 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 10
{
days := 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 11
{
days := 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 12
{
days := 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
}
}
}
}
}
}
}
}
}
}
}
}
else
{
v := mod(var1, 4)
if v = 0
{
msgbox %var1% is a leap year
Z := var1 - 1
MSGBOX %Z%
Y := Z // 4
MSGBOX %Y%
U := Z // 100
X1 := Z // 400
MSGBOX %X1%
;ODD DAYS IN YEARS PRECEEDING IF THE CURRENT ONE IS A LEAP YEAR
V := Z + Y - U + X1
ODDDAYSINYEARS := MOD(V, 7)
MSGBOX ODDDAYS IN YEARS PRECEEDING the year(leap year) input by user is %ODDDAYSINYEARS%
if n = 1
{
days := k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 2
{
days := 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 3
{
days := 31 + 29 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 4
{
days := 31 + 29 + 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 5
{
days := 31 + 29 + 31 + 30 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 6
{
days := 31 + 29 + 31 + 30 + 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 7
{
days := 31 + 29 + 31 + 30 + 31 + 30 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 8
{
days := 31 + 29 + 31 + 30 + 31 + 30 + 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 8
{
days := 31 + 29 + 31 + 30 + 31 + 30 + 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 9
{
days := 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 10
{
days := 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 11
{
days := 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 12
{
days := 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
}
}
}
}
}
}
}
}
}
}
}
}
}
else
{
msgbox %var1% is not a leap year
Z := var1 - 1
MSGBOX %Z%
Y := Z // 4
MSGBOX %Y%
U := Z // 100
X1 := Z // 400
MSGBOX %X1%
;ODD DAYS IN YEARS PRECEEDING IF THE CURRENT ONE IS A LEAP YEAR
V := Z + Y - U + X1
ODDDAYSINYEARS := MOD(V, 7)
MSGBOX ODDDAYS IN YEARS PRECEEDING the year(leap year) input by user is %ODDDAYSINYEARS%
if n = 1
{
days := k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 2
{
days := 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 3
{
days := 31 + 28 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 4
{
days := 31 + 28 + 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 5
{
days := 31 + 28 + 31 + 30 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 6
{
days := 31 + 28 + 31 + 30 + 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 7
{
days := 31 + 28 + 31 + 30 + 31 + 30 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 8
{
days := 31 + 28 + 31 + 30 + 31 + 30 + 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 9
{
days := 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 10
{
days := 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 11
{
days := 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
else
{
if n = 12
{
days := 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + k + ODDDAYSINYEARS
msgbox %days% to find day
final := mod(days, 7)
gosub, result
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
result:
if final = 0
{
msgbox Sunday
return
}
else
{
if final = 1
{
msgbox Monday
return
}
else
{
if final = 2
{
msgbox Tuesday
return
}
else
{
if final = 3
{
msgbox Wednesday
return
}
else
{
if final = 4
{
msgbox Thursday
return
}
else
{
if final = 5
{
msgbox Friday
return
}
else
{
if final = 6
{
msgbox saturday
return
}
}
}
}
}
}
}
Spoiler
2D
Code: Select all
string =
(
12,72,24,12
)
sort, string, N R D,
MsgBox %string%
StringSplit, kk, string, `,
loop, % kk0 - 1
{
kk1 := kk%A_index%
if ( hcf != "" )
kk1 := hcf
wwww := A_index + 1
kk2 := kk%wwww%
loop,
{
m := kk1 - kk2
if ( kk1 < kk2 )
{
kk1 := kk1 + abs(m)
kk2 := kk2 - abs(m)
}
div := floor(kk1/kk2)
rem := mod(kk1, kk2)
out .= kk1 "=" kk2 "*" div "+" rem "`r`n"
if ( rem = 0 )
break
kk1 := kk2
kk2 := rem
}
hcf := kk2
div := rem := out =
}
MsgBox, 4,, HCF of %String% is %hcf%
exitapp
return
Spoiler
3D (rotation only)
Code: Select all
; 2D shifting and Shifting of Axis, finding new Coordinates
;pie := 2549491779/811528438
InputBox, string, enter original Coordinates separated by Comma
;string = 2,0
InputBox, Rotation, enter origins new coordinates OR, How much x and y axis are shifted COMMA separated
;rotation = 0,0
InputBox, Rotated, enter rotation of axis, Take positive value for anticlockwise rotation
;Rotated := -50
StringSplit, r, rotation, `,
RRradius := Sqrt( r1 ** 2 + r2 ** 2 )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;begins
stringsplit, RRradius, RRradius, `.
NewStr := RegExReplace(RRradius2, "(0+)$", "")
if ( NewStr = "" )
RRradius := RRradius1
else
RRradius := RRradius1 . "." . NewStr
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ends new coordinates R generated
StringSplit, k, string, `,
radius := Sqrt( k1 ** 2 + k2 ** 2 )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;begins
stringsplit, radius, radius, `.
NewStr := RegExReplace(radius2, "(0+)$", "")
if ( NewStr = "" )
radius := radius1
else
radius := radius1 . "." . NewStr
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ends old coordinates R generated
Base := k1
Perpen := k2
theta := Atan(Perpen/Base)
degree := Theta * 180 * 811528438 / 2549491779
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;begins
stringsplit, degree, degree, `.
NewStr := RegExReplace(degree2, "(0+)$", "")
if ( NewStr = "" )
degree := degree1
else
degree := degree1 . "." . NewStr
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ends old angle generated
x := radius . "cos" . degree
y := radius . "sin" . degree
x1 := radius * cos(theta)
y1 := radius * sin(theta)
;MsgBox Polar Coordinates are %x% and %y% `n and i.e. %x1% and %y1%
;MsgBox Polar Coordinates are %x% and %y%
;;;;;;;;;;;;;;;getting new angle;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
newx := base - r1
newy := perpen - r2
;MsgBox %newx% %newy%
theta2 := Atan(newy/newx)
degree2 := Theta2 * 180 * 811528438 / 2549491779
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;begins
stringsplit, degree2, degree2, `.
NewStr := RegExReplace(degree22, "(0+)$", "")
if ( NewStr = "" )
degree2 := degree21
else
degree2 := degree21 . "." . NewStr
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;new angle generated
;MsgBox new angle is %degree2%
;MsgBox processing
if ( rotated = "" )
MsgBox new Coordinates are %newx% and %newy%
else
{
rotated := rotated * ( 2549491779/811528438 ) / 180
;MsgBox %theta2% and %rotated% are newangle and rotated angle
AA := Rotated - theta2
;MsgBox newx and newy are %newx% and %newy%
finalx := newx * Cos(AA) - newy * sin(AA)
finaly := newx * Sin(AA) + newy * cos(AA)
MsgBox new Coordinates are %finalx% and %finaly%
}
Spoiler
determinant ( order 3 )
Code: Select all
; 3D
;pie := 2549491779/811528438
InputBox, string, enter original Coordinates separated by Comma
StringSplit, s, string, `,
InputBox, Rotation, enter rotations X then Y and then Z Comma separated
StringSplit, R, rotation, `,
x := s1
y := s2
z := s3
r1 := r1 * 1/180 * 1/(811528438 / 2549491779)
r2 := r2 * 1/180 * 1/(811528438 / 2549491779)
r3 := r3 * 1/180 * 1/(811528438 / 2549491779)
x_angle := r1
y_angle := r2
z_angle := r3
;MsgBox %r1% %r2% %r3%
x := x * cos(z_angle) - y * sin(z_angle)
y := x * sin(z_angle) + y * cos(z_angle)
z := z
;MsgBox %x% %y% %z%
y := y * cos(x_angle) - z * sin(x_angle)
z := y * sin(x_angle) + z * cos(x_angle)
x := x
;MsgBox %x% %y% %z%
z := z * cos(y_angle) - x * sin(y_angle)
x := z * sin(y_angle) + x * cos(y_angle)
y := y
MsgBox %x% %y% %z%
return
Spoiler
combinations (edited)
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
UpDia_sum := 0
downdia_sum := 0
UpDia := 1
downDia := 1
col := 0
array =
(
1 2 1
3 4 2
3 4 6
)
_array := []
for k, v in StrSplit(array, "`n")
for M, q in StrSplit(v, " ")
_array[k, M] := q
StringSplit, rows, array, `n
loop % rows0
Col := col + 1
if ( col != rows0 )
{
MsgBox wrong Input
ExitApp
}
;MsgBox col is %col% and row is %rows0%
;;;adding more lines;;;;;;;;
a := 1
b := 1
R := 1
C := Col + 1
loop % rows0
{
loop % col - 1
{
_array[R, C] := _array[a, b]
;MsgBox %R% and %c% so far generated
; MsgBox % _array[R, C]
b := b + 1
c := C+1
}
R := R + 1
a := a + 1
b := 1
C := Col + 1
}
;;;;;;;;;;;; duplicate lines generated for arrays;;;;;;;;;;;;;;;;;
K := 1
M := 1
MM := 1
loop %col%
{
;MsgBox initial array for %k% and %m% and %a_index%
M := A_index
Loop
{
;MsgBox M is %M%
if ( _array[K, M] != "" )
{
; MsgBox we are at %k% and %m%
UpDia := Updia * _array[K, M]
; MsgBox % _array[K, M]
;MsgBox %updia% is the result so far
K := K + 1, M := M + 1
}
else
{
;MsgBox %updia% %k% is k and %m% m
Updia_Sum := Updia_sum + updia
K := 1, updia := 1
goto, label
}
}
label:
}
;MsgBox %updia_sum% is the sum of up diagonals ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;down diagonal sum to be calculated now;;;;;;;;;;;;;;;;;
K := col
M := 1
loop %col%
{
; MsgBox %A_index%
;MsgBox initial array for %k% and %m% and %a_index%
M := A_index
Loop
{
;MsgBox M is %M%
if ( _array[K, M] != "" )
{
; MsgBox we are at %k% and %m%
downDia := downdia * _array[K, M]
; MsgBox % _array[K, M]
;MsgBox %downdia% is the result so far
K := K - 1, M := M + 1
}
else
{
;MsgBox %downdia% %k% is k and %m% m
downdia_Sum := downdia_sum + downdia
K := col, downdia := 1
goto, label2
}
}
label2:
}
;MsgBox %downdia_sum% is the sum of up down diagonals ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MsgBox % updia_sum - downdia_sum
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
InputBox, nCr, Enter R and N separated with comma
StringSplit, ncr, ncr, `,
if (ncr1 = 1 OR ncr2 - ncr1 = 1)
{
MsgBox % ncr2
exitapp
}
else
{
n := ncr2,
r := ncr2 - ncr1 > ncr1 ? ncr2 - ncr1 : ncr1
r1 := ncr2 - ncr1 < ncr1 ? ncr2 - ncr1 : ncr1
f_r := 1
n_r := 1
;;;calculating numerator;;;;;;;;;
loop % n - r
n_r := n_r * n, n := n -1
;;;;;;;;;calculating denominator;;;;;;;;;;
loop % ncr2 - r
f_r := f_r * r1, r1 := r1 - 1
;;;result;;;;;;;;;;;;;;;;;
MsgBox % floor(n_r / f_r)
exitapp
}
http://ahkscript.org/boards/viewtopic.php?f=6&t=231
Permutations ( 3rd post by nimda )
http://www.autohotkey.com/board/topic/7 ... n-o1-time/
Angle Between hour hand and minute hand of a clock
Code: Select all
InputBox, k, enter time separated by :
StringSplit, k, k, :
MsgBox % Abs(k1 * 30 + k2/2 - k2 * 6) >= 180 ? 360 - Abs(k1 * 30 + k2/2 - k2 * 6) : Abs(k1 * 30 + k2/2 - k2 * 6)
Code: Select all
SetFormat, float, 02.0
gui, add, text, section center, LAST TWO DIGIT SOLVER (unit's digit also)
gui, add, text, section, please enter BASE: ; Save this control's position and start a new section.
gui, add, text,, Enter POWER of base:
gui, add, edit, ys vA ; Start a new column within this section.
gui, add, edit, vB
Gui, Add, Button, section xm default, SUBMIT
Gui, Show,, Simple Input Example
return
ButtonSUBMIT:
Gui, Submit
base := mod(a, 100)
ans := 1
;msgbox, base is %base%
;msgbox, loop will run for %B% times
loop, %B%
{
ans := ans * Base
ans := mod(ans, 100)
;msgbox, %A% raise to power %A_index% is %ans%
}
ans += 0.0
msgbox, last two digits are `n`n %ans%
return
Code: Select all
gui, add, text, section center, REMAINDER TELLER eg. (56)^57 / 57 = 56
gui, add, text, section, please enter BASE: ; Save this control's position and start a new section.
gui, add, text,, Enter POWER of base:
gui, add, text,, Enter the divisor:
gui, add, edit, ys vN ; Start a new column within this section.
gui, add, edit, vP
gui, add, edit, vD
Gui, Add, Button, section xm default, SUBMIT
Gui, Show,, Simple Input Example
return
ButtonSUBMIT:
Gui, Submit
a := 1
l := mod(n, d)
;msgbox, remainder is %l%
loop, %p%
{
m := l * a
a := mod(m, d)
;msgbox, remainder %A_index% is %a%
}
msgbox, REMAINDER OF `n`n(%n%)^%p% / %d% `n`nIS `n`n %a%
return
Spoiler
Sum of first N natural numbers, sum of their squares/cubes....till power 10
Sources http://mathworld.wolfram.com/PowerSum.html ( 8,9,10) and http://www.trans4mind.com/personal_deve ... umbers.htm ( 1 to 7)
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
InputBox, k, enter a perfect square,
if ( sqrt(k) - floor(sqrt(k)) != 0 )
reload
else
{
StringSplit, k, k
if ( k%k0% = 1 )
ans = the last digit is either 1 or 9
if ( k%k0% = 4 )
ans = the last digit is either 2 or 8
if ( k%k0% = 9 )
ans = the last digit is either 3 or 7
if ( k%k0% = 6 )
ans = the last digit is either 4 or 6
if ( k%k0% = 5 )
ans = the last digit is 5
if ( k%k0% = 0 )
ans = the last digit is 5
if ( k%k0% = 2 OR k%k0% = 3 ORk%k0% = 7 OR k%k0% = 8 )
{
MsgBox wrong input as such the script will close now
ExitApp
}
loop % k0 - 2
a .= k%A_index%
check := floor(sqrt(a)) * ( floor(sqrt(a)) + 1 )
; f_p := check > a ? floor(sqrt(a)) : ( floor(sqrt(a)) + 1 )
MsgBox % k . "`n`nBreak the number in two parts the last part is of last two digits and the first part is of the remaing digits.`n`nThe first part is " . a . " and the perfect square root of number just below " . a . " is " . floor(sqrt(a)) . "(this forms the first part of the answer) and " . ans . "`n`nNow compare the (this forms...etc) multiplied by next consecutive no. with the first part, if it is less than the first part take the bigger digit else the lower digit in the last digit part `ni.e. compare " . check . " with " . a . " and decide the last digit accordingly`n`n all this could be done mentally `n`n answer is ( not trimming zeroes to confirm )`n`n" . sqrt(k)
a =
k =
ans =
check =
return
}
Sources http://mathworld.wolfram.com/PowerSum.html ( 8,9,10) and http://www.trans4mind.com/personal_deve ... umbers.htm ( 1 to 7)
Spoiler
Large Factorial Calculator
Sum Of N terms of Arithmetic Progression or Geometric Progression by entering three values and N
Solving Polynomial of any integral Degree to get the nearest roots. (under construction)
Feel free to tweak the code for improvements
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
InputBox, k, Sum of %N% natural No.s till power 7, Enter natural number
n := k
one := N * (n + 1)/2
two := (n**3)/3 + (n**2)/2 + n/6
three := (n**4)/4 + (n**3)/2 + (n**2)/4
four := (n**5)/5 + (n**4)/2 + (n**3)/3 - n/30
five := (n**6)/6 + (n**5)/2 + 5 * ((n**4)/12) - (n**2)/12
six := (n**7)/7 + (n**6)/2 + (n**5)/2 - (n**3)/6 + n/42
seven := (n**8)/8 + (n**7)/2 + 7 * (n**6)/12 - 7 * (n**4)/24 + (n**2)/12
eight := 1/90 * (10 * n**9 + 45 * n**8 + 60 * n**7 - 42 * n**5 + 20 * n**3 - 3 * n)
nine := 1/20 * (2 * n**(10) + 10 * n**9 + 15 * n**8 - 14 * n**6 + 10 * n**4 - 3 * n**2)
ten := 1/66 * (6 * n**(11) + 33 * n**(10) + 55 * n**9 - 66 * n**7 + 66 * n**5 - 33 * n**3 + 5*n)
one = Sum of %N% natural numbers is %one%
two = Sum of squares of %N% natural numbers is %two%
three = Sum of cubes of %N% natural numbers is %three%
four = Sum of power 4 of %N% natural numbers is %four%
five = Sum of power 5 of %N% natural numbers is %five%
six = Sum of power 6 of %N% natural numbers is %six%
seven = Sum of power 7 of %N% natural numbers is %seven%
eight = Sum of power 8 of %N% natural numbers is %eight%
nine = Sum of power 9 of %N% natural numbers is %nine%
ten = Sum of power 10 of %N% natural numbers is %ten%
MsgBox %one% `n`n%two% `n`n%three% `n`n%four% `n`n%five% `n`n%six% `n`n%seven% `n`n%eight% `n`n%nine% `n`n%ten%
exitapp
Code: Select all
SetBatchLines -1
InputBox, o_v, Large factorial calculator, very large
answer := 0
k := 1
carry := 0
String =
(
1
)
l_i := o_v - 1
Loop, % l_i ; make this one less than the factorial required
{
k := A_Index + 1
GOSUB, label
}
MsgBox Factorial %o_v% is `n`n%final%
Clipboard := final
exitapp
/*
StringSplit, mm, final
Loop, %mm0%
answer := mm%A_index% + answer
MsgBox %answer%
*/
label:
StringSplit, l_times, string
index := l_times0
Loop %index%
{
digit := k * l_times%index% + carry
if ( digit > 9 )
{
carry := RegExReplace(digit, "(.*)(\d)", "$1")
digit := RegExReplace(digit, "(.*)(\d)", "$2")
}
else
carry := 0
r := digit r
;MsgBox %carry% "and" %digit% and result is %r% and index is %A_index%
index --
}
if ( carry != 0 )
final := carry r
else
final := r
;MsgBox % final
string := final
TrayTip, index, %k%, 1
digit := index := final := r =
r =
carry := 0
return
esc::ExitApp
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
InputBox, k, Enter three terms separated by comma AND, then the fourth term i.e. the number (INTEGER) of terms also after comma
string = k
StringSplit, k, k, `,
needle = /
IfInString, k1, %needle%
{
stringSplit, r, k1
k1 := r1 / r3
;MsgBox % k1
r1 = r2 = r3 =
}
IfInString, k2, %needle%
{
stringSplit, r, k2
k2 := r1 / r3
;MsgBox % k2
r1 = r2 = r3 =
}
IfInString, k3, %needle%
{
stringSplit, r, k3
k3 := r1 / r3
;MsgBox % k3
r1 = r2 = r3 =
}
if ( (k3 - k2) = (k2 - k1) )
{
sum := ( k4 / 2 ) * ( 2 * k1 + ( k4 - 1 ) * ( k3 - k2 ) )
MsgBox AP with %k4% terms sum required and sum as %sum%
ExitApp
}
if ( k3/k2 = k2/k1 )
{
ratio := k3/k2
MsgBox % ratio ** k4
sum := k1 * ( (ratio ** k4 - 1) / ( ratio - 1) )
MsgBox GP with %k4% terms sum required %sum%
ExitApp
}
if ( mod(k4, 1) != 0 )
Reload
else
Reload
Feel free to tweak the code for improvements
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
FileDelete, result.txt
InputBox, k, Any degree polynomial solver, Enter coefficients of X in decreading orders of power with + or - sign as the case may be`n`nThe last coefficient shall be the coefficient of x raised to power 0`n`nFor Eg.`nIF Equation: 5X^2+1=0 and the limit you want is -10 to 10`nEnter +5+0+1COMMA10`nPut this script in a separate folder`nExtract nearest roots from first few lines of sort.txt file`n`n`under testing., , 640, 640
StringSplit, m, k, `,
check := 0-m2
limit := 2 * abs(check)
result := 0
k := m1
NUMBERS := RegExReplace(k, "-", "+")
StringSplit, N, numbers, +
SIGNS := RegExReplace(k, "\d+", "|")
StringSplit, S, SIGNS, |
Loop % 2 * (s0-1)
{
omg := mod(A_index, 2)
if ( omg == 0 ) ; even
{
index := floor(A_index/2) + 1
k%A_index% := n%index%
index =
}
else ; odd
{
index := floor( (A_index + 1) / 2 )
k%A_index% := s%index%
index =
}
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Power := s0 - 1
;MsgBox power is %power%
Loop
{
if ( check > m2 )
break
Loop, % power
{
o1 := 2 * A_index - 1 ; 1,3,5,7,9..signs
e := 2 * A_index ; 2,4,6,8, coefficients
;MsgBox %check% is check
o1 := k%o1%
; MsgBox %o1% must be +
if ( o1 = "+" )
{
result := result + k%e% * ( check ** (Power-1) )
;MsgBox %result% for +
if ( abs(check) = 0 )
result := k%n0%
}
else
{
result := result - k%e% * ( check ** (Power-1) )
;MsgBox %result% for -
if ( abs(check) = 0 )
result := 0 - k%n0%
}
; MsgBox % result "power is" power - 1
power --
}
;MsgBox %result% for check %check%
;MsgBox % result " again"
absolute := abs(result)
FileAppend, %absolute% is absolute value for comparison & result is %result% for x %check% `n, result.txt
;Power := floor(k0/2)
Power := s0 - 1
result := 0
check := check + 0.1
}
FileRead, Contents, result.txt
if not ErrorLevel ; Successfully loaded.
{
Sort, Contents
FileDelete, sort.txt
FileAppend, %Contents%, sort.txt
Contents = ; Free the memory.
}
MsgBox check Sort file in the folder of the script is located
exitapp
esc::exitapp