-
Notifications
You must be signed in to change notification settings - Fork 7
next-api #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Doppelok
wants to merge
2
commits into
XanderVi:master
Choose a base branch
from
Doppelok:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
next-api #9
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| 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> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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...буде трохи чистіший код