Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions editor/animation/init.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
//Dont change it
//Dont change it
requirejs(['ext_editor_io', 'jquery_190'],
requirejs(['ext_editor_io2', 'jquery_190'],
function (extIO, $) {

var $tryit;

var io = new extIO({
multipleArguments: false,
functions: {
python: 'sun_angle',
js: 'sunAngle'
}
});
var io = new extIO({});
io.start();
}
);
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions editor/initial_code/js_node.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% comment %}New initial code template{% endcomment %}
{% block env %}import assert from "assert";{% endblock env %}

{% block start %}
function sunAngle(dayTime: string): string | number {
// your code here
return dayTime;
}
{% endblock start %}

{% block example %}
console.log('Example:');
console.log(sunAngle("07:00"))
{% endblock %}

// These "asserts" are used for self-checking
{% block tests %}
{% for t in tests %}
assert.strictEqual({% block call %}sunAngle({{t.input|j_args}})
{% endblock %}, {% block result %}{{t.answer|j}}{% endblock %});{% endfor %}
{% endblock %}

{% block final %}
console.log("Coding complete? Click 'Check Solution' to earn rewards!");
{% endblock final %}
23 changes: 23 additions & 0 deletions editor/initial_code/python_3.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% comment %}New initial code template{% endcomment %}
{% block env %}from typing import Union{% endblock env %}

{% block start %}
def sun_angle(time: str) -> Union[float, str]:
# replace this for solution
return time
{% endblock start %}

{% block example %}
print('Example:')
print(sun_angle("07:00"))
{% endblock %}

{% block tests %}
{% for t in tests %}
assert {% block call %}sun_angle({{t.input|p_args}})
{% endblock %} == {% block result %}{{t.answer|p}}{% endblock %}{% endfor %}
{% endblock %}

{% block final %}
print("The mission is done! Click 'Check Solution' to earn rewards!")
{% endblock final %}
130 changes: 130 additions & 0 deletions hints/Doppelok.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<body data-author="Doppelok">
<div class="question-answer">
<div class="question">
I don't know how to start solving this mission
</div>
<div class="answer">
The idea is to find the correspondence between one hour and one degree, between one minute and one degree.
After that, just calculate the angle of inclination, taking into account that 18:00 is 180 degrees, and 6:00 is 0 degrees.
</div>
</div>
<div class="question-answer">
<div class="question">
I need help to continue the mission
</div>
<div class="answer">
It will be helpful to read a little information about:
<a href='https://docs.python.org/3.10/library/stdtypes.html'>str.split()</a>
(<a href='https://www.w3schools.com/python/ref_string_split.asp'>example</a> ),
<a href='https://docs.python.org/3.10/library/functions.html?#map'>map()</a>
(<a href='https://www.w3schools.com/python/ref_func_map.asp'>example</a> ), and
<a href='https://docs.python.org/3.10/library/functions.html?#int'>int()</a>
(<a href='https://www.w3schools.com/python/ref_func_int.asp'>example</a> ).
</div>
</div>
<div class="question-answer">
<div class="question">
Need help!
</div>
<div class="answer">
Let's start with the preparation of our input line before calculation. We will transfer to the variables "h"
and "m" the values of hours and minutes, respectively, already converted to the integer data type using
the map() and int() functions. The form of recording through coma "h, m = map(int, ...)" is equivalent
to the next form "h = int(...)" and "m = int(...)". We use the int() function to each item of the split
line using the separator ":".
<pre class="brush: python">
time = "07:00"
h, m = map(int, time.split(':'))
print(h)
print(m)

# Output:
# 7
# 0
</pre>
</div>
</div>
<div class="question-answer">
<div class="question">
I don't know what to do anymore. I need a little hint.
</div>
<div class="answer">
Let's move on to the calculation formula. Hours and minutes correlate to degrees as follows: 6 hours = 90
degrees, so 90/6 = 15, 1 hour is 15 degrees; 6 hours = 360 minutes = 90 degrees, so 90/360 = 0.25, 1 minute
is 0.25 degrees. 6:00 = 0 degrees, then when calculating, we need to take it into
account by taking away 90 from the result. The formula will be as follows.
<pre class="brush: python">
time = "07:00"
h, m = map(int, time.split(':'))
angle = 15 * h + m * 0.25 - 90
</pre>
</div>
</div>
<div class="question-answer">
<div class="question">
Nothing works. SOS
</div>
<div class="answer">
You have to write the condition of if you will return either the result, if the sun is visible,
or the phrase "I don See the sun!", If the sun is not visible. We use the ternary operator for this purpose.
<pre class="brush: python">
time = "07:00"
h, m = map(int, time.split(':'))
angle = 15 * h + m * 0.25 - 90
print(angle) if 0 <= angle <= 180 else print("I don't see the sun!")

