15,902,635 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 11169882 (Top 12 by date)
Member 11169882
6-Feb-17 22:19pm
View
Yes, I realised that after I saw solution 4. And thank you for your helpful insight, tips like this really do help me become a better developer. At the time I was trying different things and TryGetValue wasn't liked by the compiler for some reason (when I was trying it) i was probably using it incorrectly. I am still not the best at using linq but it is very very useful in .NET from my uses of it so far. Again your input is greatly appreciated, have a great day!
Member 11169882
6-Feb-17 14:49pm
View
see Solution 4, thanks for your reply!
Member 11169882
6-Feb-17 14:24pm
View
See solution 4, thank you for your answer, really appreciate your time!
Member 11169882
6-Feb-17 14:23pm
View
I believe the lookup would work better the way i did it if i wasn't inside of a loop, however since I am looping for each item, a tryget is much more efficient. The issue was that earlier I was using a keyValuePair, and not a dictionary and the compiler wasn't accepting "TryGetValue" but now it was working as i made a few tweaks using your solution.
Thanks again!
Member 11169882
6-Feb-17 14:21pm
View
Although your solution didnt work for me, I want to thank you for your time and help :) I learned something from your implementation as well! See solution 4 for what worked for me.
Thanks
Member 11169882
6-Feb-17 14:19pm
View
Thank you!! TryGetValue is definitely more efficient.
Since I have to output in a specific way to pass the test cases, this ended up working for me:
for(int i = 0; i < n; i++)
{
int val;
Word1 = Console.ReadLine();
if(list.TryGetValue(Word1, out val))
{
Console.WriteLine(Word1 + "=" + val);
}
else
{
Console.WriteLine("Not found");
}
}
Member 11169882
6-Feb-17 13:23pm
View
Basically, you have to write code based on certain inputs and expected outputs. The problem is that some of the test cases are huge with 100's of inputs. Therefore even though some of the test cases pass, not all can because in the larger test cases the timeout occurs
Member 11169882
6-Feb-17 11:56am
View
I didnt necessarily ask anyone to improve or rewrite the code, I had only asked in this case where could the inefficiency be in the way I had written it but I see what you mean. I value the time of the community and therefore didn't ask for much.
Also, for the second for loop I tried using a while loop as follows
while((Word1 = Console.ReadLine())!= null)
{
.....
}
I am still getting the same result (TimeOut occurs). For now I've moved onto the next challenge. If i don't get any other solutions within the next day I will accept your solution
Member 11169882
11-Sep-15 11:20am
View
yes the getwordunermouse was my own function which uses getcharindexfromposition
Member 11169882
11-Sep-15 11:19am
View
Okay, that sounds like a plan. Ill accept you solution! :D thanks
Member 11169882
11-Sep-15 11:05am
View
Thanks for your comment sir, indeed, the hardest part is getting the word under the mouse for which I had developed a special function that worked with RichTextBoxes, I would pass in my richTextBoxControl as sender, and then pass in the point (as drawing point) which I had obtained using PointtoClient.
Here is some code exerpt for demonstration: the
If CType(sender, STCRichTextBox).Name = "StcRichTextBoxEnglish" Then
'ToolTip1.RemoveAll()
Dim point As New Point(StcRichTextBoxEnglish.PointToClient(Cursor.Position).X, StcRichTextBoxEnglish.PointToClient(Cursor.Position).Y)
curWord = StcRichTextBoxEnglish.GetWordUnderMouse(CType(sender, System.Windows.Forms.RichTextBox), point)
ElseIf CType(sender, STCRichTextBox).Name = "StcRichTextBoxFrench" Then
'ToolTip1.RemoveAll()
Dim point As New Point(StcRichTextBoxFrench.PointToClient(Cursor.Position).X, StcRichTextBoxFrench.PointToClient(Cursor.Position).Y)
curWord = StcRichTextBoxFrench.GetWordUnderMouse(CType(sender, System.Windows.Forms.RichTextBox), point)
End If
Im wondering that if something similar is possible with a cell, then I might end up giving it a shot. So far I have been out of luck.
If you have some insigths regarding this, do let me know. For now I will see how far I get lol!
Again, really appreciate your comment and help. Cheers
Member 11169882
11-Sep-15 11:03am
View
Deleted
Thanks for your comment sir, indeed, the hardest part is getting the word under the mouse for which I had developed a special function that worked with RichTextBoxes, I would pass in my richTextBoxControl as sender, and then pass in the point (as drawing point) which I had obtained using PointtoClient.
Here is some code exerpt for demonstration: the
<pre lang="vb">If CType(sender, STCRichTextBox).Name = "StcRichTextBoxEnglish" Then
'ToolTip1.RemoveAll()
Dim point As New Point(StcRichTextBoxEnglish.PointToClient(Cursor.Position).X, StcRichTextBoxEnglish.PointToClient(Cursor.Position).Y)
curWord = StcRichTextBoxEnglish.GetWordUnderMouse(CType(sender, System.Windows.Forms.RichTextBox), point)
ElseIf CType(sender, STCRichTextBox).Name = "StcRichTextBoxFrench" Then
'ToolTip1.RemoveAll()
Dim point As New Point(StcRichTextBoxFrench.PointToClient(Cursor.Position).X, StcRichTextBoxFrench.PointToClient(Cursor.Position).Y)
curWord = StcRichTextBoxFrench.GetWordUnderMouse(CType(sender, System.Windows.Forms.RichTextBox), point)
End If
</pre>
Im wondering that if something similar is possible with a cell, then I might end up giving it a shot. So far I have been out of luck.
If you have some insigths regarding this, do let me know. For now I will see how far I get lol!
Again, really appreciate your comment and help. Cheers
Show More