Skip to content

Commit

Permalink
Adding problem of the day
Browse files Browse the repository at this point in the history
  • Loading branch information
danfimov committed Feb 10, 2021
1 parent f2258ef commit 38f3bef
Show file tree
Hide file tree
Showing 56 changed files with 590 additions and 3 deletions.
8 changes: 8 additions & 0 deletions Python Developer/HyperJob Agency/Problems/10 puppies/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Puppy:
n_puppies = 0 # number of created puppies

def __new__(cls):
if cls.n_puppies <= 9:
cls.n_puppies += 1
return object.__new__(cls)
return None
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
type: code
files:
- name: main.py
visible: true
text: |-
class Puppy:
n_puppies = 0 # number of created puppies
# define __new__
learner_created: false
feedback_link: https://hyperskill.org/learn/step/7145#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Wed, 10 Feb 2021 08:37:54 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 7145
update_date: Fri, 01 Jan 2021 05:36:16 UTC
17 changes: 17 additions & 0 deletions Python Developer/HyperJob Agency/Problems/10 puppies/task.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<h2>10 puppies</h2>
<html>
<head></head>
<body>
<p>You want your program to work in a way that at any given time there can be <strong>no more than</strong> 10 puppies. Define <code class="java">__new__</code> method so that this restriction is placed on the class.</p>
<p><button class="btn-sm btn-outline-secondary" onclick="getElementById('hint-212').style.display='inline'"> Hint </button> </p>
<div id="hint-212" style="display:none;">
Pay attention to the comparison symbols that you use. If there are already 10 puppies (10 instances of the class
<code class="java">Puppy</code>), you should NOT be able to create another one!
</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/7139">Show topic summary</a>
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
id: 12130
update_date: Sat, 23 Jan 2021 10:41:11 UTC
update_date: Wed, 10 Feb 2021 11:39:57 UTC
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ <h2>A little about strings</h2>
<body>
<p>Often programmers face a problem that can be solved by analogy. You are already familiar with the <code class="java">string</code> data type. Now you need to study the relevant section of the <a target="_blank" href="https://docs.python.org/3/tutorial/introduction.html#strings" rel="noopener noreferrer nofollow">documentation about strings</a> to solve this problem. In the documentation you will find the necessary similar examples.</p>
<p>Your task is to correct the code so that the output would be the following:</p>
<pre><code class="language-no-highlight">It isn`t in the section 'D:\some\name_of_file'</code></pre>
<pre><code class="language-no-highlight">It isn`t in the section 'C:\some\name_of_file'</code></pre>
</body>
</html><br><b>Sample Input:</b><br><pre><code class="language-no-highlight"></code></pre><br><b>Sample Output:</b><br><pre><code class="language-no-highlight">It isn`t in the section 'C:\some\name_of_file'</code></pre><br><br><br><font color="gray">Memory limit: 256 MB</font><br><font color="gray">Time limit: 15 seconds</font><br><br>
<a href="https://hyperskill.org/learn/step/12125">Show topic summary</a>
15 changes: 15 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Birdbox/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Animal:
def __init__(self, name):
self.name = name


class Bird(Animal):
pass


class Pigeon(Bird):
pass


class Sparrow(Bird):
pass
12 changes: 12 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Birdbox/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: '# create you classes here'
learner_created: false
feedback_link: https://hyperskill.org/learn/step/7242#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Wed, 10 Feb 2021 15:07:54 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 7242
update_date: Sun, 17 Jan 2021 00:30:14 UTC
15 changes: 15 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Birdbox/task.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<h2>Birdbox</h2>
<html>
<head></head>
<body>
<p>Here's a diagram representing a class hierarchy:</p>
<p style="text-align: center;"><img alt="" src="https://ucarecdn.com/afa4d7b6-4f03-4c6a-9d0f-4cf2e533e297/"></p>
<p>The arrow points from a child class to the parent.</p>
<p>In the code below, create classes that correspond to this graph.</p>
<p>You should define the <code class="java">__init__</code> method in the class <code class="java">Animal</code> with the parameter <code class="java">name</code>. In the <code class="java">__init__</code>, you should create an instance attribute <code class="java">name</code>. In other classes, you don't need to define 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/7235">Show topic summary</a>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# finish the function
def find_the_parent(child):
if issubclass(child, Drinks):
print('Drinks')
elif issubclass(child, Pastry):
print('Pastry')
elif issubclass(child, Sweets):
print('Sweets')
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
type: code
files:
- name: main.py
visible: true
text: |-
# finish the function
def find_the_parent(child):
...
learner_created: false
feedback_link: https://hyperskill.org/learn/step/9324#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Wed, 10 Feb 2021 15:12:52 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 9324
update_date: Sat, 16 Jan 2021 23:15:59 UTC
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<h2>Bittersweet occasion</h2>
<html>
<head></head>
<body>
<p>Mysterious things have happened on the Hogwarts Express! Someone enchanted a food trolley and all the goodies got mixed up on the shelves. While the trolley witch is looking for the culprit, you will place <code class="java">Drinks</code>, <code class="java">Pastry</code> and <code class="java">Sweets</code> on three respective shelves.</p>
<p>These base classes have various children: for example, <code class="java">PumpkinJuice</code> inherits from <code class="java">Drinks</code>. Write a function that finds a parent class for an <strong>unknown class </strong>(not an instance of a class) stored in the variable <code class="java">child</code> and <strong>prints out</strong> the parent's name.</p>
<p>Note: all these classes are already created, you don't need to do that. You only need to work with the <code class="java">child</code>.</p>
<p><button class="btn-sm btn-outline-secondary" onclick="getElementById('hint-827').style.display='inline'"> Hint </button> </p>
<div id="hint-827" style="display:none;">
You can use the
<code class="java">issubclass()</code> function to check if a particular class is the parent class and
<code class="java">class.__name__</code> to print out the name of a class.
</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/7235">Show topic summary</a>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def concat(*args, sep=' '):
return sep.join(args)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type: code
files:
- name: main.py
visible: true
text: |-
def concat():
pass
learner_created: false
feedback_link: https://hyperskill.org/learn/step/9556#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Wed, 10 Feb 2021 06:31:22 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 9556
update_date: Mon, 05 Oct 2020 00:42:23 UTC
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<h2>Concatenation with the separator</h2>
<html>
<head></head>
<body>
<p>Write a <code class="language-python">concat()</code> function that will take an arbitrary number of strings and combine them into one through a separator (the keyword argument <code class="language-python">sep</code>). If no separator is specified, then it should separate the strings by spaces:</p>
<pre><code class="language-python">print(concat("turtle")) # "turtle"
print(concat("cat", "dog")) # "cat dog"
print(concat("a", "b", "c", sep=":")) # "a:b:c"</code></pre>
<p>You do not need to call a function, just implement it.</p>
<p><button class="btn-sm btn-outline-secondary" onclick="getElementById('hint-592').style.display='inline'"> Hint </button> </p>
<div id="hint-592" style="display:none;">
Consider using
<code class="language-python">sep.join(strings)</code> for concatenating arguments from your tuple.
</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/8560">Show topic summary</a>
2 changes: 2 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Cook book/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# call the function `special` here
special(ingredient, **dishes)
12 changes: 12 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Cook book/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: '# call the function `special` here'
learner_created: false
feedback_link: https://hyperskill.org/learn/step/7253#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Wed, 10 Feb 2021 07:24:29 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 7253
update_date: Wed, 02 Dec 2020 08:06:41 UTC
19 changes: 19 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Cook book/task.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<h2>Cook book</h2>
<html>
<head></head>
<body>
<p>There's a predefined function called <code class="java">special</code>, a predefined variable <code class="java">ingredient</code> that contains a string, and a predefined variable <code class="java">dishes</code> that contains a dictionary.</p>
<p>The function <code class="java">special</code> accepts a string with an ingredient name, and then a number of keyword arguments. </p>
<p>Call the function <code class="java">special</code> by means of the variables <code class="java">ingredient</code> and <code class="java">dishes</code>.</p>
<p><button class="btn-sm btn-outline-secondary" onclick="getElementById('hint-461').style.display='inline'"> Hint </button> </p>
<div id="hint-461" style="display:none;">
Mind the order: first, positional arguments, and then the rest. You cannot pass the dictionary without unpacking. What should we do to pass on
<strong>keyword </strong>arguments?
</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/9544">Show topic summary</a>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def final_deposit_amount(*interest, amount=1000):
result = amount
for elem in interest:
result = result * (1 + elem / 100)
return round(result, 2)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type: code
files:
- name: main.py
visible: true
text: |-
def final_deposit_amount(amount=1000, interest):
pass
learner_created: false
feedback_link: https://hyperskill.org/learn/step/9554#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Wed, 10 Feb 2021 06:38:36 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 9554
update_date: Mon, 05 Oct 2020 00:42:23 UTC
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<h2>Jackie's Savings</h2>
<html>
<head></head>
<body>
<p>Jackie earned <strong>€1,000</strong> and now wants to put these savings in the bank for several months. However, he has not yet decided on the exact term for the contribution.</p>
<p>Suppose that the bank that Jackie chose has offers for different amounts of time. The interest rates also change from month to month. So, let's say he decides to put money for three months, and the bank sets interest rates of <strong>5%</strong>, <strong>7%</strong> and <strong>4%</strong>. The actual algorithm will be as follows:</p>
<p>Amount after the first month: €1,000 * 1.05 = €1,050<br> Amount after the second month: €1,050 * 1.07 = €1,123.5<br> Amount after the third month: €1,123.5 * 1.04 = €1,168.44</p>
<p>Thus, the final amount will be equal to <strong>€1,168.44</strong>. Round the value to <strong>two decimal places</strong>!</p>
<p>Your task is to <strong>correct the errors</strong> in the definition of the <code class="java">final_deposit_amount()</code> function and implement it. The function should calculate and <strong>return </strong>the amount of money that Jackie will receive at the end. Note that we use interest rates as positional arguments to the function. We also have a keyword-only argument <code class="java">amount</code>. You do not need to call a function, just implement it.</p>
<p><button class="btn-sm btn-outline-secondary" onclick="getElementById('hint-1348').style.display='inline'"> Hint </button> </p>
<div id="hint-1348" style="display:none;">
Use
<code class="java">round(amount, 2)</code> to get the value you need.
</div>
<p></p>
</body>
</html><br><b>Sample Input:</b><br><pre><code class="language-no-highlight">5 7 4</code></pre><br><b>Sample Output:</b><br><pre><code class="language-no-highlight">1168.44</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/8560">Show topic summary</a>
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
id: 11104
update_date: Sat, 16 Jan 2021 15:21:55 UTC
update_date: Wed, 10 Feb 2021 17:30:05 UTC
14 changes: 14 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Patients/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Patient:
def __init__(self, name, last_name, age):
self.name = name
self.last_name = last_name
self.age = age

def __str__(self):
return f'{self.name} {self.last_name}. {self.age}'

def __repr__(self):
return f'Object of the class Patient. ' \
f'name: {self.name}, ' \
f'last_name: {self.last_name}, ' \
f'age: {self.age}'
19 changes: 19 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Patients/task-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
type: code
files:
- name: main.py
visible: true
text: |-
class Patient:
def __init__(self, name, last_name, age):
self.name = name
self.last_name = last_name
self.age = age
# create methods here
learner_created: false
feedback_link: https://hyperskill.org/learn/step/7146#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Wed, 10 Feb 2021 08:26:35 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 7146
update_date: Fri, 01 Jan 2021 05:33:46 UTC
27 changes: 27 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Patients/task.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<h2>Patients</h2>
<html>
<head></head>
<body>
<p>The class <code class="java">Patient</code> needs both an unambiguous representation for developers and a readable string for users. Here's how they are supposed to look:</p>
<ul>
<li>For developers: <strong>Object of the class Patient. name: {name}, last_name: {last_name}, age: {age}</strong></li>
<li>For users: <strong>{name} {last_name}. {age}</strong></li>
</ul>
<p>For example, for object <code class="java">john = Patient("John", "Doe", 50)</code> these representations would respectively look like this:</p>
<ul>
<li><strong>Object of the class Patient. name: John, last_name: Doe, age: 50</strong></li>
<li><strong>John Doe. 50</strong></li>
</ul>
<p>Create the necessary methods below. Pay attention to spaces and punctuation in the strings.</p>
<p> <button class="btn-sm btn-outline-secondary" onclick="getElementById('hint-747').style.display='inline'"> Hint </button> </p>
<div id="hint-747" style="display:none;">
Unambiguous representation can be defined within
<code class="java">__repr__</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/7139">Show topic summary</a>
3 changes: 3 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Percentage/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def get_percentage(number, ndigits=None):
number *= 100
return str(round(number, ndigits)) + '%'
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type: code
files:
- name: main.py
visible: true
text: |-
def get_percentage():
pass
learner_created: false
feedback_link: https://hyperskill.org/learn/step/9516#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Wed, 10 Feb 2021 06:22:36 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 9516
update_date: Wed, 30 Dec 2020 02:17:25 UTC
Loading

0 comments on commit 38f3bef

Please sign in to comment.