Skip to content

Commit

Permalink
Problems of the day
Browse files Browse the repository at this point in the history
  • Loading branch information
danfimov committed Feb 5, 2021
1 parent 2d50e38 commit ce1ac01
Show file tree
Hide file tree
Showing 21 changed files with 205 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
singleton = ([0, 1, 1, 2, 3, 5, 8, 13, 21],)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type: code
files:
- name: main.py
visible: true
text: |-
# fix the code below
singleton = ([0, 1, 1, 2, 3, 5, 8, 13, 21])
learner_created: false
feedback_link: https://hyperskill.org/learn/step/7470#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Fri, 05 Feb 2021 06:52:15 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 7470
update_date: Sat, 09 Jan 2021 19:43:40 UTC
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<h2>A single-element tuple</h2>
<html>
<head></head>
<body>
<p>Alice tried to define a <code class="java">singleton</code> tuple with the first and only item <code class="java">[0, 1, 1, 2, 3, 5, 8, 13, 21]</code>. Alas, one small detail is missing here. Fix the code Alice wrote.</p>
<p>You are <em>NOT</em> supposed to create a new variable for the tuple or print anything.</p>
</body>
</html><br><br><font color="gray">Memory limit: 256 MB</font><br><font color="gray">Time limit: 15 seconds</font><br><br>
<b>Caution</b><br><br>
You may see errors in your code or execution results due to missing context. Don’t worry about it, just write the solution and press Check.
<br><br>
<a href="https://hyperskill.org/learn/step/7462">Show topic summary</a>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def object_with_beautiful_identity():
for i in range(10_000):
# Change the next line
if id(i) % 1000 == 888:
return i
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
type: code
files:
- name: main.py
visible: true
text: |-
def object_with_beautiful_identity():
for i in range(10_000):
# Change the next line
if ...:
return i
learner_created: false
feedback_link: https://hyperskill.org/learn/step/8084#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Fri, 05 Feb 2021 07:00:15 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 8084
update_date: Mon, 18 Jan 2021 06:58:07 UTC
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<h2>Find beautiful identity</h2>
<html>
<head></head>
<body>
<p>Write a function that returns an object whose identity ends with 888.</p>
<p>Iterate numbers from 0 to 10 000 and check their identity via <code class="java">id()</code> to find a value ending with <code class="java">...888</code>.</p>
<p><button class="btn-sm btn-outline-secondary" onclick="getElementById('hint-279').style.display='inline'"> Hint </button> </p>
<div id="hint-279" style="display:none;">
You can use the
<code class="java">%</code> operator to check the last three digits, i.e
<code class="java">54321 % 1000 = 321</code>
</div>
<p></p>
</body>
</html><br><br><font color="gray">Memory limit: 256 MB</font><br><font color="gray">Time limit: 15 seconds</font><br><br>
<b>Caution</b><br><br>
You may see errors in your code or execution results due to missing context. Don’t worry about it, just write the solution and press Check.
<br><br>
<a href="https://hyperskill.org/learn/step/8077">Show topic summary</a>
4 changes: 4 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Flying high/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name = input()

