# Computer Science Principles: Unit 5/Lesson 12 problems

**URL:** <https://forum.code.org/t/computer-science-principles-unit-5-lesson-12-problems/20071>\
**Category:** Website and Tools Questions\
**Created:** [September 22, 2018, 7:35am UTC](https://forum.code.org/t/computer-science-principles-unit-5-lesson-12-problems/20071 "2018-09-22T07:35:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ifidler](https://avatars.discourse-cdn.com/v4/letter/i/a8b319/32.png) [@ifidler](https://forum.code.org/u/ifidler)\
**Post date:** [September 22, 2018, 7:35am UTC](https://forum.code.org/t/computer-science-principles-unit-5-lesson-12-problems/20071/1 "2018-09-22T07:35:19Z")

</div>

Just can’t seem to get successful code created for Unit 5/Lesson 12’s bubble 4. Here’s my code that worked for bubble 3:

var count = 0;  
while (count \<= 9) {  
write(randomNumber(0,1));  
count=count+1;  
}

If anyone has code that works in bubble 4, seeing it would help a bunch!

---

<div class="post-metadata">

**Author:** ![biermanl](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/biermanl/32/2408_2.png) [@biermanl](https://forum.code.org/u/biermanl)\
**Post date:** [September 23, 2018, 7:23pm UTC](https://forum.code.org/t/computer-science-principles-unit-5-lesson-12-problems/20071/2 "2018-09-23T19:23:24Z")

</div>

Hi,

So it looks like you need to check IF your coin flip is a heads or not, and then use that to update a “heads” counter (which will be different from your count variable). Be sure to note that each time you call randomNumber it will produce a new value…so be careful how you set up your check.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![ifidler](https://avatars.discourse-cdn.com/v4/letter/i/a8b319/32.png) [@ifidler](https://forum.code.org/u/ifidler)\
**Post date:** [September 24, 2018, 12:21pm UTC](https://forum.code.org/t/computer-science-principles-unit-5-lesson-12-problems/20071/3 "2018-09-24T12:21:01Z")

</div>

Absolutely … any chance you have the code available? I’ve tried a number of angles on this, but yet to make it run properly

---

<div class="post-metadata">

**Author:** ![gjschmidt](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/gjschmidt/32/4922_2.png) [@gjschmidt](https://forum.code.org/u/gjschmidt)\
**Post date:** [September 24, 2018, 11:35pm UTC](https://forum.code.org/t/computer-science-principles-unit-5-lesson-12-problems/20071/4 "2018-09-24T23:35:30Z")

</div>

@ifidler there is a **_Example Solution_** available in the **Teacher’s Panel**. It should provide the information you need.

---

<div class="post-metadata">

**Author:** ![ifidler](https://avatars.discourse-cdn.com/v4/letter/i/a8b319/32.png) [@ifidler](https://forum.code.org/u/ifidler)\
**Post date:** [September 25, 2018, 1:41pm UTC](https://forum.code.org/t/computer-science-principles-unit-5-lesson-12-problems/20071/7 "2018-09-25T13:41:07Z")

</div>

> [@gjschmidt](#):
>
> Teacher’s Panel

Found it … many thanks!

---

<div class="post-metadata">

**Author:** ![gjschmidt](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/gjschmidt/32/4922_2.png) [@gjschmidt](https://forum.code.org/u/gjschmidt)\
**Post date:** [September 25, 2018, 2:02pm UTC](https://forum.code.org/t/computer-science-principles-unit-5-lesson-12-problems/20071/9 "2018-09-25T14:02:13Z")

</div>

Great! Glad to help. Almost all of the programming assignments have example solutions. I do recommend that teachers “live the student experience” and try and complete the coding on their on own but when in doubt the Example Solutions are there for you.
