|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
Bisutopia19156 Posts
Anyone know the best way to study phone interview questions for C# overnight? I have an exciting phone screening interview tomorrow and would like to prepare just in case I"m asked some.
|
On May 11 2012 02:37 holdthephone wrote: What are the best webhosting services? Looking to start up a site and plan to implement a database...
Is GoDaddy the obvious choice? I've used Site5 for years. They're pretty reliable and cheap as hell
|
So it's now summer, and as a CS student with zero experience of any sort I figure it'd be nice to get some. Making some money in the meantmie would also be neat. I've been checking local classifieds and stuff, but am having the common problem of 'MINIMUM 5 YEARS EXPERIENCE.'
Anyways, the few jobs I DO find seem overwhelming and scary. All of them involve things I've never done and therefore do not know how to do. I'm afraid to apply for fear that I do get the job and then find myself lost and overwhelmed.
So I'm here hoping to learn that this is common and that my fears are irrational, I guess. I just wanna have a compsci job ;_;
|
On May 11 2012 13:53 Crazyeyes wrote: So it's now summer, and as a CS student with zero experience of any sort I figure it'd be nice to get some. Making some money in the meantmie would also be neat. I've been checking local classifieds and stuff, but am having the common problem of 'MINIMUM 5 YEARS EXPERIENCE.'
Anyways, the few jobs I DO find seem overwhelming and scary. All of them involve things I've never done and therefore do not know how to do. I'm afraid to apply for fear that I do get the job and then find myself lost and overwhelmed.
So I'm here hoping to learn that this is common and that my fears are irrational, I guess. I just wanna have a compsci job ;_;
Well, considering you've never actually programmed anything commercial, how many things that people would request do you think you'd be able to do right off the bat? 
You only learn when you try things you can't already do. It's normal, and those fears are completely rational. Maybe they do hire you and you can't do it, which is unlikely if you've stuck with programming this long. Hopefully you enjoy it and try it in your spare time and like to learn about it which will make you not only able to do it, but enjoy it.
I would think it worse if you didn't think it overwhelming and scary, which means you may be ignorant to the complexity in some ways.
You'll be fine 
|
What's a good beginner project to work on? I'm thinking about making my own version of tetris and pong which looks really simple (pacman would involve AI and would be next step if tetris/pong work out easily). Would C be a good language for it? I'm most comfortable with C but know C++ Java and Python. Reason for project is because I got rejected from every internship opportunity. It's insane how cutthroat the market is...
|
On May 11 2012 15:54 leperphilliac wrote: What's a good beginner project to work on? I'm thinking about making my own version of tetris and pong which looks really simple (pacman would involve AI and would be next step if tetris/pong work out easily). Would C be a good language for it? I'm most comfortable with C but know C++ Java and Python. Reason for project is because I got rejected from every internship opportunity. It's insane how cutthroat the market is...
What type of job are you looking for? What technologies and languages do you like?
|
+ Show Spoiler +public static MvcHtmlString ActionLink(this HtmlHelper html, string action, object routeValues) { var url = new UrlHelper(html.ViewContext.RequestContext);
// build the <a> tag var anchorBuilder = new TagBuilder("a"); anchorBuilder.MergeAttribute("href", url.Action(action, routeValues)); anchorBuilder.MergeAttribute("disabled", "true"); string anchorHtml = anchorBuilder.ToString(TagRenderMode.Normal);
return MvcHtmlString.Create(anchorHtml); }
hi, i got a problem with C#
what i'm trying to do is disabling the link like it is gray'd out and unclickable
i tried searching for it in the web and they said just to set the attribute disabled to true =/ but it doesnt work
|
On May 11 2012 16:23 icystorage wrote:+ Show Spoiler +public static MvcHtmlString ActionLink(this HtmlHelper html, string action, object routeValues) { var url = new UrlHelper(html.ViewContext.RequestContext);
// build the <a> tag var anchorBuilder = new TagBuilder("a"); anchorBuilder.MergeAttribute("href", url.Action(action, routeValues)); anchorBuilder.MergeAttribute("disabled", "true"); string anchorHtml = anchorBuilder.ToString(TagRenderMode.Normal);
return MvcHtmlString.Create(anchorHtml); }
hi, i got a problem with C# what i'm trying to do is disabling the link like it is gray'd out and unclickable i tried searching for it in the web and they said just to set the attribute disabled to true =/ but it doesnt work
That's some serious convolution in that code you've got there. If it were me, I'd just change the href to # and the style to whatever your css disable link style is. End product: <a href="#" class="a.disabled">blahblah</a>. Dunno how to do that with your multitude of "builders" though. Good thing I'm not a web developer!
|
On May 11 2012 18:11 e-Goh wrote:Show nested quote +On May 11 2012 16:23 icystorage wrote:+ Show Spoiler +public static MvcHtmlString ActionLink(this HtmlHelper html, string action, object routeValues) { var url = new UrlHelper(html.ViewContext.RequestContext);
// build the <a> tag var anchorBuilder = new TagBuilder("a"); anchorBuilder.MergeAttribute("href", url.Action(action, routeValues)); anchorBuilder.MergeAttribute("disabled", "true"); string anchorHtml = anchorBuilder.ToString(TagRenderMode.Normal);
return MvcHtmlString.Create(anchorHtml); }
hi, i got a problem with C# what i'm trying to do is disabling the link like it is gray'd out and unclickable i tried searching for it in the web and they said just to set the attribute disabled to true =/ but it doesnt work That's some serious convolution in that code you've got there. If it were me, I'd just change the href to # and the style to whatever your css disable link style is. End product: <a href="#" class="a.disabled">blahblah</a>. Dunno how to do that with your multitude of "builders" though. Good thing I'm not a web developer! nah its okay, i found it easier making it non anchor and made some conditions in abling and disabling it
|
I'm back. Im having some issues again. Im trying to create a 'webpage' that will automate monitoring calls for quality. Its only in its rough draft form but I've hit a stump. I have a 'onclick' button that I want to 'generate' my monitor notes. I was thinking like making if else statements for each Y/N answer. That way I can just copy/paste from the output field.
So the problem. I have the 'button' made, but im not a javascript guy, and i dont know of an easy way to write this in HTML using basic input methods. This is a project at work, my IT dept recommended Jquery but no access to that and i move pc's regularly. Any pointers on where i would go from from the beginning, or if the following is just terrible code?
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script language="JavaScript" type="text/javascript"> <!-- function generate ()
Here is the code:
+ Show Spoiler + <html><head><title>Monitoring Notes</title>
<table> <tr><td> <h1>Monitoring Form</h1> <h3>Greeting: Makes a connection; Builds the relationship</h3> <table class="info"> <tr><td>Answers Promptly; Identifies Self and ISP at the beginning of the call</td> <td><INPUT TYPE="radio" NAME="q1-1" VALUE="y">Yes <INPUT TYPE="radio" NAME="q1-1" VALUE="n">No</td></tr> <tr><td>Expresses empathy through words and tone; Offers welcoming words</td> <td><INPUT TYPE="radio" NAME="q1-2" VALUE="y">Yes <INPUT TYPE="radio" NAME="q1-2" VALUE="n">No</td></tr> <tr><td>Asks for the UN and caller name; Uses AdminTool to lookup user info, asks for ticket #</td> <td><INPUT TYPE="radio" NAME="q1-3" VALUE="y">Yes <INPUT TYPE="radio" NAME="q1-3" VALUE="n">No</td></tr> <tr><td>Addresses the caller by name; Starts developing a rapport with the caller</td> <td><INPUT TYPE="radio" NAME="q1-4" VALUE="y">Yes <INPUT TYPE="radio" NAME="q1-4" VALUE="n">No</td></tr> <tr><td>Tells the caller they WILL help, or what they CAN do for them</td> <td><INPUT TYPE="radio" NAME="q1-5" VALUE="y">Yes <INPUT TYPE="radio" NAME="q1-5" VALUE="n">No</td></tr> </table> <h3>Professionalism: Acts Professionally; Expresses Confidence</h3> <table class="info"> <tr><td>Takes ownership of the call and control of the situation; is specific</td> <td><INPUT TYPE="radio" NAME="q2-1" VALUE="y">Yes <INPUT TYPE="radio" NAME="q2-1" VALUE="n">No</td></tr> <tr><td>Uses MAGIC phrases to build confidence and trust</td> <td><INPUT TYPE="radio" NAME="q2-2" VALUE="y">Yes <INPUT TYPE="radio" NAME="q2-2" VALUE="n">No</td></tr> <tr><td>Expresses sincerity and helpfulness through tone; Maintains a good pace</td> <td><INPUT TYPE="radio" NAME="q2-3" VALUE="y">Yes <INPUT TYPE="radio" NAME="q2-3" VALUE="n">No</td></tr> <tr><td>Speaks clearly with proper volume; Avoids tragic phrases</td> <td><INPUT TYPE="radio" NAME="q2-4" VALUE="y">Yes <INPUT TYPE="radio" NAME="q2-4" VALUE="n">No</td></tr> <tr><td>Uses Please and Thank You to show courtesy</td> <td><INPUT TYPE="radio" NAME="q2-5" VALUE="y">Yes <INPUT TYPE="radio" NAME="q2-5" VALUE="n">No</td></tr> </table> <h3>Attentiveness: Gets to the Heart of the Matter; Listens and Asks Questions</h3> <table class="info"> <tr><td>Listens, doesn't interrupt; Rephrases appropriately</td> <td><INPUT TYPE="radio" NAME="q3-1" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-1" VALUE="n">No</td></tr> <tr><td>Uses proper grammar; Avoids the use of slang words or acronyms</td> <td><INPUT TYPE="radio" NAME="q3-2" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-2" VALUE="n">No</td></tr> <tr><td>Asks qualifying questions; Asks for permission to gain more information</td> <td><INPUT TYPE="radio" NAME="q3-3" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-3" VALUE="n">No</td></tr> <tr><td>Before a hold/lag time for transfer; explains why and receives permission</td> <td><INPUT TYPE="radio" NAME="q3-4" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-4" VALUE="n">No</td></tr> <tr><td>After a hold or wait time; uses caller's name, waits for a resopnse, and thanks him/her</td> <td><INPUT TYPE="radio" NAME="q3-5" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-5" VALUE="n">No</td></tr> </table> <h3>Courtesy & Clarity: Inform, and Clarify what you will do</h3> <table class="info"> <tr><td>Educates the caller with relevant information</td> <td><INPUT TYPE="radio" NAME="q3-1" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-1" VALUE="n">No</td></tr> <tr><td>Is proactive; offers options or solutions before they are requested</td> <td><INPUT TYPE="radio" NAME="q3-2" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-2" VALUE="n">No</td></tr> <tr><td>Sets a deadline or timeframe before the caller asks</td> <td><INPUT TYPE="radio" NAME="q3-3" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-3" VALUE="n">No</td></tr> <tr><td>Summarizes the next steps</td> <td><INPUT TYPE="radio" NAME="q3-4" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-4" VALUE="n">No</td></tr> <tr><td>Obtains the caller's agreement on the next steps</td> <td><INPUT TYPE="radio" NAME="q3-5" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-5" VALUE="n">No</td></tr> </table> <h3>Closing: Closes with the Relationship in Mind</h3> <table class="info"> <tr><td>Offers additional assistance when appropriate; makes last offer to help, offers ticket number</td> <td><INPUT TYPE="radio" NAME="q4-1" VALUE="y">Yes <INPUT TYPE="radio" NAME="q4-1" VALUE="n">No</td></tr> <tr><td>Uses the caller's name and a magic phrase in closing</td> <td><INPUT TYPE="radio" NAME="q4-2" VALUE="y">Yes <INPUT TYPE="radio" NAME="q4-2" VALUE="n">No</td></tr> <tr><td>Closes with a sincere tone</td> <td><INPUT TYPE="radio" NAME="q4-3" VALUE="y">Yes <INPUT TYPE="radio" NAME="q4-3" VALUE="n">No</td></tr> <tr><td>Gives caller their name, brands the call, advises of 24/7 availability</td> <td><INPUT TYPE="radio" NAME="q4-4" VALUE="y">Yes <INPUT TYPE="radio" NAME="q4-4" VALUE="n">No</td></tr> <tr><td>Stays with the caller until the end</td> <td><INPUT TYPE="radio" NAME="q4-5" VALUE="y">Yes <INPUT TYPE="radio" NAME="q4-5" VALUE="n">No</td></tr> </table> <h3>Technical Skills & Ability</h3> <table class="info"> <tr><td>Was able to adequately identify the issue at hand</td> <td><INPUT TYPE="radio" NAME="q5-1" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-1" VALUE="n">No</td></tr> <tr><td>Connection Type/OS of caller was correctly identfied</td> <td><INPUT TYPE="radio" NAME="q5-2" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-2" VALUE="n">No</td></tr> <tr><td>Supported issues within scope of support</td> <td><INPUT TYPE="radio" NAME="q5-3" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-3" VALUE="n">No</td></tr> <tr><td>A correct and logical sequence of events was followed for the issue at hand</td> <td><INPUT TYPE="radio" NAME="q5-4" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-4" VALUE="n">No</td></tr> <tr><td>Able to troubleshoot without assistance and/or Escalated properly</td> <td><INPUT TYPE="radio" NAME="q5-5" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-5" VALUE="n">No</td></tr> <tr><td>Displayed initiative and used skill in moving toward resolution</td> <td><INPUT TYPE="radio" NAME="q5-6" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-6" VALUE="n">No</td></tr> <tr><td>Hold times and Dead air were kept to a minimum</td> <td><INPUT TYPE="radio" NAME="q5-7" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-7" VALUE="n">No</td></tr> <tr><td>All verifications of information were made correctly</td> <td><INPUT TYPE="radio" NAME="q5-8" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-8" VALUE="n">No</td></tr> <tr><td>Timing of the call was acceptable</td> <td><INPUT TYPE="radio" NAME="q5-9" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-9" VALUE="n">No</td></tr> <tr><td>Call Tracker notes are adequate, correct, concise, and clear</td> <td><INPUT TYPE="radio" NAME="q5-10" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-10" VALUE="n">No</td></tr>
</table> </td><td valign="top"><button type="button" onclick="generate()">Generate<br />Feedback<br /></button></td><td valign="top"><textarea name="output" rows="20" cols="20" style="width:400px;height:500px;"></textarea></td></tr> </table> <br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
|
Hyrule18980 Posts
use jQuery. It's a single javascript file that sits with the rest of your site's code and will make your life a lot easier.
|
whelp I can't figure this out...
I was wondering if someone could help explain to me how to utilize bool in a function form. The reason I ask this is because I am working on this tic tac toe game and am trying to make it so that the game keeps going (asking players to make turns) until it reaches to a halt (three in a row) thus ending the game. I can't figure out how to use the boolean operation to a function form...
Here is the code to help me on:
+ Show Spoiler + int a = 0; int b = 0; int i = 0;
int j = 0; char tictac[3][3] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'} };
void board() //intialize board { for(i=0;i<3;i++) { for(j=0;j<3;j++) {cout << tictac[i][j] << " " ;} cout << endl;} cout << endl; }
void choice() //to help mark spot for player one { if(a == 1) { tictac[0][0] = 'X'; board();} else if(a == 2) {tictac[0][1] = 'X'; board();}
else if(a == 3) {tictac[0][2] = 'X'; board();}
else if(a == 4) {tictac[1][0] = 'X'; board();}
else if(a == 5) {tictac[1][1] = 'X'; board();}
else if(a == 6) {tictac[1][2] = 'X'; board();}
else if(a == 7) {tictac[2][0] = 'X'; board();}
else if(a == 8) {tictac[2][1] = 'X'; board();}
else if(a == 9) {tictac[2][2] = 'X'; board();} }
void choice1() //to help mark spot for player 2 { if(b == 1) {tictac[0][0] = 'O'; board();} else if(b == 2) {tictac[0][1] = 'O'; board();}
else if(b == 3) {tictac[0][2] = 'O'; board();}
else if(b == 4) {tictac[1][0] = 'O'; board();}
else if(b == 5) {tictac[1][1] = 'O'; board();}
else if(b == 6) {tictac[1][2] = 'O'; board();}
else if(b == 7) {tictac[2][0] = 'O'; board();}
else if(b == 8) {tictac[2][1] = 'O'; board();}
else if(b == 9) {tictac[2][2] = 'O'; board();} }
void player1() ]//loop to ask for turn for player 1 { cout << "Player 1: "; cin >> a; while (!cin || a == b) // loop to help catch bad input { cout << "choose a different spot: "; cin.clear(); cin.sync(); cin >> a; } choice(); }
void player2() //loop to ask for turn for player 2 { cout << "Player 2: "; cin >> b; while (!cin || a == b) //loop to help catch bad input { cout << "choose a different spot: "; cin.clear(); cin.sync(); cin >> b; } choice1(); }
int main() { Sleep(2000); cout << "Lets play tic tac toe between two players" << endl;
for(i=0;i<3;i++) //create board {for(j=0;j<3;j++) {cout << tictac[i][j] << " " ;} cout << endl;} cout << endl;
Sleep(2000); cout << "Here is the board. Enter the number to mark your spot." << endl; cout << "Player 1 is X and player 2 is O." << endl;
cout << "Player 1 goes first. Please enter your number: "; cin >> a; choice(); cout << "Player 2: "; cin >> b; while (!cin || a == b) { cout << "choose a different spot: "; cin.clear(); cin.sync(); cin >> b; } choice1();
[b]//below is the loop/boolean code I am trying to implement but to fail. I have tried different variations and this one here just happens to be the one that I copy and pasted here.[/b]
while(tictac[0][0] == tictac[0][1] != tictac[0][2] || tictac[0][0] == tictac[2][0] != tictac[1][0] || tictac[2][0] == tictac[2][1] != tictac[2][2] || tictac[0][0] != tictac[1][1] == tictac[2][2] || tictac[2][2] != tictac[1][2] == tictac[0][2] ) {player1(); player2(); }
//^^Here I was trying to make it so that as long as three in a row wasn't created then the game would continue in the loop (thus the while loop). However if a three in a row was detected then the statement would become false and would jump out of the loop to "end the game."
{cout << "gg" << endl;} //not the best ending but that isnt the problem.
system("PAUSE"); return 0;
}
appreciate the help btw fyi: You can ignore some of my coding in the main function (block of code above my comments). I understand it may not be "consistent" but I was more worried on making the code work. Once I can get the whole thing going then I will go around and clean it up a bit to make it nicer.
btw how is my coding "style?" Is there any bad "habits" that I should avoid that is present in my work? *********
off topic: What situation would call for you to use array over vector? Vectors can do everything an array can but better it seems...is it more efficient to use array on a small memory managment or something?
************
sorry for cluttering :/
|
boolean is not useless. It might look useless from a computer point of view (and that's why a lot of languages actually define bool only as a type but use int internally to process), but from an engineering point of view, boolean suddenly becomes VERY interesting, because it prohibits prevents a lot more syntax errors by making them actual errors (e.g. if(x = 3) instead of if(x == 3) becomes an error instead of accidentally setting x to 3 and always being true).
protip: have a look at the switch statement instead of your if elseif elseif elseif elseif elseif. Your code is hilariously unreadable :D
|
teamliquid.net/blogs/viewblog.php?topic_id=337732
I wrote this as a beginner's guide to programming. It is basically a hands-on start for Ruby.
If anyone is interested in learning to program I hope my blog can help!
And for any experienced veterans - feel free to improve and critisize it if you see fit as well.
|
On May 15 2012 21:53 Anacletus wrote: teamliquid.net/blogs/viewblog.php?topic_id=337732
I wrote this as a beginner's guide to programming. It is basically a hands-on start for Ruby.
If anyone is interested in learning to program I hope my blog can help!
And for any experienced veterans - feel free to improve and critisize it if you see fit as well.
Wow nice guide asacletun!
|
On May 14 2012 23:06 heroyi wrote:whelp I can't figure this out... I was wondering if someone could help explain to me how to utilize bool in a function form. The reason I ask this is because I am working on this tic tac toe game and am trying to make it so that the game keeps going (asking players to make turns) until it reaches to a halt (three in a row) thus ending the game. I can't figure out how to use the boolean operation to a function form... Here is the code to help me on: + Show Spoiler + int a = 0; int b = 0; int i = 0;
int j = 0; char tictac[3][3] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'} };
void board() //intialize board { for(i=0;i<3;i++) { for(j=0;j<3;j++) {cout << tictac[i][j] << " " ;} cout << endl;} cout << endl; }
void choice() //to help mark spot for player one { if(a == 1) { tictac[0][0] = 'X'; board();} else if(a == 2) {tictac[0][1] = 'X'; board();}
else if(a == 3) {tictac[0][2] = 'X'; board();}
else if(a == 4) {tictac[1][0] = 'X'; board();}
else if(a == 5) {tictac[1][1] = 'X'; board();}
else if(a == 6) {tictac[1][2] = 'X'; board();}
else if(a == 7) {tictac[2][0] = 'X'; board();}
else if(a == 8) {tictac[2][1] = 'X'; board();}
else if(a == 9) {tictac[2][2] = 'X'; board();} }
void choice1() //to help mark spot for player 2 { if(b == 1) {tictac[0][0] = 'O'; board();} else if(b == 2) {tictac[0][1] = 'O'; board();}
else if(b == 3) {tictac[0][2] = 'O'; board();}
else if(b == 4) {tictac[1][0] = 'O'; board();}
else if(b == 5) {tictac[1][1] = 'O'; board();}
else if(b == 6) {tictac[1][2] = 'O'; board();}
else if(b == 7) {tictac[2][0] = 'O'; board();}
else if(b == 8) {tictac[2][1] = 'O'; board();}
else if(b == 9) {tictac[2][2] = 'O'; board();} }
void player1() ]//loop to ask for turn for player 1 { cout << "Player 1: "; cin >> a; while (!cin || a == b) // loop to help catch bad input { cout << "choose a different spot: "; cin.clear(); cin.sync(); cin >> a; } choice(); }
void player2() //loop to ask for turn for player 2 { cout << "Player 2: "; cin >> b; while (!cin || a == b) //loop to help catch bad input { cout << "choose a different spot: "; cin.clear(); cin.sync(); cin >> b; } choice1(); }
int main() { Sleep(2000); cout << "Lets play tic tac toe between two players" << endl;
for(i=0;i<3;i++) //create board {for(j=0;j<3;j++) {cout << tictac[i][j] << " " ;} cout << endl;} cout << endl;
Sleep(2000); cout << "Here is the board. Enter the number to mark your spot." << endl; cout << "Player 1 is X and player 2 is O." << endl;
cout << "Player 1 goes first. Please enter your number: "; cin >> a; choice(); cout << "Player 2: "; cin >> b; while (!cin || a == b) { cout << "choose a different spot: "; cin.clear(); cin.sync(); cin >> b; } choice1();
[b]//below is the loop/boolean code I am trying to implement but to fail. I have tried different variations and this one here just happens to be the one that I copy and pasted here.[/b]
while(tictac[0][0] == tictac[0][1] != tictac[0][2] || tictac[0][0] == tictac[2][0] != tictac[1][0] || tictac[2][0] == tictac[2][1] != tictac[2][2] || tictac[0][0] != tictac[1][1] == tictac[2][2] || tictac[2][2] != tictac[1][2] == tictac[0][2] ) {player1(); player2(); }
//^^Here I was trying to make it so that as long as three in a row wasn't created then the game would continue in the loop (thus the while loop). However if a three in a row was detected then the statement would become false and would jump out of the loop to "end the game."
{cout << "gg" << endl;} //not the best ending but that isnt the problem.
system("PAUSE"); return 0;
} appreciate the help btw fyi: You can ignore some of my coding in the main function (block of code above my comments). I understand it may not be "consistent" but I was more worried on making the code work. Once I can get the whole thing going then I will go around and clean it up a bit to make it nicer. btw how is my coding "style?" Is there any bad "habits" that I should avoid that is present in my work? ********* off topic: What situation would call for you to use array over vector? Vectors can do everything an array can but better it seems...is it more efficient to use array on a small memory managment or something? ************ sorry for cluttering :/
while(tictac[0][0] == tictac[0][1] != tictac[0][2] || tictac[0][0] == tictac[2][0] != tictac[1][0] || tictac[2][0] == tictac[2][1] != tictac[2][2] || tictac[0][0] != tictac[1][1] == tictac[2][2] || tictac[2][2] != tictac[1][2] == tictac[0][2] )
That doesn't work. You can't do A == B != C, you would have to do A == B && B != C.
|
Did anyone previously beat the speed of MD5 with their own custom hashing function? The reason for custom hashes I'm trying to use is purely speed, a few collisions or impared security are not an issue. I only need speed because I'm creating hashing tables. I've created the most simple function I can imagine in pseudo code:
to_be_hashed_string(string) index(string)
Array convert => a=1, b=2, c=3 and so on until z=26 for loop => each substring(to_be_hashed_string, i, 1) start with i = 0 index.add => pow ( convert[substring(to_be_hashed_string, i, 1)], i ) end for
In each iteration the integer i will be incremented which stops many collisions thanks to the Exponentiation (pow) function which is calculated over the convert array number.
string(32) "c18427314aa891c19a3c4e388211eb94" MD5 hash function in 1.8 microseconds float(1.6514813305334E+29) Custom hash function in 7.1 microseconds
|
On May 14 2012 23:06 heroyi wrote:+ Show Spoiler +whelp I can't figure this out... I was wondering if someone could help explain to me how to utilize bool in a function form. The reason I ask this is because I am working on this tic tac toe game and am trying to make it so that the game keeps going (asking players to make turns) until it reaches to a halt (three in a row) thus ending the game. I can't figure out how to use the boolean operation to a function form... Here is the code to help me on: + Show Spoiler + int a = 0; int b = 0; int i = 0;
int j = 0; char tictac[3][3] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'} };
void board() //intialize board { for(i=0;i<3;i++) { for(j=0;j<3;j++) {cout << tictac[i][j] << " " ;} cout << endl;} cout << endl; }
void choice() //to help mark spot for player one { if(a == 1) { tictac[0][0] = 'X'; board();} else if(a == 2) {tictac[0][1] = 'X'; board();}
else if(a == 3) {tictac[0][2] = 'X'; board();}
else if(a == 4) {tictac[1][0] = 'X'; board();}
else if(a == 5) {tictac[1][1] = 'X'; board();}
else if(a == 6) {tictac[1][2] = 'X'; board();}
else if(a == 7) {tictac[2][0] = 'X'; board();}
else if(a == 8) {tictac[2][1] = 'X'; board();}
else if(a == 9) {tictac[2][2] = 'X'; board();} }
void choice1() //to help mark spot for player 2 { if(b == 1) {tictac[0][0] = 'O'; board();} else if(b == 2) {tictac[0][1] = 'O'; board();}
else if(b == 3) {tictac[0][2] = 'O'; board();}
else if(b == 4) {tictac[1][0] = 'O'; board();}
else if(b == 5) {tictac[1][1] = 'O'; board();}
else if(b == 6) {tictac[1][2] = 'O'; board();}
else if(b == 7) {tictac[2][0] = 'O'; board();}
else if(b == 8) {tictac[2][1] = 'O'; board();}
else if(b == 9) {tictac[2][2] = 'O'; board();} }
void player1() ]//loop to ask for turn for player 1 { cout << "Player 1: "; cin >> a; while (!cin || a == b) // loop to help catch bad input { cout << "choose a different spot: "; cin.clear(); cin.sync(); cin >> a; } choice(); }
void player2() //loop to ask for turn for player 2 { cout << "Player 2: "; cin >> b; while (!cin || a == b) //loop to help catch bad input { cout << "choose a different spot: "; cin.clear(); cin.sync(); cin >> b; } choice1(); }
int main() { Sleep(2000); cout << "Lets play tic tac toe between two players" << endl;
for(i=0;i<3;i++) //create board {for(j=0;j<3;j++) {cout << tictac[i][j] << " " ;} cout << endl;} cout << endl;
Sleep(2000); cout << "Here is the board. Enter the number to mark your spot." << endl; cout << "Player 1 is X and player 2 is O." << endl;
cout << "Player 1 goes first. Please enter your number: "; cin >> a; choice(); cout << "Player 2: "; cin >> b; while (!cin || a == b) { cout << "choose a different spot: "; cin.clear(); cin.sync(); cin >> b; } choice1();
[b]//below is the loop/boolean code I am trying to implement but to fail. I have tried different variations and this one here just happens to be the one that I copy and pasted here.[/b]
while(tictac[0][0] == tictac[0][1] != tictac[0][2] || tictac[0][0] == tictac[2][0] != tictac[1][0] || tictac[2][0] == tictac[2][1] != tictac[2][2] || tictac[0][0] != tictac[1][1] == tictac[2][2] || tictac[2][2] != tictac[1][2] == tictac[0][2] ) {player1(); player2(); }
//^^Here I was trying to make it so that as long as three in a row wasn't created then the game would continue in the loop (thus the while loop). However if a three in a row was detected then the statement would become false and would jump out of the loop to "end the game."
{cout << "gg" << endl;} //not the best ending but that isnt the problem.
system("PAUSE"); return 0;
} appreciate the help btw fyi: You can ignore some of my coding in the main function (block of code above my comments). I understand it may not be "consistent" but I was more worried on making the code work. Once I can get the whole thing going then I will go around and clean it up a bit to make it nicer. btw how is my coding "style?" Is there any bad "habits" that I should avoid that is present in my work? ********* off topic: What situation would call for you to use array over vector? Vectors can do everything an array can but better it seems...is it more efficient to use array on a small memory managment or something? ************ sorry for cluttering :/ I'm terrible at programming, so I won't comment on much, but it seems like your choice() function can be replaced with: + Show Spoiler +void choice() { tictac[(a-1)/3][(a-1)%3]='X'; board(); } also, are you using global variables? Otherwise wouldn't you need choice(int a) instead of choice()?
|
On May 16 2012 05:52 peacenl wrote:Did anyone previously beat the speed of MD5 with their own custom hashing function? The reason for custom hashes I'm trying to use is purely speed, a few collisions or impared security are not an issue. I only need speed because I'm creating hashing tables. I've created the most simple function I can imagine in pseudo code: to_be_hashed_string(string) index(string)
Array convert => a=1, b=2, c=3 and so on until z=26 for loop => each substring(to_be_hashed_string, i, 1) start with i = 0 index.add => pow ( convert[substring(to_be_hashed_string, i, 1)], i ) end for
In each iteration the integer i will be incremented which stops many collisions thanks to the Exponentiation (pow) function which is calculated over the convert array number. string(32) "c18427314aa891c19a3c4e388211eb94" MD5 hash function in 1.8 microseconds float(1.6514813305334E+29) Custom hash function in 7.1 microseconds
stick to int, don't use float, that's stupid if you're aiming for speed also, try less cluttering. a simple:
int hash(String string) { int hash = 0; for(char c : string) { hash = hash * 31 + (int)c; } return hash; }
will probably suffice. Also, if you recalculate hashes for the same string repeatedly without mutating the string inbetween, it might help to use a wrapper data structure, which calculates the hash value on creation and caches it. Then you can simply reuse it and don't have to recalculate over and over.
|
Hey everyone ive recently been becoming more and more interested in learning the C language as a start point as personally I just really love the thought of being able to just create things Id need or just want to (hell even maybe at some point make some PSP or DS homebrews for myself as a little project too). I have a PDF book on C and I want to get myself more familiar with Linux.
ATM I have Ubuntu installed but I feel like its to Noob friendly in the sense that I dont feel pressured to actually have to get used to terminal am I being ignorant? Is there any other Linux distros that would be better to force me to learn things without being completely thrown down a creek with no paddle? A friend told me Gentoo if I want hard times since you are forced to compile everything and another said Debian but didnt really elaborate
also whats your guys Distro of choice?
|
|
|
|