Help with Python exercise on Future Engineer site.

boncru -  
 Helper -

Hello everyone,

I am a teacher and I discovered Citizen Code Python on the website (Amazon) www.futureenginer.fr, the format with the creation of a virtual class is interesting for introducing the discovery of (pseudo...) Python.

However, I can't manage to solve (in Python mode) the exercise Season 1 Episode 7: The advertisements in less than 20 lines.

Can you help me please?

Thank you

6 answers

Helper
 

I found it in Python, but I haven't figured out how to do it in Blockly.

from robot import * for x in range(4): # 0, 1, 2, 3     right() for x in range(4): # 1st iteration: 4 - x = 4 - 0 = 4 # 2nd iteration: 4 - x = 4 - 1 = 3 # 3rd iteration: 4 - x = 4 - 2 = 2 # 4th iteration: 4 - x = 4 - 3 = 1     for y in range(3):         pick()         for z in range(4 - x):             right()         drop()         for z in range(4 - x):             left()     left()
5
boncru
 

Here is the statement (see on the site futureengineer.fr S01E07):

"Move the advertising screens to insert an empty column between each of the five columns of screens. I specify that there are 4 rows and 4 columns, with the first 4 not moving, which means 12 screens to move.

Note: the size of your program is limited to 20 blocks."

Here is what I did, there are already 17 blocks (the if function with or without else: takes 4 blocks): the last screens are not in their place:

for loop in range(4): for loop in range(4): right() for loop in range(4): left() if heightColumn() == 3: right() for loop in range(3): take() right() put() left() left() else: pass right()

In just 3 more blocks, I still can't finish, I can only do it in 24 blocks. I've been struggling for 2 weeks, thank you for your help.

1
SugarSnake
 

Hello,

I don't know if you found it since, but here is some help for the solution (I managed it in 17 blocks):

You need to find a way for the movements to the right or left to vary in each round of a loop.

For a loop:

for loop in range(N):

"loop" varies from 0 to N-1, increasing by 1 in each loop iteration.

So in the first move, you need to move 4 spaces, then in the second move, 3 spaces, then in the third move, 2 spaces, and so on.

Start from the last column.

1
Anonymous user
 

Hello

yes, on the condition that these few points are respected https://www.commentcamarche.net/infos/25899-forum-ccm-mode-d-emploi-demander-de-l-aide-pour-un-exercice/


When I was little, the Dead Sea was just sick.
George Burns

0
Anonymous user
 

It will require a bit of context because I did not intend to sign up on this site or complete all the preceding exercises to understand what it's about.

I assume that the functions take, put, right, left, and columnHeight are provided by the game.

What I believe I understand is that the first 4 are used to move a cursor to hold or drop a panel, how do we go up and down with the cursor? And otherwise, what are they for?

Does the columnHeight function return the position of the cursor?

If an if statement takes 4 "blocks", how many blocks does a for loop take? And how many for a simple line?


When I was young, the Dead Sea was only sick.
George Burns

0
mamiemando Posted messages 34250 Registration date   Status Moderator Last intervention   7 902
 

Hello,

As Whismeril says, when you're asking for help, make sure to:

  • present your exercise in a way that we can understand it (just like you would when posing a math problem). Here, the statement is incomprehensible without an image
  • show what you've done
  • explain what's blocking you
  • search with your favorite search engine to see if someone has already answered the question you're asking.

In this case, by searching a bit, we find this video (it seems to resemble what you're describing, but it doesn't appear to be exactly the same exercise).

Good luck

0