Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit d1011f3

Browse files
committed
fix: clean up Dockerfile to leverage layer caches and solutions
1 parent 28e86b9 commit d1011f3

File tree

6 files changed

+72
-1
lines changed

6 files changed

+72
-1
lines changed

Dockerfile

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ COPY . .
77
RUN apt-get update \
88
&& apt-get install aspell -y
99

10-
RUN apt-get install python3 -y && apt-get install python3-pip -y && apt-get install pipenv -y && ln -s /usr/bin/python3 /usr/bin/python
10+
RUN apt-get install python3 -y && \
11+
apt-get install python3-pip -y && \
12+
apt-get install pipenv -y && \
13+
ln -s /usr/bin/python3 /usr/bin/python
14+
1115
RUN apt-get install ghc -y
1216

1317
RUN pipenv sync --system -d
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
def count_in_order_character_occurence(string_input):
2+
char_count = 0
3+
char_counts =[]
4+
last_char_seen = ""
5+
6+
idx = 0
7+
while(idx < len(string_input)):
8+
last_char_seen = string_input[idx]
9+
while(idx < len(string_input) and string_input[idx] == last_char_seen):
10+
char_count += 1
11+
idx += 1
12+
char_counts.append((last_char_seen, char_count))
13+
char_count = 0
14+
15+
return char_counts
16+
17+
if __name__ == "__main__":
18+
assert count_in_order_character_occurence("aaaabbbcca") == [('a', 4), ('b', 3), ('c', 2), ('a', 1)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from typing import List
2+
"""
3+
Analysis:
4+
N = number of elements in nums list
5+
Time = O(N)
6+
Space = O(N) + O(1) = O(N)
7+
"""
8+
def running_sum(nums: List[int]) -> List[int]:
9+
sums = [0] * len(nums)
10+
last_sum = 0
11+
for i in range(len(nums)):
12+
sums[i] = last_sum + nums[i]
13+
"""
14+
This is the key to O(N) runtime, that is remembering the result of the computation.
15+
Making the next computation, the sum of the previous computation + the new value.
16+
This is consant time.
17+
"""
18+
last_sum = sums[i]
19+
return sums
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def summingSeries(n):
2+
"""
3+
O(N) solution.
4+
This is not good enough, because n can be 10^16, which is too large for a linear time algorith.
5+
"""
6+
series_sum = 0
7+
for i in range(1, n + 1):
8+
series_sum += i**2 - (i -1)**2
9+
print(series_sum)
10+
return series_sum%(10**9 + 7)
11+
12+
13+
14+
if __name__ == "__main__":
15+
print(summingSeries(3))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
from running_sum import running_sum
3+
4+
def test_running_um():
5+
assert running_sum([1,2,3,4]) == [1,3,6,10]

todo.txt

+10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66
- assignments:
77
- exams:
88

9+
- computer programming techniques:
10+
- lectures:
11+
- readings:
12+
- Donald Knuth. 1968. The Art of Computer Programming, Volume 1: Fundamental Algorithms. 1, 2, 3, 4A, and 4B
13+
- https://pabloagn.com/blog/10-advanced-programming-techniques/
14+
- assignments:
15+
- exams:
16+
17+
18+
919
============================================================================================================
1020
- next field template:
1121
- lectures:

0 commit comments

Comments
 (0)