# \[SOLVED\] Problem with Snowflakes on the ice

**URL:** https://discourse.codecombat.com/t/solved-problem-with-snowflakes-on-the-ice/25198
**Category:** Level Help
**Created:** [November 3, 2020, 5:37pm UTC](https://discourse.codecombat.com/t/solved-problem-with-snowflakes-on-the-ice/25198 "2020-11-03T17:37:37Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Anonym](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/anonym/32/47546_2.png) [@Anonym](https://discourse.codecombat.com/u/Anonym)
#### Post date: [November 3, 2020, 5:37pm UTC](https://discourse.codecombat.com/t/solved-problem-with-snowflakes-on-the-ice/25198/1 "2020-11-03T17:37:37Z")

</div>

Hello!  
The only problem I have here is that my hero can’t draw a flake.  
Here is my code:

```python
# На этот уровне нам понадобится линейный фрактал, как основа для нашей шестиугольной снежинки. Сама снежинка будет состоять из 6 линейных фракталов. Обратись к описанию за инструкцией и изображением желаемого результата.

def degreesToRadians(degrees):
    # Все векторные операции предпочтительнее выполнять в радианах, нежели в градусах.
    return Math.PI / 180 * degrees
    
# Это функция создает линейный фрактал. Вчитайся в код, чтобы понять концепцию рекурсии.
def line(start, end):
    # Для начала нам необходимо получить размер полного вектора, чтобы проверить его на минимальный порог.
    full = Vector.subtract(end, start) 
    distance = full.magnitude()
    if distance < 4:
        # Если ниже порогового размера, то просто построим линию вдоль вектора и закончим (возврат из функции).
        hero.toggleFlowers(False)
        hero.moveXY(start.x, start.y)
        hero.toggleFlowers(True)
        hero.moveXY(end.x, end.y)
        return
        
    # Иначе мы создадим наш фрактал, используя вектор половинной длины.
    half = Vector.divide(full, 2)
    
    # Мы создадим 4 линейных фрактала (старт -> А, А -> В, В -> А, и А -> конец), следовательно, нужно будет рассчитать промежуточные позиции А и В.
    A = Vector.add(half, start)
    
    # Чтобы получить В, необходимо развернуть половину вектора на 90 градусов и умножить на 2/3 (в итоге получится 1/3 полной длины вектора), после прибавить полученный вектор к А.
    rotate = Vector.rotate(half, degreesToRadians(90))
    rotate = Vector.multiply(rotate, 2 / 3)
    B = Vector.add(rotate, A)
    # Теперь просто построй 4 линии, используя функции линий.
    line(start, A)
    line(A, B)
    line(B, A)
    line(A, end)

def flake(start, end):
    # Для создания шестиугольной снежинки нужно создать 6 линейных фракталов, каждый раз поворачивая на 60 градусов.
    side = Vector.subtract(end, start)
    a = start
    b = end
    for i in range(6):
        line(a, b)
        # Чтобы получить следующую грань, необходимо развернуть сторону на 60 градусов.
        side = Vector.rotate(side, degreesToRadians(60))
        # Теперь нужно переназначить `a` и `b` на начальную и конечную точки новой стороны.
        a = side.end
        b = side.start

whiteXs = [Vector(12, 10), Vector(60, 10)]
redXs = [Vector(64, 52), Vector(52, 52)]

# Для построения граней придётся вызывать функции с указанием начального и конечного вектора.
line(whiteXs[0], whiteXs[1])
# Используй объекты `Vector`, простые объекты в данном случае не подойдут.
flake(redXs[0], redXs[1])
# Refresh often to avoid a memory leak and crash (working on it)

```

Here is an error:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/4/d/4d3a5c1771e0e00959a4fc95103d5b321fee5768.jpeg)

---

<div class="post-metadata">

### Author: ![riticmaster9087](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/riticmaster9087/32/15515_2.png) [@riticmaster9087](https://discourse.codecombat.com/u/riticmaster9087)
#### Post date: [November 3, 2020, 6:32pm UTC](https://discourse.codecombat.com/t/solved-problem-with-snowflakes-on-the-ice/25198/2 "2020-11-03T18:32:47Z")

