Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 282 283 [284] 285 286 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 907366 times)

Mini

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4245 on: March 20, 2013, 12:49:08 am »

If you posted your code then we'd be able to help a lot more effectively. Without seeing your code, I can say that it's possible that variable has fallen out of scope when you're trying to use it, maybe.
Logged

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4246 on: March 20, 2013, 12:51:08 am »

Spoiler (click to show/hide)
I'm also getting errors about missing semicolons and stuff. This is not the first time for loops have utterly failed on this computer...

Oh, and the pattern is supposed to look something like this:
Code: [Select]
@@@@@
@@@@5
@@@55
@@555
@5555
« Last Edit: March 20, 2013, 12:58:07 am by Sirus »
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

alexandertnt

  • Bay Watcher
  • (map 'list (lambda (post) (+ post awesome)) posts)
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4247 on: March 20, 2013, 01:17:56 am »

Yes, it is very useful when you are creating a custom collection that you want to be able to optimize at runtime for the efficiency of the task you are performing. You would not want to be stuck using an class that extends LinkedList when you need random read for a specific task and you wouldn't want to be stuck with an array list if another task involved a lot of random inserts and deletes that require shifting a lot of elements. This way you can have a custom collection that uses the collection optimal to whatever your current task is without having multiple different types of collections.

Oops, I meant programming overhead. But the performance too I suppose.

snip

You cannot declare variables in the for loops (the check variable) in C89, only in C99. Try to compile with -std=c99, or declare check outside of the loop like this:

Code: (compiles) [Select]
void patternThree(int option, int size, char symb)
{
//Local variables. i represents characters, j represents integers. lines measures the proper height of the pattern
int lines, i, j;
i = size;
j = 0;
lines = 1;

while(lines != size)
{
//i loop
int check;
for(check = i; check > 0; check--)
printf("%c", symb);

//j loop
for (check = j; check > 0; check--)
printf("%d", size);

printf("/n");
i--;
j++;
lines++;
}
}
Logged
This is when I imagine the hilarity which may happen if certain things are glichy. Such as targeting your own body parts to eat.

You eat your own head
YOU HAVE BEEN STRUCK DOWN!

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4248 on: March 20, 2013, 01:23:20 am »

I tried that too. No matter where I declare check, the program acts as if it doesn't exist. It doesn't make any sense.

EDIT: And now while loops aren't working either. My mainstay before I started getting a handle on for loops, and they fail. Armok, strike me down where I sit.
« Last Edit: March 20, 2013, 01:25:38 am by Sirus »
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #4249 on: March 20, 2013, 02:03:43 am »

What program are you using to program in? O_o

Also, go look up a tutorial :D Computer classes are so slow.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4250 on: March 20, 2013, 02:08:27 am »

Visual Studio 2010. And online tutorials won't give me credits towards a degree.

I managed to mostly get it working eventually, but I had to turn it in unfinished to get it in in time.
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #4251 on: March 20, 2013, 02:28:43 am »

I understood your post as meaning that you're just waiting for other loops that aren't while loops o_O

Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Dutchling

  • Bay Watcher
  • Ridin' with Biden
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4252 on: March 20, 2013, 11:35:51 am »

I'm not sure how to do the following :/
Quote
"Can  you design an algorithm that performs only 3n/2 comparisons to find the smallest and largest numbers in the list?"
2n is easy, but obviously not correct.
Logged

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4253 on: March 20, 2013, 11:50:55 am »

Always read two numbers at a time. Compare them to each other. Only the larger can be the largest number, and only the smaller can be the smallest.
Logged

RedKing

  • Bay Watcher
  • hoo hoo motherfucker
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4254 on: March 20, 2013, 11:56:15 am »

* RedKing reads the answers given for Java question...

o_0
O_o
>_<
x_x
;_;

Question withdrawn. I'll just blame North Korea or something. >_>
Logged

Remember, knowledge is power. The power to make other people feel stupid.
Quote from: Neil DeGrasse Tyson
Science is like an inoculation against charlatans who would have you believe whatever it is they tell you.

Dutchling

  • Bay Watcher
  • Ridin' with Biden
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4255 on: March 20, 2013, 12:16:19 pm »

Always read two numbers at a time. Compare them to each other. Only the larger can be the largest number, and only the smaller can be the smallest.
Thanks :D
Logged

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #4256 on: March 20, 2013, 12:22:30 pm »

* RedKing reads the answers given for Java question...

o_0
O_o
>_<
x_x
;_;

Question withdrawn. I'll just blame North Korea or something. >_>

Well java obviously isn't the best language of you are going to run a half second task once, due to the overhead of starting the VM. You could use python and get the answer in 3 or 4 seconds.

But if you had a million half second tasks, java can do them in about half a million seconds, less if you they can be done in parallel and you have multiple cpu's. That same python code would take  3 or 4 million seconds.

Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

MadocComadrin

  • Bay Watcher
  • A mysterious laboratory goblin!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4257 on: March 20, 2013, 01:39:40 pm »

Anyone see today's XKCD?
Logged

Dutchling

  • Bay Watcher
  • Ridin' with Biden
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4258 on: March 20, 2013, 01:42:02 pm »

Yes. Please explain. Me no understando.
Logged

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4259 on: March 20, 2013, 02:13:31 pm »

Yes. Please explain. Me no understando.
Well, it's two people taking turns throwing a ball at themselves (not at each other, mind you).

EDIT: Fix'd. Now they properly throw balls at each other.
Code: [Select]
public class Person {
public Ball ball;

public Person(Ball ball) {
this.ball = ball;
}

public void aim() throws Ball {
if (ball == null) return;
Ball temp = ball;
ball = null;
throw temp;
}

public void wave(Person target) {
try {
target.aim();
} catch(Ball ball) {
this.ball = ball;
waitFor(target);
}
}

public void waitFor(Person target) {
target.wave(this);
}

public static void main(String[] args) {
Person parent = new Person(new Ball());
Person child = new Person(null);
child.wave(parent);
}

public static class Ball extends Throwable {
}
}
« Last Edit: March 20, 2013, 02:26:15 pm by MagmaMcFry »
Logged
Pages: 1 ... 282 283 [284] 285 286 ... 796