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 7, 2021
1 parent ce1ac01 commit 90b9c01
Show file tree
Hide file tree
Showing 38 changed files with 404 additions and 16 deletions.
9 changes: 9 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Big family/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# The following lines create dictionaries from the input. Do not modify them, please
first_family = json.loads(input())
second_family = json.loads(input())

big_new_family = {}
big_new_family.update(first_family)
big_new_family.update(second_family)

print(big_new_family)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
type: code
files:
- name: main.py
visible: true
text: |-
# The following lines create dictionaries from the input. Do not modify them, please
first_family = json.loads(input())
second_family = json.loads(input())
# Work with the 'first_family' and 'second_family' and create a new dictionary
learner_created: false
feedback_link: https://hyperskill.org/learn/step/11103#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Sun, 07 Feb 2021 07:50:41 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 11103
update_date: Thu, 04 Feb 2021 14:06:57 UTC
16 changes: 16 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Big family/task.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<h2>Big family</h2>
<html>
<head></head>
<body>
<p>Let's say it's a wedding day, and two happy people are getting married. </p>
<p>We have a dictionary <code class="language-python">first_family</code>, which contains the names of the wife's family members. For example: </p>
<pre><code class="language-python">first_family = {"wife": "Janet", "wife's mother": "Katie", "wife's father": "George"}</code></pre>
<p>And a similar dictionary <code class="language-python">second_family</code> for the husband's family:</p>
<pre><code class="language-python">second_family = {"husband": "Leon", "husband's mother": "Eva", "husband's father": "Gaspard", "husband's sister": "Isabelle"}</code></pre>
<p>Create a new dictionary that would contain information about the big new family. Similarly with the ones above, family members should be keys and their names should be values. First, update the new dictionary with elements from <code class="language-python">first_family</code> and then from <code class="language-python">second_family</code>. <strong>Print</strong> it out.</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/9008">Show topic summary</a>
5 changes: 5 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Black box/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# use the function blackbox(lst) that is already defined
lst = [1, 2, 3]


print('modifies' if id(blackbox(lst)) == id(lst) else 'new')
12 changes: 12 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Black box/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: '# use the function blackbox(lst) that is already defined'
learner_created: false
feedback_link: https://hyperskill.org/learn/step/9267#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Sun, 07 Feb 2021 09:30:53 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 9267
update_date: Tue, 05 Jan 2021 02:08:36 UTC
18 changes: 18 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Black box/task.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<h2>Black box</h2>
<html>
<head></head>
<body>
<p>There's a function <code class="java">blackbox(lst)</code> that takes a list, does some magic, and returns a list. You don't know if it modifies the given list or creates a completely different one. Find this out and print <code class="java">"modifies"</code> if the function changes the given list or <code class="java">"new"</code> if the returned list is not connected to the initial one.</p>
<p>Remember to define your list. Content is not important.</p>
<p><button class="btn-sm btn-outline-secondary" onclick="getElementById('hint-475').style.display='inline'"> Hint </button> </p>
<div id="hint-475" style="display:none;">
You should create your own list, then call the
<code class="java">blackbox()</code> function on it to get the second list, and finally compare the two lists.
</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/9262">Show topic summary</a>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# squares = {1: 1, 3: 9, 5: 25, 6: 36, 8: 64, 10: 100, 11: 121, 15: 225}

