Coding is great, just ask Marty.

Posted by: Parallel on October 30, 2019

Trick or treat

Posted by: Parallel on October 31, 2019

This should be interesting

Posted by: lbishere on October 31, 2019

We did this before and created a team! Was fun and interesting.

Anyone wanting to do it again, I created the team: ContestGirl

Code to join is CG

Once registered you can join the team.

Here's the link. https://coding-challenge.lighthouselabs.ca/teams/join/contestgirl

Posted by: all3y3zonm3 on October 31, 2019

Contest Girl
Captain: cococo

New Member URL: https://coding-challenge.lighthouselabs.ca/teams/join/contest-girl

Posted by: BadGirl on October 31, 2019

So it looks like Marty knows about coding?

Posted by: Scully on November 1, 2019

Week 1 answer:

var volunteers = [
'Sally',
'Jake',
'Brian',
'Hamid'
];

var neighbourhoods = [
'Central Valley',
'Big Mountain',
'Little Bridge',
'Bricktown',
'Brownsville',
"Paul's Boutique",
'Clay Park',
'Fox Nest'
];

console.log(volunteers);

function doorToDoor (p1,p2) {
return p2.length / p1.length;
}

doorToDoor(volunteers,neighbourhoods);

Posted by: bozotheclown on November 1, 2019

thank you so much bozo :)

Posted by: BigSister1 on November 1, 2019

These challenges are so confusing

Posted by: BigSister1 on November 1, 2019

Well that sucks, I created a team first and it seems like most people have gone with Bad Girl's team.


Posted by: all3y3zonm3 on November 1, 2019

What is the team link for Bad Girl's?

Posted by: BigSister1 on November 1, 2019

I'm on the ContestGirl Team, Didn't even see the other one you mentioned all3y3zonm3. I just completed it thanks to bozotheclown !!!! What I don't understand is if the team wins a $500 gift card, how will that be shared?

Posted by: lbishere on November 1, 2019

There are 35 members on the team and BadGirl is listed as on team Contest Girl.

Posted by: lbishere on November 1, 2019

I am not sure if it makes sense for me to just join the other team instead now.

Posted by: all3y3zonm3 on November 1, 2019

all3y3zonm3.. I posted the link for our original Contest Girl team above. It was not a new team. That's why it says COCOA is Captain.

Posted by: BadGirl on November 1, 2019

haha, Sorry, I'm so confused. When was your team created? Was it the last time we participated in this?
Does COCOA stand for something? The team I created says Captain: ALL3Y3ZONM3... not sure what that has to do with anything. What am I missing here?


Posted by: all3y3zonm3 on November 1, 2019

The first team was created when Linda first posted this contest. Prior to her accidentally deleting it. So we just re-posted the original team Link.

Posted by: BadGirl on November 1, 2019

Ahhh! That makes sense now I understand. Thanks for letting me know :)

Posted by: all3y3zonm3 on November 1, 2019

You're welcome :)

Posted by: BadGirl on November 1, 2019

I'm sorry to be so dumb, but do we put in that whole comment as our answer? I really don't get this.

Posted by: kathielu on November 1, 2019

So I joined the team but not sure what I'm suppose to do now


Posted by: kahuna on November 2, 2019

Todays answer:

function interviewAnswer (a) {
if (a == 'economy')
{
return "Time is money.";
}
else if (a =='arts funding')
{
return "We'll have to get creative!";
}
else if (a =='transportation')
{
return "It's going to be a long road, so we better get moving.";
}
else
{
return "I have no comment";
}
}

Posted by: bozotheclown on November 2, 2019

Thanks Bozo

Posted by: zdenoz on November 2, 2019

What is the answer today?

Posted by: BigSister1 on November 3, 2019

Thanks

Posted by: Parallel on November 3, 2019

Watched the video and mess with this for about 1/2 hour. No luck for me. Sorry. New to all this.

Posted by: pansy on November 3, 2019

I am trying this but with no luck
voteTally = votes;

if (name == Tim ) {
voteTally[1] = votes[1] + 1;
}
else if (name == Sally ) {
voteTally[1] = votes[2] + 1;
}
else if (name == Beth ) {
voteTally[1] = votes[1] + 1;
}

Posted by: hibby on November 4, 2019

anyone have ideas?


Posted by: hibby on November 4, 2019

Hey all! If you're still having issues I strongly recommend checking out the 'Discuss' tab. You can find the answers there as well! It really helped me out! Good luck!!!

