Play at! Click here for a free diamond. Also visit our Discord!
Hello There, Guest! Login Register

Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Programmer thread :D
Oh yeah to actually say something with a meaning:
I really enjoyed problem 128, Hexagonal tile differences and wouldn't have thought that problem 137, Fibonacci golden nuggets is that easy.
My collection:

Aww yeah the competition is on Numbers!!!
Your catching up really fast XD
Its taking all ym skill to solve any of these lol.

Fibonacci Golden nuggets took me a tun of googling. I liked 128 too! I'm feeling extremely proud of 250 and 500 :D
They were hard, but once I got the key idea down, they both became easy.
Still haven't been able to figure out problem 215, its a tough one xD
The very first thing you need to learn is how to say things. Use this command: print("Text")
This will print whatever you want to say on the output for example, print("cat") output: cat
By using print('Text') you can use external variables in your text by adding another ' and .. then close it off by ..' in between the four periods is where you tell the computer what variable you want to add. For example: name =
print('hello,'.. name ..'!')
What does is ask you to enter text and the print displays that text. This will all be helpful when we start the calculator.

Now what i'm going to teach you is the math functions. Addition, Subtraction, Multiplication, And Division are all the standard keyboard functions (+,-,*,/) but the other ones like square root, absolute value, and pi are all a bit different. The function for square root is math.sqrt(#). The # is replaced by the number you want to use the function with. An example:
number = math.sqrt(4)
print(' '.. number ..' ')
The output would be two.

Last thing I want to let you know is about the basic math functions. Math CAN be done in variables. I've been confused about this before when I was reading articles and experimenting so I just wanted to let you know.

You can name it anything you want. Next open the text document you just made. This is the place we will make the calculator. Now we can begin to code! We can begin the program by telling the user what it does. Make it say square root calculator or if you have a better name go ahead and use it. If you already feel confident and you are not confused scroll down to the paragraph that says ADVANCED CODING and it will teach you how to make the calculator even more user friendly.

Next, you want to tell the user to enter a value for x (the number you are rooting). Now make and name a variable that is two or more letters and make it so it equals What that will do is allow the user to enter a number or a letter. Next if you will like add a sign that says "calculating...".
Now its time for the math, make a variable that will equal the math done. Use math.sqrt(var) and replace var with your variable that contains information about x.
Lastly add a sign that shows your variable on the output screen by using print(' '.. var ..' '). After you did this guess what YOU ARE DONE! Your screen should look like this:

Press ctrl+s and on the drop down menu choose "all files". Next to the name of the document type ".lua" and click save.
If you want to run this program you have to install a compatible program or get the iphone version: TouchLua. Install: (The download will only work if you already have C++)

On line 2 type repeat and make a new line for "enter the value of x". All the rest of the code MUST be indented with three spaces. At the last time add a sign that asks if the user needs to reuse the calculator. Make any random variable that equals DO NOT INDENT ON THIS LINE!
type until variable ~= "y" What this does is checks if you type in y. If you type in anything else it wont work and the computer will recognize it as no. After this line you do not have to indent. It is up to you if you want to add a closing statement like see you soon or goodbye.
Your screen should sort of look like this:
All pics N/A
Thank you for reading this post. I really LOVE coding.
(08-12-2013, 04:54 PM)djurg Wrote: So many programmers yet no one can build a website for Pigcraft? :(
I'm very good with HTML and C++.

Forum Jump:

Browsing: 1 Guest(s)