user_input = int(input())
try:
print(squares[user_input])
del squares[user_input]
except Exception:
print('There is no such key')
print(squares)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type: code
files:
- name: main.py
visible: true
learner_created: false
feedback_link: https://hyperskill.org/learn/step/11100#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Sun, 07 Feb 2021 07:57:05 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 11100
update_date: Fri, 05 Feb 2021 16:51:18 UTC
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<h2>Delete from squares</h2>
<html>
<head></head>
<body>
<p>We have a dictionary <code class="language-python">squares</code> which contains numbers as keys and their squares as values. It looks like this:</p>
<pre><code class="language-python">squares = {1: 1, 3: 9, 5: 25, ...}</code></pre>
<p>Your task is to read the input as a key that needs to be <em>deleted</em> from the dictionary and <em>print</em> the value of this key. If the number read from the input <em>does not exist</em> in the dictionary, then you need to <em>print</em> <code class="language-python">There is no such key</code>. Finally, <em>print</em> the <code class="language-python">squares</code> dictionary on the next line after all the changes.</p>
<p>The dictionary <code class="language-python">squares</code> is already defined for you.</p>
</body>
</html><br><b>Sample Input:</b><br><pre><code class="language-no-highlight">4</code></pre><br><b>Sample Output:</b><br><pre><code class="language-no-highlight">There is no such key<br>{1: 1, 3: 9, 5: 25, 6: 36, 8: 64, 10: 100, 11: 121, 15: 225}</code></pre><br><br><b>Sample Input:</b><br><pre><code class="language-no-highlight">3</code></pre><br><b>Sample Output:</b><br><pre><code class="language-no-highlight">9<br>{1: 1, 5: 25, 6: 36, 8: 64, 10: 100, 11: 121, 15: 225}</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/9008">Show topic summary</a>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sidekicks = {'Don Quixote': 'Sancho Panza', 'Batman': 'Robin', 'Holmes': 'Watson'}
print('Sancho Panza' not in sidekicks)
print('Batman' in sidekicks)
print('Han Solo' not in sidekicks)
print('' not in sidekicks)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
type: code
files:
- name: main.py
visible: true
text: |-
sidekicks = {'Don Quixote': 'Sancho Panza', 'Batman': 'Robin', 'Holmes': 'Watson'}
print('Sancho Panza' ... sidekicks)
print('Batman' ... sidekicks)
print('Han Solo' ... sidekicks)
print('' ... sidekicks)
learner_created: false
feedback_link: https://hyperskill.org/learn/step/8834#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Sun, 07 Feb 2021 09:16:39 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 8834
update_date: Thu, 15 Oct 2020 07:48:18 UTC
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<h2>Dictionary membership</h2>
<html>
<head></head>
<body>
<p>Replace the dots with membership operators so that the output result would always be <code class="java">True</code>.</p>
</body>
</html><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/11096">Show topic summary</a>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# The following line creates a dictionary from the input. Do not modify it, please
test_dict = json.loads(input())

# Work with the 'test_dict'
print('min:', min(test_dict, key=lambda elem: test_dict[elem]))
print('max:', max(test_dict, key=lambda elem: test_dict[elem]))
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
type: code
files:
- name: main.py
visible: true
text: |-
# The following line creates a dictionary from the input. Do not modify it, please
test_dict = json.loads(input())
# Work with the 'test_dict'
learner_created: false
feedback_link: https://hyperskill.org/learn/step/6490#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Sun, 07 Feb 2021 09:22:09 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 6490
update_date: Thu, 15 Oct 2020 07:47:32 UTC
24 changes: 24 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Extreme Points/task.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<h2>Extreme Points</h2>
<html>
<head></head>
<body>
<p>Write a program that prints keys for the minimum and maximum values of the dictionary.</p>
<p>You are supposed to work with the variable <code class="language-python">test_dict</code> which is a dictionary.</p>
<p>Sample output for the dictionary <code class="language-python">{"a": 43, "b": 1233, "c": 8}</code> should be as follows:</p>
<pre><code class="language-python">min: c
max: b</code></pre>
<p><button class="btn-sm btn-outline-secondary" onclick="getElementById('hint-363').style.display='inline'"> Hint </button> </p>
<div id="hint-363" style="display:none;">
The built-in
<code class="language-python">min()</code> and
<code class="language-python">max()</code> functions have the
<a target="_blank" href="https://docs.python.org/3/library/functions.html#max" rel="noopener noreferrer nofollow">key</a> argument you can use to set the ordering by the dictionary
<em>values</em>.
</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/11096">Show topic summary</a>
2 changes: 2 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Flip/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a = list(map(int, input().split()))
print(*reversed(a))
11 changes: 11 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Flip/task-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type: code
files:
- name: main.py
visible: true
learner_created: false
feedback_link: https://hyperskill.org/learn/step/9466#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Sun, 07 Feb 2021 06:43:44 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 9466
update_date: Thu, 16 Jul 2020 08:20:21 UTC
17 changes: 17 additions & 0 deletions Python Developer/HyperJob Agency/Problems/Flip/task.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<h2>Flip</h2>
<html>
<head></head>
<body>
<p>Let's try to reverse a numeric sequence. Read it from the input and print its numbers in reverse order separated by spaces.</p>
<p><button class="btn-sm btn-outline-secondary" onclick="getElementById('hint-177').style.display='inline'"> Hint </button> </p>
<div id="hint-177" style="display:none;">
You can use slicing
<code class="java">list[::-1]</code> or the method
<code class="java">list.reverse()</code> to invert the order. Notice that the numbers themselves should remain unchanged, for example,
<strong>23</strong> is not the same as
<strong>32</strong>.
</div>
<p></p>
</body>
</html><br><b>Sample Input:</b><br><pre><code class="language-no-highlight">1 22 3</code></pre><br><b>Sample Output:</b><br><pre><code class="language-no-highlight">3 22 1</code></pre><br><br><b>Sample Input:</b><br><pre><code class="language-no-highlight">17 9</code></pre><br><b>Sample Output:</b><br><pre><code class="language-no-highlight">9 17</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/6972">Show topic summary</a>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
numbers = {"first": 1, "second": 2, "third": 3, "fourth": 4}

