how's the "for loop in range(x)" work? and how do you know a loop(while/for) is done? cause in C/C++, etc, you have the { } to tell ya.
P.S. you can do lose two lines from your code.
You only have to place the code inside the loop in a block if there is more than one statment.
If there is no block around the code then only the first statment applies.
C/C++ you only need the block (braces) if there is more than one statment.
Although I use a block (braces) even if there is only one statment as I think it keeps the code more consistent and readable.
Originally posted by Sepero teckno, do you program in anything besides C/C++? I don't know what language that guy wrote that in, but I can read/understand it perfectly... Then again, maybe that's what makes me an outcast.
want a cookie?
i should have just ran the program, i see you need indents to run the program.
if (i_forgot && this_is_about_code)
language = c++;
Strike: you don't even need the range(int(math.sqrt(10000))). The square root of 10000 is 100, so you can just use range(100).
(Of course, this doesn't negate the fact that x**2 is "multiplication". However, the way that multiplication is done on the CPU does negate this fact -- multiplication is done on the CPU by a series of additions, IIRC from Architecture. So hah; any solution is valid. )
Multiplication by 2 is most often optimized into var << 1.
The lucky thing with binary multiplicaiton is EVERYTHING is a multiple of 2, so shifts are all you need. After all the shifts you still need to add the individual products just as we do with decimal math.
I found this animated picture that illustrates multiplication very well.
Originally posted by Trogdor I'm doing a project for my compy sci class. I'll have three years to work on it. I am going to do it in PHP (so I can make it on my linux box and run it on my teacher's winblows 98 . . . also for the MySQL integration), and I need a good idea for my project. There are seven requirements, that I must show mastery in my program. Almost all of them I could do in my sleep, but I need a good idea.
1. Arrays || Records || Objects
2. Selection Constructs (branching)
3. Iteration Constructs (looping)
4. subprograms (built-in && user defined)
5. parameter passing (hah!)
6. Sorting || Searching Techniques
7. File Access
It looks like a job for MySQL. But what should I make? Any ideas?
Thanks,
TROGDOR!!!
I thought of something today that I'm not sure has ever been done. What about a website where people can go and store a list of favorites....like the favorites folder, but accessible anywhere. Users would log into their account to access and edit their list. You would have to allow new accounts to be created, possibly setup cookies so that the user can auto-login to the site from thier own computer...they could set it as their homepage. My friend was trying to get to a megatokyo comic today at school, but there were so many, he couldn't find the one he was looking for, but he had it bookmarked at home and a site like this would have fixed that problem. Maybe you could set it up so that you could just import the list of favorites from your browser, thereby avoiding having to type in all the URLs. I think a site of this sort could be very popular because almost everyone has wanted to go to a site on another computer that they had bookmarked on their own computer, but can't remember the URL.
I don't recall what it was called, but Netscape offered something very simular to that several years ago. I'm not sure if they still do.
There was a setting in the Netscape options that allowed you to store your settings and favorites on a network, so a user's multiple computers could share the same set of favorites.
It's still a good idea... Go ahead and burninate the countryside.
Originally posted by Hey15Bob I thought of something today that I'm not sure has ever been done. What about a website where people can go and store a list of favorites....
I used to use a site like this a couple years ago. I quit using it though. It's only really useful if you connect using public computers or have a lot of your own computers.
I go to a school where there are quite a few people quit adept at programming, but I offer this challenge: Write your own programming language. The requirements:
1. An executable parser/compiler
2. A wide array of functions and variables
3. Language should be able to handle a majority of programs that C/C++ can handle
4. Must be able to run on both Linux and Windoze
5. Simple syntax
Maybe the "JL" language could come out of here. Start coding
If you're going to write your own programming language, take a look at flex and bison to help you. Linux Format (in the UK) has been running a great series on creating a programming language for several issues now, and flex and bison are what the author uses.
Registered Linux User #325947
Check out Feather Linux, my distro.
(Yes, it's shameless self promotion, deal with it )