</div>

this may make you sad but I can not read what the error is can you translate?

---

<div class="post-metadata">

### Author: ![Anonym](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/anonym/32/47546_2.png) [@Anonym](https://discourse.codecombat.com/u/Anonym)
#### Post date: [November 3, 2020, 6:44pm UTC](https://discourse.codecombat.com/t/solved-problem-with-snowflakes-on-the-ice/25198/3 "2020-11-03T18:44:17Z")

</div>

TypeError: e is undefined.

---

<div class="post-metadata">

### Author: ![jka2706](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/jka2706/32/13636_2.png) [@jka2706](https://discourse.codecombat.com/u/jka2706)
#### Post date: [November 3, 2020, 8:37pm UTC](https://discourse.codecombat.com/t/solved-problem-with-snowflakes-on-the-ice/25198/4 "2020-11-03T20:37:02Z")

</div>

Hi Anonym,

These two lines are the problem.

> [@Anonym](#):
>
> ```python
> a = side.end
> b = side.start
> 
> ```

Remember that a and b represent the start and end of the second (and third/fourth/fifth/sixth) side. How do you write this in code?

Jenny

---

<div class="post-metadata">

### Author: ![Anonym](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/anonym/32/47546_2.png) [@Anonym](https://discourse.codecombat.com/u/Anonym)
#### Post date: [November 4, 2020, 7:03am UTC](https://discourse.codecombat.com/t/solved-problem-with-snowflakes-on-the-ice/25198/5 "2020-11-04T07:03:35Z")

</div>

I don’t know how to write the start and the end of the Vector: There are Vector.x, Vector.y, and even Vector.z.How to write the start and the end of the Vector?

---

<div class="post-metadata">

### Author: ![jka2706](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/jka2706/32/13636_2.png) [@jka2706](https://discourse.codecombat.com/u/jka2706)
#### Post date: [November 4, 2020, 7:52am UTC](https://discourse.codecombat.com/t/solved-problem-with-snowflakes-on-the-ice/25198/6 "2020-11-04T07:52:29Z")

</div>

So ‘a’ (the start point of the new side) is the end point of the old side. What do you already have that’s the end (remember that you want to use a variable that updates each time)?

For ‘b’, you want to add (Vector.add) two variables to set the new end point of the sides. A hint - both the things you add are variables that you have already defined in your function.

Jenny

---

<div class="post-metadata">

### Author: ![Anonym](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/anonym/32/47546_2.png) [@Anonym](https://discourse.codecombat.com/u/Anonym)
#### Post date: [November 4, 2020, 1:00pm UTC](https://discourse.codecombat.com/t/solved-problem-with-snowflakes-on-the-ice/25198/7 "2020-11-04T13:00:38Z")

</div>

```python
a = b
b = Vector.add(a, side)

```

Is that right?

---

<div class="post-metadata">

### Author: ![jka2706](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/jka2706/32/13636_2.png) [@jka2706](https://discourse.codecombat.com/u/jka2706)
#### Post date: [November 4, 2020, 1:04pm UTC](https://discourse.codecombat.com/t/solved-problem-with-snowflakes-on-the-ice/25198/8 "2020-11-04T13:04:42Z")

</div>

Try it 😁. Does it work?

Jenny

---

<div class="post-metadata">

### Author: ![Anonym](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/anonym/32/47546_2.png) [@Anonym](https://discourse.codecombat.com/u/Anonym)
#### Post date: [November 5, 2020, 7:58pm UTC](https://discourse.codecombat.com/t/solved-problem-with-snowflakes-on-the-ice/25198/9 "2020-11-05T19:58:11Z")

</div>

Yes, it does!Thanks a lot! 😁

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a9445509d1a758c41b5ddcddc8c8e20a5dedb67f.png) [@system](https://discourse.codecombat.com/u/system)
#### Post date: [November 6, 2020, 7:58am UTC](https://discourse.codecombat.com/t/solved-problem-with-snowflakes-on-the-ice/25198/10 "2020-11-06T07:58:23Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