# print(numbers.get(4))

# print(numbers.get("fourth"))

# print(numbers.popitem())

# print(numbers.get(4, "4"))

# print(numbers.pop())

print(numbers.pop("fourth"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
type: code
files:
- name: main.py
visible: true
text: |-
def merge_arrays(a, b):
# "c" will contain the result of merging arrays "a" and "b"
c = []
# CHECK that "a" or "b" are not empty
while ...:
# CHECK that "b" is empty, or that "a" and "b" are not empty and compare the elements
if ...:
# removing the first element from "a" and adding it to "c"
c.append(a[0])
a.pop(0)
else:
# removing the first element from "b" and adding it to "c"
c.append(b[0])
b.pop(0)
return c
learner_created: false
feedback_link: https://hyperskill.org/learn/step/10658#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Sun, 07 Feb 2021 07:21:10 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 10658
update_date: Tue, 27 Oct 2020 13:12:22 UTC
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<h2>Merge sorted lists</h2>
<html>
<head></head>
<body>
<p>The <code class="java">merge_arrays(a, b)</code> function, which is partly implemented below, takes two sorted lists of integers, merges them into one sorted list, and returns the result. The function should work in the following way: create an empty list <code class="java">c</code> which will store the result; keep finding the smallest remaining element in <code class="java">a</code> and <code class="java">b</code> and moving it to the list <code class="java">c</code>; stop when there are no elements left in <code class="java">a</code> and <code class="java">b</code>.</p>
<p>Your task is to fill in the gaps so that the function works correctly. Note, that during the execution any of the lists <code class="java">a</code> and <code class="java">b</code> can become empty, so handle these cases carefully. Try to use non-boolean values in logical expressions when possible.</p>
<p>Your program shouldn't read any input or call the function, just implement it.</p>
<p><button class="btn-sm btn-outline-secondary" onclick="getElementById('hint-920').style.display='inline'"> Hint </button> </p>
<div id="hint-920" style="display:none;">
The expression in the while loop should check if there are any elements left in
<code class="java">a</code> or
<code class="java">b</code>.
<br> The if statement should check if the next element should be taken from list
<code class="java">a</code>. This happens in two situations:
<p></p>
<ul>
<li>list <code class="java">b</code> is empty;</li>
<li>both lists are not empty and the first element in <code class="java">a</code> is less than the first element in <code class="java">b</code>.</li>
</ul>
<p></p>
</div>
<p></p>
</body>
</html><br><b>Sample Input:</b><br><pre><code class="language-no-highlight">1 2 3<br>2 3 4 4</code></pre><br><b>Sample Output:</b><br><pre><code class="language-no-highlight">1 2 2 3 3 4 4</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/10327">Show topic summary</a>
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,8 @@ files:
pass
learner_created: false
feedback_link: https://hyperskill.org/learn/step/8085#comment
status: Failed
status: Solved
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
message: <html>Correct solution</html>
time: Fri, 05 Feb 2021 07:05:52 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# the list with words from string
# please, do not modify it
some_iterable = input().split()

# use dictionary comprehension to create a new dictionary
print({elem.upper(): elem.lower() for elem in some_iterable})
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
type: code
files:
- name: main.py
visible: true
text: |-
# the list with words from string
# please, do not modify it
some_iterable = input().split()
# use dictionary comprehension to create a new dictionary
learner_created: false
feedback_link: https://hyperskill.org/learn/step/11098#comment
status: Solved
feedback:
message: <html>Correct solution</html>
time: Sun, 07 Feb 2021 09:14:56 UTC
record: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 11098
update_date: Sat, 17 Oct 2020 12:37:48 UTC
Loading

0 comments on commit 90b9c01

Please sign in to comment.