# Output:
# 15.0
</pre>
</div>
</div>
<div class="question-answer">
<div class="question">
I don't want to give up, help!
</div>
<div class="answer">
All you have to do is wrap your code in a function, and add our if condition to the return expression.
<pre class="brush: python">
def sun_angle(time: str) -> Union[float, str]:
h, m = map(int, time.split(':'))
angle = 15 * h + m * 0.25 - 90
return angle if 0 <= angle <= 180 else "I don't see the sun!"
</pre>
</div>
</div>
<div class="question-answer">
<div class="question">
I want to be the best of the best PROGRAMMERS!!! SHOW ME MORE SOLUTIONS!!1!!!11!
</div>
<div class="answer">
Okay, okay! That's the spirit!=)
The formula is the same as in our decision, but instead of dividing the line into components of the list, it is simply used
slicing.
<pre class="brush: python">
def sun_angle(time):
t = int(time[:2]) * 15 + int(time[3:]) / 4 - 90
return t if 0 <= t <= 180 else "I don't see the sun!"
</pre>
</div>
</div>
<div class="question-answer">
<div class="question">
I want more!
</div>
<div class="answer">
Look at this solution. With the help of the datetime module, we can perform our calculation in time units,
and only then translate the value into angle units.
<pre class="brush: python">
import datetime

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можна написати один раз from datetime import datetime і тоді далі не треба буде двічі писати datetime.datetime...буде трохи чистіший код

def sun_angle(time):
start=datetime.datetime.strptime("06:00","%H:%M")
end=datetime.datetime.strptime("18:00","%H:%M")
time=datetime.datetime.strptime(time,"%H:%M")
diff=(time-start).seconds/60*0.25
return diff if start<=time<=end else "I don't see the sun!"
</pre>
</div>
</div>


</body>
10 changes: 1 addition & 9 deletions info/task_description.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,7 @@
<p>
<strong>Example:</strong>
</p>
{% if interpreter.slug == "js-node" %}
<pre class="brush: javascript">sunAngle("07:00") == 15
sunAngle("12:15") == 93.75
sunAngle("01:23") == "I don't see the sun!"</pre>
{% else %}
<pre class="brush: python">sun_angle("07:00") == 15
sun_angle("12:15") == 93.75
sun_angle("01:23") == "I don't see the sun!"</pre>
{% endif %}
<pre class="brush: {% if is_js %}javascript{% else %}python{% endif %}">{{init_code_tmpl}}</pre>
</div>

<!-- Here you can explain how it can be used in development and what is usage of this. -->
Expand Down
10 changes: 1 addition & 9 deletions translations/ja/info/task_description.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,7 @@
<p>
<strong>Example:</strong>
</p>
{% if interpreter.slug == "js-node" %}
<pre class="brush: javascript">sunAngle("07:00") == 15
sunAngle("12:15"] == 93.75
sunAngle("01:23") == "I don't see the sun!"</pre>
{% else %}
<pre class="brush: python">sun_angle("07:00") == 15
sun_angle("12:15"] == 93.75
sun_angle("01:23") == "I don't see the sun!"</pre>
{% endif %}
<pre class="brush: {% if is_js %}javascript{% else %}python{% endif %}">{{init_code_tmpl}}</pre>
</div>

<!-- Here you can explain how it can be used in development and what is usage of this. -->
Expand Down
10 changes: 1 addition & 9 deletions translations/ru/info/task_description.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,7 @@
<p>
<strong>Пример:</strong>
</p>
{% if interpreter.slug == "js-node" %}
<pre class="brush: javascript">sunAngle("07:00") == 15
sunAngle("12:15"] == 93.75
sunAngle("01:23") == "I don't see the sun!"</pre>
{% else %}
<pre class="brush: python">sun_angle("07:00") == 15
sun_angle("12:15"] == 93.75
sun_angle("01:23") == "I don't see the sun!"</pre>
{% endif %}
<pre class="brush: {% if is_js %}javascript{% else %}python{% endif %}">{{init_code_tmpl}}</pre>
</div>

