  | 
				
				Cheat Engine The Official Site of Cheat Engine   
				
 
				 | 
			 
		 
		 
	
		| View previous topic :: View next topic   | 
	 
	
	
		| Author | 
		Message | 
	 
	
		Evil_Intentions Expert Cheater
  Reputation: 65
  Joined: 07 Jan 2010 Posts: 214
 
  | 
		
			
				 Posted: Sun Jun 13, 2010 2:36 pm    Post subject: Any ideas for a beginner? | 
				       | 
			 
			
				
  | 
			 
			
				| I love to program, and i find that the best way to learn, is to do. Unfortunately, im not a clever person. So i ask if anyone has a program idea (C++) nothing over the top, im still relatively new.
 | 
			 
		  | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		Flyte Peanuts!!!!
  Reputation: 6
  Joined: 19 Apr 2006 Posts: 1887 Location: Canada
  | 
		 | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		Evil_Intentions Expert Cheater
  Reputation: 65
  Joined: 07 Jan 2010 Posts: 214
 
  | 
		
			
				 Posted: Sun Jun 13, 2010 2:54 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				| Thanks! thats exactly what i was looking for. i LOVE math based programs.
 | 
			 
		  | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		Deltron Z Expert Cheater
  Reputation: 1
  Joined: 14 Jun 2009 Posts: 164
 
  | 
		
			
				 Posted: Sun Jun 13, 2010 3:44 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				I love Project Euler, I solved quite a few problems there myself. I don't go there anymore because I'm kinda stuck, solved most problems I can which aren't brute force or no special algorithm needed...
 
 
Anyway, here's a little something a friend sent me a few hours ago, I've already solved all recurrsions and a few logic and all warm-ups. even the recurrsions aren't that difficault, but even if you can't make it there are a lot easier problems, some with solutions.
 
http://codingbat.com/
 
You have to use Java or Python, I don't know much of both but I pretty much know the syntax, so I didn't have any problems solving with nither of them, except for math and strings functions, then I just googled for the correct syntax. (most strings problems are pretty ugly, however I do recommend solving all of the recurrsions ones to gain experience!)
 
 
There's something else my friend sent me - the game Light Bot 2.0. same with Coding Bat, solved basics, recurrsions and conditions in a few minutes and a few of expert, also most of Light Bot 1.0 - it's really fun and addicting.    
 
 
Another game I know, very fun and important to understand boolean logic is GATE. A bit buggy, but until levels 20~25 you should manage, very simple circuits. after that, it's just too buggy to solve. I think it varies from computer to computer. Anyway, while reverse engineering this game I have found a bug that requires nothing but renaming the levels' names - adding a 0 at the beginning of the file, then you will have the first few levels you renamed, depending on how many levels you've solved. in the worst case, just rename one at a time.
 | 
			 
		  | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		XSV GTH Moderator
  Reputation: 9
  Joined: 12 Oct 2005 Posts: 1007 Location: USA
  | 
		 | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		Deltron Z Expert Cheater
  Reputation: 1
  Joined: 14 Jun 2009 Posts: 164
 
  | 
		
			
				 Posted: Sun Jun 13, 2010 3:55 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				
 
Don't talk nonsense... I think learning Java as the first language is bad, as it handle your garbage collecting, it's compiled at runtime and you might get a wrong perception on programming, but most important of all - in C/C++, what you write is what you get, usually. when not optimizing the code or any special options, you can run what you really think you're running, and by that get the right perception on programming. only then I would recommand learning Object Oriented Programming and then you can easily learn most languages based on C like Java or C# and use their great power.
 | 
			 
		  | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		Evil_Intentions Expert Cheater
  Reputation: 65
  Joined: 07 Jan 2010 Posts: 214
 
  | 
		
			
				 Posted: Sun Jun 13, 2010 4:03 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				 	  | Deltron Z wrote: | 	 		  
 
Don't talk nonsense... I think learning Java as the first language is bad, as it handle your garbage collecting, it's compiled at runtime and you might get a wrong perception on programming, but most important of all - in C/C++, what you write is what you get, usually. when not optimizing the code or any special options, you can run what you really think you're running, and by that get the right perception on programming. only then I would recommand learning Object Oriented Programming and then you can easily learn most languages based on C like Java or C# and use their great power. | 	  
 
 
yes. I know for an ABSOLUTE FACT that its going to be quite a while before i start java. Im prety much up to my neck in c++ at the moment. Im reading through 2 textbooks, then i have an opengl book for when im done.
 
 
 
Also, off topic. How would you rate my coding? by that i mean cleanness, operator use etc.
 
 	  | Code: | 	 		  #include <iostream>
 
 
using namespace std;
 
 
int main()
 