Posted by: saraYA on November 4, 2019

This works

if (name=='Sally'){
votes[1]=votes[1]+1;
}
if (name=='Tim'){
votes[0]=votes[0]+1;
}
if (name=='Beth'){
votes[2]=votes[2]+1;
}
return votes;


Posted by: mario990 on November 4, 2019

Really appreciate your answers, thank you. However, Challenge 3 is still not working for me. Is there a trick to where or how you paste the copy?

Posted by: jmclou01 on November 4, 2019

The pasted copy should be inside the curly brackets (not after or before) that are given in the default answer. You can press [Test Code] button and check for the error code you get.

Posted by: mario990 on November 4, 2019

This works for #4. (This is definitely not the most simple or the optimum solution. But it works fine).

var index = unregisteredVoters.indexOf(name);
if (index > -1) {
unregisteredVoters.splice(index, 1);
}
return unregisteredVoters;

Posted by: mario990 on November 4, 2019

Thanks Mario :)

Posted by: BigSister1 on November 4, 2019

Must be a real newly to this. Can't even get the copy and paste thing about the brackets?? Any help appreciated?


Posted by: pansy on November 4, 2019

You're the best Mario! Worked for me! Thanks!

Posted by: saraYA on November 4, 2019

can anyone provide the full answer with the before and after parts, accidentally deleted mine. thanks

Posted by: jasonkinnin on November 4, 2019

I accidentally deleted everything too, for #4 try

const registerToVote = (name, unregisteredVoters) => {
var index = unregisteredVoters.indexOf(name);
if (index > -1) {
unregisteredVoters.splice(index, 1);
}
return unregisteredVoters;
}

Posted by: Rianna on November 4, 2019

Sorry to ask again but really trying to understand this and I can't even get the test to run when I drag and drop. Don't understand about the curly brackets before etc that Mario990 was mentioning. Would love to move on to #4 but can't until this works.


Posted by: pansy on November 4, 2019

I am still struggling with 3 as well I think I almost have it but yes now mine is deleted and I cannot remember what was at the top

Posted by: hibby on November 4, 2019

