Browse Source

Updated descriptions

pull/64/head
Edward Donner 5 months ago
parent
commit
cb0b8a8d45
  1. 32
      week1/community-contributions/day1-webscraping-selenium-for-javascript.ipynb
  2. 8
      week2/day4.ipynb
  3. 8
      week4/day3.ipynb
  4. 32
      week4/day4.ipynb
  5. 41
      week4/optimized.cpp
  6. 7
      week4/simple.cpp
  7. 8
      week8/day5.ipynb

32
week1/community-contributions/day1-webscraping-selenium-for-javascript.ipynb

@ -28,7 +28,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": null,
"id": "4e2a9393-7767-488e-a8bf-27c12dca35bd", "id": "4e2a9393-7767-488e-a8bf-27c12dca35bd",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -91,7 +91,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": null,
"id": "019974d9-f3ad-4a8a-b5f9-0a3719aea2d3", "id": "019974d9-f3ad-4a8a-b5f9-0a3719aea2d3",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -135,7 +135,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": null,
"id": "c5e793b2-6775-426a-a139-4848291d0463", "id": "c5e793b2-6775-426a-a139-4848291d0463",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -197,7 +197,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": null,
"id": "abdb8417-c5dc-44bc-9bee-2e059d162699", "id": "abdb8417-c5dc-44bc-9bee-2e059d162699",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -211,7 +211,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": null,
"id": "f0275b1b-7cfe-4f9d-abfa-7650d378da0c", "id": "f0275b1b-7cfe-4f9d-abfa-7650d378da0c",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -258,7 +258,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": null,
"id": "f25dcd35-0cd0-4235-9f64-ac37ed9eaaa5", "id": "f25dcd35-0cd0-4235-9f64-ac37ed9eaaa5",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -292,7 +292,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": null,
"id": "0134dfa4-8299-48b5-b444-f2a8c3403c88", "id": "0134dfa4-8299-48b5-b444-f2a8c3403c88",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -328,7 +328,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 16, "execution_count": null,
"id": "905b9919-aba7-45b5-ae65-81b3d1d78e34", "id": "905b9919-aba7-45b5-ae65-81b3d1d78e34",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -356,7 +356,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 18, "execution_count": null,
"id": "3d926d59-450e-4609-92ba-2d6f244f1342", "id": "3d926d59-450e-4609-92ba-2d6f244f1342",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -459,7 +459,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 20, "execution_count": null,
"id": "682eff74-55c4-4d4b-b267-703edbc293c7", "id": "682eff74-55c4-4d4b-b267-703edbc293c7",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -474,7 +474,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 21, "execution_count": null,
"id": "90ca6dd0", "id": "90ca6dd0",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -532,7 +532,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 23, "execution_count": null,
"id": "947eac30", "id": "947eac30",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -543,7 +543,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 24, "execution_count": null,
"id": "2cba8c91", "id": "2cba8c91",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -572,7 +572,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 26, "execution_count": null,
"id": "7880ce6a", "id": "7880ce6a",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -601,7 +601,7 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "llm_env", "display_name": "Python 3 (ipykernel)",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },
@ -615,7 +615,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.11.9" "version": "3.11.11"
} }
}, },
"nbformat": 4, "nbformat": 4,

8
week2/day4.ipynb

@ -228,14 +228,6 @@
"source": [ "source": [
"gr.ChatInterface(fn=chat, type=\"messages\").launch()" "gr.ChatInterface(fn=chat, type=\"messages\").launch()"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"id": "11c9da69-d0cf-4cf2-a49e-e5669deec47b",
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {

8
week4/day3.ipynb

@ -275,9 +275,12 @@
"It compiles the file `optimized.cpp` into an executable called `optimized` \n", "It compiles the file `optimized.cpp` into an executable called `optimized` \n",
"Then it runs the program called `optimized`\n", "Then it runs the program called `optimized`\n",
"\n", "\n",
"You can google (or ask ChatGPT!) for how to do this on your platform, then replace the lines below.\n", "In the next lab (day4), a student has contributed a full solution that compiles to efficient code on Mac, PC and Linux!\n",
"\n",
"You can wait for this, or you can google (or ask ChatGPT!) for how to do this on your platform, then replace the lines below.\n",
"If you're not comfortable with this step, you can skip it for sure - I'll show you exactly how it performs on my Mac.\n", "If you're not comfortable with this step, you can skip it for sure - I'll show you exactly how it performs on my Mac.\n",
"\n", "\n",
"\n",
"OR alternatively: student Sandeep K.G. points out that you can run Python and C++ code online to test it out that way. Thank you Sandeep! \n", "OR alternatively: student Sandeep K.G. points out that you can run Python and C++ code online to test it out that way. Thank you Sandeep! \n",
"> Not an exact comparison but you can still get the idea of performance difference.\n", "> Not an exact comparison but you can still get the idea of performance difference.\n",
"> For example here: https://www.programiz.com/cpp-programming/online-compiler/" "> For example here: https://www.programiz.com/cpp-programming/online-compiler/"
@ -326,7 +329,8 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"python_hard = \"\"\"\n", "python_hard = \"\"\"# Be careful to support large number sizes\n",
"\n",
"def lcg(seed, a=1664525, c=1013904223, m=2**32):\n", "def lcg(seed, a=1664525, c=1013904223, m=2**32):\n",
" value = seed\n", " value = seed\n",
" while True:\n", " while True:\n",

32
week4/day4.ipynb

@ -282,7 +282,8 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"python_hard = \"\"\"\n", "python_hard = \"\"\"# Be careful to support large number sizes\n",
"\n",
"def lcg(seed, a=1664525, c=1013904223, m=2**32):\n", "def lcg(seed, a=1664525, c=1013904223, m=2**32):\n",
" value = seed\n", " value = seed\n",
" while True:\n", " while True:\n",
@ -472,7 +473,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 107, "execution_count": null,
"id": "77f3ab5d-fcfb-4d3f-8728-9cacbf833ea6", "id": "77f3ab5d-fcfb-4d3f-8728-9cacbf833ea6",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -640,6 +641,27 @@
" yield stream_so_far " " yield stream_so_far "
] ]
}, },
{
"cell_type": "markdown",
"id": "4b0a6a97-5b8a-4a9b-8ee0-7561e0ced673",
"metadata": {},
"source": [
"<table style=\"margin: 0; text-align: left;\">\n",
" <tr>\n",
" <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",
" <img src=\"../thankyou.jpg\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
" </td>\n",
" <td>\n",
" <h2 style=\"color:#090;\">Thank you to @CloudLlama for an amazing contribution</h2>\n",
" <span style=\"color:#090;\">\n",
" A student has contributed a chunk of code to improve this, in the next 2 cells. You can now select which Python porgram to run,\n",
" and a compiler is automatically selected that will work on PC, Windows and Mac. Massive thank you @CloudLlama!\n",
" </span>\n",
" </td>\n",
" </tr>\n",
"</table>"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
@ -658,7 +680,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 115, "execution_count": null,
"id": "e42286bc-085c-45dc-b101-234308e58269", "id": "e42286bc-085c-45dc-b101-234308e58269",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -795,7 +817,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "f12bfe23-135b-45a7-8c6d-0c27d68b0a82", "id": "9d0ad093-425b-488e-8c3f-67f729dd9c06",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": []
@ -817,7 +839,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.11.10" "version": "3.11.11"
} }
}, },
"nbformat": 4, "nbformat": 4,

