Quick SmartHaggle C#: Code (Text): /// <summary> /// Generates and returns a string that repeats a specified number of first characters in a string for the length of that string. Useful for haggling, especially on Neopets. /// </summary> /// <param name="strPrice">Required. The string 'price' to haggle.</param> /// <param name="iLen">Optional. The number of characters to repeat.</param> /// <returns></returns> public string QuickSmartHaggle(string strPrice, byte iLen = 2) { return (strPrice.Length > iLen ? string.Join("", Enumerable.Repeat(strPrice.Substring(0, iLen), (int)((strPrice.Length / iLen) + 1))).Substring(0, strPrice.Length) : strPrice); } Visual Basic .NET: Code (Text): ''' <summary> ''' Generates and returns a string that repeats a specified number of first characters in a string for the length of that string. Useful for haggling, especially on Neopets. ''' </summary> ''' <param name="strPrice">Required. The string 'price' to haggle.</param> ''' <param name="iLen">Optional. The number of characters to repeat.</param> ''' <returns></returns> Public Function QuickSmartHaggle(strPrice As String, Optional iLen As Byte = 2) As String Return (If(strPrice.Length > iLen, String.Join("", Enumerable.Repeat(strPrice.Substring(0, iLen), CInt((strPrice.Length \ iLen) + 1))).Substring(0, strPrice.Length), strPrice)) End Function This function is pretty simple and and done in 1 line. So if iLen = 2 and strPrice = 23019, it will return 23232. If you're looking for a simple haggle, this is it. Genius Haggle C#: Spoiler Code (Text): /// <summary> /// Generates a haggled price based on a specified price. For the more 'convenient' prices, the maximum range parameter, 'iRange', is used. /// </summary> /// <param name="strPrice">Required. The price of which to haggle off of.</param> /// <param name="iRange">Optional. For more advanced 'convenient' prices, this value determines the maximum absolute value of the difference between haggled price and the original, specified price.</param> /// <returns></returns> public string GeniusHaggle(string strPrice, uint iRange = 500) { strPrice = strPrice.Replace(",", ""); strPrice = strPrice.Replace(" ", ""); strPrice = strPrice.Replace(".", ""); int iPrice = Convert.ToInt32(strPrice); int strPriceLength = strPrice.Length; if (strPriceLength < 1) return string.Empty; else if (strPriceLength <= 2) return ((int)(iPrice * 0.98)).ToString(); else if ((strPriceLength == 3) | (strPriceLength == 4)) { string strPrice0 = strPrice[0].ToString(); int iPrice1 = Convert.ToInt32(strPrice.Substring(1, 1)); if (Math.Abs(iPrice - Convert.ToInt32(RepeatString(strPrice0, strPriceLength))) <= iRange) return RepeatString(strPrice0, strPriceLength); else if (iPrice1 == 0) { strPrice0 = (Convert.ToInt32(strPrice0) - 1).ToString(); return strPrice0 + "9" + strPrice0 + (strPriceLength == 4 ? "9" : ""); } else return strPrice0 + (iPrice1 - 1).ToString() + strPrice0 + (strPriceLength == 4 ? (iPrice1 - 1).ToString() : ""); } else { string strPrice0 = strPrice[0].ToString(); string strPrice1 = strPrice[1].ToString(); int iPrice0 = Convert.ToInt32(strPrice0); int iPrice1 = Convert.ToInt32(strPrice1); int iRepeat = (int)(strPriceLength / 2) + 1; if (Math.Abs(iPrice - (Convert.ToInt32(RepeatString(strPrice0, strPriceLength)))) <= iRange) //XXXXX... { return RepeatString(strPrice0, strPriceLength); } else if ((iPrice0 > 1) && (Math.Abs(iPrice - (Convert.ToInt32(RepeatString((iPrice0 - 1).ToString(), strPriceLength)))) <= iRange)) //-1 XXXXX... { return RepeatString((iPrice0 - 1).ToString(), strPriceLength); } else if (Math.Abs(iPrice - Convert.ToInt32(RepeatString(strPrice0 + strPrice1, iRepeat).Substring(0, strPriceLength))) <= iRange) //XYXYX... { return RepeatString(strPrice0 + strPrice1, iRepeat).Substring(0, strPriceLength); } else if ((iPrice1 > 0) && (Math.Abs(iPrice - Convert.ToInt32(RepeatString(strPrice0 + (iPrice1 - 1).ToString(), iRepeat).Substring(0, strPriceLength))) <= iRange)) //-1 XYXYX... { return RepeatString(strPrice0 + (iPrice1 - 1).ToString(), iRepeat).Substring(0, strPriceLength); } else if (Math.Abs(iPrice - Convert.ToInt32(strPrice0 + strPrice1 + RepeatString((iPrice0 < iPrice1 ? strPrice0 : strPrice1), strPriceLength - 2))) <= iRange) //XYSSS... (smaller) { return strPrice0 + strPrice1 + RepeatString((iPrice0 > iPrice1 ? strPrice0 : strPrice1), strPriceLength - 2); } else if (Math.Abs(iPrice - Convert.ToInt32(strPrice0 + strPrice1 + RepeatString((iPrice0 > iPrice1 ? strPrice0 : strPrice1), strPriceLength - 2))) <= iRange) //XXLLL... (larger) { return strPrice0 + strPrice1 + RepeatString((iPrice0 < iPrice1 ? strPrice0 : strPrice1), strPriceLength - 2); } else if ((iPrice1 > 0) && Math.Abs(iPrice - Convert.ToInt32(strPrice0 + (iPrice1 - 1).ToString() + RepeatString((iPrice0 > iPrice1 - 1 ? strPrice0 : strPrice1), strPriceLength - 2))) <= iRange) //X(-1Y)SSS... (smaller) { return strPrice0 + (iPrice1 - 1).ToString() + RepeatString((iPrice0 < iPrice1 ? strPrice0 : strPrice1), strPriceLength - 2); } else if ((iPrice1 > 0) && Math.Abs(iPrice - Convert.ToInt32(strPrice0 + (iPrice1 - 1).ToString() + RepeatString((iPrice0 < iPrice1 - 1 ? strPrice0 : strPrice1), strPriceLength - 2))) <= iRange) //X(-1Y)LLL... (larger) { return strPrice0 + (iPrice1 - 1).ToString() + RepeatString((iPrice0 > iPrice1 ? strPrice0 : strPrice1), strPriceLength - 2); } else { int iPrice3 = Convert.ToInt32(strPrice[3].ToString()); iPrice -= (iPrice > 0 ? 1 : 0); return strPrice0 + strPrice1 + RepeatString(strPrice[2].ToString() + iPrice3.ToString(), iRepeat).Substring(0, strPriceLength - 2); } } } /// <summary> /// Returns a string that contains a specified string repeated a specified amount of times. /// </summary> /// <param name="strRepeat">Required. The string to repeat.</param> /// <param name="iCount">Required. The value indicating how many times to repeat the parameter 'strRepeat'.</param> /// <returns></returns> public string RepeatString(string strRepeat, int iCount) { return string.Join("", Enumerable.Repeat(strRepeat, iCount)); } Visual Basic .NET: Spoiler Code (Text): ''' <summary> ''' Generates a haggled price based on a specified price. For the more 'convenient' prices, the maximum range parameter, 'iRange', is used. ''' </summary> ''' <param name="strPrice">Required. The price of which to haggle off of.</param> ''' <param name="iRange">Optional. For more advanced 'convenient' prices, this value determines the maximum absolute value of the difference between haggled price and the original, specified price.</param> ''' <returns></returns> Public Function GeniusHaggle(strPrice As String, Optional iRange As UInteger = 500) As String strPrice = strPrice.Replace(",", "") strPrice = strPrice.Replace(" ", "") strPrice = strPrice.Replace(".", "") Dim iPrice As Integer = Convert.ToInt32(strPrice) Dim strPriceLength As Integer = strPrice.Length If strPriceLength < 1 Then Return String.Empty ElseIf strPriceLength <= 2 Then Return CInt(Math.Truncate(iPrice * 0.98)).ToString() ElseIf (strPriceLength = 3) Or (strPriceLength = 4) Then Dim strPrice0 As String = strPrice(0).ToString() Dim iPrice1 As Integer = Convert.ToInt32(strPrice.Substring(1, 1)) If Math.Abs(iPrice - Convert.ToInt32(RepeatString(strPrice0, strPriceLength))) <= iRange Then Return RepeatString(strPrice0, strPriceLength) ElseIf iPrice1 = 0 Then strPrice0 = (Convert.ToInt32(strPrice0) - 1).ToString() Return strPrice0 & "9" & strPrice0 & (If(strPriceLength = 4, "9", "")) Else Return strPrice0 & (iPrice1 - 1).ToString() & strPrice0 & (If(strPriceLength = 4, (iPrice1 - 1).ToString(), "")) End If Else Dim strPrice0 As String = strPrice(0).ToString() Dim strPrice1 As String = strPrice(1).ToString() Dim iPrice0 As Integer = Convert.ToInt32(strPrice0) Dim iPrice1 As Integer = Convert.ToInt32(strPrice1) Dim iRepeat As Integer = CInt(strPriceLength \ 2) + 1 If Math.Abs(iPrice - (Convert.ToInt32(RepeatString(strPrice0, strPriceLength)))) <= iRange Then 'XXXXX... Return RepeatString(strPrice0, strPriceLength) ElseIf (iPrice0 > 1) AndAlso (Math.Abs(iPrice - (Convert.ToInt32(RepeatString((iPrice0 - 1).ToString(), strPriceLength)))) <= iRange) Then '-1 XXXXX... Return RepeatString((iPrice0 - 1).ToString(), strPriceLength) ElseIf Math.Abs(iPrice - Convert.ToInt32(RepeatString(strPrice0 & strPrice1, iRepeat).Substring(0, strPriceLength))) <= iRange Then 'XYXYX... Return RepeatString(strPrice0 & strPrice1, iRepeat).Substring(0, strPriceLength) ElseIf (iPrice1 > 0) AndAlso (Math.Abs(iPrice - Convert.ToInt32(RepeatString(strPrice0 & (iPrice1 - 1).ToString(), iRepeat).Substring(0, strPriceLength))) <= iRange) Then '-1 XYXYX... Return RepeatString(strPrice0 & (iPrice1 - 1).ToString(), iRepeat).Substring(0, strPriceLength) ElseIf Math.Abs(iPrice - Convert.ToInt32(strPrice0 & strPrice1 & RepeatString((If(iPrice0 < iPrice1, strPrice0, strPrice1)), strPriceLength - 2))) <= iRange Then 'XYSSS... (smaller) Return strPrice0 & strPrice1 & RepeatString((If(iPrice0 > iPrice1, strPrice0, strPrice1)), strPriceLength - 2) ElseIf Math.Abs(iPrice - Convert.ToInt32(strPrice0 & strPrice1 & RepeatString((If(iPrice0 > iPrice1, strPrice0, strPrice1)), strPriceLength - 2))) <= iRange Then 'XXLLL... (larger) Return strPrice0 & strPrice1 & RepeatString((If(iPrice0 < iPrice1, strPrice0, strPrice1)), strPriceLength - 2) ElseIf (iPrice1 > 0) AndAlso Math.Abs(iPrice - Convert.ToInt32(strPrice0 & (iPrice1 - 1).ToString() & RepeatString((If(iPrice0 > iPrice1 - 1, strPrice0, strPrice1)), strPriceLength - 2))) <= iRange Then 'X(-1Y)SSS... (smaller) Return strPrice0 & (iPrice1 - 1).ToString() & RepeatString((If(iPrice0 < iPrice1, strPrice0, strPrice1)), strPriceLength - 2) ElseIf (iPrice1 > 0) AndAlso Math.Abs(iPrice - Convert.ToInt32(strPrice0 & (iPrice1 - 1).ToString() & RepeatString((If(iPrice0 < iPrice1 - 1, strPrice0, strPrice1)), strPriceLength - 2))) <= iRange Then 'X(-1Y)LLL... (larger) Return strPrice0 & (iPrice1 - 1).ToString() & RepeatString((If(iPrice0 > iPrice1, strPrice0, strPrice1)), strPriceLength - 2) Else Dim iPrice3 As Integer = Convert.ToInt32(strPrice(3).ToString()) iPrice -= (If(iPrice > 0, 1, 0)) Return strPrice0 & strPrice1 & RepeatString(strPrice(2).ToString() & iPrice3.ToString(), iRepeat).Substring(0, strPriceLength - 2) End If End If End Function ''' <summary> ''' Returns a string that contains a specified string repeated a specified amount of times. ''' </summary> ''' <param name="strRepeat">Required. The string to repeat.</param> ''' <param name="iCount">Required. The value indicating how many times to repeat the parameter 'strRepeat'.</param> ''' <returns></returns> Public Function RepeatString(strRepeat As String, iCount As Integer) As String Return String.Join("", Enumerable.Repeat(strRepeat, iCount)) End Function This function was one that I worked on for a little longer. I tried to make it so that it returns the most 'convenient' haggle price for a human. It looks like a lot of code and a lot to process, but most of the functions are pretty simple and it is mostly If statements. It usually takes less than 0 milliseconds, believe it or not, when using both the System.Diagnostics.Stopwatch and DateTime difference methods. It can be done a little more efficiently in VB because of the Case keyword, but C#'s switch does not allow a 'range' of numbers. And I was too lazy, so I just stuck it into a converter . If you guys have any suggestions, please do post. Appreciate any feedback .