<!-- Here you can explain how it can be used in development and what is usage of this. -->
Expand Down
130 changes: 130 additions & 0 deletions translations/uk/hints/Doppelok.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<body data-author="Doppelok">
<div class="question-answer">
<div class="question">
Я не знаю, як розпочати вирішення цієї місії
</div>
<div class="answer">
Ідея в тому, щоб знайти відповідність між одною годиною та одним градусом, між одною хвилиною та одним градусом.
Після цього просто розрахуй кут нахилу, враховуючи що 18:00 - це 180 градусів, а 6:00 - це 0 градусів.
</div>
</div>
<div class="question-answer">
<div class="question">
Мені потрібна допомога, щоб продовжити місію
</div>
<div class="answer">
Тобі буде корисно прочитати трохи інформації про:
<a href='https://docs.python.org/3.10/library/stdtypes.html'>str.split()</a>
(<a href='https://www.w3schools.com/python/ref_string_split.asp'>приклад</a> ),
<a href='https://docs.python.org/3.10/library/functions.html?#map'>map()</a>
(<a href='https://www.w3schools.com/python/ref_func_map.asp'>приклад</a> ), та
<a href='https://docs.python.org/3.10/library/functions.html?#int'>int()</a>
(<a href='https://www.w3schools.com/python/ref_func_int.asp'>приклад</a> ).
</div>
</div>
<div class="question-answer">
<div class="question">
Потрібна допомога!
</div>
<div class="answer">
Давай розпочнемо з підготовки нашого вхідного рядка перед розрахунком. Ми передамо до змінних "h" та "m" значення
годин і хвилин відповідно, вже конвертовані у цілочисельний тип даних за допомогою функцій map() та int().
Форма запису через кому "h, m = map(int, ...)" еквівалентна до наступної форми "h = int(...)" та "m = int(...)".
Ми використовуємо функцію int() до кожного елементу списку розділеного рядка використовуючи сепаратор ":".
<pre class="brush: python">
time = "07:00"
h, m = map(int, time.split(':'))
print(h)
print(m)

# Output:
# 7
# 0
</pre>
</div>
</div>
<div class="question-answer">
<div class="question">
Я вже не знаю що робити. Мені потрібна маленька підказка.
</div>
<div class="answer">
Перейдемо до формули розрахунку. Години і хвилини співвідносяться до градусів наступним чином: 6 годин = 90 градусів,
отже 90/6 = 15, 1 година - це 15 градусів; 6 годин = 360 хвилин = 90 градусів, отже 90/360 = 0.25, 1 хвилина - це 0.25 градуса.
Враховуючи, що 6:00 це має бути 0 градусів, то при розрахунку нам потрібно це врахувати віднявши 90 від результату.
Формула буде наступною.
<pre class="brush: python">
time = "07:00"
h, m = map(int, time.split(':'))
angle = 15 * h + m * 0.25 - 90
</pre>
</div>
</div>
<div class="question-answer">
<div class="question">
Нічого не працює. SOS
</div>
<div class="answer">
Тобі залишилось написати умову if за допомогою якої ти будеш повертати або результат, якщо сонце видно, або
фразу "I don't see the sun!", якщо сонця не видно. Використаємо для цього тернарний оператор.
<pre class="brush: python">
time = "07:00"
h, m = map(int, time.split(':'))
angle = 15 * h + m * 0.25 - 90
print(angle) if 0 <= angle <= 180 else print("I don't see the sun!")

# Output:
# 15.0
</pre>
</div>
</div>
<div class="question-answer">
<div class="question">
Не хочу здаватись, допоможи!
</div>
<div class="answer">
Тобі залишилось тільки обгорнути свій код у функцію, та до виразу return вписати нашу умову if.
<pre class="brush: python">
def sun_angle(time: str) -> Union[float, str]:
h, m = map(int, time.split(':'))
angle = 15 * h + m * 0.25 - 90
return angle if 0 <= angle <= 180 else "I don't see the sun!"
</pre>
</div>
</div>
<div class="question-answer">
<div class="question">
Я хочу бути кращим з кращих ПРОГРАМІСТІВ!!! ПОКАЖИ МЕНІ БІЛЬШЕ РІШЕНЬ!!1!!!11!
</div>
<div class="answer">
Добре, добре! Оце настрій!=)
Формула така сама як в нашому рішенні, але замість розділення рядка на складові списку, тут просто використовують
зрізи.
<pre class="brush: python">
def sun_angle(time):
t = int(time[:2]) * 15 + int(time[3:]) / 4 - 90
return t if 0 <= t <= 180 else "I don't see the sun!"
</pre>
</div>
</div>
<div class="question-answer">
<div class="question">
Я хочу більше!
</div>
<div class="answer">
Подивись на цей розв'язок. За допомогою модуля datetime ми можемо виконати наш розрахунок в одиницях виміру часу,
а вже потім перевести значення в одиниці виміру кута.
<pre class="brush: python">
import datetime
def sun_angle(time):
#replace this for solution

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зайве

start=datetime.datetime.strptime("06:00","%H:%M")
end=datetime.datetime.strptime("18:00","%H:%M")
time=datetime.datetime.strptime(time,"%H:%M")
diff=(time-start).seconds/60*0.25
return diff if start<=time<=end else "I don't see the sun!"
</pre>
</div>
</div>


</body>
Loading