{
 
    int first = 1;
 
    int second = 2;
 
    int third = 0;
 
 
    int total = second;
 
 
    for(int counter = 3; counter <=100; counter++)
 
    {
 
 
        third = first + second;
 
        first = second;
 
        second = third;
 
            if (third % 2 == 0 && third < 4000000 && third > 0)
 
            {
 
                total += third;
 
 
            }
 
    }
 
 
    cout << total;
 
    cin.get();
 
    return 0;
 
}
 
 | 	  
 
 
any way i can improve anything? It runs perfectly fine and gets the job done, I just want to know what people think.
 | 
			 
		  | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		Deltron Z Expert Cheater
  Reputation: 1
  Joined: 14 Jun 2009 Posts: 164
 
  | 
		
			
				 Posted: Sun Jun 13, 2010 4:44 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				It's fine, but the code is too small to tell enough about your coding style.
 
Anyway, I would use spaces to make things more clear:
 
 	  | Code: | 	 		  "for(" => "for "
 
"if(" =< "if ("
 
and also
 
"counter<=100" => "i <= 100" or "counter <= 100" | 	  
 
Just notice that 100 iterations isn't upper or lower bound, it's pretty much a guess... instead you should've looped using while loop and the condition of Fib < 4000000.
 
Also, notice the pattern of fibonacci sequence:
 
 	  | Code: | 	 		  | 1, 1, 2, 3, 5, 8, 13, 21, 34, ... | 	  
 
Every 3rd element is even!
 
Thus you could simply do:
 
 	  | Code: | 	 		  int fib1 = 1;
 
int fib2 = 1;
 
int temp;
 
 
while (fib2 < 4000000)
 
