Groups

# Anyone rcognise this type of code?

I think this is computery code.
It is part of a puzzle im trying to solve. anyone more tech savvy than me lend some input?

public class DistanceWalked { int dickDastardly = 11; int dougal = 5; int scooby; int florence = 3; int totalMileage = 0; int offset = 0; const int noOfDays = 4; public void Page_Load(object sender, eventArgs e) { try { int dailyMileage = CalculateDailyMileage(dickDastardly, dougal, scooby, florence); } catch { System.Console.WriteLine("oops!!"); } switch(dailyMileage) { case 19: offset += 3; case 20: offset += 1; case 21: offset += 2; case 22: offset += 2; case 23: offset += 4; case 24: offset += 3; case 25: offset += 4; case 26: offset += 3; case 27: offset += 7; case 28: offset += 6; case 29: offset += 4; case 30: offset += 5; default: offset += 0; } totalMileage = CalculateTotalMileage(dickDastardly, dougal, scooby, florence, offset, noOfDays); System.Console.WriteLine("Total miles walked : " + totalMileage; } private int CalculateDailyMileage(int dist1, int dist2, int dist3, int dist4) { return dist1 + dist2 + dist3 + dist4; } private int CalculateTotalMileage(int dist1, int dist2, int dist3, int dist4, int offset, int noOfDays) { int theTotal = 0; int[] mileage = new int[] { dist1, dist2, dist3, dist4 }; foreach (int i in mileage) { theTotal += i; } theTotal = ((Math.Round(theTotal, 2) * noOfDays) - offset) * noOfDays); return theTotal } }

I need to know:
theTotal
No of bugs in code
offset

?????

Banned

offset = 0

bugs, depends on programming language (id fail you for messy code!)

i think total is 76

im guessing visual basic

It's java. I'm importing it into an IDE so I can read it easier, then I should be able to give some answers.

Edit: Nope, it's not java.

Edit2: I'm pretty certain its C# (C Sharp)

Original Poster

im glad you guys seem to have ideas because i dont!

Seems a bit incomplete, is that definitely all the code?

offset=3
totalmileage = 292

not sure which language

It's C#

are we doing your homework for you?

Original Poster

Yep that is all the code there is.

Its part of a puzzle so its meant to have errors in it or whatever, i just wasn't sure what i was looking at.
Any idea for the number of bugs? :P

cheers so far guys you are super awesome!

Original Poster

wobinb;8535646

are we doing your homework for you?

hahaha, I'm a teacher, so no. :P
it's a puzzle I need the Offset, theTotal and number of bugs so i can plug that into some other numbers to get more numbers :P

If it's C#, which I'm pretty sure it is, there are two errors.

Offset is 3.
Are you sure it's theTotal and not totalMileage that you need? Because theTotal is cleared before the end of the program.

paste it into notepad++ it should flag up all the brackets that are not closed, missing semi colons etc.

The first error is:
System.Console.WriteLine("Total miles walked : " + totalMileage;
should be
System.Console.WriteLine("Total miles walked : " + totalMileage);

And the second is:
return theTotal
should be
return theTotal;

theTotal = ((Math.Round(theTotal, 2) * noOfDays) - offset) * noOfDays);

is missing an open bracket

Original Poster

InfernoZeus;8535753

If it's C#, which I'm pretty sure it is, there are two errors.Offset is … If it's C#, which I'm pretty sure it is, there are two errors.Offset is 3.Are you sure it's theTotal and not totalMileage that you need? Because theTotal is cleared before the end of the program.

The Puzzle is:

N 51° (No of men in cartoon strips + 1). (theTotal * 2) - 6
W 002° (No of Blue Ties + Red Ties - Green Ties) (Sum of digits of Day + Month of strip). (No of bugs in code - offset) (No of bugs in my code !!)

And it uses dilbert strips:
3.29.10 and 3.17.10

as to be honest i have no sodding clue what im looking at or what the errors would be :P

wobinb;8535825

theTotal = ((Math.Round(theTotal, 2) * noOfDays) - offset) * noOfDays);is … theTotal = ((Math.Round(theTotal, 2) * noOfDays) - offset) * noOfDays);is missing an open bracket

Yeh, it is. Oops, 3 errors then.

int[] mileage = new int[] { dist1, dist2, dist3, dist4 };
foreach (int i in mileage) {
theTotal += i;
}

what does this do? add dist1 dist 2 dist3 and dist4?

in which cast theTotal = 19

...which is then multiplied on the next line to give us 276

or even 292!

Original Poster

well (theTotal*2)-6 HAS to be a 3 digit number
so both 292 and 276 are viable :P

Its the bugs i need now :P as you have got the offset down as 3?

wobinb;8535893

...which is then multiplied on the next line to give us 276

I got 292.

(((Math.Round(theTotal, 2) * noOfDays) - offset) * noOfDays)

Math.Round doesn't do anything as theTotal is an integer.
so
((19*4) -3) * 4
= (76 - 3) * 4
= 73 *4 = 292

Edit: too slow

So it seems offset = 3, bugs = 3, total = 292.

Original Poster

InfernoZeus;8535943

I got 292. (((Math.Round(theTotal, 2) * noOfDays) - offset) * … I got 292. (((Math.Round(theTotal, 2) * noOfDays) - offset) * noOfDays)Math.Round doesn't do anything as theTotal is an integer.so((19*4) -3) * 4= (76 - 3) * 4= 73 *4 = 292Edit: too slow :(So it seems offset = 3, bugs = 3, total = 292.

(No of bugs in code - offset) (No of bugs in my code !!)
should be a 3 digit number aswell. the eventual solution gives coordinates so wit should be in the form xx.xxx
Which makes me think the number of bugs is 10,11, or 12

i reckon theres more bugs, i don't like this line:

public void Page_Load(object sender, eventArgs e) {

i don't know anything about c# so cannot say for sure

Original Poster

ive just tried using
3 as an offset and 10,11,12 as bugs to no avail, assuming i have the dilbert bits right.

int scooby;
can you declare an integer without a value?

Original Poster

I need the No of days total as well! any ideas for that one?
Scooby is potentially 3.. im making a rought guess at that, if it does have a value at all i mean.

noofDays in the program is 4, but isn't your puzzle referring to the date of the dilbert cartoon?

Original Poster

Thats what i thought, but having looked at it ive realised it cant be correct as the answer needs to be a single digit, so if it is 4 that gives me the answer 7 which gives me a single digit i need

EDIT: Actually.... It says sum of digits. Is there a day variable that is 2 or 3 digits?