# Save the identity number of `name` here
id_card = id(name)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
type: code
files:
- name: main.py
visible: true
text: |-
name = input()
# Save the identity number of `name` here
id_card = ...
learner_created: false
feedback_link: https://hyperskill.org/learn/step/8289#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Fri, 05 Feb 2021 06:58:51 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 8289
update_date: Fri, 21 Aug 2020 18:18:16 UTC
12 changes: 12 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Flying high/task.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<h2>Flying high</h2>
<html>
<head></head>
<body>
<p>It's time for fantastic adventures! You are going to another planet on a giant spaceship. Each large ship needs a large crew, so there's no chance of knowing everyone in person.</p>
<p>Help the captain to identify the crew. Read a person's name from the input and find the identity integer.</p>
</body>
</html><br><br><font color="gray">Memory limit: 256 MB</font><br><font color="gray">Time limit: 15 seconds</font><br><br>
<b>Caution</b><br><br>
You may see errors in your code or execution results due to missing context. Don’t worry about it, just write the solution and press Check.
<br><br>
<a href="https://hyperskill.org/learn/step/8077">Show topic summary</a>
7 changes: 7 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Nested/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
for key in children.keys():
if key == 'Emily':
children[key] = {'profession': 'artist', 'age': 5}
elif key == 'Adam':
children[key] = {'profession': 'astronaut', 'age': 9}
else:
children[key] = {'profession': 'programmer', 'age': 14}
12 changes: 12 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Nested/task-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
type: code
files:
- name: main.py
visible: true
text: '# please work with the variable children'
learner_created: false
feedback_link: https://hyperskill.org/learn/step/9146#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Fri, 05 Feb 2021 06:41:22 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 9146
update_date: Thu, 16 Jul 2020 08:20:21 UTC
15 changes: 15 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Nested/task.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<h2>Nested</h2>
<html>
<head></head>
<body>
<p>Imagine, there are three children in a family and they wrote down what they want to be when they grow up:</p>
<pre><code class="language-python">children = {'Emily': 'artist', 'Adam': 'astronaut', 'Nancy': 'programmer'}</code></pre>
<p>Let's say you want to store not only the profession they have chosen, but also their age: Emily is 5, Adam is 9, and Nancy is 14. To do so, you can create nested dictionaries for each key in the outer dictionary.</p>
<p>For each name, create a nested dictionary with the keys <code class="language-python">'profession'</code> and <code class="language-python">'age'</code>, modify the dictionary <code class="language-python">children</code> but don't print it.</p>
<p><strong>NB:</strong> write the age as an integer.</p>
</body>
</html><br><br><font color="gray">Memory limit: 256 MB</font><br><font color="gray">Time limit: 15 seconds</font><br><br>
<b>Caution</b><br><br>
You may see errors in your code or execution results due to missing context. Don’t worry about it, just write the solution and press Check.
<br><br>
<a href="https://hyperskill.org/learn/step/6481">Show topic summary</a>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def print_book_info(title, author=None, year=None):
if author and year:
print(f'"{title}" was written by {author} in {year}')
elif author:
print(f'"{title}" was written by {author}')
elif year:
print(f'"{title}" was written in {year}')
else:
print(f'"{title}"')
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
type: code
files:
- name: main.py
visible: true
text: |-
def print_book_info(title, author=None, year=None):
# Write your code here
pass
learner_created: false
feedback_link: https://hyperskill.org/learn/step/8085#comment
status: Failed
feedback:
message: |
Failed test #2 of 7. Wrong answer
This is a sample test from the problem statement!
Test input:
title: Crime and Punishment
author: None
year: 1866
Correct output:
"Crime and Punishment" was written in 1866
Your code output:
"Crime and Punishment"
time: Fri, 05 Feb 2021 07:04:46 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 8085
update_date: Fri, 08 Jan 2021 06:37:09 UTC
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<h2>Print book info</h2>
<html>
<head></head>
<body>
<p>Your task is to write a function <code class="java">print_book_info(title, author=None, year=None)</code> that prints information about a book. Arguments <code class="java">author</code> and <code class="java">year</code> are optional, so be ready that they might equal to <code class="java">None</code>.</p>
<p>You don't have to read the input. The information about a book will be passed to your function, and it should output it in the right format.</p>
<p>See the samples below to understand the output format.</p>
<p></p>
<div class="alert alert-warning">
The knowledge of
<strong>if-elif-else</strong> statements is expected in this task. If it's not the case, please proceed to the next challenge.
</div>
<p></p>
</body>
</html><br><b>Sample Input:</b><br><pre><code class="language-no-highlight">title: War and Peace<br>author: Leo Tolstoy<br>year: 1869</code></pre><br><b>Sample Output:</b><br><pre><code class="language-no-highlight">"War and Peace" was written by Leo Tolstoy in 1869</code></pre><br><br><b>Sample Input:</b><br><pre><code class="language-no-highlight">title: Crime and Punishment<br>author: None<br>year: 1866</code></pre><br><b>Sample Output:</b><br><pre><code class="language-no-highlight">"Crime and Punishment" was written in 1866</code></pre><br><br><b>Sample Input:</b><br><pre><code class="language-no-highlight">title: The Chronicles of Narnia<br>author: C. S. Lewis<br>year: None</code></pre><br><b>Sample Output:</b><br><pre><code class="language-no-highlight">"The Chronicles of Narnia" was written by C. S. Lewis</code></pre><br><br><b>Sample Input:</b><br><pre><code class="language-no-highlight">title: Harry Potter<br>author: None<br>year: None</code></pre><br><b>Sample Output:</b><br><pre><code class="language-no-highlight">"Harry Potter"</code></pre><br><br><br><font color="gray">Memory limit: 256 MB</font><br><font color="gray">Time limit: 15 seconds</font><br><br>
<b>Caution</b><br><br>
You may see errors in your code or execution results due to missing context. Don’t worry about it, just write the solution and press Check.
<br><br>
<a href="https://hyperskill.org/learn/step/8077">Show topic summary</a>
5 changes: 5 additions & 0 deletions Python Developer/HyperJob Agency/Problems/lesson-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ content:
- How long is that word?
- Incomplete implementation
- Running total
- Nested
- A single-element tuple
- Flying high
- Find beautiful identity
- Print book info

0 comments on commit ce1ac01

Please sign in to comment.