{
 
   for (int i = 1; i <= 3; i++)
 
   {
 
      temp = fib1;
 
      fib1 = fib2;
 
      fib2 = temp + fib1;
 
   }
 
   sum += fib2;
 
} | 	  
 
 
And that was my original solution. later, I kept digging a little further, and if you read in wikipedia you will see that the ratio between each element in the fibonacci sequence is aproximatly 1.618 - the golden ratio. (which can be calculated by the formula (√5 + 1) / 2 ≈ (2.236 + 1) / 2 = 3.236 / 2 = 1.618 (Phi - φ).
 
I figured out that the next element, Fn+1, can be calculated as Fn * φ rounded to the nearest number (Fn * φ + 0.5 rounded down).
 
Then I got the code:
 
 	  | Code: | 	 		  unsigned int Problem2()
 
{
 
   unsigned int sum = 0, fib = 1;
 
 
   while (fib < 4000000)
 
   {
 
      if ((fib & 1) == 0)
 
         sum += (unsigned int)fib;
 
      fib = (unsigned int)(((float)fib*1.6180339887498948482045868343656f) + 0.5f);
 
   }
 
   return sum;
 
} | 	  
 
Or with a loop:
 
 	  | Code: | 	 		  unsigned int Problem2()
 
{
 
   unsigned int sum = 0, fib = 2;
 
 
   while (fib < 4000000)
 
   {
 
      sum += (unsigned int)fib;
 
      for (int i = 1; i <= 3; i++)
 
         fib = (unsigned int)(((float)fib*1.6180339887498948482045868343656f) + 0.5f);
 
   }
 
   return sum;
 
} | 	  
 | 
			 
		  | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		Beyond Awesomeness Grandmaster Cheater Supreme
  Reputation: 0
  Joined: 15 Jul 2008 Posts: 1640 Location: under your bed
  | 
		
			
				 Posted: Sun Jun 13, 2010 5:14 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				
 
 
C++ has always been the best language to start in.
 _________________
  
 
The New Trainer v0.80 and many more popular flash game trainers. | 
			 
		  | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		Deltron Z Expert Cheater
  Reputation: 1
  Joined: 14 Jun 2009 Posts: 164
 
  | 
		
			
				 Posted: Sun Jun 13, 2010 5:16 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				 	  | $HINe ONe wrote: | 	 		  
 
 
C++ has always been the best language to start in. | 	  
 
Actually you should start with ASM or at least C for procedural programming understanding. Object Oriented Programming is concidered quite advanced.  
 | 
			 
		  | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		Beyond Awesomeness Grandmaster Cheater Supreme
  Reputation: 0
  Joined: 15 Jul 2008 Posts: 1640 Location: under your bed
  | 
		
			
				 Posted: Sun Jun 13, 2010 5:31 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				 	  | Deltron Z wrote: | 	 		   	  | $HINe ONe wrote: | 	 		  
 
 
C++ has always been the best language to start in. | 	  
 
Actually you should start with ASM or at least C for procedural programming understanding. Object Oriented Programming is concidered quite advanced.   | 	  
 
Yes it is true, C++ is a very difficult language to learn but once you have learned it, it is definitely one of the most powerful languages. once you learn it, other languages will be learned a lot quicker. apart from that once you learn C++ you will rarely need to use another language.
 _________________
  
 
The New Trainer v0.80 and many more popular flash game trainers. | 
			 
		  | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		Evil_Intentions Expert Cheater
  Reputation: 65
  Joined: 07 Jan 2010 Posts: 214
 
  | 
		
			
				 Posted: Sun Jun 13, 2010 5:41 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				 	  | Deltron Z wrote: | 	 		  It's fine, but the code is too small to tell enough about your coding style.
 
Anyway, I would use spaces to make things more clear:
 
 	  | Code: | 	 		  "for(" => "for "
 
"if(" =< "if ("
 
and also
 
"counter<=100" => "i <= 100" or "counter <= 100" | 	  
 
Just notice that 100 iterations isn't upper or lower bound, it's pretty much a guess... instead you should've looped using while loop and the condition of Fib < 4000000.
 
Also, notice the pattern of fibonacci sequence:
 
 	  | Code: | 	 		  | 1, 1, 2, 3, 5, 8, 13, 21, 34, ... | 	  
 
Every 3rd element is even!
 
Thus you could simply do:
 
 	  | Code: | 	 		  int fib1 = 1;
 
int fib2 = 1;
 
int temp;
 
 
while (fib2 < 4000000)
 
{
 
   for (int i = 1; i <= 3; i++)
 
   {
 
      temp = fib1;
 
      fib1 = fib2;
 
      fib2 = temp + fib1;
 
   }
 
   sum += fib2;
 
} | 	  
 
 
And that was my original solution. later, I kept digging a little further, and if you read in wikipedia you will see that the ratio between each element in the fibonacci sequence is aproximatly 1.618 - the golden ratio. (which can be calculated by the formula (√5 + 1) / 2 ≈ (2.236 + 1) / 2 = 3.236 / 2 = 1.618 (Phi - φ).
 
I figured out that the next element, Fn+1, can be calculated as Fn * φ rounded to the nearest number (Fn * φ + 0.5 rounded down).
 
Then I got the code:
 
 	  | Code: | 	 		  unsigned int Problem2()
 
{
 
   unsigned int sum = 0, fib = 1;
 
 
   while (fib < 4000000)
 
   {
 
      if ((fib & 1) == 0)
 
         sum += (unsigned int)fib;
 
      fib = (unsigned int)(((float)fib*1.6180339887498948482045868343656f) + 0.5f);
 
   }
 
   return sum;
 
} | 	  
 
Or with a loop:
 
 	  | Code: | 	 		  unsigned int Problem2()
 
{
 
   unsigned int sum = 0, fib = 2;
 
 
   while (fib < 4000000)
 
   {
 
      sum += (unsigned int)fib;
 
      for (int i = 1; i <= 3; i++)
 
         fib = (unsigned int)(((float)fib*1.6180339887498948482045868343656f) + 0.5f);
 
   }
 
   return sum;
 
} | 	 
  | 	  
 
 
Thanks for the criticism. The reason some things are off, is because i never used a for statement before, and i wanted to give it a shot.
 
 
Also, i've made a perfectly capable fib sequence generator before, allowing the generation of arbitrary length numbers(can be found here: http://forum.cheatengine.org/viewtopic.php?t=506785 ), this particular version was for one of the challenges here: http://projecteuler.net/index.php?section=problems&id=2
 | 
			 
		  | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		Deltron Z Expert Cheater
  Reputation: 1
  Joined: 14 Jun 2009 Posts: 164
 
  | 
		
			
				 Posted: Sun Jun 13, 2010 5:47 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				Never used a for-loop before? you're just a beginner!    even more than what I've expected...
 
 
Well, good luck with that. try solving the interesting problems that require math or a smart algorithm first!   
 | 
			 
		  | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		Evil_Intentions Expert Cheater
  Reputation: 65
  Joined: 07 Jan 2010 Posts: 214
 
  | 
		
			
				 Posted: Sun Jun 13, 2010 5:52 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				 	  | Deltron Z wrote: | 	 		  Never used a for-loop before? you're just a beginner!    even more than what I've expected...
 
 
Well, good luck with that. try solving the interesting problems that require math or a smart algorithm first!    | 	  
 
 
HEY NOW... i never used a for loop, because i never felt the need to. I thought it was time to at least try it out. Im not THAT new, i even started getting into basic memory editing of other processes. Im used to using do/while loops, and they are the main loops i use.
 | 
			 
		  | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		Deltron Z Expert Cheater
  Reputation: 1
  Joined: 14 Jun 2009 Posts: 164
 
  | 
		
			
				 Posted: Sun Jun 13, 2010 5:59 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				What I meant to say is that it's a good thing that you're just a beginner and already solving problems from Project Euler.   
 | 
			 
		  | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		 | 
	 
 
  
	 
	    
	   | 
	
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
  | 
   
 
		 |