Resend my activation email : Register : Log in 
BCF: Bike Chat Forums


Lateral thinking required

Reply to topic
Bike Chat Forums Index -> Random Banter
View previous topic : View next topic  
Author Message

Gazdaman
I did a trackday!!!



Joined: 12 Aug 2004
Karma :

PostPosted: 20:29 - 13 Mar 2006    Post subject: Lateral thinking required Reply with quote

Well, I've come up against a problem in one of my uni modules, they're using a theoretical programming language called "minimum Java"

It uses similar syntax, but knowing Java has nothing to do with it.

Basically, you can only have a while loop, i.e

while (y != 0) {
x = x + 1;
y = y - 1;

}


I've been asked to show that x = y, x = x + y and x = x-y.

I don't even know where to start with those!! If you know this kind of thing, it's very similar to a turing machine.

In a turing machine you'd change 1 thing to another to mark you've already been there.

But I just don't know..

Any suggestions or even vague ideas very much appreciated.

Gaz
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts

Walloper
Super Spammer



Joined: 24 Feb 2005
Karma :

PostPosted: 01:36 - 14 Mar 2006    Post subject: Reply with quote

Eye don't know Y
____________________
W-ireless A-rtificial L-ifeform L-imited to O-bservation P-eacekeeping and E-fficient R-epair
 Back to top
View user's profile Send private message You must be logged in to rate posts

The View Askew
World Chat Champion



Joined: 30 Nov 2005
Karma :

PostPosted: 03:56 - 14 Mar 2006    Post subject: Reply with quote

all=0

It is the ONLY thing that could make sense. piss take Shocked
____________________
"Do what you always did, get what you always got"
 Back to top
View user's profile Send private message You must be logged in to rate posts

Hex
Party Boy



Joined: 04 Feb 2002
Karma :

PostPosted: 09:59 - 14 Mar 2006    Post subject: Reply with quote

Well if you show that x = whatever by the loop ending then it should just be a case of changing the condition on the loop, no?

For example:

x = 0
while (x != y) {
x = x + 1;
}
display x

Of course with y not been declared then you have the problem that it could be a negative number.

Is that the kind of thing your after?

As for showing x = x+y and x=x-y, then surely y can only be 0 as how could x = itself plus or minus anything else?
____________________
The BCF's very own Party boy! Though he's getting old and feeling it!
Monkey hanger, Born and bred
My little photo portfolio
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts

Gazdaman
I did a trackday!!!



Joined: 12 Aug 2004
Karma :

PostPosted: 12:17 - 14 Mar 2006    Post subject: Reply with quote

That's exactly what I thought Hex. But I wasn't sure, and in the documentation I'm pretty sure it states that while (x != 0) { } is the only while statement allowed.

Otherwise I agree, that way makes sense.

We have a /very/ chinese teacher, and hopefully she's neglected to mention we can in fact use x != y.

And thanks to everyone else that replied Rolling Eyes

Gaz
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts

Gazdaman
I did a trackday!!!



Joined: 12 Aug 2004
Karma :

PostPosted: 12:23 - 14 Mar 2006    Post subject: Reply with quote

In fact, I just had a thought.

It says you can't do x =y because that depends on the value of y.

I think what it wants you to do is:

x=0;
z=0;
while ( y != 0 ) {
y--;
x++;
z++;
}

while ( z != 0 ) {
z--;
y++;
}

If I'm correct, I think that should make x and y equal while staying within the rules.

It's all very simple stuff technically, it's just getting your head around the bastard.

Let this be a lesson to you guys! If you're faced with a list of modules to pick for your computing course don't pick "computer science concepts" because it looks interesting. It's hard!

Gaz
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts
Old Thread Alert!

The last post was made 20 years, 105 days ago. Instead of replying here, would creating a new thread be more useful?
  Display posts from previous:   
This page may contain affiliate links, which means we may earn a small commission if a visitor clicks through and makes a purchase. By clicking on an affiliate link, you accept that third-party cookies will be set.

Post new topic   Reply to topic    Bike Chat Forums Index -> Random Banter All times are GMT + 1 Hour
Page 1 of 1

 
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 cannot download files in this forum

Read the Terms of Use! - Powered by phpBB © phpBB Group
 

Debug Mode: ON - Server: birks (www) - Page Generation Time: 0.08 Sec - Server Load: 1.53 - MySQL Queries: 14 - Page Size: 49.67 Kb