Anyone rcognise this type of code? - HotUKDeals
We use cookie files to improve site functionality and personalisation. By continuing to use HotUKDeals, you accept our cookie and privacy policy.
Get the HotUKDeals app free at Google Play

Search Error

An error occurred when searching, please try again!

Login / Sign UpSubmit

Anyone rcognise this type of code?

£0.00 @
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… Read More
Jetpac Avatar
6y, 11m agoPosted 6 years, 11 months ago
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
Jetpac Avatar
6y, 11m agoPosted 6 years, 11 months ago
Options

All Comments

(30) Jump to unreadPost a comment
Comments/page:
#1
?????
banned#2
offset = 0

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

i think total is 76

im guessing visual basic
#3
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)
#4
im glad you guys seem to have ideas because i dont!
#5
Seems a bit incomplete, is that definitely all the code?
#6
offset=3
totalmileage = 292

not sure which language
#7
It's C#
#8
are we doing your homework for you?
#9
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!
#10
wobinb
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
#11
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.
#12
paste it into notepad++ it should flag up all the brackets that are not closed, missing semi colons etc.
#13
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;
#14
theTotal = ((Math.Round(theTotal, 2) * noOfDays) - offset) * noOfDays);

is missing an open bracket
#15
InfernoZeus
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
#16
wobinb
theTotal = ((Math.Round(theTotal, 2) * noOfDays) - offset) * noOfDays);

is missing an open bracket


Yeh, it is. Oops, 3 errors then.
#17
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
#18
...which is then multiplied on the next line to give us 276
#19
or even 292!

its too late to be thinking about this!
#20
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?
#21
wobinb
...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.
#22
InfernoZeus
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.


(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
#23
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
#24
ive just tried using
3 as an offset and 10,11,12 as bugs to no avail, assuming i have the dilbert bits right.
#25
int scooby;
can you declare an integer without a value?
#26
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.
#27
noofDays in the program is 4, but isn't your puzzle referring to the date of the dilbert cartoon?
#28
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?
1 Like #29
time for bed here, your on your own now! good luck
#30
noooo! please say you will come back and help! :P
Rep so far btw :P

Post a Comment

You don't need an account to leave a comment. Just enter your email address. We'll keep it private.

...OR log in with your social account

...OR comment using your social account

Thanks for your comment! Keep it up!
We just need to have a quick look and it will be live soon.
The community is happy to hear your opinion! Keep contributing!