diff --git a/editor/animation/init.js b/editor/animation/init.js index fbda18b..acdc733 100644 --- a/editor/animation/init.js +++ b/editor/animation/init.js @@ -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(); } ); diff --git a/editor/initial_code/js_node b/editor/initial_code/_js_node similarity index 100% rename from editor/initial_code/js_node rename to editor/initial_code/_js_node diff --git a/editor/initial_code/python_3 b/editor/initial_code/_python_3 similarity index 100% rename from editor/initial_code/python_3 rename to editor/initial_code/_python_3 diff --git a/editor/initial_code/js_node.tmpl b/editor/initial_code/js_node.tmpl new file mode 100644 index 0000000..d016511 --- /dev/null +++ b/editor/initial_code/js_node.tmpl @@ -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 %} \ No newline at end of file diff --git a/editor/initial_code/python_3.tmpl b/editor/initial_code/python_3.tmpl new file mode 100644 index 0000000..5bbae49 --- /dev/null +++ b/editor/initial_code/python_3.tmpl @@ -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 %} \ No newline at end of file diff --git a/hints/Doppelok.html b/hints/Doppelok.html new file mode 100644 index 0000000..fa15f75 --- /dev/null +++ b/hints/Doppelok.html @@ -0,0 +1,130 @@ + +
+
+ I don't know how to start solving this mission +
+
+ 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. +
+
+
+
+ I need help to continue the mission +
+
+ It will be helpful to read a little information about: + str.split() + (example ), + map() + (example ), and + int() + (example ). +
+
+
+
+ Need help! +
+
+ 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 ":". +
+time = "07:00"
+h, m = map(int, time.split(':'))
+print(h)
+print(m)
+
+# Output:
+# 7
+# 0
+        
+
+
+
+
+ I don't know what to do anymore. I need a little hint. +
+
+ 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. +
+time = "07:00"
+h, m = map(int, time.split(':'))
+angle = 15 * h + m * 0.25 - 90
+        
+
+
+
+
+ Nothing works. SOS +
+
+ 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. +
+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
+        
+
+
+
+
+ I don't want to give up, help! +
+
+ All you have to do is wrap your code in a function, and add our if condition to the return expression. +
+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!"
+        
+
+
+
+
+ I want to be the best of the best PROGRAMMERS!!! SHOW ME MORE SOLUTIONS!!1!!!11! +
+
+ 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. +
+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!"
+        
+
+
+
+
+ I want more! +
+
+ 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. +
+import 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!"
+        
+
+
+ + + diff --git a/info/task_description.html b/info/task_description.html index c847ddd..0f8e8ee 100644 --- a/info/task_description.html +++ b/info/task_description.html @@ -28,15 +28,7 @@

Example:

-{% if interpreter.slug == "js-node" %} -
sunAngle("07:00") == 15
-sunAngle("12:15") == 93.75
-sunAngle("01:23") == "I don't see the sun!"
-{% else %} -
sun_angle("07:00") == 15
-sun_angle("12:15") == 93.75
-sun_angle("01:23") == "I don't see the sun!"
-{% endif %} +
{{init_code_tmpl}}
diff --git a/translations/ja/info/task_description.html b/translations/ja/info/task_description.html index afa4caf..517dd69 100644 --- a/translations/ja/info/task_description.html +++ b/translations/ja/info/task_description.html @@ -28,15 +28,7 @@

Example:

-{% if interpreter.slug == "js-node" %} -
sunAngle("07:00") == 15
-sunAngle("12:15"] == 93.75
-sunAngle("01:23") == "I don't see the sun!"
-{% else %} -
sun_angle("07:00") == 15
-sun_angle("12:15"] == 93.75
-sun_angle("01:23") == "I don't see the sun!"
-{% endif %} +
{{init_code_tmpl}}
diff --git a/translations/ru/info/task_description.html b/translations/ru/info/task_description.html index eb763bf..7dea810 100644 --- a/translations/ru/info/task_description.html +++ b/translations/ru/info/task_description.html @@ -28,15 +28,7 @@

Пример:

-{% if interpreter.slug == "js-node" %} -
sunAngle("07:00") == 15
-sunAngle("12:15"] == 93.75
-sunAngle("01:23") == "I don't see the sun!"
-{% else %} -
sun_angle("07:00") == 15
-sun_angle("12:15"] == 93.75
-sun_angle("01:23") == "I don't see the sun!"
-{% endif %} +
{{init_code_tmpl}}
diff --git a/translations/uk/hints/Doppelok.html b/translations/uk/hints/Doppelok.html new file mode 100644 index 0000000..fe963eb --- /dev/null +++ b/translations/uk/hints/Doppelok.html @@ -0,0 +1,130 @@ + +
+
+ Я не знаю, як розпочати вирішення цієї місії +
+
+ Ідея в тому, щоб знайти відповідність між одною годиною та одним градусом, між одною хвилиною та одним градусом. + Після цього просто розрахуй кут нахилу, враховуючи що 18:00 - це 180 градусів, а 6:00 - це 0 градусів. +
+
+
+
+ Мені потрібна допомога, щоб продовжити місію +
+
+ Тобі буде корисно прочитати трохи інформації про: + str.split() + (приклад ), + map() + (приклад ), та + int() + (приклад ). +
+
+
+
+ Потрібна допомога! +
+
+ Давай розпочнемо з підготовки нашого вхідного рядка перед розрахунком. Ми передамо до змінних "h" та "m" значення + годин і хвилин відповідно, вже конвертовані у цілочисельний тип даних за допомогою функцій map() та int(). + Форма запису через кому "h, m = map(int, ...)" еквівалентна до наступної форми "h = int(...)" та "m = int(...)". + Ми використовуємо функцію int() до кожного елементу списку розділеного рядка використовуючи сепаратор ":". +
+time = "07:00"
+h, m = map(int, time.split(':'))
+print(h)
+print(m)
+
+# Output:
+# 7
+# 0
+        
+
+
+
+
+ Я вже не знаю що робити. Мені потрібна маленька підказка. +
+
+ Перейдемо до формули розрахунку. Години і хвилини співвідносяться до градусів наступним чином: 6 годин = 90 градусів, + отже 90/6 = 15, 1 година - це 15 градусів; 6 годин = 360 хвилин = 90 градусів, отже 90/360 = 0.25, 1 хвилина - це 0.25 градуса. + Враховуючи, що 6:00 це має бути 0 градусів, то при розрахунку нам потрібно це врахувати віднявши 90 від результату. + Формула буде наступною. +
+time = "07:00"
+h, m = map(int, time.split(':'))
+angle = 15 * h + m * 0.25 - 90
+        
+
+
+
+
+ Нічого не працює. SOS +
+
+ Тобі залишилось написати умову if за допомогою якої ти будеш повертати або результат, якщо сонце видно, або + фразу "I don't see the sun!", якщо сонця не видно. Використаємо для цього тернарний оператор. +
+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
+        
+
+
+
+
+ Не хочу здаватись, допоможи! +
+
+ Тобі залишилось тільки обгорнути свій код у функцію, та до виразу return вписати нашу умову if. +
+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!"
+        
+
+
+
+
+ Я хочу бути кращим з кращих ПРОГРАМІСТІВ!!! ПОКАЖИ МЕНІ БІЛЬШЕ РІШЕНЬ!!1!!!11! +
+
+ Добре, добре! Оце настрій!=) + Формула така сама як в нашому рішенні, але замість розділення рядка на складові списку, тут просто використовують + зрізи. +
+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!"
+        
+
+
+
+
+ Я хочу більше! +
+
+ Подивись на цей розв'язок. За допомогою модуля datetime ми можемо виконати наш розрахунок в одиницях виміру часу, + а вже потім перевести значення в одиниці виміру кута. +
+import datetime
+def sun_angle(time):
+    #replace this for solution
+    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!"
+        
+
+
+ + + diff --git a/translations/uk/info/task_description.html b/translations/uk/info/task_description.html new file mode 100644 index 0000000..c4c2f71 --- /dev/null +++ b/translations/uk/info/task_description.html @@ -0,0 +1,50 @@ + + +

+ Кожен справжній мандрівник повинен знати, як зробити 3 речі: розпалити вогонь, знайти воду та отримати корисну + інформацію з природи навколо нього. Програмування не допоможе вам розпалити вогонь або знайти воду, але якщо мова йде про отримання + інформації - це може бути те, що вам потрібно. +

