- My Forums
- Tiger Rant
- LSU Recruiting
- SEC Rant
- Saints Talk
- Pelicans Talk
- More Sports Board
- Fantasy Sports
- Golf Board
- Soccer Board
- O-T Lounge
- Tech Board
- Home/Garden Board
- Outdoor Board
- Health/Fitness Board
- Movie/TV Board
- Book Board
- Music Board
- Political Talk
- Money Talk
- Fark Board
- Gaming Board
- Travel Board
- Food/Drink Board
- Ticket Exchange
- TD Help Board
Customize My Forums- View All Forums
- Show Left Links
- Topic Sort Options
- Trending Topics
- Recent Topics
- Active Topics
Started By
Message
Code.org = great site...and I need help on problem #71
Posted on 6/13/14 at 9:59 am
Posted on 6/13/14 at 9:59 am
If you've never been to Code.org and you're looking to get into coding, or at least understand some of it, you should check it out!
There's computer scientists, educators, and celebrities who talk about how coding is important, and when you do exercises, they introduce each section with a practical example of code we use in the real world without even knowing!
If anything, these projects are fun to do...it's like playing a video game. You assemble code by snapping together blocks in the right order to complete each problem. You can view the code you made in real code in a separate panel.
It's fun!
Here's where I'm stuck: I can't seem to get this farmer to do what it's supposed to do. Maybe I didn't flesh out all the commands I should have.
#71
Do you think you know how to make this guy walk the whole field without leaving it and level it by filling holes and removing piles? How few blocks can you do it in?
ETA I can do this we 40 lines of code, if I spell it out for the farmer. But that's not the point of coding....
There's computer scientists, educators, and celebrities who talk about how coding is important, and when you do exercises, they introduce each section with a practical example of code we use in the real world without even knowing!
If anything, these projects are fun to do...it's like playing a video game. You assemble code by snapping together blocks in the right order to complete each problem. You can view the code you made in real code in a separate panel.
It's fun!
Here's where I'm stuck: I can't seem to get this farmer to do what it's supposed to do. Maybe I didn't flesh out all the commands I should have.
#71
Do you think you know how to make this guy walk the whole field without leaving it and level it by filling holes and removing piles? How few blocks can you do it in?
ETA I can do this we 40 lines of code, if I spell it out for the farmer. But that's not the point of coding....
This post was edited on 6/13/14 at 10:08 am
Posted on 6/13/14 at 10:04 am to Pectus
I'm no help but I'm jumping on this bandwagon.
Posted on 6/13/14 at 10:19 am to Pectus
did it with 21 lines the first time and then didn't look at the code and lost it, did it in 24 lines the second time. at least on the first puzzle. kind of fun.
Posted on 6/13/14 at 10:24 am to Doldil
quote:
did it with 21 lines the first time and then didn't look at the code and lost it, did it in 24 lines the second time. at least on the first puzzle. kind of fun.
I just feel like it should be fewer lines.
How did you implement the "while path ahead" block?
Posted on 6/13/14 at 10:31 am to Pectus
There's probably a more efficient way, but that's what I came up with.
(15 lines of code)
This post was edited on 6/13/14 at 10:33 am
Posted on 6/13/14 at 10:32 am to Pectus
It can definitely be fewer lines, I just was being lazy with a couple of move forwards once the first path was done but it was essentially...
while path ahead
.....do 1 time (this defaults to 10 and I changed)
..........move forward
..........dig
while path ahead
.....do 1 time (this defaults to 10 and I changed)
..........move forward
..........dig
Posted on 6/13/14 at 10:35 am to InVolNerable
quote:
There's probably a more efficient way, but that's what I came up with.
Awesome.
Thanks for the pic to go with it.
Seem like you still spelled it out for the farmer, though. I feel like there's an easier way. Maybe they don't want the user to think ahead that much and exploit the blocks they can use, but then why would they let you use any amount?
So far, I think you've devised the shortest way.
This has me thinking...I think we should as admins for a way to make a pane in a post to post code, and make it keep its format and make it easy to copy and paste as well as not screwed up from TD's own coding for posting...and make it only work on the tech board.
Pretty sure there's free lines of code out there for this...
Posted on 6/13/14 at 10:38 am to Pectus
quote:
Seem like you still spelled it out for the farmer, though. I feel like there's an easier way
I don't understand what you mean by this.
Posted on 6/13/14 at 10:41 am to Doldil
quote:quote:
quote:
Seem like you still spelled it out for the farmer, though. I feel like there's an easier way
I don't understand what you mean by this.
I think you can get the farmer to walk all around the plot and do what they need to do to level it without having to tell it to walk this way this many steps and turn.
I feel like there's enough variety in the blocks that using the right commands could have the farmer do their job without having to tell them how many times to do it on each side, basically.
Posted on 6/13/14 at 11:01 am to Pectus
A little longer, but not specific to the field. It moves horizontally then up. Then, if it has nowhere else to go, checks the last plot for a pile/hole.
Still seems verbose though.
This post was edited on 6/13/14 at 11:05 am
Posted on 6/13/14 at 11:06 am to Pectus
last one I did was in 20 lines of code...I hate that once you press play, if it succeeds you can't don anything with your blocks and it just goes on.
Mine latest basically worked like this:
Remove
Turn left
While path ahead - repeat 1 move forward remove
turn right
while path ahead - move forward - if hole - remove
turn right
while path ahead - repeat 1 move forward remove
repeat 2 turn right move forward fill
all movements are based on whether or not there is a path ahead save for the last line which is just the repeat loop.
Mine latest basically worked like this:
Remove
Turn left
While path ahead - repeat 1 move forward remove
turn right
while path ahead - move forward - if hole - remove
turn right
while path ahead - repeat 1 move forward remove
repeat 2 turn right move forward fill
all movements are based on whether or not there is a path ahead save for the last line which is just the repeat loop.
Posted on 6/13/14 at 11:12 am to InVolNerable
That's it! It is hefty, but it's what I envisioned!
Popular
Back to top
Follow TigerDroppings for LSU Football News