# C3\_W2\_Square distance Ex:1

**URL:** <https://community.deeplearning.ai/t/c3-w2-square-distance-ex-1/175908>\
**Category:** Unsupervised Learning, Recommenders, Reinforcement\
**Tags:** week-module-2\
**Created:** [August 2, 2022, 4:36am UTC](https://community.deeplearning.ai/t/c3-w2-square-distance-ex-1/175908 "2022-08-02T04:36:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sujon.buet](https://avatars.discourse-cdn.com/v4/letter/s/c68b51/32.png) [@sujon.buet](https://community.deeplearning.ai/u/sujon.buet)\
**Post date:** [August 2, 2022, 4:36am UTC](https://community.deeplearning.ai/t/c3-w2-square-distance-ex-1/175908/1 "2022-08-02T04:36:38Z")

</div>

After solving the Square distance problem in 3 different ways ,each time I got 50% mark and the following message :Code Cell UNQ\_C2 failed: sq\_dist test 2 failed .  
“If you see many functions being marked as incorrect, try to trace back your steps & identify if there is an incorrect function that is being used in other steps.  
This dependency may be the cause of the errors.”

I think my defining a and b are wrong  
1st time:  
a = np.random.rand(10)  
b = np.random.rand(10)  
d =  
return d

2nd time:  
a= np.array((1,2,3))  
b= np.array((4,5,6))  
d =  
return d  
3rd time:  
Without define a and b I wrote square distance formula with a and b  
since def sq\_dist(a,b):  
so,  
d=  
return d

How can I fix the problem?

---

<div class="post-metadata">

**Author:** ![rmwkwok](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/rmwkwok/32/126977_2.png) [@rmwkwok](https://community.deeplearning.ai/u/rmwkwok)\
**Post date:** [August 2, 2022, 5:42am UTC](https://community.deeplearning.ai/t/c3-w2-square-distance-ex-1/175908/2 "2022-08-02T05:42:55Z")

</div>

Hello @sujon.buet,

When you implement the `sq_dist` function, `a` and `b` are provided as input parameters, so if you had defined them inside your `sq_dist` function, you need to remove them.

Raymond

---

<div class="post-metadata">

**Author:** ![Shayan\_Chakraborty](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@Shayan\_Chakraborty](https://community.deeplearning.ai/u/Shayan_Chakraborty)\
**Post date:** [August 2, 2022, 6:35pm UTC](https://community.deeplearning.ai/t/c3-w2-square-distance-ex-1/175908/3 "2022-08-02T18:35:25Z")

</div>

I’m also not able to solve this any help would be appreciated

---

<div class="post-metadata">

**Author:** ![rmwkwok](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/rmwkwok/32/126977_2.png) [@rmwkwok](https://community.deeplearning.ai/u/rmwkwok)\
**Post date:** [August 2, 2022, 7:35pm UTC](https://community.deeplearning.ai/t/c3-w2-square-distance-ex-1/175908/4 "2022-08-02T19:35:31Z")

</div>

Learner should have solved the problem

> [@C3\_W2\_RecSysNN Assignment Problem](https://community.deeplearning.ai/t/c3-w2-recsysnn-assignment-problem/176364/2):
>
> Hi @Shayan_Chakraborty a and b are inputs for this function. You do not need to implement them inside your function. If you do it like that then your function will always return the same value because you “hard codded” what a and b are. You only need one line of code here to calculate the value of d according to given values of a and b

---

<div class="post-metadata">

**Author:** ![rmwkwok](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/rmwkwok/32/126977_2.png) [@rmwkwok](https://community.deeplearning.ai/u/rmwkwok)\
**Post date:** [August 2, 2022, 7:35pm UTC](https://community.deeplearning.ai/t/c3-w2-square-distance-ex-1/175908/5 "2022-08-02T19:35:48Z")

</div>


