|
Hi, don't know really where to post this but because I wrote the program in c# to solve this problem, I guess its as good a place as any.
Project Euler is for bored programmers (like myself) that like to solve problems.
Well I am pretty sure I solved problem 9[^] correctly, yet the site tells me i'm crazy.
The answer I got was:
{200, 375, 425} [a^2 + b^2 = c^2]
And the product of abc is 6375000000.
Am I reading the problem wrong?
This checks out on my end, please double check this for me and let me know I'm not crazy.
Matthew Hazlett
Fighting the good fight for web usability.
|
|
|
|
|
Heres the code if you want to see how I did it:
int objectNum = 1000;
for (int counterOne = 1; counterOne < objectNum; counterOne++)
{
for (int counterTwo = 1; counterTwo < objectNum; counterTwo++)
{
double a = Math.Pow(counterOne, 2);
double b = Math.Pow(counterTwo, 2);
double c = Math.Sqrt(a + b);
if (Math.Truncate(c) == c)
if (counterOne + counterTwo + c == (double)objectNum)
Console.WriteLine("{0}, {1}, {2}", counterOne, counterTwo, c);
}
}
Matthew Hazlett
Fighting the good fight for web usability.
|
|
|
|
|
lol, the answer is right, I just multiplied wrong to get the product.. lol
I'm an idiot.
The correct answer is: 31,875,000
Matthew Hazlett
Fighting the good fight for web usability.
|
|
|
|
|
Hi All,
I am currently working on using the ajax autocomplete application that queries from the database for the input entered into the textbox. However nothing shows when i load it up and i am unsure as to whether it is to do with the way i have created the web method or maybe to to do with the static method. Nonetheless it does not work.
Would anyone be able to provide assistance for this? Many Thanks + Kind Regards.
<br />
-Class<br />
<br />
using System;<br />
using System.Data;<br />
using System.Configuration;<br />
using System.Linq;<br />
using System.Web;<br />
using System.Web.Security;<br />
using System.Web.UI;<br />
using System.Web.UI.HtmlControls;<br />
using System.Web.UI.WebControls;<br />
using System.Web.UI.WebControls.WebParts;<br />
using System.Xml.Linq;<br />
using System.Web.Services;<br />
using System.Data.SqlClient;<br />
<br />
public class MyClass<br />
{<br />
public MyClass()<br />
{<br />
}<br />
<br />
<br />
<br />
<br />
public static string [] GetCountry(string country)<br />
{<br />
<br />
string query = "SELECT DISTINCT COUNTRY FROM CUSTOMERS WHERE COUNTRY LIKE @Country";<br />
using (SqlConnection conn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\NORTHWIND.MDF;Integrated Security=True;User Instance=True"))<br />
{<br />
<br />
SqlDataAdapter adapter = new SqlDataAdapter(query, conn);<br />
adapter.SelectCommand.Parameters.Add("@Country", SqlDbType.VarChar, 15).Value = country + "%";<br />
DataTable dt = new DataTable();<br />
adapter.Fill(dt);<br />
string[] items = new string[dt.Rows.Count];<br />
int i = 0;<br />
foreach (DataRow dr in dt.Rows)<br />
{<br />
items.SetValue(dr["Country"].ToString(), i);<br />
<br />
i++;<br />
}<br />
return items;<br />
<br />
<br />
<br />
<br />
}<br />
}<br />
}<br />
<br />
<br />
-Web Method<br />
<br />
using System;<br />
using System.Collections;<br />
using System.Linq;<br />
using System.Web;<br />
using System.Web.Services;<br />
using System.Web.Services.Protocols;<br />
using System.Xml.Linq;<br />
<br />
[WebService(Namespace = "http://tempuri.org/")]<br />
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]<br />
[System.Web.Script.Services.ScriptService]<br />
public class WebService : System.Web.Services.WebService {<br />
<br />
public WebService () {<br />
<br />
}<br />
<br />
[System.Web.Services.WebMethod]<br />
[System.Web.Script.Services.ScriptMethod]<br />
<br />
public string [] GetMyCountry(string country)<br />
{<br />
<br />
return MyClass.GetCountry(country).ToArray();<br />
<br />
<br />
}<br />
<br />
}<br />
<br />
- Source Code<br />
<br />
<![CDATA[<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>]]><br />
<br />
<![CDATA[<br />
<br />
<br />
<br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<head runat="server"><br />
<title>Untitled Page</title><br />
<style type="text/css"><br />
.style1<br />
{<br />
width: 170px;<br />
}<br />
</style><br />
</head><br />
<body><br />
<form id="form1" runat="server"><br />
<div><br />
<br />
<table style="width: 100%; height: 161px;"><br />
<tr><br />
<td class="style1"><br />
</td><br />
<td><br />
</td><br />
<td><br />
</td><br />
</tr><br />
<tr><br />
<td class="style1"><br />
Choose a Country</td><br />
<td><br />
<asp:textbox id="TextBox1" runat="server" xmlns:asp="#unknown"></asp:textbox><br />
</td><br />
<td><br />
</td><br />
</tr><br />
<tr><br />
<td class="style1"><br />
<cc1:autocompleteextender id="AutoCompleteExtender1" runat="server" targetcontrolid="Textbox1" servicepath="WebService.asmx" servicemethod="GetMyCountry" minimumprefixlength="1" completionsetcount="12" enablecaching="true" xmlns:cc1="#unknown"></cc1:autocompleteextender></td><br />
<td><br />
<asp:scriptmanager id="ScriptManager1" runat="server" xmlns:asp="#unknown"><br />
<services><br />
<asp:servicereference path="WebService.asmx" /><br />
</services><br />
</asp:scriptmanager><br />
</td><br />
<td><br />
</td><br />
</tr><br />
</table><br />
<br />
</div><br />
</form><br />
</body><br />
</html><br />
<br />
<br />
|
|
|
|
|
We have an ASP.NET forum.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
assume i have a class named "Student" with the attributes of "Name", "Id" & "Address".
i make a list of "Student" type where i add only "Name" & "Id"
i want to show this data in a data grid view.
if the data grid is custom then how could i manage the column number here?
i want to get the number of attributes which i add in the list & it's may be dynamically changed.
thanks in advance.
raihansazal
|
|
|
|
|
raihansazal wrote: named "Student" with the attributes of "Name", "Id" & "Address".
Maybe you mean property in you case, not attributes.
raihansazal wrote: i make a list of "Student" type where i add only "Name" & "Id"
i want to show this data in a data grid view.
You mean you did not want to display the Address in datagrid view?
I Love KongFu~
|
|
|
|
|
Dragonfly_Lee wrote:
Maybe you mean property in you case, not attributes.
You mean you did not want to display the Address in datagrid view?
Yes.
i don't want to add Address in datagrid.
& i just want to give the list in datagrid as source & datagrid will manage the columns from the the list.
so how can i define that how many properties did i add in my list?
|
|
|
|
|
How can take printout contents from listview and from textboxes ?
Is it Possible??
|
|
|
|
|
If you want to print a specific control, you can render it to a bitmap first, then print that.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
k... thanks..
I will try this method...
|
|
|
|
|
In my DataGridView I have three columns whose ValueType is set to double so that it'll accept only numbers. Now I want it to always show 2 decimal places like "17.00" instead of "17". How do I do that?
modified on Saturday, January 31, 2009 9:43 PM
|
|
|
|
|
By specifying a format string.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
And how would I do that?
modified on Saturday, January 31, 2009 7:02 PM
|
|
|
|
|
|
|
Okay that seems like that would work but I'm still not sure how I'd enforce 2 decimals.
|
|
|
|
|
k....
Do this....
DataGridView:>>Properties:>>Edit Columns::>Appearence::>DefualtCellStyle::>Format::>FormatType::>Numeric::>Decimal Places::>2
|
|
|
|
|
Thanks Najmal that worked.
|
|
|
|
|
|
|
|
I have no idea what it is that you're asking, but I *think* you're asking how to take an image that is itself distorted and undistort it. A picture box won't do that. If you want to DISTORT the image, by changing it's aspect ratio, then just draw it into a new bitmap of the required size using one of the DrawImage overloads on the Graphics class. That's easy.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I want to know how can I rename the [Main Report] tab on the Crystal Report Viewer to whatever name I want?
|
|
|
|
|
I want to know how can I remove the [Main Report] tab from the Crystal Report Viewer?
|
|
|
|