+ +

+ Твоє завдання - знайти кут сонця над горизонтом, знаючи час доби. Вхідні дані: сонце сходить на Сході о 6:00 ранку, + що відповідає куту 0 градусів. О 12:00 дня сонце сягає його зеніту, а це означає, що кут дорівнює 90 градусів. + 18:00 - час заходу сонця, тому кут становить 180 градусів. Якщо на вхід буде передано час ночі (до 6:00 ранку або після 18:00), + твоя функція повинна повертати - "I don't see the sun!". +

+ + +

+ example +

+ + +

+ Вхідні дані: Час доби як рядок. +

+ +

+ Вихідні дані: Кут сонця, округлений до 2 знаків після коми. +

+ + + +
+

+Приклади: +

+
{{init_code_tmpl}}
+
+ + + +

+ Як це використовується: + Одного разу це може врятувати твоє життя, якщо ти загубишся далеко від цивілізації. +

+ + + +

Передумова:
+ 00:00 <= time <= 23:59 +

diff --git a/translations/uk/info/task_short_description.html b/translations/uk/info/task_short_description.html new file mode 100644 index 0000000..5138927 --- /dev/null +++ b/translations/uk/info/task_short_description.html @@ -0,0 +1 @@ +Визнач кут сонця над горизонтом. \ No newline at end of file diff --git a/verification/referee.py b/verification/referee.py index 3288b46..4718a48 100644 --- a/verification/referee.py +++ b/verification/referee.py @@ -1,35 +1,7 @@ -""" -CheckiOReferee is a base referee for checking you code. - arguments: - tests -- the dict contains tests in the specific structure. - You can find an example in tests.py. - cover_code -- is a wrapper for the user function and additional operations before give data - in the user function. You can use some predefined codes from checkio.referee.cover_codes - checker -- is replacement for the default checking of an user function result. If given, then - instead simple "==" will be using the checker function which return tuple with result - (false or true) and some additional info (some message). - You can use some predefined codes from checkio.referee.checkers - add_allowed_modules -- additional module which will be allowed for your task. - add_close_builtins -- some closed builtin words, as example, if you want, you can close "eval" - remove_allowed_modules -- close standard library modules, as example "math" - -checkio.referee.checkers - checkers.float_comparison -- Checking function fabric for check result with float numbers. - Syntax: checkers.float_comparison(digits) -- where "digits" is a quantity of significant - digits after coma. - -checkio.referee.cover_codes - cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this - before user function calling, then using this function. For example: if your test's input - is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2) - cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict. - -""" - from checkio.signals import ON_CONNECT from checkio import api -from checkio.referees.io import CheckiOReferee -from checkio.referees import cover_codes +from checkio.referees.io_template import CheckiOReferee +# from checkio.referees.checkers import to_list from tests import TESTS @@ -37,12 +9,15 @@ ON_CONNECT, CheckiOReferee( tests=TESTS, + # checker=to_list, function_name={ "python": "sun_angle", "js": "sunAngle" }, cover_code={ - #'python-3': cover_codes.unwrap_args, - #'js-node': cover_codes.js_unwrap_args + 'python-3': {}, + 'js-node': { + # "dateForZeros": True, + } } ).on_ready) diff --git a/verification/tests.py b/verification/tests.py index b370cd3..92e467e 100644 --- a/verification/tests.py +++ b/verification/tests.py @@ -11,37 +11,37 @@ TESTS = { "Basics": [ { - "input": '07:00', + "input": ['07:00'], "answer": 15 }, { - "input": '12:15', + "input": ['12:15'], "answer": 93.75 } ], "Extra": [ { - "input": '12:30', + "input": ['12:30'], "answer": 97.5 }, { - "input": '05:55', + "input": ['05:55'], "answer": "I don't see the sun!" }, { - "input": "18:01", + "input": ["18:01"], "answer": "I don't see the sun!" }, { - "input": "23:59", + "input": ["23:59"], "answer": "I don't see the sun!" }, { - "input": "18:00", + "input": ["18:00"], "answer": 180 }, { - "input": "06:00", + "input": ["06:00"], "answer": 0 } ]