Try
const castVote = (name, votes) => {
As the first line for #3

Posted by: Rianna on November 4, 2019

Pansy. The first and last line of the code are already in the black box where you type the answer. So when you drag and drop Mario's solution it needs to be in between the first line, which I believe should be
const castVote = (name, votes) => {
And the last line that is given is
}

Posted by: Rianna on November 4, 2019

Has anyone been able to get today's I'm struggling. thanks


Posted by: kahuna on November 4, 2019

Rianna thank you so much. I must have typed the various options in dozens of times. I finally decided it was beyond my capabilities. But it is really interesting and I would love to learn so thank you.


Posted by: pansy on November 4, 2019

Did anyone figure out #3 I have tried Mario's and still can't get it to go


Posted by: kahuna on November 4, 2019

kahuna check a few comments back . Rianna helped me and it work. Also good advice for #4 You have to put the answer of Mario's in between the top line of :
const castVote = (name, votes) => {
and the bottom
}
Hope this helps.

Posted by: pansy on November 5, 2019

for people still struggling on number 3
try this
const castVote = (name, votes) => {
if (name=='Sally'){
votes[1]=votes[1]+1;
}
if (name=='Tim'){
votes[0]=votes[0]+1;
}
if (name=='Beth'){
votes[2]=votes[2]+1;
}
return votes;
}

Posted by: hibby on November 5, 2019

Thank you so much that worked


Posted by: kahuna on November 5, 2019

added myself to a group and no clue what to do


Posted by: cassmat on November 5, 2019

Code for day 5

var sels=[];
for( var i = 0; i < stations.length; i++){
if ( stations[i][1] > 19 & (stations[i][2]=="school" | stations[i][2]=="community centre")) {
sels.push(stations[i][0])
}
}
return sels;

Posted by: mario990 on November 5, 2019

Thanks super Mario!

Posted by: jasonkinnin on November 5, 2019

When I try Mario's solution I get errors, am I missing something?


Posted by: kahuna on November 6, 2019

Kahuna, The first and last line of the code are already in the black box where you type the answer. So when you drag and drop Mario's solution it needs to be in between those 2 lines

Posted by: Rianna on November 6, 2019

Code for day 6. (I copied everything together including the default steps)

const voterTurnout = (voter_signatures, voter_ids) => {
// Code here!
if (voter_signatures.length!=voter_ids.length){
return false;
}else{
for( var i = 0; i <=voter_ids.length; i++){
if (voter_ids[i]!=voter_signatures[i]) {
return "FRAUD!";
}
}
return "All clear, we can count the votes!" ;
}
}

Posted by: mario990 on November 6, 2019

For the last solution you can just copy and paste.

Posted by: mario990 on November 6, 2019

ah thanks


Posted by: kahuna on November 6, 2019

Mario, my test couldn't run it says unmatched " { ". What should I do

Posted by: BigSister1 on November 6, 2019

@BigSister1
Are you missing the final curly bracket ?

Posted by: mario990 on November 6, 2019

Code for day 7

const termTopics = (interviews) => {
var vals=[0,0,0];
for(var i=0;i switch(interviews[i]){
case 'smart city':
vals[0]=vals[0]+1;
break;
case 'arts funding':
vals[1]=vals[1]+1;
break;
case 'transportation':
vals[2]=vals[2]+1;
break;
}
}
return vals;
}

Posted by: mario990 on November 7, 2019

didnt work for me, had to modify it a bit:

const termTopics = (interviews) => {
var vals=[0,0,0];
for(var i=0;i <=interviews.length; i++){
switch(interviews[i])
{
case 'smart city':
vals[0]=vals[0]+1;
break;
case 'arts funding':
vals[1]=vals[1]+1;
break;
case 'transportation':
vals[2]=vals[2]+1;
break;
}
}
return vals;
}

Posted by: bozotheclown on November 7, 2019

Thanks very much bozotheclown


Posted by: kahuna on November 7, 2019

Sorry. May be messed up while copying and pasting. "bozotheclown"s answer is correct.

Posted by: mario990 on November 7, 2019

Thank you mario990

Posted by: kahuna on November 7, 2019

No, the final curly line is set on line 12 mario for day 6, I copy and paste everything you did, but line 1 says, unmatched '{ '

Line 1: const voterTurnout = (voter_signatures, voter_ids) => {



Posted by: Bigsister1 on November 8, 2019

Also for day 6, the test couldn't run due to "Reason: voter_signatures is not defined". Someone help me, thanks

Posted by: Bigsister1 on November 8, 2019

Nvm Mario, I got it fixed

Posted by: BigSister1 on November 8, 2019

Day 7

const smartGarbage = (trash, bins) => {
bins[trash]=bins[trash]+1;
return bins;
}


Posted by: mario990 on November 8, 2019

Thanks mario990

Posted by: kahuna on November 8, 2019

Todays
const carPassing = (cars, speed) => {
cars.push({ time: Date.now(), speed: speed });
return cars;
};



Posted by: hibby on November 9, 2019

Is there a way of resetting the workspace if you've made a mistake? I've messed up this last one and cannot get it to run or back to its original state. Failing that, does anyone have the code right from Line 1

Posted by: jmclou01 on November 10, 2019

what challenge are you needing help with jmclou01?

Posted by: hibby on November 10, 2019

Challenge 10

Posted by: jmclou01 on November 11, 2019

Challenge 11:

const busTimes = buses => {
for (var dest in buses){
buses[dest]=(buses[dest].distance/buses[dest].speed)
}
return (buses);
}

Posted by: zdenoz on November 11, 2019

This worked for me for challenge 10
const whereCanIPark = (spots, vehicle) => {
let options = { regular: 'R', small: 'RS', motorcycle: 'RSM' }
for (let i=0; i for (let j=0; j if (options[vehicle].includes(spots[i][j])) {
return [j,i]
}
return false;
}

Posted by: zdenoz on November 11, 2019

zdenoz, your day 10 code doesn't work for me

Posted by: BigSister1 on November 12, 2019

challenge 10
const whereCanIPark = (spots, vehicle) => {
const sizes = {
M: 1,
S: 2,
R: 3
}

const v = vehicle[0].toUpperCase();
for (let i = 0; i < spots.length; i++) {
for (let j = 0; j < spots[i].length; j++) {
const currentSpot = spots[i][j];
if (sizes[currentSpot] && sizes[currentSpot] >= sizes[v])
return [j, i];
}
}
return false;
}

Posted by: hibby on November 12, 2019

sorry I am a little behind on this contest but will try and catch up

Posted by: hibby on November 12, 2019

any idea how this contest works? Does the team with the highest points automatically win or does it just give them a higher chance of winning?

Posted by: SaraYA on November 12, 2019

challenge 12
const checkAir = (samples, threshold)=>{
if ((samples.filter(sample=>sample=='dirty').length/samples.length) return 'Clean'
}else return 'Polluted'
}

Posted by: pansy on November 12, 2019

pansy's did not work for me

so I did one myself

if you have trouble with the one above try this one

const checkAir = (samples, threshold) => {
let dirtyCount = 0;

return samples
.every( sample => {
if (sample !== "dirty") return true;
dirtyCount += 1;
return dirtyCount < threshold * samples.length;
})? "Clean": "Polluted"
}

Posted by: hibby on November 12, 2019

Tried typing the code for day 13. But my comment disappears when I press send in this thread.

Posted by: mario990 on November 13, 2019

const lightsOn = function(lights) {
for(var t of lights){
t.on=true;
}
return lights;
// Code here!
}

const lightsOff = function(lights) {
for(var t of lights){
t.on=false;
}
return lights;
}

const toggleLights = function(lights, lightsAreOn) {
if(lightsAreOn){
return lightsOff(lights);
}else{
return lightsOn(lights);
}
}


Posted by: mario990 on November 13, 2019

14

const dynamicPricing = (numberOfPeople, distanceTraveled) => {
let basePrice = 1 + distanceTraveled*0.25;
return numberOfPeople >= 30 ? $${(0.25 + basePrice).toFixed(2)} : $${basePrice.toFixed(2)};
}

Posted by: hibby on November 14, 2019

How many people are still playing? Just wondering if I should keep putting up codes and if they are useful to anyone

Posted by: hibby on November 14, 2019

They sure are please don't stop


Posted by: kahuna on November 14, 2019

I'm playing and thank you for the codes, because I have no clue how this works.

Posted by: kathielu on November 14, 2019

I am getting an error on line 3


Posted by: kahuna on November 15, 2019

Kahuna try moving the code up and see if it works

Posted by: hibby on November 15, 2019

const dynamicPricing = (numberOfPeople, distanceTraveled) => {
const basePrice = 1;
const chargePerKm = 0.25;
const threshold = 30;
const thresholdAddition = 0.25;

const totalPrice =
basePrice +
chargePerKm * distanceTraveled +
(numberOfPeople >= threshold ? thresholdAddition : 0);

return "$" + totalPrice.toFixed(2);
};

Posted by: hibby on November 15, 2019

sorry the code above is still 14 - incase people are having trouble with the above one I posted they can try this - I have not done 15 yet

Posted by: hibby on November 15, 2019

Code for day 15

const finalPosition = (moves) => {
var ty=[0,0];
for(var th of moves){
switch(th){
case 'west':
ty[0]=ty[0]-1;
break;
case 'east':
ty[0]=ty[0]+1;
break;
case 'south':
ty[1]=ty[1]-1;
break;
case 'north':
ty[1]=ty[1]+1;
break;
}
}
return ty;
}


Posted by: mario990 on November 15, 2019

Day 16.
(This not the perfect code. But it passes all the test cases)

const festivalColours = color1 => {
var vals=[0,0];
vals[0]=Math.abs(color1+150);
vals[1]=Math.abs(color1+210);
return vals;
}

Posted by: mario990 on November 16, 2019

You can try this one too - for #16

const festivalColours = color1 => {
return [color1 + 210, color1 + 150];
}

Posted by: hibby on November 17, 2019

#17

const judgeVegetable = (vegetables, metric) => {
return vegetables.reduce((acc, cv) => cv[metric] > acc[metric] ? cv : acc).submitter;
}

Posted by: hibby on November 17, 2019

I'm stuck again, any one help I really struggle with this I guess coding is just not my thing.

Posted by: kahuna 18 hours ago

what one kahuna?



Posted by: hibby 18 hours ago

#18
const countTickets = (tickets) => {
// Code here!
let obj = {
red:0,green:0,blue:0};
tickets.forEach(e=>{
if(e in obj){
obj[e]++;
}

});
return obj;
}

const bestOdds = (tickets, raffleEntries) => {
// Code here!
let obj = countTickets(tickets);
let oddc = [];
for(let p in raffleEntries)
{
oddc.push([p,obj[p]/raffleEntries[p]]);
}
oddc.sort(function(a, b) {
return b[1] - a[1];
});

return You have the best odds of winning the ${oddc[0][0]} raffle.

}

Posted by: hibby 18 hours ago



** You need to be logged in to add a comment **