Click here to Skip to main content
16,006,514 members
Home / Discussions / C#
   

C#

 
Questionc# Brain teaser Pin
izakfick20-Jun-06 2:47
izakfick20-Jun-06 2:47 
AnswerRe: c# Brain teaser Pin
Wjousts20-Jun-06 3:05
Wjousts20-Jun-06 3:05 
AnswerRe: c# Brain teaser Pin
J4amieC20-Jun-06 3:07
J4amieC20-Jun-06 3:07 
GeneralRe: c# Brain teaser Pin
izakfick20-Jun-06 3:17
izakfick20-Jun-06 3:17 
GeneralRe: c# Brain teaser Pin
thelastjedi20-Jun-06 3:23
thelastjedi20-Jun-06 3:23 
GeneralRe: c# Brain teaser Pin
izakfick20-Jun-06 3:31
izakfick20-Jun-06 3:31 
AnswerRe: c# Brain teaser Pin
thelastjedi20-Jun-06 3:36
thelastjedi20-Jun-06 3:36 
GeneralRe: c# Brain teaser Pin
izakfick20-Jun-06 3:42
izakfick20-Jun-06 3:42 
OK I'm now left with less results but results that applies to the rules

class Class1
{
[STAThread]
static void Main(string[] args)
{
int[] intArray = {1,2,3,4,5,6,7,8,9};
Calculate c = new Calculate();
CheckHash ch = new CheckHash();
Hashtable hash = new Hashtable();

for(int a = 1; a < intArray.Length; a++)
{
string output = c.calc(a,a);
if(output!="")
{
if(!ch.Check(hash,output))
{
Console.WriteLine(output + " = 10");
hash[hash.Count] = output;
}
}
for(int b = 1; b < intArray.Length; b++)
{
output = c.calc(a,b);
if(output!="")
{
if(!ch.Check(hash,output))
{
Console.WriteLine(output + " = 10");
hash[hash.Count] = output;
}
}
}
}
string stop = "";
}
}
public class Calculate
{
public string calc(int x, int y)
{
int iTotal = 0;
string s_out = "";

while(iTotal < 10)
{
iTotal = iTotal + x + y;
s_out = s_out + x.ToString() + " + " + y.ToString() + " + ";
if(iTotal == 10)
{
s_out = s_out.Substring(0,s_out.LastIndexOf("+")-1);
}
}
if(iTotal>10)
{
s_out = "";
}
return s_out;
}
}
public class CheckHash
{
public bool Check(Hashtable hsh,string s_in)
{
bool bTrue = false;

string ReverseString = "";
char[] arrays = s_in.ToCharArray();
for(int a = s_in.Length - 1; a >= 0;a--)
{
ReverseString = ReverseString + arrays[a];
}
if(hsh.ContainsValue(s_in))
{
bTrue = true;
}
if(hsh.ContainsValue(ReverseString))
{
bTrue = true;
}

return bTrue;
}
}

I'd like some help now
GeneralRe: c# Brain teaser Pin
izakfick20-Jun-06 3:43
izakfick20-Jun-06 3:43 
GeneralRe: c# Brain teaser Pin
thelastjedi20-Jun-06 4:08
thelastjedi20-Jun-06 4:08 
GeneralRe: c# Brain teaser Pin
izakfick20-Jun-06 4:10
izakfick20-Jun-06 4:10 
AnswerRe: c# Brain teaser Pin
thelastjedi20-Jun-06 4:38
thelastjedi20-Jun-06 4:38 
GeneralRe: c# Brain teaser Pin
izakfick20-Jun-06 4:49
izakfick20-Jun-06 4:49 
GeneralRe: c# Brain teaser Pin
thelastjedi20-Jun-06 5:07
thelastjedi20-Jun-06 5:07 
GeneralRe: c# Brain teaser Pin
izakfick20-Jun-06 5:40
izakfick20-Jun-06 5:40 
AnswerRe: c# Brain teaser Pin
Guffa20-Jun-06 4:09
Guffa20-Jun-06 4:09 
AnswerRe: c# Brain teaser Pin
athulathulsi12-Mar-12 22:06
athulathulsi12-Mar-12 22:06 
QuestionList All Web Methods In a WebService!! Pin
Comdesign20-Jun-06 2:27
Comdesign20-Jun-06 2:27 
AnswerRe: List All Web Methods In a WebService!! Pin
Dustin Metzgar22-Jun-06 13:32
Dustin Metzgar22-Jun-06 13:32 
QuestionDisabling keyboard keys Pin
Prashant Gadhave20-Jun-06 2:09
Prashant Gadhave20-Jun-06 2:09 
AnswerRe: Disabling keyboard keys Pin
J4amieC20-Jun-06 2:28
J4amieC20-Jun-06 2:28 
GeneralRe: Disabling keyboard keys Pin
Prashant Gadhave20-Jun-06 2:38
Prashant Gadhave20-Jun-06 2:38 
GeneralRe: Disabling keyboard keys Pin
J4amieC20-Jun-06 2:57
J4amieC20-Jun-06 2:57 
GeneralRe: Disabling keyboard keys Pin
Prashant Gadhave20-Jun-06 18:11
Prashant Gadhave20-Jun-06 18:11 
GeneralRe: Disabling keyboard keys Pin
nueer20-Jun-06 2:55
nueer20-Jun-06 2:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.