41
week4/optimized.cpp

@ -4,15 +4,12 @@
#include <limits> #include <limits>
#include <iomanip> #include <iomanip>
using namespace std;
using namespace chrono;
class LCG { class LCG {
private: private:
uint64_t value; uint64_t value;
static const uint64_t a = 1664525; const uint64_t a = 1664525;
static const uint64_t c = 1013904223; const uint64_t c = 1013904223;
static const uint64_t m = 1ULL << 32; const uint64_t m = 1ULL << 32;
public: public:
LCG(uint64_t seed) : value(seed) {} LCG(uint64_t seed) : value(seed) {}
@ -25,21 +22,17 @@ public:
int64_t max_subarray_sum(int n, uint64_t seed, int min_val, int max_val) { int64_t max_subarray_sum(int n, uint64_t seed, int min_val, int max_val) {
LCG lcg(seed); LCG lcg(seed);
vector<int64_t> random_numbers(n); std::vector<int> random_numbers(n);
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
random_numbers[i] = lcg.next() % (max_val - min_val + 1) + min_val; random_numbers[i] = static_cast<int>(lcg.next() % (max_val - min_val + 1) + min_val);
} }
int64_t max_sum = numeric_limits<int64_t>::min(); int64_t max_sum = std::numeric_limits<int64_t>::min();
int64_t current_sum = 0; int64_t current_sum = 0;
int64_t min_sum = 0;
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
current_sum += random_numbers[i]; current_sum = std::max(static_cast<int64_t>(random_numbers[i]), current_sum + random_numbers[i]);
max_sum = max(max_sum, current_sum - min_sum); max_sum = std::max(max_sum, current_sum);
min_sum = min(min_sum, current_sum);
} }
return max_sum; return max_sum;
} }
@ -54,19 +47,19 @@ int64_t total_max_subarray_sum(int n, uint64_t initial_seed, int min_val, int ma
} }
int main() { int main() {
const int n = 10000; int n = 10000;
const uint64_t initial_seed = 42; uint64_t initial_seed = 42;
const int min_val = -10; int min_val = -10;
const int max_val = 10; int max_val = 10;
auto start_time = high_resolution_clock::now(); auto start_time = std::chrono::high_resolution_clock::now();
int64_t result = total_max_subarray_sum(n, initial_seed, min_val, max_val); int64_t result = total_max_subarray_sum(n, initial_seed, min_val, max_val);
auto end_time = high_resolution_clock::now(); auto end_time = std::chrono::high_resolution_clock::now();
auto duration = duration_cast<microseconds>(end_time - start_time); auto duration = std::chrono::duration_cast<std::chrono::microseconds>(end_time - start_time);
cout << "Total Maximum Subarray Sum (20 runs): " << result << endl; std::cout << "Total Maximum Subarray Sum (20 runs): " << result << std::endl;
cout << "Execution Time: " << fixed << setprecision(6) << duration.count() / 1e6 << " seconds" << endl; std::cout << "Execution Time: " << std::fixed << std::setprecision(6) << duration.count() / 1e6 << " seconds" << std::endl;
return 0; return 0;
} }

7
week4/simple.cpp

@ -0,0 +1,7 @@
#include <iostream>
int main() {
std::cout << "Hello";
return 0;
}

8
week8/day5.ipynb

@ -172,6 +172,14 @@
" </tr>\n", " </tr>\n",
"</table>" "</table>"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"id": "096397f9-1215-4814-ab4b-e32002ff4ceb",
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {

Loading…
Cancel
Save