<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Tech Blog</title><description>From Ziwen Hua</description><link>https://tech.kinghua0629.com/</link><language>en</language><item><title>CS50 Final Project</title><link>https://tech.kinghua0629.com/posts/cs50-final-project/</link><guid isPermaLink="true">https://tech.kinghua0629.com/posts/cs50-final-project/</guid><description>The video demo for my CS50 Final Project</description><pubDate>Sun, 22 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;Table of contents&lt;/h2&gt;
&lt;h1&gt;CS50 Final Project&lt;/h1&gt;
&lt;p&gt;This is the video of my CS50 final project.&lt;/p&gt;
&lt;h2&gt;YouTube&lt;/h2&gt;
&lt;p&gt;&amp;lt;iframe width=&quot;100%&quot; height=&quot;468&quot; src=&quot;https://www.youtube.com/embed/tzwww0bJy3c?si=rhqI5xAUwnntphIj&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; allowfullscreen&amp;gt;&amp;lt;/iframe&amp;gt;&lt;/p&gt;
&lt;h2&gt;Bilibili&lt;/h2&gt;
&lt;p&gt;&amp;lt;iframe src=&quot;//player.bilibili.com/player.html?isOutside=true&amp;amp;aid=116164873161767&amp;amp;bvid=BV1bvAoziEq1&amp;amp;cid=36423732752&amp;amp;p=1&quot; scrolling=&quot;false&quot; border=&quot;0&quot; frameborder=&quot;false&quot; framespacing=&quot;0&quot; allowfullscreen=&quot;true&quot; width=800px height=450px&amp;gt;&amp;lt;/iframe&amp;gt;&lt;/p&gt;
</content:encoded></item><item><title>My First GRE Passage</title><link>https://tech.kinghua0629.com/posts/my-first-gre-passage/</link><guid isPermaLink="true">https://tech.kinghua0629.com/posts/my-first-gre-passage/</guid><description>My First GRE Passage</description><pubDate>Wed, 18 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;Table of contents&lt;/h2&gt;
&lt;p&gt;这是我的第一篇GRE文章，如果有写得不好得地方，请留言指正。&lt;/p&gt;
&lt;h2&gt;题目&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Claim: In any situation, the best way to persuade other people is to present them with facts and statistics rather than with emotional arguments.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Reason: Facts are objective, so they are more persuasive than subjective appeals.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Write a response in which you discuss the extent to which you agree or disagree with the claim and the reason on which that claim is based.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;作文&lt;/h2&gt;
&lt;p&gt;With the advancement of the society, many of us take it for granted that the best way to persuade other people is to present them with facts and statics rather than with emotional arguments. The underlying reason for this is that since facts are objective, they are more persuasive than subjective appeals. Unfortunately, I disagree with the claim and the reason, and here are the reasons why I disagree with it.&lt;/p&gt;
&lt;p&gt;Admittedly, in some aspect, persuading people by presenting them with statics is an effective way, especially in the field of science and engineering. For instance, critical data taken generated from numerous experiments on patients plays a vital role in the process of developing a new kind of drug. Companies cannot persuade FDA to approve certain kinds of medicine by telling the urgent need for this medicine. Instead, they have to provide reliable and convincing data which was taken from numerous experiments in labs and on patients in order to prove that the drug is effective and does not have side effects. In this case, facts and statistics are not just the best way to persuade; they are the only acceptable way.&lt;/p&gt;
&lt;p&gt;However, this claim can hardly become useful when it comes to the topics which are more related to our personal lives. The main reason is that human beings are not purely rational actors; our decisions are deeply influenced by emotions, morals, and shared values. Take Martin Luther King as an example. Indeed, he cited the fact of racial segregation and discrimination between black and white people, but he could not achieve the success of promoting the Civil Rights Act without delivering emotional speeches like “I have a dream”. His vivid description of black people’s unequally treated situation and calling for equality between different races successfully evoked the resonance in the communities, engaging more people into this movement, which is the main cause for the fundamental change. It will be quixotic for Martin to call on people to engage in the movement if he just used data and historical facts in his speeches.&lt;/p&gt;
&lt;p&gt;What’s more, there is a serious flaw in facts and statistics which can call the claim and reason mentioned above into question. Ordinary people are not willing to understand the meanings behind the facts. Several previous experiments indicate that with the rising of number of statics and facts in a speech of a representative, the less likely voters would like to get interested in his political position, therefore achieving lower vote than others. People will get tired after listening to numerous times of similar facts, and they instead want to hear someone who can stand out and clearly express themselves. So in this case, using only facts is not convincing enough.&lt;/p&gt;
&lt;p&gt;Moreover, the most compelling persuasion often combines both elements. A skilled advocate uses facts as the skeleton of the argument and emotional appeal to attract those who have the same ambition. A nonprofit seeking donation for poor people will show statistics on salary and food supply of these families but will also tell the story of one specific child to create a connection that moves potential donators. The fact establishes the scale of the problem, while the emotional appeal evokes the empathy necessary to motivate action.&lt;/p&gt;
&lt;p&gt;In conclusion, I believe that using statistics rather than emotional arguments when persuading others is not the best way in any cases. Only by combining facts and emotions together in lectures can we persuade others from the deep heart.&lt;/p&gt;
</content:encoded></item><item><title>CS50 Problem Set 1</title><link>https://tech.kinghua0629.com/posts/cs50-problem-set-1/</link><guid isPermaLink="true">https://tech.kinghua0629.com/posts/cs50-problem-set-1/</guid><description>Answer for CS50 Problem Set 1</description><pubDate>Wed, 18 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h1&gt;CS50 Problem Set 1&lt;/h1&gt;
&lt;p&gt;Here&apos;s my answer for the CS50 Problem Set 1. Hope that will help you a bit.&lt;/p&gt;
&lt;h2&gt;Problem 1: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/1/me/#hello-its-me&quot;&gt;Hello, It’s Me&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;lt;cs50.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;

int main(void)
{
    string name = get_string(&quot;What&apos;s your name?\n&quot;);
    printf(&quot;Hello, %s\n&quot;, name);
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Problem 2: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/1/mario/more/#mario&quot;&gt;Mario&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;lt;cs50.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;

void mario(int n);

int main(void)
{
    int n;
    do
    {
        n = get_int(&quot;Height: &quot;);
    }
    while (n &amp;lt; 1 || n &amp;gt; 8);
    mario(n);
    return 0;
}

void mario(int n)
{
    for (int i = 1; i &amp;lt; n + 1; i++)
    {
        for (int j = 0; j &amp;lt; n - i; j++)
        {
            printf(&quot; &quot;);
        }

        for (int k = 0; k &amp;lt; i; k++)
        {
            printf(&quot;#&quot;);
        }

        printf(&quot;  &quot;);

        for (int k = 0; k &amp;lt; i; k++)
        {
            printf(&quot;#&quot;);
        }
        //        for (int j = 0; j &amp;lt; n - i; j++)
        //        {
        //            printf(&quot; &quot;);
        //        }

        printf(&quot;\n&quot;);
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Problem 3: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/1/cash/&quot;&gt;Cash&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;lt;cs50.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;

int main(void)
{
    int cash;
    do
    {
        cash = get_int(&quot;Change owed: &quot;);
    }
    while (cash &amp;lt; 0);

    int n_25 = 0;
    int n_10 = 0;
    int n_5 = 0;
    int n_1 = 0;
    int sum = 0;

    while (cash &amp;gt; 24)
    {
        cash -= 25;
        n_25 += 1;
    }
    // printf(&quot;%d\n&quot;, n_25);

    while (cash &amp;gt; 9)
    {
        cash -= 10;
        n_10 += 1;
    }
    // printf(&quot;%d\n&quot;, n_10);

    while (cash &amp;gt; 4)
    {
        cash -= 5;
        n_5 += 1;
    }
    // printf(&quot;%d\n&quot;, n_5);

    while (cash &amp;gt; 0)
    {
        cash -= 1;
        n_1 += 1;
    }
    // printf(&quot;%d\n&quot;, n_1);
    sum = n_25 + n_10 + n_5 + n_1;
    printf(&quot;%d\n&quot;, sum);
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>CS50 Problem Set 2</title><link>https://tech.kinghua0629.com/posts/cs50-problem-set-2/</link><guid isPermaLink="true">https://tech.kinghua0629.com/posts/cs50-problem-set-2/</guid><description>Answer for CS50 Problem Set 2</description><pubDate>Wed, 18 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h1&gt;CS50 Problem Set 2&lt;/h1&gt;
&lt;p&gt;Here&apos;s my answer for the CS50 Problem Set 2. Hope that will help you a bit.&lt;/p&gt;
&lt;h2&gt;Problem 1: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/2/scrabble/#scrabble&quot;&gt;Scrabble&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;lt;cs50.h&amp;gt;
#include &amp;lt;ctype.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

int compute_score(string word);

int points[] = {1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10};

int main(void)
{
    string word1 = get_string(&quot;Player 1: &quot;);
    string word2 = get_string(&quot;Player 2: &quot;);

    int score1 = compute_score(word1);
    int score2 = compute_score(word2);

    if (score1 &amp;gt; score2)
    {
        printf(&quot;Player 1 wins!\n&quot;);
        return 0;
    }
    else if (score1 &amp;lt; score2)
    {
        printf(&quot;Player 2 wins!\n&quot;);
        return 0;
    }
    else
    {
        printf(&quot;Tie!\n&quot;);
        return 0;
    }
}

int compute_score(string word)
{
    int score = 0;

    for (int i = 0; i &amp;lt; strlen(word); i++)
    {
        if (isupper(word[i]))
        {
            score += points[word[i] - &apos;A&apos;];
        }
        else if (islower(word[i]))
        {
            score += points[word[i] - &apos;a&apos;];
        }
    }
    return score;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Problem 2: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/2/readability/#readability&quot;&gt;Readability&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;lt;cs50.h&amp;gt;
#include &amp;lt;ctype.h&amp;gt;
#include &amp;lt;math.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

int letters(string text);
int sentences(string text);
int words(string text);

int main(void)
{
    string text = get_string(&quot;Text: &quot;);

    int index = (int) round(0.0588 * letters(text) / words(text) * 100 -
                            0.296 * sentences(text) / words(text) * 100 - 15.8);

    if (index &amp;lt; 1)
    {
        printf(&quot;Before Grade 1\n&quot;);
        return 0;
    }
    else if (index &amp;gt;= 16)
    {
        printf(&quot;Grade 16+\n&quot;);
        return 0;
    }
    else
    {
        printf(&quot;Grade %i\n&quot;, index);
        return 0;
    }
}

int words(string text)
{
    int words = 1;
    for (int i = 0; i &amp;lt; strlen(text); i++)
    {
        if (text[i] == &apos; &apos;)
        {
            words += 1;
        }
    }
    return words;
}

int letters(string text)
{
    int letters = 0;
    for (int i = 0; i &amp;lt; strlen(text); i++)
    {
        if (isalpha(text[i]))
        {
            letters += 1;
        }
    }
    return letters;
}

int sentences(string text)
{
    int sentences = 0;
    for (int i = 0; i &amp;lt; strlen(text); i++)
    {
        if (text[i] == &apos;.&apos; || text[i] == &apos;!&apos; || text[i] == &apos;?&apos;)
        {
            sentences += 1;
        }
    }
    return sentences;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Problem 3: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/2/substitution/#substitution&quot;&gt;Substitution&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;lt;cs50.h&amp;gt;
#include &amp;lt;ctype.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

int main(int argc, string argv[])
{
    string key = argv[1];
    if (argc != 2)
    {
        printf(&quot;Usage: ./substitution key\n&quot;);
        return 1;
    }
    else if (strlen(argv[1]) != 26)
    {
        printf(&quot;Key must contain 26 characters.\n&quot;);
        return 1;
    }
    else
    {
        for (int i = 0, n = strlen(key); i &amp;lt; n; i++)
        {
            if (isalpha(argv[1][i]) == 0)
            {
                printf(&quot;Key should be all alphabets.\n&quot;);
                return 1;
            }

            for (int j = i + 1; j &amp;lt; n; j++)
            {
                if (argv[1][i] == argv[1][j] || argv[1][i] + 32 == argv[1][j] ||
                    argv[1][i] - 32 == argv[1][j])
                {
                    printf(&quot;There should be no duplicate in the key.\n&quot;);
                    return 1;
                }
            }
        }
        string ptext = get_string(&quot;plaintext:  &quot;);
        printf(&quot;ciphertext: &quot;);
        for (int i = 0, length = strlen(ptext); i &amp;lt; length; i++)
        {
            if (isupper(ptext[i]))
            {
                char result = toupper(key[ptext[i] - &apos;A&apos;]);
                printf(&quot;%c&quot;, result);
            }
            else if (islower(ptext[i]))
            {
                char result = tolower(key[ptext[i] - &apos;a&apos;]);
                printf(&quot;%c&quot;, result);
            }
            else
            {
                printf(&quot;%c&quot;, ptext[i]);
            }
        }
        printf(&quot;\n&quot;);
        return 0;
    }
}
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>CS50 Problem Set 5</title><link>https://tech.kinghua0629.com/posts/cs50-problem-set-5/</link><guid isPermaLink="true">https://tech.kinghua0629.com/posts/cs50-problem-set-5/</guid><description>Answer for CS50 Problem Set 5</description><pubDate>Wed, 18 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h1&gt;CS50 Problem Set 5&lt;/h1&gt;
&lt;p&gt;Here&apos;s my answer for the CS50 Problem Set 5. Hope that will help you a bit.&lt;/p&gt;
&lt;h2&gt;Problem 1: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/5/inheritance/#inheritance&quot;&gt;Inheritance&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;// Simulate genetic inheritance of blood type
#define _DEFAULT_SOURCE
#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;time.h&amp;gt;

// Each person has two parents and two alleles
typedef struct person
{
    struct person *parents[2];
    char alleles[2];
} person;

const int GENERATIONS = 3;
const int INDENT_LENGTH = 4;

person *create_family(int generations);
void print_family(person *p, int generation);
void free_family(person *p);
char random_allele();

int main(void)
{
    // Seed random number generator
    srandom(time(0));

    // Create a new family with three generations
    person *p = create_family(GENERATIONS);

    // Print family tree of blood types
    print_family(p, 0);

    // Free memory
    free_family(p);
}

// Create a new individual with `generations`
person *create_family(int generations)
{
    // TODO: Allocate memory for new person
    person *p = malloc(sizeof(person));

    // If there are still generations left to create
    if (generations &amp;gt; 1)
    {
        // Create two new parents for current person by recursively calling create_family
        person *parent0 = create_family(generations - 1);
        person *parent1 = create_family(generations - 1);

        // TODO: Set parent pointers for current person
        p-&amp;gt;parents[0] = parent0;
        p-&amp;gt;parents[1] = parent1;

        // TODO: Randomly assign current person&apos;s alleles based on the alleles of their parents
        p-&amp;gt;alleles[0] = parent0-&amp;gt;alleles[random() % 2];
        p-&amp;gt;alleles[1] = parent1-&amp;gt;alleles[random() % 2];
    }

    // If there are no generations left to create
    else
    {
        // TODO: Set parent pointers to NULL
        p-&amp;gt;parents[0] = NULL;
        p-&amp;gt;parents[1] = NULL;

        // TODO: Randomly assign alleles
        p-&amp;gt;alleles[0] = random_allele();
        p-&amp;gt;alleles[1] = random_allele();
    }

    // TODO: Return newly created person
    return p;

    return NULL;
}

// Free `p` and all ancestors of `p`.
void free_family(person *p)
{
    // TODO: Handle base case
    if (p == NULL)
    {
        return;
    }

    // TODO: Free parents recursively
    free_family(p-&amp;gt;parents[0]);
    free_family(p-&amp;gt;parents[1]);

    // TODO: Free child
    free(p);
}

// Print each family member and their alleles.
void print_family(person *p, int generation)
{
    // Handle base case
    if (p == NULL)
    {
        return;
    }

    // Print indentation
    for (int i = 0; i &amp;lt; generation * INDENT_LENGTH; i++)
    {
        printf(&quot; &quot;);
    }

    // Print person
    if (generation == 0)
    {
        printf(&quot;Child (Generation %i): blood type %c%c\n&quot;, generation, p-&amp;gt;alleles[0],
               p-&amp;gt;alleles[1]);
    }
    else if (generation == 1)
    {
        printf(&quot;Parent (Generation %i): blood type %c%c\n&quot;, generation, p-&amp;gt;alleles[0],
               p-&amp;gt;alleles[1]);
    }
    else
    {
        for (int i = 0; i &amp;lt; generation - 2; i++)
        {
            printf(&quot;Great-&quot;);
        }
        printf(&quot;Grandparent (Generation %i): blood type %c%c\n&quot;, generation, p-&amp;gt;alleles[0],
               p-&amp;gt;alleles[1]);
    }

    // Print parents of current generation
    print_family(p-&amp;gt;parents[0], generation + 1);
    print_family(p-&amp;gt;parents[1], generation + 1);
}

// Randomly chooses a blood type allele.
char random_allele()
{
    int r = random() % 3;
    if (r == 0)
    {
        return &apos;A&apos;;
    }
    else if (r == 1)
    {
        return &apos;B&apos;;
    }
    else
    {
        return &apos;O&apos;;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Problem 2: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/5/speller/#speller&quot;&gt;Speller&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;// Implements a dictionary&apos;s functionality

#include &amp;lt;ctype.h&amp;gt;
#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;strings.h&amp;gt;

#include &quot;dictionary.h&quot;

// Represents a node in a hash table
typedef struct node
{
    char word[LENGTH + 1];
    struct node *next;
} node;

int word_counter = 0;

// TODO: Choose number of buckets in hash table
const unsigned int N = 26;

// Hash table
node *table[N];

// Returns true if word is in dictionary, else false
bool check(const char *word)
{
    // TODO
    // Hash the word to obtain its hash value
    int hash_value = hash(word);

    // Search the hash table at the location specified by the word’s hash value
    // Return &quot;true&quot; if the word is found
    node *cursor = table[hash_value];
    while (cursor != NULL)
    {
        if (strcasecmp(cursor-&amp;gt;word, word) == 0)
        {
            return true;
        }
        else
        {
            cursor = cursor-&amp;gt;next;
        }
    }

    return false;
}

// Hashes word to a number
unsigned int hash(const char *word)
{
    // TODO: Improve this hash function
    return toupper(word[0]) - &apos;A&apos;;
}

// Loads dictionary into memory, returning true if successful, else false
bool load(const char *dictionary)
{
    // TODO
    // Make sure there is no garbage values
    for (int i = 0; i &amp;lt; N; i++)
    {
        table[i] = NULL;
    }

    // Open the dictionary file
    FILE *dict = fopen(dictionary, &quot;r&quot;);
    if (dict == NULL)
    {
        printf(&quot;The dictinary does not exist.\n&quot;);
        return false;
    }

    // Read strings from file one at a time
    char temp_word[LENGTH];

    while (fscanf(dict, &quot;%s&quot;, temp_word) != EOF)
    {
        // Create space for a new hash table node
        node *new_word = malloc(sizeof(node));

        // Copy the word into the new node
        strcpy(new_word-&amp;gt;word, temp_word);

        // Hash the word to obtain its hash value
        int hash_value = hash(temp_word);

        // Insert the new node into the hash table (using the index specified by its hash value)
        new_word-&amp;gt;next = table[hash_value];
        table[hash_value] = new_word;
        word_counter += 1;
    }

    // close the dictinary file
    fclose(dict);

    return true;
}

// Returns number of words in dictionary if loaded, else 0 if not yet loaded
unsigned int size(void)
{
    // TODO
    return word_counter;
}

// Unloads dictionary from memory, returning true if successful, else false
bool unload(void)
{
    // TODO
    for (int i = 0; i &amp;lt; N; i++)
    {
        node *tmp = table[i];
        node *cursor = table[i];

        while (cursor != NULL)
        {
            cursor = cursor-&amp;gt;next;
            free(tmp);
            tmp = cursor;
        }
    }
    return true;
}
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>CS50 Problem Set 4</title><link>https://tech.kinghua0629.com/posts/cs50-problem-set-4/</link><guid isPermaLink="true">https://tech.kinghua0629.com/posts/cs50-problem-set-4/</guid><description>Answer for CS50 Problem Set 4</description><pubDate>Wed, 18 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h1&gt;CS50 Problem Set 4&lt;/h1&gt;
&lt;p&gt;Here&apos;s my answer for the CS50 Problem Set 4. Hope that will help you a bit.&lt;/p&gt;
&lt;h2&gt;Problem 1: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/4/volume/#volume&quot;&gt;Volume&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;// Modifies the volume of an audio file

#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;

// Number of bytes in .wav header
const int HEADER_SIZE = 44;

int main(int argc, char *argv[])
{
    // Check command-line arguments
    if (argc != 4)
    {
        printf(&quot;Usage: ./volume input.wav output.wav factor\n&quot;);
        return 1;
    }

    // Open files and determine scaling factor
    FILE *input = fopen(argv[1], &quot;r&quot;);
    if (input == NULL)
    {
        printf(&quot;Could not open file.\n&quot;);
        return 1;
    }

    FILE *output = fopen(argv[2], &quot;w&quot;);
    if (output == NULL)
    {
        printf(&quot;Could not open file.\n&quot;);
        return 1;
    }

    float factor = atof(argv[3]);

    // TODO: Copy header from input file to output file
    uint8_t header[44];
    fread(&amp;amp;header, 44, 1, input);
    fwrite(&amp;amp;header, 44, 1, output);

    // TODO: Read samples from input file and write updated data to output file
    int16_t buffer;

    while (fread(&amp;amp;buffer, sizeof(int16_t), 1, input))
    {
        buffer *= factor;
        fwrite(&amp;amp;buffer, sizeof(int16_t), 1, output);
    }

    // Close files
    fclose(input);
    fclose(output);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Problem 2: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/4/filter/less/#filter&quot;&gt;Filter&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;#include &quot;helpers.h&quot;
#include &amp;lt;math.h&amp;gt;

// Convert image to grayscale
void grayscale(int height, int width, RGBTRIPLE image[height][width])
{
    int avg = 0;

    for (int i = 0; i &amp;lt; height; i++)
    {
        for (int j = 0; j &amp;lt; width; j++)
        {
            avg = (int) round((image[i][j].rgbtRed + image[i][j].rgbtGreen + image[i][j].rgbtBlue) /
                              3.0);

            image[i][j].rgbtRed = avg;
            image[i][j].rgbtGreen = avg;
            image[i][j].rgbtBlue = avg;
        }
    }
    return;
}

// Convert image to sepia
void sepia(int height, int width, RGBTRIPLE image[height][width])
{
    for (int i = 0; i &amp;lt; height; i++)
    {
        for (int j = 0; j &amp;lt; width; j++)
        {
            int sepiaRed = (int) round(.393 * image[i][j].rgbtRed + .769 * image[i][j].rgbtGreen +
                                       .189 * image[i][j].rgbtBlue);
            int sepiaGreen = (int) round(.349 * image[i][j].rgbtRed + .686 * image[i][j].rgbtGreen +
                                         .168 * image[i][j].rgbtBlue);
            int sepiaBlue = (int) round(.272 * image[i][j].rgbtRed + .534 * image[i][j].rgbtGreen +
                                        .131 * image[i][j].rgbtBlue);
            // sepiaRed = .393 * originalRed + .769 * originalGreen + .189 * originalBlue
            // sepiaGreen = .349 * originalRed + .686 * originalGreen + .168 * originalBlue
            // sepiaBlue = .272 * originalRed + .534 * originalGreen + .131 * originalBlue

            // Make sure that if the value of sepiaRed, sepiaGreen and sepiaBlue exceed 255, their
            // value will be capped at 255
            if (sepiaRed &amp;gt; 255)
            {
                sepiaRed = 255;
            }
            if (sepiaGreen &amp;gt; 255)
            {
                sepiaGreen = 255;
            }
            if (sepiaBlue &amp;gt; 255)
            {
                sepiaBlue = 255;
            }

            image[i][j].rgbtRed = sepiaRed;
            image[i][j].rgbtGreen = sepiaGreen;
            image[i][j].rgbtBlue = sepiaBlue;
        }
    }
    return;
}

// Reflect image horizontally
void reflect(int height, int width, RGBTRIPLE image[height][width])
{
    int temp_width = 0;
    RGBTRIPLE temp[height][width];

    if (width % 2 == 0)
    {
        temp_width = width / 2;
    }
    else
    {
        temp_width = (width + 1) / 2;
    }
    for (int i = 0; i &amp;lt; height; i++)
    {
        for (int j = 0; j &amp;lt; temp_width; j++)
        {
            // Swap pixels
            temp[i][j] = image[i][j];
            image[i][j] = image[i][width - 1 - j];
            image[i][width - 1 - j] = temp[i][j];
        }
    }
    return;
}

// Blur image
void blur(int height, int width, RGBTRIPLE image[height][width])
{
    // Create a copy of image
    RGBTRIPLE copy[height][width];
    for (int i = 0; i &amp;lt; height; i++)
    {
        for (int j = 0; j &amp;lt; width; j++)
        {
            int tempRed = 0, tempGreen = 0, tempBlue = 0;
            float pixel_count = 0;
            copy[i][j] = image[i][j];

            // get the average of the pixel RGB values
            for (int m = i - 1; m &amp;lt;= i + 1; m++)
            {
                for (int n = j - 1; n &amp;lt;= j + 1; n++)
                {
                    if (m &amp;gt;= 0 &amp;amp;&amp;amp; m &amp;lt; height &amp;amp;&amp;amp; n &amp;gt;= 0 &amp;amp;&amp;amp;
                        n &amp;lt; width) // avoiding the pixels that cross the edge
                    {
                        tempRed += image[m][n].rgbtRed;
                        tempGreen += image[m][n].rgbtGreen;
                        tempBlue += image[m][n].rgbtBlue;

                        pixel_count += 1;
                    }
                }
            }
            copy[i][j].rgbtRed = round(tempRed / pixel_count);
            copy[i][j].rgbtGreen = round(tempGreen / pixel_count);
            copy[i][j].rgbtBlue = round(tempBlue / pixel_count);
        }
    }

    // give the value of copy[i][j] back to image[i][j]
    for (int i = 0; i &amp;lt; height; i++)
    {
        for (int j = 0; j &amp;lt; width; j++)
        {
            image[i][j] = copy[i][j];
        }
    }
    return;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Problem 3: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/4/recover/#recover&quot;&gt;Recover&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;

int main(int argc, char *argv[])
{
    // Accept a single command-line argument
    if (argc != 2)
    {
        printf(&quot;Usage: ./recover FILE\n&quot;);
        return 1;
    }

    // Open the memory card
    FILE *card = fopen(argv[1], &quot;r&quot;);

    // Create a buffer for a block of data
    uint8_t buffer[512];
    int counter = 0;
    int found_image = 1;
    FILE *img;
    char filename[8];
    // While there&apos;s still data left to read from the memory card
    while (fread(buffer, 1, 512, card) == 512)
    {
        // Create JPEGs from the data
        if (buffer[0] == 0xff &amp;amp;&amp;amp; buffer[1] == 0xd8 &amp;amp;&amp;amp; buffer[2] == 0xff &amp;amp;&amp;amp;
            (buffer[3] &amp;amp; 0xf0) == 0xe0)
        {
            found_image = 0;
        }

        if (found_image == 0)
        {
            if (counter != 0)
            {
                fclose(img);
            } // close the previous file and start a new file to write (except the first file)

            sprintf(filename, &quot;%03i.jpg&quot;, counter);
            img = fopen(filename, &quot;w&quot;);
            fwrite(buffer, 1, 512, img);
            counter += 1;
            found_image = 1;
        }
        else if (counter != 0)
        // the block does not contain the signature of jpg, so it will be continuously written into
        // the previously opened file if the first block does not contain the signature, it won&apos;t be
        // written to the image
        {
            fwrite(buffer, 1, 512, img);
        }
    }

    // there&apos;s nothing to write, so close all the files
    fclose(img);
    fclose(card);
}
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>CS50 Problem Set 3</title><link>https://tech.kinghua0629.com/posts/cs50-problem-set-3/</link><guid isPermaLink="true">https://tech.kinghua0629.com/posts/cs50-problem-set-3/</guid><description>Answer for CS50 Problem Set 3</description><pubDate>Wed, 18 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h1&gt;CS50 Problem Set 3&lt;/h1&gt;
&lt;p&gt;Here&apos;s my answer for the CS50 Problem Set 3. Hope that will help you a bit.&lt;/p&gt;
&lt;h2&gt;Problem 1: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/3/sort/#sort&quot;&gt;Sort&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;sort1 uses: bubble sort

How do you know?: When sorting the sorted numbers, bubble sort&apos;s time complexity is omega(n); while sorting the random numbers, bubble sort&apos;s time complexity is O(n^2).

sort2 uses: merge sort

How do you know?: the time sort2 uses to sort every kind of txt is the least between the three sorts.

sort3 uses: selection sort

How do you know?: the time it uses to sort three kinds of txt is almost the same, but it cost more time than sort2.
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Problem 2: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/3/plurality/#plurality&quot;&gt;Plurality&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;lt;cs50.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

// Max number of candidates
#define MAX 9

// Candidates have name and vote count
typedef struct
{
    string name;
    int votes;
} candidate;

// Array of candidates
candidate candidates[MAX];

// Number of candidates
int candidate_count;

// Function prototypes
bool vote(string name);
void print_winner(void);

int main(int argc, string argv[])
{
    // Check for invalid usage
    if (argc &amp;lt; 2)
    {
        printf(&quot;Usage: plurality [candidate ...]\n&quot;);
        return 1;
    }

    // Populate array of candidates
    candidate_count = argc - 1;
    if (candidate_count &amp;gt; MAX)
    {
        printf(&quot;Maximum number of candidates is %i\n&quot;, MAX);
        return 2;
    }
    for (int i = 0; i &amp;lt; candidate_count; i++)
    {
        candidates[i].name = argv[i + 1];
        candidates[i].votes = 0;
    }

    int voter_count = get_int(&quot;Number of voters: &quot;);

    // Loop over all voters
    for (int i = 0; i &amp;lt; voter_count; i++)
    {
        string name = get_string(&quot;Vote: &quot;);

        // Check for invalid vote
        if (!vote(name))
        {
            printf(&quot;Invalid vote.\n&quot;);
        }
    }

    // Display winner of election
    print_winner();
}

// Update vote totals given a new vote
bool vote(string name)
{
    for (int i = 0; i &amp;lt; candidate_count; i++)
    {
        if (strcmp(candidates[i].name, name) == 0)
        {
            candidates[i].votes += 1;
            return true;
        }
    }
    return false;
}

// Print the winner (or winners) of the election
void print_winner(void)
{
    int highest = 0;
    string name;
    for (int i = 0; i &amp;lt; candidate_count; i++)
    {
        if (candidates[i].votes &amp;gt; highest)
        {
            highest = candidates[i].votes;
        }
    }
    for (int i = 0; i &amp;lt; candidate_count; i++)
    {
        if (candidates[i].votes == highest)
        {
            printf(&quot;%s\n&quot;, candidates[i].name);
        }
    }
    return;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Problem 3: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/3/runoff/#runoff&quot;&gt;Runoff&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;lt;cs50.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

// Max voters and candidates
#define MAX_VOTERS 100
#define MAX_CANDIDATES 9

// preferences[i][j] is jth preference for voter i
int preferences[MAX_VOTERS][MAX_CANDIDATES];

// Candidates have name, vote count, eliminated status
typedef struct
{
    string name;
    int votes;
    bool eliminated;
} candidate;

// Array of candidates
candidate candidates[MAX_CANDIDATES];

// Numbers of voters and candidates
int voter_count;
int candidate_count;

// Function prototypes
bool vote(int voter, int rank, string name);
void tabulate(void);
bool print_winner(void);
int find_min(void);
bool is_tie(int min);
void eliminate(int min);

int main(int argc, string argv[])
{
    // Check for invalid usage
    if (argc &amp;lt; 2)
    {
        printf(&quot;Usage: runoff [candidate ...]\n&quot;);
        return 1;
    }

    // Populate array of candidates
    candidate_count = argc - 1;
    if (candidate_count &amp;gt; MAX_CANDIDATES)
    {
        printf(&quot;Maximum number of candidates is %i\n&quot;, MAX_CANDIDATES);
        return 2;
    }
    for (int i = 0; i &amp;lt; candidate_count; i++)
    {
        candidates[i].name = argv[i + 1];
        candidates[i].votes = 0;
        candidates[i].eliminated = false;
    }

    voter_count = get_int(&quot;Number of voters: &quot;);
    if (voter_count &amp;gt; MAX_VOTERS)
    {
        printf(&quot;Maximum number of voters is %i\n&quot;, MAX_VOTERS);
        return 3;
    }

    // Keep querying for votes
    for (int i = 0; i &amp;lt; voter_count; i++)
    {

        // Query for each rank
        for (int j = 0; j &amp;lt; candidate_count; j++)
        {
            string name = get_string(&quot;Rank %i: &quot;, j + 1);

            // Record vote, unless it&apos;s invalid
            if (!vote(i, j, name))
            {
                printf(&quot;Invalid vote.\n&quot;);
                return 4;
            }
        }

        printf(&quot;\n&quot;);
    }

    // Keep holding runoffs until winner exists
    while (true)
    {
        // Calculate votes given remaining candidates
        tabulate();

        // Check if election has been won
        bool won = print_winner();
        if (won)
        {
            break;
        }

        // Eliminate last-place candidates
        int min = find_min();
        bool tie = is_tie(min);

        // If tie, everyone wins
        if (tie)
        {
            for (int i = 0; i &amp;lt; candidate_count; i++)
            {
                if (!candidates[i].eliminated)
                {
                    printf(&quot;%s\n&quot;, candidates[i].name);
                }
            }
            break;
        }

        // Eliminate anyone with minimum number of votes
        eliminate(min);

        // Reset vote counts back to zero
        for (int i = 0; i &amp;lt; candidate_count; i++)
        {
            candidates[i].votes = 0;
        }
    }
    return 0;
}

// Record preference if vote is valid
bool vote(int voter, int rank, string name)
{
    for (int i = 0; i &amp;lt; candidate_count; i++)
    {
        if (strcmp(candidates[i].name, name) == 0)
        {
            preferences[voter][rank] = i;
            return true;
        }
    }
    return false;
}

// Tabulate votes for non-eliminated candidates
void tabulate(void)
{
    for (int i = 0; i &amp;lt; voter_count; i++)
    {
        for (int j = 0; j &amp;lt; candidate_count; j++)
        {
            if (!candidates[preferences[i][j]].eliminated == true)
            {
                candidates[preferences[i][j]].votes += 1;
                break;
            }
        }
    }
    return;
}

// Print the winner of the election, if there is one
bool print_winner(void)
{
    int limit = voter_count / 2;
    for (int i = 0; i &amp;lt; candidate_count; i++)
    {
        if (!candidates[i].eliminated &amp;amp;&amp;amp; (candidates[i].votes &amp;gt; limit))
        {
            printf(&quot;%s\n&quot;, candidates[i].name);
            return true;
        }
    }
    return false;
}

// Return the minimum number of votes any remaining candidate has
int find_min(void)
{
    int min = 0;
    for (int i = 0; i &amp;lt; candidate_count; i++)
    {
        if (!candidates[i].eliminated)
        {
            if (i == 0)
            {
                min = candidates[i].votes;
            }
            if (candidates[i].votes &amp;lt; min)
            {
                min = candidates[i].votes;
            }
        }
    }
    return min;
}

// Return true if the election is tied between all candidates, false otherwise
bool is_tie(int min)
{
    for (int i = 0; i &amp;lt; candidate_count; i++)
    {
        if (!candidates[i].eliminated &amp;amp;&amp;amp; candidates[i].votes != min)
        {
            return false;
        }
    }
    return true;
}

// Eliminate the candidate (or candidates) in last place
void eliminate(int min)
{
    for (int i = 0; i &amp;lt; candidate_count; i++)
    {
        if (!candidates[i].eliminated &amp;amp;&amp;amp; candidates[i].votes == min)
        {
            candidates[i].eliminated = true;
        }
    }
    return;
}
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>CS50 Problem Set 6</title><link>https://tech.kinghua0629.com/posts/cs50-problem-set-6/</link><guid isPermaLink="true">https://tech.kinghua0629.com/posts/cs50-problem-set-6/</guid><description>Answer for CS50 Problem Set 6</description><pubDate>Wed, 18 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h1&gt;CS50 Problem Set 6&lt;/h1&gt;
&lt;p&gt;Here&apos;s my answer for the CS50 Problem Set 6. Hope that will help you a bit.&lt;/p&gt;
&lt;h2&gt;Problem 1: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/6/hello/#hello-again&quot;&gt;Hello, Again&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;name = input(&quot;What is your name? &quot;)

print(f&quot;hello, {name}&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Probelm 2: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/6/mario/more/#mario&quot;&gt;Mario&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;while True:
    try:
        h = int(input(&quot;Height: &quot;))

        if 1 &amp;lt;= h &amp;lt;= 8:
            break
        else:
            print(&quot;&quot;, end=&apos;&apos;)
    except ValueError:
        print(&quot;&quot;, end=&apos;&apos;)

for i in range(1, h+1):
    for j in range(0, h-i):
        print(&quot; &quot;, end=&apos;&apos;)
#        j += 1

    for k in range(0, i):
        print(&quot;#&quot;, end=&apos;&apos;)
#        k += 1

    print(&quot;  &quot;, end=&apos;&apos;)

    for m in range(0, i):
        print(&quot;#&quot;, end=&apos;&apos;)
#        m += 1

    print()
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Problem 3: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/6/credit/#credit&quot;&gt;Credit&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;while True:
    number = input(&quot;Number: &quot;)
    if number.isdigit() == True:
        break
    else:
        number = input(&quot;Number: &quot;)

reversed_number = number[::-1]

if len(number) == 15:
    sum = 0
    temp_sum_1 = 0
    temp_sum_2 = 0
    if number[:2] != &quot;37&quot; and number[:2] != &quot;34&quot;:
        print(&quot;INVALID&quot;)
    else:
        for i in range(1, 15, 2):
            temp = int(reversed_number[i]) * 2
            if temp &amp;gt; 9:
                temp = temp // 10 + temp % 10
            temp_sum_1 += temp

        for i in range(0, 15, 2):
            temp = int(reversed_number[i])
            temp_sum_2 += temp

        sum = temp_sum_1 + temp_sum_2
        if sum % 10 == 0:
            print(&quot;AMEX&quot;)
        else:
            print(&quot;INVALID&quot;)

elif len(number) == 13:
    sum = 0
    temp_sum_1 = 0
    temp_sum_2 = 0
    if number[:1] != &quot;4&quot;:
        print(&quot;INVALID&quot;)
    else:
        for i in range(1, 13, 2):
            temp = int(reversed_number[i]) * 2
            if temp &amp;gt; 9:
                temp = temp // 10 + temp % 10
            temp_sum_1 += temp

        for i in range(0, 13, 2):
            temp = int(reversed_number[i])
            temp_sum_2 += temp

        sum = temp_sum_1 + temp_sum_2
        if sum % 10 == 0:
            print(&quot;VISA&quot;)
        else:
            print(&quot;INVALID&quot;)

elif len(number) == 16:
    sum = 0
    temp_sum_1 = 0
    temp_sum_2 = 0
    if number[:1] != &quot;4&quot; and number[:2] != &quot;51&quot; and number[:2] != &quot;52&quot; and number[:2] != &quot;53&quot; and number[:2] != &quot;54&quot; and number[:2] != &quot;55&quot;:
        print(&quot;INVALID&quot;)
    elif number[:1] == &quot;4&quot;:
        for i in range(1, 16, 2):
            temp = int(reversed_number[i]) * 2
            if temp &amp;gt; 9:
                temp = temp // 10 + temp % 10
            temp_sum_1 += temp

        for i in range(0, 16, 2):
            temp = int(reversed_number[i])
            temp_sum_2 += temp

        sum = temp_sum_1 + temp_sum_2
        if sum % 10 == 0:
            print(&quot;VISA&quot;)
        else:
            print(&quot;INVALID&quot;)
    else:
        for i in range(1, 16, 2):
            temp = int(reversed_number[i]) * 2
            if temp &amp;gt; 9:
                temp = temp // 10 + temp % 10
            temp_sum_1 += temp

        for i in range(0, 16, 2):
            temp = int(reversed_number[i])
            temp_sum_2 += temp

        sum = temp_sum_1 + temp_sum_2
        if sum % 10 == 0:
            print(&quot;MASTERCARD&quot;)
        else:
            print(&quot;INVALID&quot;)

else:
    print(&quot;INVALID&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Problem 4: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/6/readability/#readability&quot;&gt;Readability&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;def words(text):
    words = 1
    for i in range(0, len(text)):
        if text[i] == &apos; &apos;:
            words += 1
    return words


def letters(text):
    letters = 0
    for i in range(0, len(text)):
        if text[i].isalpha() == True:
            letters += 1
    return letters


def sentences(text):
    sentences = 0
    for i in range(0, len(text)):
        if text[i] == &apos;.&apos; or text[i] == &apos;!&apos; or text[i] == &apos;?&apos;:
            sentences += 1
    return sentences


text = input(&quot;Text: &quot;)

index = round(0.0588 * letters(text) / words(text) * 100 -
              0.296 * sentences(text) / words(text) * 100 - 15.8)

if index &amp;lt; 1:
    print(&quot;Before Grade 1&quot;)

elif index &amp;gt;= 16:
    print(&quot;Grade 16+&quot;)
else:
    print(f&quot;Grade {index}&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Problem 5: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/6/dna/#dna&quot;&gt;DNA&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;import csv
import sys


def main():

    # TODO: Check for command-line usage
    if len(sys.argv) != 3:
        print(&quot;Missing command line arguments! &quot;)
        sys.exit()

    # TODO: Read database file into a variable
    database = []
    with open(sys.argv[1], &quot;r&quot;) as database_file:
        reader = csv.DictReader(database_file)
        for row in reader:
            database.append(row)

    # TODO: Read DNA sequence file into a variable
    sequence = []
    with open(sys.argv[2], &quot;r&quot;) as sequence_file:
        sequence = sequence_file.read()

    # TODO: Find longest match of each STR in DNA sequence
    str_count = {}  # Initlize a list
    for key in database[0].keys():
        if key == &quot;name&quot;:
            continue
        # When you insert a value but the key doesn&apos;t exist, python will create the key automatically and insert the value
        str_count[key] = longest_match(sequence, key)

    # TODO: Check database for matching profiles
    for row in database:
        match = True
        # 遍历所有的key，并去除&apos;name&apos;
        for key in row.keys():
            if key == &quot;name&quot;:
                continue
            # 当row[key]与str_count[key]不相等时，返回false，继续下一个key
            if str_count[key] != int(row[key]):
                match = False
                break
        if match:
            print(row[&quot;name&quot;])
            return
    print(&quot;No match&quot;)


def longest_match(sequence, subsequence):
    &quot;&quot;&quot;Returns length of longest run of subsequence in sequence.&quot;&quot;&quot;

    # Initialize variables
    longest_run = 0
    subsequence_length = len(subsequence)
    sequence_length = len(sequence)

    # Check each character in sequence for most consecutive runs of subsequence
    for i in range(sequence_length):

        # Initialize count of consecutive runs
        count = 0

        # Check for a subsequence match in a &quot;substring&quot; (a subset of characters) within sequence
        # If a match, move substring to next potential match in sequence
        # Continue moving substring and checking for matches until out of consecutive matches
        while True:

            # Adjust substring start and end
            start = i + count * subsequence_length
            end = start + subsequence_length

            # If there is a match in the substring
            if sequence[start:end] == subsequence:
                count += 1

            # If there is no match in the substring
            else:
                break

        # Update most consecutive matches found
        longest_run = max(longest_run, count)

    # After checking for runs at each character in sequence, return longest run found
    return longest_run


main()
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>CS50 Problem Set 9</title><link>https://tech.kinghua0629.com/posts/cs50-problem-set-9/</link><guid isPermaLink="true">https://tech.kinghua0629.com/posts/cs50-problem-set-9/</guid><description>Answer for CS50 Problem Set 9</description><pubDate>Wed, 18 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h1&gt;CS50 Problem Set 9&lt;/h1&gt;
&lt;p&gt;Here&apos;s my answers for the CS50 Problem Set 9. Hope that will help you a bit.&lt;/p&gt;
&lt;h2&gt;Problem 1: &lt;a href=&quot;https://cs50.harvard.edu/x/2026/psets/9/birthdays/#birthdays&quot;&gt;Birthdays&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;

&amp;lt;html lang=&quot;en&quot;&amp;gt;

    &amp;lt;head&amp;gt;
        &amp;lt;link href=&quot;https://fonts.googleapis.com/css2?family=Montserrat:wght@500&amp;amp;display=swap&quot; rel=&quot;stylesheet&quot;&amp;gt;
        &amp;lt;link href=&quot;/static/styles.css&quot; rel=&quot;stylesheet&quot;&amp;gt;
        &amp;lt;title&amp;gt;Birthdays&amp;lt;/title&amp;gt;
    &amp;lt;/head&amp;gt;

    &amp;lt;body&amp;gt;
        &amp;lt;div class=&quot;header&quot;&amp;gt;
            &amp;lt;h1&amp;gt;Birthdays&amp;lt;/h1&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class=&quot;container&quot;&amp;gt;
            &amp;lt;div class=&quot;section&quot;&amp;gt;

                &amp;lt;h2&amp;gt;Add a Birthday&amp;lt;/h2&amp;gt;
                &amp;lt;!-- TODO: Create a form for users to submit a name, a month, and a day --&amp;gt;
                &amp;lt;!-- With {action=&quot;/&quot; method =&quot;post&quot;}, the form can send data back to the server, and meet the requirement {request.method == &quot;POST&quot;} in app.py--&amp;gt;
                &amp;lt;form action=&quot;/&quot; method=&quot;post&quot;&amp;gt;
                    &amp;lt;input name=&quot;name&quot; placeholder=&quot;Name&quot; autofocus autocomplete=&quot;off&quot; type=&quot;text&quot; min=&quot;1&quot; max=&quot;12&quot;&amp;gt;
                    &amp;lt;input name=&quot;month&quot; placeholder=&quot;Month&quot; autocomplete=&quot;off&quot; type=&quot;number&quot; min=&quot;1&quot; max=&quot;31&quot;&amp;gt;
                    &amp;lt;input name=&quot;day&quot; placeholder=&quot;Day&quot; autocomplete=&quot;off&quot; type=&quot;number&quot;&amp;gt;
                    &amp;lt;input type=&quot;submit&quot; value=&quot;Add Birthday&quot;&amp;gt;
                &amp;lt;/form&amp;gt;


            &amp;lt;/div&amp;gt;

            &amp;lt;div class=&quot;section&quot;&amp;gt;

                &amp;lt;h2&amp;gt;All Birthdays&amp;lt;/h2&amp;gt;
                &amp;lt;table&amp;gt;
                    &amp;lt;thead&amp;gt;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt;
                            &amp;lt;th&amp;gt;Birthday&amp;lt;/th&amp;gt;
                        &amp;lt;/tr&amp;gt;
                    &amp;lt;/thead&amp;gt;
                    &amp;lt;tbody&amp;gt;
                        &amp;lt;!-- TODO: Loop through the database entries to display them in this table --&amp;gt;
                        {% for birthday in birthdays %}
                            &amp;lt;tr&amp;gt;
                                &amp;lt;td&amp;gt;{{ birthday[&quot;name&quot;] }}&amp;lt;/td&amp;gt;
                                &amp;lt;td&amp;gt;{{ birthday[&quot;month&quot;] }}/{{ birthday[&quot;day&quot;] }}&amp;lt;/td&amp;gt;
                            &amp;lt;/tr&amp;gt;
                        {% endfor %}
                    &amp;lt;/tbody&amp;gt;
                &amp;lt;/table&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;import os

from cs50 import SQL
from flask import Flask, flash, jsonify, redirect, render_template, request, session

# Configure application
app = Flask(__name__)

# Ensure templates are auto-reloaded
app.config[&quot;TEMPLATES_AUTO_RELOAD&quot;] = True

# Configure CS50 Library to use SQLite database
db = SQL(&quot;sqlite:///birthdays.db&quot;)


@app.after_request
def after_request(response):
    &quot;&quot;&quot;Ensure responses aren&apos;t cached&quot;&quot;&quot;
    response.headers[&quot;Cache-Control&quot;] = &quot;no-cache, no-store, must-revalidate&quot;
    response.headers[&quot;Expires&quot;] = 0
    response.headers[&quot;Pragma&quot;] = &quot;no-cache&quot;
    return response


@app.route(&quot;/&quot;, methods=[&quot;GET&quot;, &quot;POST&quot;])
def index():
    if request.method == &quot;POST&quot;:

        # TODO: Add the user&apos;s entry into the database
        name = request.form.get(&quot;name&quot;)
        if not name:
            return redirect(&quot;/&quot;)

        month = request.form.get(&quot;month&quot;)
        if not month:
            return redirect(&quot;/&quot;)

        day = request.form.get(&quot;day&quot;)
        if not day:
            return redirect(&quot;/&quot;)

        db.execute(&quot;INSERT INTO birthdays (name, month, day) VALUES(?, ?, ?)&quot;, name, month, day)

        return redirect(&quot;/&quot;)

    else:

        # TODO: Display the entries in the database on index.html
        birthdays = db.execute(&quot;SELECT * FROM birthdays&quot;)

        return render_template(&quot;index.html&quot;, birthdays=birthdays)
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Problem 2: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/9/finance/#c50-finance&quot;&gt;Finance&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;import os

from cs50 import SQL
from flask import Flask, flash, redirect, render_template, request, session
from flask_session import Session
from werkzeug.security import check_password_hash, generate_password_hash

from helpers import apology, login_required, lookup, usd

# Configure application
app = Flask(__name__)

# Custom filter
app.jinja_env.filters[&quot;usd&quot;] = usd

# Configure session to use filesystem (instead of signed cookies)
app.config[&quot;SESSION_PERMANENT&quot;] = False
app.config[&quot;SESSION_TYPE&quot;] = &quot;filesystem&quot;
Session(app)

# Configure CS50 Library to use SQLite database
db = SQL(&quot;sqlite:///finance.db&quot;)


@app.after_request
def after_request(response):
    &quot;&quot;&quot;Ensure responses aren&apos;t cached&quot;&quot;&quot;
    response.headers[&quot;Cache-Control&quot;] = &quot;no-cache, no-store, must-revalidate&quot;
    response.headers[&quot;Expires&quot;] = 0
    response.headers[&quot;Pragma&quot;] = &quot;no-cache&quot;
    return response


@app.route(&quot;/&quot;)
@login_required
def index():
    &quot;&quot;&quot;Show portfolio of stocks&quot;&quot;&quot;
    # select user&apos;s portfolio and cash
    rows = db.execute(&quot;SELECT * FROM portfolio WHERE userid = ?&quot;, session[&quot;user_id&quot;])
    cash_result = db.execute(&quot;SELECT cash FROM users WHERE id = ?&quot;, session[&quot;user_id&quot;])

    # get cash value
    cash = cash_result[0][&apos;cash&apos;]

    # intilize sum = cash
    sum = cash

    for row in rows:
        stock_info = lookup(row[&apos;symbol&apos;])
        if stock_info is None:
            continue  # Skip if stock info not available
        row[&apos;name&apos;] = stock_info[&apos;name&apos;]

        # Ensure price is numeric before calculations (handles string prices from API)
        try:
            price_numeric = float(stock_info[&apos;price&apos;])
        except (ValueError, TypeError):
            continue  # Skip if price is not a valid number

        row[&apos;price&apos;] = price_numeric
        row[&apos;total&apos;] = price_numeric * row[&apos;shares&apos;]
        sum = sum + row[&apos;total&apos;]

        # Format price and total as USD for display (don&apos;t modify original numeric values)
        row[&apos;price_usd&apos;] = usd(price_numeric)
        row[&apos;total_usd&apos;] = usd(row[&apos;total&apos;])

    return render_template(&quot;index.html&quot;, rows=rows, cash=usd(cash), sum=usd(sum))


@app.route(&quot;/buy&quot;, methods=[&quot;GET&quot;, &quot;POST&quot;])
@login_required
def buy():
    &quot;&quot;&quot;Buy shares of stock&quot;&quot;&quot;
    # if the method is GET, display buy.html to the user
    if request.method == &quot;GET&quot;:
        return render_template(&quot;buy.html&quot;)

    # if the method is POST
    else:
        symbol = request.form.get(&quot;symbol&quot;)
        shares = request.form.get(&quot;shares&quot;)
        quote = lookup(symbol)

        if not symbol:
            return apology(&quot;Please provide a stock symbol!&quot;, 400)

        if not shares:
            return apology(&quot;Please provide number of shares!&quot;, 400)

        if quote == None:
            return apology(&quot;Invalid stock symbol!&quot;, 400)

        # validate shares: must be a positive integer
        try:
            shares = float(shares)
            if shares != int(shares):
                return apology(&quot;Shares must be a whole number (no fractions)!&quot;, 400)
            shares = int(shares)
            if shares &amp;lt;= 0:
                return apology(&quot;Shares must be a positive number!&quot;, 400)
        except (ValueError, TypeError):
            return apology(&quot;Shares must be a numeric value!&quot;, 400)

        # calculate the purchase
        symbol = symbol.upper()
        # Ensure quote[&apos;price&apos;] is a number for calculations
        try:
            price = float(quote[&apos;price&apos;])
        except (ValueError, TypeError):
            return apology(&quot;Invalid stock price data!&quot;, 400)

        purchase = price * shares

        # get the balance
        balance_result = db.execute(&quot;SELECT cash FROM users WHERE id = ?&quot;, session[&quot;user_id&quot;])
        balance = balance_result[0][&apos;cash&apos;]

        # calculate the remainder
        remainder = balance - purchase

        if remainder &amp;lt; 0:
            return apology(&quot;Insufficient money!&quot;, 400)

        # update the database
        db.execute(&quot;UPDATE users SET cash = ? WHERE id = ?&quot;, remainder, session[&quot;user_id&quot;])

        # check if user already owns this stock
        existing = db.execute(&quot;SELECT shares FROM portfolio WHERE userid = ? AND symbol = ?&quot;,
                              session[&quot;user_id&quot;], symbol)

        if existing:
            # update existing position
            old_shares = existing[0][&apos;shares&apos;]
            new_shares = old_shares + shares
            db.execute(&quot;UPDATE portfolio SET shares = ? WHERE userid = ? AND symbol = ?&quot;,
                       new_shares, session[&quot;user_id&quot;], symbol)
        else:
            # create new position
            db.execute(&quot;INSERT INTO portfolio (userid, symbol, shares) VALUES (?, ?, ?)&quot;,
                       session[&quot;user_id&quot;], symbol, shares)

        # update history
        db.execute(&quot;INSERT INTO history (userid, symbol, shares, method, price) VALUES (?, ?, ?, ?, ?)&quot;,
                   session[&quot;user_id&quot;], symbol, shares, &apos;Buy&apos;, price)

        flash(f&quot;Bought {shares} shares of {symbol} costing {usd(purchase)}&quot;)
        return redirect(&quot;/&quot;)


@app.route(&quot;/history&quot;)
@login_required
def history():
    &quot;&quot;&quot;Show history of transactions&quot;&quot;&quot;

    rows = db.execute(&quot;SELECT * FROM history WHERE userid = ?&quot;, session[&quot;user_id&quot;])

    return render_template(&quot;history.html&quot;, rows=rows)


@app.route(&quot;/login&quot;, methods=[&quot;GET&quot;, &quot;POST&quot;])
def login():
    &quot;&quot;&quot;Log user in&quot;&quot;&quot;

    # Forget any user_id
    session.clear()

    # User reached route via POST (as by submitting a form via POST)
    if request.method == &quot;POST&quot;:
        # Ensure username was submitted
        username = request.form.get(&quot;username&quot;)
        if not username:
            return apology(&quot;must provide username&quot;, 403)

        # Ensure password was submitted
        password = request.form.get(&quot;password&quot;)
        if not password:
            return apology(&quot;must provide password&quot;, 403)

        # Query database for username
        rows = db.execute(
            &quot;SELECT * FROM users WHERE username = ?&quot;, username
        )

        # Ensure username exists and password is correct
        if len(rows) != 1 or not check_password_hash(
            rows[0][&quot;hash&quot;], password
        ):
            return apology(&quot;invalid username and/or password&quot;, 403)

        # Remember which user has logged in
        session[&quot;user_id&quot;] = rows[0][&quot;id&quot;]

        # Redirect user to home page
        return redirect(&quot;/&quot;)

    # User reached route via GET (as by clicking a link or via redirect)
    else:
        return render_template(&quot;login.html&quot;)


@app.route(&quot;/logout&quot;)
def logout():
    &quot;&quot;&quot;Log user out&quot;&quot;&quot;

    # Forget any user_id
    session.clear()

    # Redirect user to login form
    return redirect(&quot;/&quot;)


@app.route(&quot;/quote&quot;, methods=[&quot;GET&quot;, &quot;POST&quot;])
@login_required
def quote():
    &quot;&quot;&quot;Get stock quote.&quot;&quot;&quot;

    # if GET received, send quote.html to the user
    if request.method == &quot;GET&quot;:
        return render_template(&quot;quote.html&quot;)

    else:

        # lookup in the database
        symbol = lookup(request.form.get(&quot;symbol&quot;))

        if symbol == None:
            return apology(&quot;invalid stock symbol&quot;, 400)
        else:
            return render_template(&quot;quoted.html&quot;, symbol=symbol)


@app.route(&quot;/register&quot;, methods=[&quot;GET&quot;, &quot;POST&quot;])
def register():
    &quot;&quot;&quot;Register user&quot;&quot;&quot;
    # clear previous session
    session.clear()

    # submit the register form
    if request.method == &quot;POST&quot;:

        # check whether the username exists
        if not request.form.get(&quot;username&quot;):
            return apology(&quot;Username is required!&quot;, 400)

        # check whether the password exists
        elif not request.form.get(&quot;password&quot;):
            return apology(&quot;Password is required!&quot;, 400)

        # check whether the confirmation exists
        elif not request.form.get(&quot;confirmation&quot;):
            return apology(&quot;Confirmation is required!&quot;, 400)

        password = request.form.get(&quot;password&quot;)
        confirmation = request.form.get(&quot;confirmation&quot;)

        if not password or not confirmation:
            return apology(&quot;Password fields cannot be empty!&quot;, 400)

        # check whether the password is the same as confirmation
        if password != confirmation:
            return apology(&quot;Passwords do not match!&quot;, 400)

        # save the username, and hash the password
        username = request.form.get(&quot;username&quot;)
        hash = generate_password_hash(password)

        # check if the username has been taken
        rows = db.execute(&quot;SELECT * FROM users WHERE username = ?&quot;, username)
        if len(rows) != 0:
            return apology(&quot;Username already exists!&quot;, 400)

        # insert username and hash into database
        db.execute(&quot;INSERT INTO users (username, hash) VALUES (?, ?)&quot;, username, hash)

        # create new session for the user
        id = db.execute(&quot;SELECT id FROM users WHERE username = ?&quot;, username)
        session[&quot;user_id&quot;] = id[0][&quot;id&quot;]

        # redirect to login page
        return redirect(&quot;/login&quot;)

    else:
        return render_template(&quot;register.html&quot;)


@app.route(&quot;/sell&quot;, methods=[&quot;GET&quot;, &quot;POST&quot;])
@login_required
def sell():
    &quot;&quot;&quot;Sell shares of stock&quot;&quot;&quot;

    # if method=GET, send sell.html to the user
    if request.method == &quot;GET&quot;:
        # get the user&apos;s current stock
        portfolio = db.execute(&quot;SELECT symbol FROM portfolio WHERE userid = ?&quot;, session[&quot;user_id&quot;])
        return render_template(&quot;sell.html&quot;, portfolio=portfolio)

    # if method=POST, sell stocks
    else:
        # Save stock symbol, number of shares, and quote dict from form
        symbol = request.form.get(&quot;symbol&quot;)
        shares = request.form.get(&quot;shares&quot;)

        # check for symbol
        if not symbol:
            return apology(&quot;Must provide valid stock symbol!&quot;, 400)

        quote = lookup(symbol)
        if quote is None:
            return apology(&quot;Invalid stock symbol!&quot;, 400)

        rows = db.execute(&quot;SELECT * FROM portfolio WHERE userid = ? AND symbol = ?&quot;,
                          session[&quot;user_id&quot;], symbol.upper())

        # check for errors
        if len(rows) != 1:
            return apology(&quot;Must provide valid stock symbol!&quot;, 400)
        if not shares:
            return apology(&quot;Must provide number of shares!&quot;, 400)

        # validate shares: must be a positive integer
        try:
            shares = float(shares)
            if shares != int(shares):
                return apology(&quot;Shares must be a whole number (no fractions)!&quot;, 400)
            shares = int(shares)
            if shares &amp;lt;= 0:
                return apology(&quot;Shares must be a positive number!&quot;, 400)
        except (ValueError, TypeError):
            return apology(&quot;Shares must be a numeric value!&quot;, 400)

        # get the old shares
        oldshares = rows[0][&apos;shares&apos;]

        # check for errors
        if shares &amp;gt; oldshares:
            return apology(&quot;Shares sold can&apos;t exceed shares owned&quot;, 400)

        # calculate sold money
        # Ensure quote[&apos;price&apos;] is a number for calculations
        try:
            price = float(quote[&apos;price&apos;])
        except (ValueError, TypeError):
            return apology(&quot;Invalid stock price data!&quot;, 400)

        sold = price * shares

        # get the current cash of the user
        cash_result = db.execute(&quot;SELECT cash FROM users WHERE id = ?&quot;, session[&quot;user_id&quot;])
        cash = cash_result[0][&apos;cash&apos;]

        # calculate the new amount of cash
        cash = cash + sold

        # update the database
        db.execute(&quot;UPDATE users SET cash = ? WHERE id = ?&quot;, cash, session[&quot;user_id&quot;])

        # calcualte new shares
        newshares = oldshares - shares

        # if there&apos;s shares remain, update portfolio
        if newshares &amp;gt; 0:
            db.execute(&quot;UPDATE portfolio SET shares = ? WHERE userid = ? AND symbol = ?&quot;,
                       newshares, session[&quot;user_id&quot;], symbol)
        else:
            db.execute(&quot;DELETE FROM portfolio WHERE symbol = ? AND userid = ?&quot;,
                       symbol, session[&quot;user_id&quot;])

        # update history
        db.execute(&quot;INSERT INTO history (userid, symbol, shares, method, price) VALUES (?, ?, ?, ?, ?)&quot;,
                   session[&quot;user_id&quot;], symbol, shares, &apos;Sell&apos;, price)

        flash(f&quot;Sold {shares} shares of {symbol.upper()} for {usd(sold)}&quot;)
        return redirect(&quot;/&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;{% extends &quot;layout.html&quot; %}

{% block title %}
    Buy
{% endblock %}

{% block main %}
    &amp;lt;h2&amp;gt;Buy Shares&amp;lt;/h2&amp;gt;
    &amp;lt;form action=&quot;/buy&quot; method=&quot;post&quot;&amp;gt;
        &amp;lt;div&amp;gt;
            &amp;lt;input name=&quot;symbol&quot; placeholder=&quot;Symbol&quot; type=&quot;text&quot; autocomplete=&quot;off&quot; autofocus&amp;gt;
            &amp;lt;input name=&quot;shares&quot; placeholder=&quot;Shares&quot; type=&quot;number&quot; autocomplete=&quot;off&quot; autofocus min=&quot;0&quot;&amp;gt;
            &amp;lt;button type=&quot;submit&quot;&amp;gt;Buy&amp;lt;/button&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
{% endblock %}
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;{% extends &quot;layout.html&quot; %}

{% block title %}
    C$50 Finance: Portfolio
{% endblock %}

{% block main %}
    &amp;lt;table class=&quot;table table-bordered table-striped&quot;&amp;gt;
        &amp;lt;thead class=&quot;thead-light&quot;&amp;gt;
            &amp;lt;tr&amp;gt;
                &amp;lt;th&amp;gt;Symbol&amp;lt;/th&amp;gt;
                &amp;lt;th&amp;gt;Shares&amp;lt;/th&amp;gt;
                &amp;lt;th&amp;gt;Method&amp;lt;/th&amp;gt;
                &amp;lt;th&amp;gt;Price&amp;lt;/th&amp;gt;
                &amp;lt;th&amp;gt;Transacted&amp;lt;/th&amp;gt;
            &amp;lt;/thead&amp;gt;
            &amp;lt;tbody&amp;gt;
                {% for row in rows %}
                    &amp;lt;tr&amp;gt;
                        &amp;lt;td&amp;gt;{{ row[&apos;symbol&apos;] }}&amp;lt;/td&amp;gt;
                        &amp;lt;td&amp;gt;{{ row[&apos;shares&apos;] }}&amp;lt;/td&amp;gt;
                        &amp;lt;td&amp;gt;{{ row[&apos;method&apos;] }}&amp;lt;/td&amp;gt;
                        &amp;lt;td&amp;gt;{{ row[&apos;price&apos;] | usd }}&amp;lt;/td&amp;gt;
                        &amp;lt;td&amp;gt;{{ row[&apos;transacted&apos;] }}&amp;lt;/td&amp;gt;
                    &amp;lt;/tr&amp;gt;
                {% endfor %}
            &amp;lt;/tbody&amp;gt;
        &amp;lt;/table&amp;gt;
{% endblock %}
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;{% extends &quot;layout.html&quot; %}

{% block title %}
    C$50 Finance: Portfolio
{% endblock %}

{% block main %}
    &amp;lt;table class=&quot;table table-bordered table-striped&quot;&amp;gt;
        &amp;lt;thead class=&quot;thead-light&quot;&amp;gt;
            &amp;lt;tr&amp;gt;
                &amp;lt;th&amp;gt;Symbol&amp;lt;/th&amp;gt;
                &amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt;
                &amp;lt;th&amp;gt;Shares&amp;lt;/th&amp;gt;
                &amp;lt;th&amp;gt;Price&amp;lt;/th&amp;gt;
                &amp;lt;th&amp;gt;Total Value&amp;lt;/th&amp;gt;
            &amp;lt;/thead&amp;gt;
            &amp;lt;tbody&amp;gt;
                {% for row in rows %}
                    &amp;lt;tr&amp;gt;
                        &amp;lt;td&amp;gt;{{ row[&apos;symbol&apos;] }}&amp;lt;/td&amp;gt;
                        &amp;lt;td&amp;gt;{{ row[&apos;name&apos;] }}&amp;lt;/td&amp;gt;
                        &amp;lt;td&amp;gt;{{ row[&apos;shares&apos;] }}&amp;lt;/td&amp;gt;
                        &amp;lt;td&amp;gt;{{ row[&apos;price_usd&apos;] }}&amp;lt;/td&amp;gt;
                        &amp;lt;td&amp;gt;{{ row[&apos;total_usd&apos;] }}&amp;lt;/td&amp;gt;
                    &amp;lt;/tr&amp;gt;
                {% endfor %}
                &amp;lt;tr&amp;gt;
                    &amp;lt;td colspan=&quot;4&quot; align=&quot;right&quot;&amp;gt;Cash&amp;lt;/td&amp;gt;
                    &amp;lt;td&amp;gt;{{ cash }}&amp;lt;/td&amp;gt;
                &amp;lt;/tr&amp;gt;
                &amp;lt;tr&amp;gt;
                    &amp;lt;td colspan=&quot;4&quot; align=&quot;right&quot;&amp;gt;Total Value&amp;lt;/td&amp;gt;
                    &amp;lt;td&amp;gt;{{ sum }}&amp;lt;/td&amp;gt;
                &amp;lt;/tr&amp;gt;
            &amp;lt;/tbody&amp;gt;
        &amp;lt;/table&amp;gt;
{% endblock %}
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;{% extends &quot;layout.html&quot; %}

{% block title %}
    Log In
{% endblock %}

{% block main %}
    &amp;lt;form action=&quot;/login&quot; method=&quot;post&quot;&amp;gt;
        &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
            &amp;lt;input autocomplete=&quot;off&quot; autofocus class=&quot;form-control mx-auto w-auto&quot; name=&quot;username&quot; placeholder=&quot;Username&quot; type=&quot;text&quot;&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
            &amp;lt;input class=&quot;form-control mx-auto w-auto&quot; name=&quot;password&quot; placeholder=&quot;Password&quot; type=&quot;password&quot;&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;button class=&quot;btn btn-primary&quot; type=&quot;submit&quot;&amp;gt;Log In&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
{% endblock %}
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;{% extends &quot;layout.html&quot; %}

{% block title %}
    Quote
{% endblock %}

{% block main %}
    &amp;lt;h2&amp;gt;Get a stock quote&amp;lt;/h2&amp;gt;
    &amp;lt;form action=&quot;/quote&quot; method=&quot;post&quot;&amp;gt;
        &amp;lt;input autofocus name=&quot;symbol&quot; placeholder=&quot;Symbol&quot; type=&quot;text&quot;&amp;gt;
        &amp;lt;button type=&quot;submit&quot;&amp;gt;Get Quote&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
{% endblock %}
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;{% extends &quot;layout.html&quot; %}

{% block title %}
    Quote
{% endblock %}

{% block main %}
    A share of {{ symbol[&apos;name&apos;]}} ({{symbol[&apos;symbol&apos;]}}) costs {{ symbol[&apos;price&apos;] | usd}}
{% endblock %}
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;{% extends &quot;layout.html&quot; %}

{% block title %}
    Register
{% endblock %}

{% block main %}
    &amp;lt;form action=&quot;/register&quot; method=&quot;post&quot;&amp;gt;
        &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
            &amp;lt;input autocomplete=&quot;off&quot; autofocus class=&quot;form-control mx-auto w-auto&quot; name=&quot;username&quot; placeholder=&quot;Username&quot; type=&quot;text&quot;&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
            &amp;lt;input class=&quot;form-control mx-auto w-auto&quot; name=&quot;password&quot; placeholder=&quot;Password&quot; type=&quot;password&quot;&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
            &amp;lt;input class=&quot;form-control mx-auto w-auto&quot; name=&quot;confirmation&quot; placeholder=&quot;Confirmation&quot; type=&quot;password&quot;&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;button class=&quot;btn btn-primary&quot; type=&quot;submit&quot;&amp;gt;Register&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
{% endblock %}
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;{% extends &quot;layout.html&quot; %}

{% block title %}
    Sell
{% endblock %}

{% block main %}
    &amp;lt;h2&amp;gt;Sell Shares&amp;lt;/h2&amp;gt;
    &amp;lt;form action=&quot;/sell&quot; method=&quot;post&quot;&amp;gt;
        &amp;lt;div&amp;gt;
            &amp;lt;select class=&quot;form-control&quot; name=&quot;symbol&quot; type=&quot;text&quot;&amp;gt;
                &amp;lt;option value=&quot;&quot; disabled selected&amp;gt;Symbol&amp;lt;/option&amp;gt;
                {% for row in portfolio %}
                    &amp;lt;option value=&quot;{{ row[&apos;symbol&apos;] }}&quot;&amp;gt;{{ row[&apos;symbol&apos;] }}&amp;lt;/option&amp;gt;
                {% endfor %}
            &amp;lt;/select&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div&amp;gt;
            &amp;lt;input name=&quot;shares&quot; placeholder=&quot;Shares&quot; type=&quot;number&quot; min=&quot;1&quot;&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;button type=&quot;submit&quot;&amp;gt;Sell&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
{% endblock %}
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>CS50 Problem Set 8</title><link>https://tech.kinghua0629.com/posts/cs50-problem-set-8/</link><guid isPermaLink="true">https://tech.kinghua0629.com/posts/cs50-problem-set-8/</guid><description>Answer for CS50 Problem Set 8</description><pubDate>Wed, 18 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h1&gt;CS50 Problem Set 8&lt;/h1&gt;
&lt;p&gt;Here&apos;s my answers for the CS50 Problem Set 8. Hope that will help you a bit.&lt;/p&gt;
&lt;h2&gt;Problem 1: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/8/trivia/#trivia&quot;&gt;Trivia&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;

&amp;lt;html lang=&quot;en&quot;&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;link
      href=&quot;https://fonts.googleapis.com/css2?family=Montserrat:wght@500&amp;amp;display=swap&quot;
      rel=&quot;stylesheet&quot;
    /&amp;gt;
    &amp;lt;link href=&quot;styles.css&quot; rel=&quot;stylesheet&quot; /&amp;gt;
    &amp;lt;title&amp;gt;Trivia!&amp;lt;/title&amp;gt;
    &amp;lt;script&amp;gt;
      // TODO: Add code to check answers to questions
      function checkMultipleChoices(event) {
        // Get the element which triggered the event
        let button = event.target;

        // Check if the element&apos;s inner HTML matches expected answer
        if (button.innerHTML == &quot;1 person per 6 sheep&quot;) {
          button.style.backgroundColor = &quot;Green&quot;;
          button.parentElement.querySelector(&quot;.feedback&quot;).innerHTML =
            &quot;Correcrt&quot;;
        } else {
          button.style.backgroundColor = &quot;Red&quot;;
          button.parentElement.querySelector(&quot;.feedback&quot;).innerHTML =
            &quot;Incorrecrt&quot;;
        }
      }

      function checkFreeResponse(event) {
        // Get the element which triggered the event
        let button = event.target;

        // Get the input element corresponding to the button
        let input = button.parentElement.querySelector(&quot;input&quot;);

        //Check if the answer is correct
        if (input.value == &quot;Switzerland&quot;) {
          input.style.backgroundColor = &quot;Green&quot;;
          input.parentElement.querySelector(&quot;.feedback&quot;).innerHTML = &quot;Correcrt&quot;;
        } else {
          input.style.backgroundColor = &quot;Red&quot;;
          input.parentElement.querySelector(&quot;.feedback&quot;).innerHTML =
            &quot;Incorrecrt&quot;;
        }
      }
    &amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;
    &amp;lt;div class=&quot;header&quot;&amp;gt;
      &amp;lt;h1&amp;gt;Trivia!&amp;lt;/h1&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;div class=&quot;container&quot;&amp;gt;
      &amp;lt;div class=&quot;section&quot;&amp;gt;
        &amp;lt;h2&amp;gt;Part 1: Multiple Choice&amp;lt;/h2&amp;gt;
        &amp;lt;hr /&amp;gt;
        &amp;lt;!-- TODO: Add multiple choice question here --&amp;gt;
        &amp;lt;h3&amp;gt;
          What is the approximate ratio of people to sheep in New Zealand?
        &amp;lt;/h3&amp;gt;
        &amp;lt;button onclick=&quot;checkMultipleChoices(event)&quot;&amp;gt;
          6 people per 1 sheep
        &amp;lt;/button&amp;gt;
        &amp;lt;button onclick=&quot;checkMultipleChoices(event)&quot;&amp;gt;
          3 people per 1 sheep
        &amp;lt;/button&amp;gt;
        &amp;lt;button onclick=&quot;checkMultipleChoices(event)&quot;&amp;gt;
          1 person per 1 sheep
        &amp;lt;/button&amp;gt;
        &amp;lt;button onclick=&quot;checkMultipleChoices(event)&quot;&amp;gt;
          1 person per 3 sheep
        &amp;lt;/button&amp;gt;
        &amp;lt;button onclick=&quot;checkMultipleChoices(event)&quot;&amp;gt;
          1 person per 6 sheep
        &amp;lt;/button&amp;gt;
        &amp;lt;p class=&quot;feedback&quot;&amp;gt;&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;

      &amp;lt;div class=&quot;section&quot;&amp;gt;
        &amp;lt;h2&amp;gt;Part 2: Free Response&amp;lt;/h2&amp;gt;
        &amp;lt;hr /&amp;gt;
        &amp;lt;!-- TODO: Add free response question here --&amp;gt;
        &amp;lt;h3&amp;gt;
          In which country is it illegal to own only one guinea pig, as a lone
          guinea pig might get lonely?
        &amp;lt;/h3&amp;gt;
        &amp;lt;input type=&quot;text&quot; placeholder=&quot;Enter text here&quot; /&amp;gt;
        &amp;lt;button onclick=&quot;checkFreeResponse(event)&quot;&amp;gt;Check Answer&amp;lt;/button&amp;gt;
        &amp;lt;p class=&quot;feedback&quot;&amp;gt;&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Problem 2: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/8/homepage/#homepage&quot;&gt;Homepage&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang=&quot;en&quot;&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset=&quot;UTF-8&quot; /&amp;gt;
    &amp;lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&amp;gt;
    &amp;lt;title&amp;gt;About Me - My Homepage&amp;lt;/title&amp;gt;
    &amp;lt;!-- Bootstrap CSS --&amp;gt;
    &amp;lt;link
      href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css&quot;
      rel=&quot;stylesheet&quot;
      integrity=&quot;sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB&quot;
      crossorigin=&quot;anonymous&quot;
    /&amp;gt;
    &amp;lt;!-- Custom CSS --&amp;gt;
    &amp;lt;link href=&quot;styles.css&quot; rel=&quot;stylesheet&quot; /&amp;gt;
  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;
    &amp;lt;!-- Navigation Bar --&amp;gt;
    &amp;lt;nav class=&quot;navbar navbar-expand-lg navbar-dark bg-primary sticky-top&quot;&amp;gt;
      &amp;lt;div class=&quot;container&quot;&amp;gt;
        &amp;lt;a class=&quot;navbar-brand&quot; href=&quot;index.html&quot;&amp;gt;My Homepage&amp;lt;/a&amp;gt;
        &amp;lt;button
          class=&quot;navbar-toggler&quot;
          type=&quot;button&quot;
          data-bs-toggle=&quot;collapse&quot;
          data-bs-target=&quot;#navbarNav&quot;
        &amp;gt;
          &amp;lt;span class=&quot;navbar-toggler-icon&quot;&amp;gt;&amp;lt;/span&amp;gt;
        &amp;lt;/button&amp;gt;
        &amp;lt;div class=&quot;navbar-collapse collapse&quot; id=&quot;navbarNav&quot;&amp;gt;
          &amp;lt;ul class=&quot;navbar-nav ms-auto&quot;&amp;gt;
            &amp;lt;li class=&quot;nav-item&quot;&amp;gt;
              &amp;lt;a class=&quot;nav-link&quot; href=&quot;index.html&quot;&amp;gt;Home&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
            &amp;lt;li class=&quot;nav-item&quot;&amp;gt;
              &amp;lt;a class=&quot;nav-link active&quot; href=&quot;about.html&quot;&amp;gt;About Me&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
            &amp;lt;li class=&quot;nav-item&quot;&amp;gt;
              &amp;lt;a class=&quot;nav-link&quot; href=&quot;hobbies.html&quot;&amp;gt;Hobbies&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
            &amp;lt;li class=&quot;nav-item&quot;&amp;gt;
              &amp;lt;a class=&quot;nav-link&quot; href=&quot;contact.html&quot;&amp;gt;Contact&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
          &amp;lt;/ul&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/nav&amp;gt;

    &amp;lt;!-- Page Header --&amp;gt;
    &amp;lt;header class=&quot;bg-secondary py-5 text-white&quot;&amp;gt;
      &amp;lt;div class=&quot;container text-center&quot;&amp;gt;
        &amp;lt;h1 class=&quot;display-4&quot;&amp;gt;About Me&amp;lt;/h1&amp;gt;
        &amp;lt;p class=&quot;lead&quot;&amp;gt;Get to know me better&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/header&amp;gt;

    &amp;lt;!-- Main Content --&amp;gt;
    &amp;lt;main class=&quot;container my-5&quot;&amp;gt;
      &amp;lt;div class=&quot;row&quot;&amp;gt;
        &amp;lt;div class=&quot;col-lg-8 mx-auto&quot;&amp;gt;
          &amp;lt;article&amp;gt;
            &amp;lt;h2 class=&quot;mb-4&quot;&amp;gt;Hello There!&amp;lt;/h2&amp;gt;

            &amp;lt;section class=&quot;mb-5&quot;&amp;gt;
              &amp;lt;h3&amp;gt;Who Am I?&amp;lt;/h3&amp;gt;
              &amp;lt;p&amp;gt;
                I&apos;m a passionate learner currently working on expanding my web
                development skills through the CS50 course. This homepage
                represents my journey into HTML, CSS, and JavaScript
                development.
              &amp;lt;/p&amp;gt;
              &amp;lt;p&amp;gt;
                As someone interested in technology and programming, I enjoy
                exploring new concepts and applying them to create meaningful
                projects like this one.
              &amp;lt;/p&amp;gt;
            &amp;lt;/section&amp;gt;

            &amp;lt;section class=&quot;mb-5&quot;&amp;gt;
              &amp;lt;h3&amp;gt;My Background&amp;lt;/h3&amp;gt;
              &amp;lt;p&amp;gt;
                I have a diverse background with interests spanning multiple
                fields. While I&apos;m currently focused on computer science and web
                development, I maintain curiosity about various subjects
                including:
              &amp;lt;/p&amp;gt;
              &amp;lt;ul&amp;gt;
                &amp;lt;li&amp;gt;Computer Science and Programming&amp;lt;/li&amp;gt;
                &amp;lt;li&amp;gt;Formula 1&amp;lt;/li&amp;gt;
                &amp;lt;li&amp;gt;Mathmatics and Physics&amp;lt;/li&amp;gt;
              &amp;lt;/ul&amp;gt;
            &amp;lt;/section&amp;gt;

            &amp;lt;section class=&quot;mb-5&quot;&amp;gt;
              &amp;lt;h3&amp;gt;Education &amp;amp; Learning&amp;lt;/h3&amp;gt;
              &amp;lt;p&amp;gt;
                I&apos;m currently enrolled in Harvard&apos;s CS50 course, which has been
                an incredible learning experience. Through this course, I&apos;ve
                gained valuable insights into:
              &amp;lt;/p&amp;gt;
              &amp;lt;div class=&quot;row&quot;&amp;gt;
                &amp;lt;div class=&quot;col-md-6&quot;&amp;gt;
                  &amp;lt;ul&amp;gt;
                    &amp;lt;li&amp;gt;Programming fundamentals&amp;lt;/li&amp;gt;
                    &amp;lt;li&amp;gt;Web development basics&amp;lt;/li&amp;gt;
                    &amp;lt;li&amp;gt;Problem-solving approaches&amp;lt;/li&amp;gt;
                  &amp;lt;/ul&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div class=&quot;col-md-6&quot;&amp;gt;
                  &amp;lt;ul&amp;gt;
                    &amp;lt;li&amp;gt;Algorithm thinking&amp;lt;/li&amp;gt;
                    &amp;lt;li&amp;gt;Code optimization&amp;lt;/li&amp;gt;
                    &amp;lt;li&amp;gt;Project development&amp;lt;/li&amp;gt;
                  &amp;lt;/ul&amp;gt;
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;

            &amp;lt;section class=&quot;bg-light rounded p-4&quot;&amp;gt;
              &amp;lt;h3&amp;gt;Fun Facts About Me&amp;lt;/h3&amp;gt;
              &amp;lt;div class=&quot;row&quot;&amp;gt;
                &amp;lt;div class=&quot;col-md-4 text-center&quot;&amp;gt;
                  &amp;lt;div class=&quot;p-3&quot;&amp;gt;
                    &amp;lt;h4 class=&quot;text-primary&quot;&amp;gt;📚&amp;lt;/h4&amp;gt;
                    &amp;lt;p&amp;gt;I love reading books on technology and science&amp;lt;/p&amp;gt;
                  &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div class=&quot;col-md-4 text-center&quot;&amp;gt;
                  &amp;lt;div class=&quot;p-3&quot;&amp;gt;
                    &amp;lt;h4 class=&quot;text-primary&quot;&amp;gt;🎮&amp;lt;/h4&amp;gt;
                    &amp;lt;p&amp;gt;Enjoy playing strategy games in my free time&amp;lt;/p&amp;gt;
                  &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div class=&quot;col-md-4 text-center&quot;&amp;gt;
                  &amp;lt;div class=&quot;p-3&quot;&amp;gt;
                    &amp;lt;h4 class=&quot;text-primary&quot;&amp;gt;☕&amp;lt;/h4&amp;gt;
                    &amp;lt;p&amp;gt;Believe that good coffee fuels great ideas&amp;lt;/p&amp;gt;
                  &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;
          &amp;lt;/article&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;

    &amp;lt;!-- Footer --&amp;gt;
    &amp;lt;footer class=&quot;bg-dark mt-5 py-4 text-white&quot;&amp;gt;
      &amp;lt;div class=&quot;container text-center&quot;&amp;gt;
        &amp;lt;p&amp;gt;2026 My Homepage.&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/footer&amp;gt;

    &amp;lt;!-- Bootstrap JS --&amp;gt;
    &amp;lt;script
      src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js&quot;
      integrity=&quot;sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI&quot;
      crossorigin=&quot;anonymous&quot;
    &amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;!-- Custom JavaScript --&amp;gt;
    &amp;lt;script src=&quot;script.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang=&quot;en&quot;&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset=&quot;UTF-8&quot; /&amp;gt;
    &amp;lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&amp;gt;
    &amp;lt;title&amp;gt;Contact Me - My Homepage&amp;lt;/title&amp;gt;
    &amp;lt;!-- Bootstrap CSS --&amp;gt;
    &amp;lt;link
      href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css&quot;
      rel=&quot;stylesheet&quot;
      integrity=&quot;sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB&quot;
      crossorigin=&quot;anonymous&quot;
    /&amp;gt;
    &amp;lt;!-- Custom CSS --&amp;gt;
    &amp;lt;link href=&quot;styles.css&quot; rel=&quot;stylesheet&quot; /&amp;gt;
  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;
    &amp;lt;!-- Navigation Bar --&amp;gt;
    &amp;lt;nav class=&quot;navbar navbar-expand-lg navbar-dark bg-primary sticky-top&quot;&amp;gt;
      &amp;lt;div class=&quot;container&quot;&amp;gt;
        &amp;lt;a class=&quot;navbar-brand&quot; href=&quot;index.html&quot;&amp;gt;My Homepage&amp;lt;/a&amp;gt;
        &amp;lt;button
          class=&quot;navbar-toggler&quot;
          type=&quot;button&quot;
          data-bs-toggle=&quot;collapse&quot;
          data-bs-target=&quot;#navbarNav&quot;
        &amp;gt;
          &amp;lt;span class=&quot;navbar-toggler-icon&quot;&amp;gt;&amp;lt;/span&amp;gt;
        &amp;lt;/button&amp;gt;
        &amp;lt;div class=&quot;navbar-collapse collapse&quot; id=&quot;navbarNav&quot;&amp;gt;
          &amp;lt;ul class=&quot;navbar-nav ms-auto&quot;&amp;gt;
            &amp;lt;li class=&quot;nav-item&quot;&amp;gt;
              &amp;lt;a class=&quot;nav-link&quot; href=&quot;index.html&quot;&amp;gt;Home&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
            &amp;lt;li class=&quot;nav-item&quot;&amp;gt;
              &amp;lt;a class=&quot;nav-link&quot; href=&quot;about.html&quot;&amp;gt;About Me&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
            &amp;lt;li class=&quot;nav-item&quot;&amp;gt;
              &amp;lt;a class=&quot;nav-link&quot; href=&quot;hobbies.html&quot;&amp;gt;Hobbies&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
            &amp;lt;li class=&quot;nav-item&quot;&amp;gt;
              &amp;lt;a class=&quot;nav-link active&quot; href=&quot;contact.html&quot;&amp;gt;Contact&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
          &amp;lt;/ul&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/nav&amp;gt;

    &amp;lt;!-- Page Header --&amp;gt;
    &amp;lt;header class=&quot;bg-warning text-dark py-5&quot;&amp;gt;
      &amp;lt;div class=&quot;container text-center&quot;&amp;gt;
        &amp;lt;h1 class=&quot;display-4&quot;&amp;gt;Get In Touch&amp;lt;/h1&amp;gt;
        &amp;lt;p class=&quot;lead&quot;&amp;gt;
          Feel free to reach out for any inquiries or collaborations
        &amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/header&amp;gt;

    &amp;lt;!-- Main Content --&amp;gt;
    &amp;lt;main class=&quot;container my-5&quot;&amp;gt;
      &amp;lt;div class=&quot;row&quot;&amp;gt;
        &amp;lt;!-- Contact Form --&amp;gt;
        &amp;lt;div class=&quot;col-lg-6 mb-5&quot;&amp;gt;
          &amp;lt;div class=&quot;card shadow&quot;&amp;gt;
            &amp;lt;div class=&quot;card-header bg-primary text-white&quot;&amp;gt;
              &amp;lt;h3 class=&quot;mb-0&quot;&amp;gt;Send Me a Message&amp;lt;/h3&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class=&quot;card-body&quot;&amp;gt;
              &amp;lt;form id=&quot;contactForm&quot;&amp;gt;
                &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                  &amp;lt;label for=&quot;name&quot; class=&quot;form-label&quot;&amp;gt;Name *&amp;lt;/label&amp;gt;
                  &amp;lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;name&quot; required /&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                  &amp;lt;label for=&quot;email&quot; class=&quot;form-label&quot;&amp;gt;Email *&amp;lt;/label&amp;gt;
                  &amp;lt;input
                    type=&quot;email&quot;
                    class=&quot;form-control&quot;
                    id=&quot;email&quot;
                    required
                  /&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                  &amp;lt;label for=&quot;subject&quot; class=&quot;form-label&quot;&amp;gt;Subject&amp;lt;/label&amp;gt;
                  &amp;lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;subject&quot; /&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                  &amp;lt;label for=&quot;message&quot; class=&quot;form-label&quot;&amp;gt;Message *&amp;lt;/label&amp;gt;
                  &amp;lt;textarea
                    class=&quot;form-control&quot;
                    id=&quot;message&quot;
                    rows=&quot;5&quot;
                    required
                  &amp;gt;&amp;lt;/textarea&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;button type=&quot;submit&quot; class=&quot;btn btn-primary&quot;&amp;gt;
                  Send Message
                &amp;lt;/button&amp;gt;
                &amp;lt;button type=&quot;reset&quot; class=&quot;btn btn-outline-secondary ms-2&quot;&amp;gt;
                  Clear Form
                &amp;lt;/button&amp;gt;
              &amp;lt;/form&amp;gt;
              &amp;lt;div id=&quot;formSuccess&quot; class=&quot;alert alert-success d-none mt-3&quot;&amp;gt;
                Thank you for your message! I&apos;ll get back to you soon.
              &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;

        &amp;lt;!-- Contact Information --&amp;gt;
        &amp;lt;div class=&quot;col-lg-6&quot;&amp;gt;
          &amp;lt;div class=&quot;card shadow&quot;&amp;gt;
            &amp;lt;div class=&quot;card-header bg-success text-white&quot;&amp;gt;
              &amp;lt;h3 class=&quot;mb-0&quot;&amp;gt;Contact Information&amp;lt;/h3&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class=&quot;card-body&quot;&amp;gt;
              &amp;lt;ul class=&quot;list-group list-group-flush&quot;&amp;gt;
                &amp;lt;li class=&quot;list-group-item&quot;&amp;gt;
                  &amp;lt;strong&amp;gt;📧 Email:&amp;lt;/strong&amp;gt;
                  &amp;lt;a
                    href=&quot;mailto:kinghua0629@outlook.com&quot;
                    class=&quot;text-decoration-none&quot;
                    &amp;gt;kinghua0629@outlook.com&amp;lt;/a
                  &amp;gt;
                &amp;lt;/li&amp;gt;
                &amp;lt;li class=&quot;list-group-item&quot;&amp;gt;
                  &amp;lt;strong&amp;gt;🌐 Website:&amp;lt;/strong&amp;gt;
                  &amp;lt;a
                    href=&quot;https://kinghua0629.github.io&quot;
                    target=&quot;_blank&quot;
                    class=&quot;text-decoration-none&quot;
                    &amp;gt;kinghua0629.github.io&amp;lt;/a
                  &amp;gt;
                &amp;lt;/li&amp;gt;
                &amp;lt;li class=&quot;list-group-item&quot;&amp;gt;
                  &amp;lt;strong&amp;gt;📍 Location:&amp;lt;/strong&amp;gt; Shanghai, China
                &amp;lt;/li&amp;gt;
                &amp;lt;li class=&quot;list-group-item&quot;&amp;gt;
                  &amp;lt;strong&amp;gt;🕒 Availability:&amp;lt;/strong&amp;gt; Usually responsive during
                  business hours
                &amp;lt;/li&amp;gt;
              &amp;lt;/ul&amp;gt;

              &amp;lt;div class=&quot;mt-4&quot;&amp;gt;
                &amp;lt;h5&amp;gt;Social Links&amp;lt;/h5&amp;gt;
                &amp;lt;div class=&quot;d-flex gap-2&quot;&amp;gt;
                  &amp;lt;a
                    href=&quot;https://github.com/kinghua0629&quot;
                    class=&quot;btn btn-outline-primary&quot;
                    &amp;gt;GitHub&amp;lt;/a
                  &amp;gt;
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;

          &amp;lt;!-- FAQ Section --&amp;gt;
          &amp;lt;div class=&quot;card mt-4 shadow&quot;&amp;gt;
            &amp;lt;div class=&quot;card-header bg-info text-white&quot;&amp;gt;
              &amp;lt;h3 class=&quot;mb-0&quot;&amp;gt;Frequently Asked Questions&amp;lt;/h3&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class=&quot;card-body&quot;&amp;gt;
              &amp;lt;div class=&quot;accordion&quot; id=&quot;faqAccordion&quot;&amp;gt;
                &amp;lt;div class=&quot;accordion-item&quot;&amp;gt;
                  &amp;lt;h2 class=&quot;accordion-header&quot; id=&quot;faqHeading1&quot;&amp;gt;
                    &amp;lt;button
                      class=&quot;accordion-button&quot;
                      type=&quot;button&quot;
                      data-bs-toggle=&quot;collapse&quot;
                      data-bs-target=&quot;#faqCollapse1&quot;
                    &amp;gt;
                      How long does it take to get a response?
                    &amp;lt;/button&amp;gt;
                  &amp;lt;/h2&amp;gt;
                  &amp;lt;div
                    id=&quot;faqCollapse1&quot;
                    class=&quot;accordion-collapse show collapse&quot;
                    data-bs-parent=&quot;#faqAccordion&quot;
                  &amp;gt;
                    &amp;lt;div class=&quot;accordion-body&quot;&amp;gt;
                      I typically respond to emails within 24 hours during
                      weekdays.
                    &amp;lt;/div&amp;gt;
                  &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;

                &amp;lt;div class=&quot;accordion-item&quot;&amp;gt;
                  &amp;lt;h2 class=&quot;accordion-header&quot; id=&quot;faqHeading2&quot;&amp;gt;
                    &amp;lt;button
                      class=&quot;accordion-button collapsed&quot;
                      type=&quot;button&quot;
                      data-bs-toggle=&quot;collapse&quot;
                      data-bs-target=&quot;#faqCollapse2&quot;
                    &amp;gt;
                      Do you accept collaboration requests?
                    &amp;lt;/button&amp;gt;
                  &amp;lt;/h2&amp;gt;
                  &amp;lt;div
                    id=&quot;faqCollapse2&quot;
                    class=&quot;accordion-collapse collapse&quot;
                    data-bs-parent=&quot;#faqAccordion&quot;
                  &amp;gt;
                    &amp;lt;div class=&quot;accordion-body&quot;&amp;gt;
                      Yes! I&apos;m always interested in interesting projects and
                      collaborations. Feel free to describe your idea in the
                      message.
                    &amp;lt;/div&amp;gt;
                  &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;

    &amp;lt;!-- Footer --&amp;gt;
    &amp;lt;footer class=&quot;bg-dark mt-5 py-4 text-white&quot;&amp;gt;
      &amp;lt;div class=&quot;container text-center&quot;&amp;gt;
        &amp;lt;p&amp;gt;&amp;amp;copy; 2026 My Homepage.&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/footer&amp;gt;

    &amp;lt;!-- Bootstrap JS --&amp;gt;
    &amp;lt;script
      src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js&quot;
      integrity=&quot;sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI&quot;
      crossorigin=&quot;anonymous&quot;
    &amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;!-- Custom JavaScript --&amp;gt;
    &amp;lt;script src=&quot;script.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang=&quot;en&quot;&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset=&quot;UTF-8&quot; /&amp;gt;
    &amp;lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&amp;gt;
    &amp;lt;title&amp;gt;My Hobbies - My Homepage&amp;lt;/title&amp;gt;
    &amp;lt;!-- Bootstrap CSS --&amp;gt;
    &amp;lt;link
      href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css&quot;
      rel=&quot;stylesheet&quot;
      integrity=&quot;sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB&quot;
      crossorigin=&quot;anonymous&quot;
    /&amp;gt;
    &amp;lt;!-- Custom CSS --&amp;gt;
    &amp;lt;link href=&quot;styles.css&quot; rel=&quot;stylesheet&quot; /&amp;gt;
  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;
    &amp;lt;!-- Navigation Bar --&amp;gt;
    &amp;lt;nav class=&quot;navbar navbar-expand-lg navbar-dark bg-primary sticky-top&quot;&amp;gt;
      &amp;lt;div class=&quot;container&quot;&amp;gt;
        &amp;lt;a class=&quot;navbar-brand&quot; href=&quot;index.html&quot;&amp;gt;My Homepage&amp;lt;/a&amp;gt;
        &amp;lt;button
          class=&quot;navbar-toggler&quot;
          type=&quot;button&quot;
          data-bs-toggle=&quot;collapse&quot;
          data-bs-target=&quot;#navbarNav&quot;
        &amp;gt;
          &amp;lt;span class=&quot;navbar-toggler-icon&quot;&amp;gt;&amp;lt;/span&amp;gt;
        &amp;lt;/button&amp;gt;
        &amp;lt;div class=&quot;navbar-collapse collapse&quot; id=&quot;navbarNav&quot;&amp;gt;
          &amp;lt;ul class=&quot;navbar-nav ms-auto&quot;&amp;gt;
            &amp;lt;li class=&quot;nav-item&quot;&amp;gt;
              &amp;lt;a class=&quot;nav-link&quot; href=&quot;index.html&quot;&amp;gt;Home&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
            &amp;lt;li class=&quot;nav-item&quot;&amp;gt;
              &amp;lt;a class=&quot;nav-link&quot; href=&quot;about.html&quot;&amp;gt;About Me&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
            &amp;lt;li class=&quot;nav-item&quot;&amp;gt;
              &amp;lt;a class=&quot;nav-link active&quot; href=&quot;hobbies.html&quot;&amp;gt;Hobbies&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
            &amp;lt;li class=&quot;nav-item&quot;&amp;gt;
              &amp;lt;a class=&quot;nav-link&quot; href=&quot;contact.html&quot;&amp;gt;Contact&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
          &amp;lt;/ul&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/nav&amp;gt;

    &amp;lt;!-- Page Header --&amp;gt;
    &amp;lt;header class=&quot;bg-success py-5 text-white&quot;&amp;gt;
      &amp;lt;div class=&quot;container text-center&quot;&amp;gt;
        &amp;lt;h1 class=&quot;display-4&quot;&amp;gt;My Hobbies &amp;amp; Interests&amp;lt;/h1&amp;gt;
        &amp;lt;p class=&quot;lead&quot;&amp;gt;Things I enjoy doing in my spare time&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/header&amp;gt;

    &amp;lt;!-- Main Content --&amp;gt;
    &amp;lt;main class=&quot;container my-5&quot;&amp;gt;
      &amp;lt;!-- Hobbies Gallery --&amp;gt;
      &amp;lt;div class=&quot;row&quot;&amp;gt;
        &amp;lt;div class=&quot;col-md-4 mb-4&quot;&amp;gt;
          &amp;lt;div class=&quot;card h-100&quot;&amp;gt;
            &amp;lt;div class=&quot;card-body&quot;&amp;gt;
              &amp;lt;h5 class=&quot;card-title text-success&quot;&amp;gt;💻 Programming&amp;lt;/h5&amp;gt;
              &amp;lt;p class=&quot;card-text&quot;&amp;gt;
                I love solving problems through code and building applications.
                Currently learning web development through CS50.
              &amp;lt;/p&amp;gt;
              &amp;lt;div class=&quot;progress&quot;&amp;gt;
                &amp;lt;div
                  class=&quot;progress-bar bg-success&quot;
                  role=&quot;progressbar&quot;
                  style=&quot;width: 75%&quot;
                &amp;gt;
                  75%
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;

        &amp;lt;div class=&quot;col-md-4 mb-4&quot;&amp;gt;
          &amp;lt;div class=&quot;card h-100&quot;&amp;gt;
            &amp;lt;div class=&quot;card-body&quot;&amp;gt;
              &amp;lt;h5 class=&quot;card-title text-primary&quot;&amp;gt;📖 Reading&amp;lt;/h5&amp;gt;
              &amp;lt;p class=&quot;card-text&quot;&amp;gt;
                Passionate about books on technology, science fiction, and
                personal development. Always looking for new recommendations.
              &amp;lt;/p&amp;gt;
              &amp;lt;div class=&quot;progress&quot;&amp;gt;
                &amp;lt;div
                  class=&quot;progress-bar bg-primary&quot;
                  role=&quot;progressbar&quot;
                  style=&quot;width: 70%&quot;
                &amp;gt;
                  70%
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;

        &amp;lt;div class=&quot;col-md-4 mb-4&quot;&amp;gt;
          &amp;lt;div class=&quot;card h-100&quot;&amp;gt;
            &amp;lt;div class=&quot;card-body&quot;&amp;gt;
              &amp;lt;h5 class=&quot;card-title text-warning&quot;&amp;gt;🎮 Gaming&amp;lt;/h5&amp;gt;
              &amp;lt;p class=&quot;card-text&quot;&amp;gt;
                Enjoy strategy games and puzzles. Love the problem-solving
                aspect and competitive elements.
              &amp;lt;/p&amp;gt;
              &amp;lt;div class=&quot;progress&quot;&amp;gt;
                &amp;lt;div
                  class=&quot;progress-bar bg-warning&quot;
                  role=&quot;progressbar&quot;
                  style=&quot;width: 50%&quot;
                &amp;gt;
                  50%
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;

      &amp;lt;!-- Skills Section --&amp;gt;
      &amp;lt;div class=&quot;row mt-5&quot;&amp;gt;
        &amp;lt;div class=&quot;col-lg-8 mx-auto&quot;&amp;gt;
          &amp;lt;h2 class=&quot;mb-4 text-center&quot;&amp;gt;Skills &amp;amp; Interests&amp;lt;/h2&amp;gt;
          &amp;lt;div class=&quot;accordion&quot; id=&quot;skillsAccordion&quot;&amp;gt;
            &amp;lt;div class=&quot;accordion-item&quot;&amp;gt;
              &amp;lt;h2 class=&quot;accordion-header&quot; id=&quot;headingOne&quot;&amp;gt;
                &amp;lt;button
                  class=&quot;accordion-button&quot;
                  type=&quot;button&quot;
                  data-bs-toggle=&quot;collapse&quot;
                  data-bs-target=&quot;#collapseOne&quot;
                &amp;gt;
                  🎯 Problem Solving
                &amp;lt;/button&amp;gt;
              &amp;lt;/h2&amp;gt;
              &amp;lt;div
                id=&quot;collapseOne&quot;
                class=&quot;accordion-collapse show collapse&quot;
                data-bs-parent=&quot;#skillsAccordion&quot;
              &amp;gt;
                &amp;lt;div class=&quot;accordion-body&quot;&amp;gt;
                  I enjoy tackling complex problems and finding creative
                  solutions. This skill translates well to both programming and
                  everyday challenges.
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div class=&quot;accordion-item&quot;&amp;gt;
              &amp;lt;h2 class=&quot;accordion-header&quot; id=&quot;headingTwo&quot;&amp;gt;
                &amp;lt;button
                  class=&quot;accordion-button collapsed&quot;
                  type=&quot;button&quot;
                  data-bs-toggle=&quot;collapse&quot;
                  data-bs-target=&quot;#collapseTwo&quot;
                &amp;gt;
                  🎨 Creative Design
                &amp;lt;/button&amp;gt;
              &amp;lt;/h2&amp;gt;
              &amp;lt;div
                id=&quot;collapseTwo&quot;
                class=&quot;accordion-collapse collapse&quot;
                data-bs-parent=&quot;#skillsAccordion&quot;
              &amp;gt;
                &amp;lt;div class=&quot;accordion-body&quot;&amp;gt;
                  Interested in UI/UX design and creating visually appealing
                  interfaces. Always looking to improve the aesthetic aspects of
                  my projects.
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div class=&quot;accordion-item&quot;&amp;gt;
              &amp;lt;h2 class=&quot;accordion-header&quot; id=&quot;headingThree&quot;&amp;gt;
                &amp;lt;button
                  class=&quot;accordion-button collapsed&quot;
                  type=&quot;button&quot;
                  data-bs-toggle=&quot;collapse&quot;
                  data-bs-target=&quot;#collapseThree&quot;
                &amp;gt;
                  📚 Continuous Learning
                &amp;lt;/button&amp;gt;
              &amp;lt;/h2&amp;gt;
              &amp;lt;div
                id=&quot;collapseThree&quot;
                class=&quot;accordion-collapse collapse&quot;
                data-bs-parent=&quot;#skillsAccordion&quot;
              &amp;gt;
                &amp;lt;div class=&quot;accordion-body&quot;&amp;gt;
                  Committed to lifelong learning and staying updated with new
                  technologies and methodologies in the ever-evolving tech
                  landscape.
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;

      &amp;lt;!-- Interactive Hobby Selector --&amp;gt;
      &amp;lt;div class=&quot;row mt-5&quot;&amp;gt;
        &amp;lt;div class=&quot;col-lg-6 mx-auto&quot;&amp;gt;
          &amp;lt;div class=&quot;bg-info rounded p-4 text-center text-white&quot;&amp;gt;
            &amp;lt;h3&amp;gt;What&apos;s Your Favorite Hobby?&amp;lt;/h3&amp;gt;
            &amp;lt;div class=&quot;mt-3&quot;&amp;gt;
              &amp;lt;select id=&quot;hobbySelect&quot; class=&quot;form-select&quot;&amp;gt;
                &amp;lt;option value=&quot;&quot;&amp;gt;Choose a hobby...&amp;lt;/option&amp;gt;
                &amp;lt;option value=&quot;programming&quot;&amp;gt;Programming/Coding&amp;lt;/option&amp;gt;
                &amp;lt;option value=&quot;reading&quot;&amp;gt;Reading&amp;lt;/option&amp;gt;
                &amp;lt;option value=&quot;gaming&quot;&amp;gt;Gaming&amp;lt;/option&amp;gt;
                &amp;lt;option value=&quot;music&quot;&amp;gt;Music&amp;lt;/option&amp;gt;
                &amp;lt;option value=&quot;sports&quot;&amp;gt;Sports&amp;lt;/option&amp;gt;
                &amp;lt;option value=&quot;travel&quot;&amp;gt;Traveling&amp;lt;/option&amp;gt;
              &amp;lt;/select&amp;gt;
              &amp;lt;button id=&quot;hobbySubmit&quot; class=&quot;btn btn-light mt-2&quot;&amp;gt;
                Share Your Choice
              &amp;lt;/button&amp;gt;
              &amp;lt;p id=&quot;hobbyResponse&quot; class=&quot;mt-3&quot;&amp;gt;&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;

    &amp;lt;!-- Footer --&amp;gt;
    &amp;lt;footer class=&quot;bg-dark mt-5 py-4 text-white&quot;&amp;gt;
      &amp;lt;div class=&quot;container text-center&quot;&amp;gt;
        &amp;lt;p&amp;gt;2026 My Homepage.&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/footer&amp;gt;

    &amp;lt;!-- Bootstrap JS --&amp;gt;
    &amp;lt;script
      src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js&quot;
      integrity=&quot;sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI&quot;
      crossorigin=&quot;anonymous&quot;
    &amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;!-- Custom JavaScript --&amp;gt;
    &amp;lt;script src=&quot;script.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang=&quot;en&quot;&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;link
      href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css&quot;
      rel=&quot;stylesheet&quot;
      integrity=&quot;sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB&quot;
      crossorigin=&quot;anonymous&quot;
    /&amp;gt;
    &amp;lt;script
      src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js&quot;
      integrity=&quot;sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI&quot;
      crossorigin=&quot;anonymous&quot;
    &amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;link href=&quot;styles.css&quot; rel=&quot;stylesheet&quot; /&amp;gt;
    &amp;lt;title&amp;gt;Welcome to My Homepage&amp;lt;/title&amp;gt;
    &amp;lt;meta charset=&quot;UTF-8&quot; /&amp;gt;
    &amp;lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&amp;gt;
  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;
    &amp;lt;!-- Navigation Bar --&amp;gt;
    &amp;lt;nav class=&quot;navbar navbar-expand-lg navbar-dark bg-primary sticky-top&quot;&amp;gt;
      &amp;lt;div class=&quot;container&quot;&amp;gt;
        &amp;lt;a class=&quot;navbar-brand&quot; href=&quot;index.html&quot;&amp;gt;My Homepage&amp;lt;/a&amp;gt;
        &amp;lt;button
          class=&quot;navbar-toggler&quot;
          type=&quot;button&quot;
          data-bs-toggle=&quot;collapse&quot;
          data-bs-target=&quot;#navbarNav&quot;
        &amp;gt;
          &amp;lt;span class=&quot;navbar-toggler-icon&quot;&amp;gt;&amp;lt;/span&amp;gt;
        &amp;lt;/button&amp;gt;
        &amp;lt;div class=&quot;navbar-collapse collapse&quot; id=&quot;navbarNav&quot;&amp;gt;
          &amp;lt;ul class=&quot;navbar-nav ms-auto&quot;&amp;gt;
            &amp;lt;li class=&quot;nav-item&quot;&amp;gt;
              &amp;lt;a class=&quot;nav-link active&quot; href=&quot;index.html&quot;&amp;gt;Home&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
            &amp;lt;li class=&quot;nav-item&quot;&amp;gt;
              &amp;lt;a class=&quot;nav-link&quot; href=&quot;about.html&quot;&amp;gt;About Me&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
            &amp;lt;li class=&quot;nav-item&quot;&amp;gt;
              &amp;lt;a class=&quot;nav-link&quot; href=&quot;hobbies.html&quot;&amp;gt;Hobbies&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
            &amp;lt;li class=&quot;nav-item&quot;&amp;gt;
              &amp;lt;a class=&quot;nav-link&quot; href=&quot;contact.html&quot;&amp;gt;Contact&amp;lt;/a&amp;gt;
            &amp;lt;/li&amp;gt;
          &amp;lt;/ul&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/nav&amp;gt;

    &amp;lt;!-- Hero Section --&amp;gt;
    &amp;lt;header class=&quot;bg-light py-5&quot;&amp;gt;
      &amp;lt;div class=&quot;container text-center&quot;&amp;gt;
        &amp;lt;h1 class=&quot;display-4 fw-bold&quot;&amp;gt;Welcome to My Personal Homepage!&amp;lt;/h1&amp;gt;
        &amp;lt;p class=&quot;lead&quot;&amp;gt;
          This is my CS50 homepage assignment showcasing HTML, CSS, and
          JavaScript skills.
        &amp;lt;/p&amp;gt;
        &amp;lt;button id=&quot;welcomeBtn&quot; class=&quot;btn btn-primary btn-lg mt-3&quot;&amp;gt;
          Click for a Surprise!
        &amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/header&amp;gt;

    &amp;lt;!-- Main Content --&amp;gt;
    &amp;lt;main class=&quot;container my-5&quot;&amp;gt;
      &amp;lt;div class=&quot;row&quot;&amp;gt;
        &amp;lt;div class=&quot;col-md-4 mb-4&quot;&amp;gt;
          &amp;lt;div class=&quot;card h-100 shadow-sm&quot;&amp;gt;
            &amp;lt;div class=&quot;card-body text-center&quot;&amp;gt;
              &amp;lt;h3 class=&quot;card-title&quot;&amp;gt;About Me&amp;lt;/h3&amp;gt;
              &amp;lt;p class=&quot;card-text&quot;&amp;gt;
                Learn more about who I am and my background.
              &amp;lt;/p&amp;gt;
              &amp;lt;a href=&quot;about.html&quot; class=&quot;btn btn-outline-primary&quot;
                &amp;gt;View Details&amp;lt;/a
              &amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class=&quot;col-md-4 mb-4&quot;&amp;gt;
          &amp;lt;div class=&quot;card h-100 shadow-sm&quot;&amp;gt;
            &amp;lt;div class=&quot;card-body text-center&quot;&amp;gt;
              &amp;lt;h3 class=&quot;card-title&quot;&amp;gt;My Hobbies&amp;lt;/h3&amp;gt;
              &amp;lt;p class=&quot;card-text&quot;&amp;gt;
                Discover my interests and favorite activities.
              &amp;lt;/p&amp;gt;
              &amp;lt;a href=&quot;hobbies.html&quot; class=&quot;btn btn-outline-primary&quot;
                &amp;gt;Explore Hobbies&amp;lt;/a
              &amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class=&quot;col-md-4 mb-4&quot;&amp;gt;
          &amp;lt;div class=&quot;card h-100 shadow-sm&quot;&amp;gt;
            &amp;lt;div class=&quot;card-body text-center&quot;&amp;gt;
              &amp;lt;h3 class=&quot;card-title&quot;&amp;gt;Get in Touch&amp;lt;/h3&amp;gt;
              &amp;lt;p class=&quot;card-text&quot;&amp;gt;
                Feel free to contact me for any inquiries.
              &amp;lt;/p&amp;gt;
              &amp;lt;a href=&quot;contact.html&quot; class=&quot;btn btn-outline-primary&quot;
                &amp;gt;Contact Me&amp;lt;/a
              &amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;

      &amp;lt;!-- Interactive Section --&amp;gt;
      &amp;lt;div class=&quot;row mt-5&quot;&amp;gt;
        &amp;lt;div class=&quot;col-12&quot;&amp;gt;
          &amp;lt;div class=&quot;bg-primary rounded p-4 text-white&quot;&amp;gt;
            &amp;lt;h2 class=&quot;mb-4 text-center&quot;&amp;gt;Interactive Demo&amp;lt;/h2&amp;gt;
            &amp;lt;div class=&quot;text-center&quot;&amp;gt;
              &amp;lt;button id=&quot;colorChangeBtn&quot; class=&quot;btn btn-light me-2&quot;&amp;gt;
                Change Background Color
              &amp;lt;/button&amp;gt;
              &amp;lt;button id=&quot;showTimeBtn&quot; class=&quot;btn btn-light&quot;&amp;gt;
                Show Current Time
              &amp;lt;/button&amp;gt;
              &amp;lt;p id=&quot;timeDisplay&quot; class=&quot;fs-5 mt-3&quot;&amp;gt;&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;

    &amp;lt;!-- Footer --&amp;gt;
    &amp;lt;footer class=&quot;bg-dark mt-5 py-4 text-white&quot;&amp;gt;
      &amp;lt;div class=&quot;container text-center&quot;&amp;gt;
        &amp;lt;p&amp;gt;2026 My Homepage&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/footer&amp;gt;

    &amp;lt;!-- Bootstrap JS --&amp;gt;
    &amp;lt;script
      src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js&quot;
      integrity=&quot;sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI&quot;
      crossorigin=&quot;anonymous&quot;
    &amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;!-- Custom JavaScript --&amp;gt;
    &amp;lt;script src=&quot;script.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;// Wait for DOM to be fully loaded
document.addEventListener(&quot;DOMContentLoaded&quot;, function () {
  // Welcome button functionality
  const welcomeBtn = document.getElementById(&quot;welcomeBtn&quot;);
  if (welcomeBtn) {
    welcomeBtn.addEventListener(&quot;click&quot;, function () {
      alert(&quot;🎉 Welcome to my homepage! Thanks for visiting! 🎉&quot;);
    });
  }

  // Color changing functionality
  const colorChangeBtn = document.getElementById(&quot;colorChangeBtn&quot;);
  if (colorChangeBtn) {
    colorChangeBtn.addEventListener(&quot;click&quot;, function () {
      const colors = [
        &quot;#ff6b6b&quot;,
        &quot;#4ecdc4&quot;,
        &quot;#45b7d1&quot;,
        &quot;#96ceb4&quot;,
        &quot;#feca57&quot;,
        &quot;#ff9ff3&quot;,
      ];
      const randomColor = colors[Math.floor(Math.random() * colors.length)];
      document.body.style.backgroundColor = randomColor;

      // Add temporary notification
      showNotification(`Background changed to ${randomColor}`, &quot;success&quot;);
    });
  }

  // Show current time functionality
  const showTimeBtn = document.getElementById(&quot;showTimeBtn&quot;);
  const timeDisplay = document.getElementById(&quot;timeDisplay&quot;);
  if (showTimeBtn &amp;amp;&amp;amp; timeDisplay) {
    showTimeBtn.addEventListener(&quot;click&quot;, function () {
      const now = new Date();
      const timeString = now.toLocaleTimeString();
      timeDisplay.textContent = `Current time: ${timeString}`;
      timeDisplay.classList.add(&quot;fade-in&quot;);

      // Remove animation class after animation completes
      setTimeout(() =&amp;gt; {
        timeDisplay.classList.remove(&quot;fade-in&quot;);
      }, 600);
    });
  }

  // Hobby selector functionality
  const hobbySelect = document.getElementById(&quot;hobbySelect&quot;);
  const hobbySubmit = document.getElementById(&quot;hobbySubmit&quot;);
  const hobbyResponse = document.getElementById(&quot;hobbyResponse&quot;);
  if (hobbySelect &amp;amp;&amp;amp; hobbySubmit &amp;amp;&amp;amp; hobbyResponse) {
    hobbySubmit.addEventListener(&quot;click&quot;, function () {
      const selectedHobby = hobbySelect.value;
      if (selectedHobby) {
        const responses = {
          programming:
            &quot;Great choice! Programming opens up endless possibilities.&quot;,
          reading: &quot;Wonderful! Reading expands our minds and knowledge.&quot;,
          gaming: &quot;Awesome! Games develop strategic thinking skills.&quot;,
          music: &quot;Fantastic! Music is truly universal language.&quot;,
          sports: &quot;Excellent! Sports promote health and teamwork.&quot;,
          travel: &quot;Amazing! Travel broadens our perspectives.&quot;,
        };

        hobbyResponse.textContent =
          responses[selectedHobby] || &quot;That sounds interesting!&quot;;
        hobbyResponse.className = &quot;mt-3 alert alert-info&quot;;
      } else {
        hobbyResponse.textContent = &quot;Please select a hobby first!&quot;;
        hobbyResponse.className = &quot;mt-3 alert alert-warning&quot;;
      }
    });
  }

  // Contact form functionality
  const contactForm = document.getElementById(&quot;contactForm&quot;);
  const formSuccess = document.getElementById(&quot;formSuccess&quot;);
  if (contactForm &amp;amp;&amp;amp; formSuccess) {
    contactForm.addEventListener(&quot;submit&quot;, function (e) {
      e.preventDefault();

      // Get form values
      const name = document.getElementById(&quot;name&quot;).value;
      const email = document.getElementById(&quot;email&quot;).value;
      const message = document.getElementById(&quot;message&quot;).value;

      // Simple validation
      if (name &amp;amp;&amp;amp; email &amp;amp;&amp;amp; message) {
        // Simulate form submission
        showLoadingState(contactForm);

        setTimeout(() =&amp;gt; {
          hideLoadingState(contactForm);
          formSuccess.classList.remove(&quot;d-none&quot;);
          contactForm.reset();

          // Hide success message after 5 seconds
          setTimeout(() =&amp;gt; {
            formSuccess.classList.add(&quot;d-none&quot;);
          }, 5000);
        }, 1500);
      } else {
        showNotification(&quot;Please fill in all required fields!&quot;, &quot;warning&quot;);
      }
    });
  }

  // Smooth scrolling for anchor links
  document.querySelectorAll(&apos;a[href^=&quot;#&quot;]&apos;).forEach(anchor =&amp;gt; {
    anchor.addEventListener(&quot;click&quot;, function (e) {
      e.preventDefault();
      const target = document.querySelector(this.getAttribute(&quot;href&quot;));
      if (target) {
        target.scrollIntoView({
          behavior: &quot;smooth&quot;,
          block: &quot;start&quot;,
        });
      }
    });
  });

  // Add fade-in animation to cards when they come into view
  const observerOptions = {
    threshold: 0.1,
    rootMargin: &quot;0px 0px -50px 0px&quot;,
  };

  const observer = new IntersectionObserver(function (entries) {
    entries.forEach(entry =&amp;gt; {
      if (entry.isIntersecting) {
        entry.target.classList.add(&quot;fade-in&quot;);
      }
    });
  }, observerOptions);

  // Observe all cards
  document.querySelectorAll(&quot;.card&quot;).forEach(card =&amp;gt; {
    observer.observe(card);
  });

  // Dynamic greeting based on time of day
  const greetingElement = document.querySelector(&quot;header h1&quot;);
  if (greetingElement) {
    const hour = new Date().getHours();
    let greeting = &quot;&quot;;

    if (hour &amp;lt; 12) {
      greeting = &quot;Good Morning&quot;;
    } else if (hour &amp;lt; 18) {
      greeting = &quot;Good Afternoon&quot;;
    } else {
      greeting = &quot;Good Evening&quot;;
    }

    // Update greeting with smooth transition
    setTimeout(() =&amp;gt; {
      greetingElement.textContent = `${greeting}! Welcome to My Personal Homepage!`;
    }, 1000);
  }

  // Keyboard shortcuts
  document.addEventListener(&quot;keydown&quot;, function (e) {
    // Press &apos;H&apos; to go home
    if (e.key === &quot;h&quot; || e.key === &quot;H&quot;) {
      window.location.href = &quot;index.html&quot;;
    }
    // Press &apos;A&apos; for about
    if (e.key === &quot;a&quot; || e.key === &quot;A&quot;) {
      window.location.href = &quot;about.html&quot;;
    }
    // Press &apos;C&apos; for contact
    if (e.key === &quot;c&quot; || e.key === &quot;C&quot;) {
      window.location.href = &quot;contact.html&quot;;
    }
  });

  // Session storage for user preferences
  if (typeof Storage !== &quot;undefined&quot;) {
    // Store visit count
    let visitCount = sessionStorage.getItem(&quot;visitCount&quot;) || 0;
    visitCount++;
    sessionStorage.setItem(&quot;visitCount&quot;, visitCount);

    // Show welcome back message for returning visitors
    if (visitCount &amp;gt; 1) {
      setTimeout(() =&amp;gt; {
        showNotification(
          `Welcome back! This is your visit #${visitCount}`,
          &quot;info&quot;
        );
      }, 2000);
    }
  }

  // Console message for developers
  console.log(
    &quot;%c👋 Hello Developer!&quot;,
    &quot;color: #667eea; font-size: 20px; font-weight: bold;&quot;
  );
  console.log(
    &quot;%cThis site was built with HTML, CSS, Bootstrap, and JavaScript for CS50 assignment.&quot;,
    &quot;color: #333; font-size: 14px;&quot;
  );
});

// Helper Functions

function showNotification(message, type = &quot;info&quot;) {
  // Create notification element
  const notification = document.createElement(&quot;div&quot;);
  notification.className = `alert alert-${type} position-fixed`;
  notification.style.cssText = `
        top: 20px;
        right: 20px;
        z-index: 1000;
        min-width: 300px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    `;
  notification.textContent = message;

  document.body.appendChild(notification);

  // Auto remove after 3 seconds
  setTimeout(() =&amp;gt; {
    notification.remove();
  }, 3000);
}

function showLoadingState(form) {
  const submitBtn = form.querySelector(&apos;button[type=&quot;submit&quot;]&apos;);
  const originalText = submitBtn.textContent;

  submitBtn.innerHTML = &apos;&amp;lt;span class=&quot;loading-spinner&quot;&amp;gt;&amp;lt;/span&amp;gt; Sending...&apos;;
  submitBtn.disabled = true;

  // Store original text for later restoration
  submitBtn.dataset.originalText = originalText;
}

function hideLoadingState(form) {
  const submitBtn = form.querySelector(&apos;button[type=&quot;submit&quot;]&apos;);
  submitBtn.textContent = submitBtn.dataset.originalText || &quot;Send Message&quot;;
  submitBtn.disabled = false;
}

// Handle page visibility changes
document.addEventListener(&quot;visibilitychange&quot;, function () {
  if (!document.hidden) {
    // Page became visible
    document.title = &quot;Welcome Back! - My Homepage&quot;;
  } else {
    // Page hidden
    document.title = &quot;Come Back Soon! - My Homepage&quot;;
  }
});
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;HTML Tags Used (10+ distinct tags):
1. &amp;lt;!DOCTYPE&amp;gt; - Defines the document type
2. &amp;lt;html&amp;gt; - Root element of the HTML document
3. &amp;lt;head&amp;gt; - Contains meta information and links
4. &amp;lt;meta&amp;gt; - Provides metadata about the HTML document
5. &amp;lt;title&amp;gt; - Sets the title of the webpage
6. &amp;lt;link&amp;gt; - Links external resources like CSS and Bootstrap
7. &amp;lt;script&amp;gt; - Includes JavaScript files
8. &amp;lt;body&amp;gt; - Contains the visible page content
9. &amp;lt;nav&amp;gt; - Navigation section with Bootstrap navbar
10. &amp;lt;header&amp;gt; - Introductory content or navigation aids
11. &amp;lt;main&amp;gt; - Main content area of the document
12. &amp;lt;section&amp;gt; - Generic section of content
13. &amp;lt;article&amp;gt; - Independent, self-contained content
14. &amp;lt;div&amp;gt; - Generic container for flow content
15. &amp;lt;span&amp;gt; - Inline container for phrasing content
16. &amp;lt;p&amp;gt; - Paragraph element
17. &amp;lt;h1&amp;gt;, &amp;lt;h2&amp;gt;, &amp;lt;h3&amp;gt;, &amp;lt;h4&amp;gt;, &amp;lt;h5&amp;gt; - Heading elements
18. &amp;lt;ul&amp;gt;, &amp;lt;ol&amp;gt; - Unordered and ordered lists
19. &amp;lt;li&amp;gt; - List items
20. &amp;lt;a&amp;gt; - Anchor element for hyperlinks
21. &amp;lt;img&amp;gt; - Image element
22. &amp;lt;button&amp;gt; - Clickable button
23. &amp;lt;form&amp;gt; - Form for user input
24. &amp;lt;input&amp;gt; - Input field
25. &amp;lt;textarea&amp;gt; - Multi-line text input
26. &amp;lt;select&amp;gt; - Drop-down list
27. &amp;lt;option&amp;gt; - Options in a drop-down list
28. &amp;lt;label&amp;gt; - Label for form elements
29. &amp;lt;footer&amp;gt; - Footer section of the document

CSS Properties Used (5+ distinct properties):
1. font-family - Sets the font family for text
2. background - Sets background colors and gradients
3. color - Sets text color
4. margin - Sets margins around elements
5. padding - Sets padding inside elements
6. border-radius - Rounds corners of elements
7. box-shadow - Adds shadow effects to elements
8. transition - Animates property changes
9. transform - Applies 2D/3D transformations
10. display - Specifies display behavior of elements
11. position - Specifies positioning method
12. z-index - Controls stacking order of elements
13. width - Sets element width
14. height - Sets element height
15. text-shadow - Adds shadow to text

JavaScript Features Used:
I integrated multiple JavaScript features to make the site interactive:
1. DOM manipulation - Dynamically changing page content and styles
2. Event listeners - Handling user interactions like clicks and form submissions
3. Alert dialogs - Showing popup notifications and welcome messages
4. Dynamic content generation - Creating elements and updating text content
5. Form validation - Checking user input before submission
6. Animation effects - Adding CSS classes for smooth transitions
7. Local storage - Storing visitor count using session storage
8. Intersection Observer API - Creating fade-in effects for elements
9. Keyboard event handling - Adding keyboard shortcuts (H, A, C keys)
10. Page visibility API - Changing page title based on tab visibility
11. Timed functions - Using setTimeout for delayed actions and auto-hiding elements
12. Console logging - Providing developer information in browser console

Bootstrap Integration:
I incorporated Bootstrap 5.3.8 throughout the site for responsive design:
1. Grid system - Using container, row, and col classes for responsive layouts
2. Components - Navbar, cards, buttons, forms, accordions, progress bars
3. Utilities - Spacing, colors, shadows, and responsive utilities
4. JavaScript plugins - Modal, tooltip, and collapse functionality
5. Responsive breakpoints - Automatic adaptation to different screen sizes

Responsive Design:
The site is fully responsive and works well on:
- Mobile devices (phones)
- Tablets
- Laptops/desktops
- Various screen sizes and orientations
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;/* Body style */
body {
  font-family: &quot;Segoe UI&quot;, Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: #333;
}

/* Navigation bar style */
.navbar-brand {
  font-weight: bold;
  font-size: 1.5rem;
}

.nav-link:hover {
  transform: translateY(-2px);
  transition: transform 0.3s ease;
}

/* Header/Hero Section Styling */
header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

header h1 {
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

/* Card Hover Effects */
.card {
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

/* Button Animations */
.btn {
  transition: all 0.3s ease;
}

.btn:hover {
  transform: scale(1.05);
}

/* Progress Bar Customization */
.progress {
  height: 10px;
  border-radius: 5px;
}

.progress-bar {
  transition: width 1s ease-in-out;
}

/* Form Styling */
.form-control:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* Accordion Customization */
.accordion-button:not(.collapsed) {
  background-color: #e7f1ff;
  color: #0c63e4;
}

/* Footer Styling */
footer {
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

/* Responsive Typography */
@media (max-width: 768px) {
  .display-4 {
    font-size: 2.5rem;
  }

  .lead {
    font-size: 1.1rem;
  }
}

/* Mobile-Specific Adjustments */
@media (max-width: 576px) {
  .navbar-brand {
    font-size: 1.2rem;
  }

  .card {
    margin-bottom: 1rem;
  }

  .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }
}

/* Animation Classes */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.6s ease forwards;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

/* Custom Utility Classes */
.text-shadow {
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.bg-gradient-custom {
  background: linear-gradient(45deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%);
}

.border-radius-lg {
  border-radius: 15px;
}

.shadow-soft {
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* Interactive Elements */
.interactive-element {
  cursor: pointer;
  user-select: none;
}

.interactive-element:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

/* Loading Spinner */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Alert Customization */
.alert-success {
  background-color: #d4edda;
  border-color: #c3e6cb;
  color: #155724;
}

.alert-warning {
  background-color: #fff3cd;
  border-color: #ffeaa7;
  color: #856404;
}

/* List Group Customization */
.list-group-item:hover {
  background-color: #f8f9fa;
  transition: background-color 0.2s ease;
}

/* Scroll Behavior */
html {
  scroll-behavior: smooth;
}

/* Focus Styles for Accessibility */
.btn:focus,
.form-control:focus,
.nav-link:focus {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>CS50 Problem Set 7</title><link>https://tech.kinghua0629.com/posts/cs50-problem-set-7/</link><guid isPermaLink="true">https://tech.kinghua0629.com/posts/cs50-problem-set-7/</guid><description>Answer for CS50 Problem Set 7</description><pubDate>Wed, 18 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h1&gt;CS50 Problem Set 7&lt;/h1&gt;
&lt;p&gt;Here&apos;s my answer for the CS50 Problem Set 7. Hope that will help you a bit.&lt;/p&gt;
&lt;h2&gt;Problem 1: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/7/songs/#songs&quot;&gt;Songs&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;SELECT name FROM songs;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;SELECT name
FROM songs
ORDER BY tempo;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;SELECT name
FROM songs
ORDER BY duration_ms DESC
LIMIT 5;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;SELECT name
FROM songs
WHERE danceability &amp;gt; 0.75 AND energy &amp;gt; 0.75 AND valence &amp;gt; 0.75;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;SELECT AVG(energy)
FROM songs;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;SELECT name
FROM songs
WHERE artist_id = (
    SELECT id
    FROM artists
    WHERE name = &apos;Post Malone&apos;
);
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;SELECT AVG(energy)
FROM songs
WHERE artist_id = (
    SELECT id
    FROM artists
    WHERE name = &apos;Drake&apos;
);
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;SELECT name
FROM songs
WHERE name LIKE &apos;%feat.%&apos;;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;1. I will use the SQL to count the average energy, valence, and danceability of a person’s top 100 songs from the past year.

2. I should consider how many times they listen to each music.
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Problem 2: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/7/movies/#movies&quot;&gt;Movies&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;-- 1. Titles of all movies from 2008
SELECT title
FROM movies
WHERE year = 2008;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;-- 2. Birth year of Emma Stone
SELECT birth
FROM people
WHERE name = &apos;Emma Stone&apos;;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;-- 3. Titles of all movies since 2018, in alphabetical order
SELECT title
FROM movies
WHERE year &amp;gt;= 2018
ORDER BY title ASC;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;-- 4. Number of movies with a 10.0 rating
SELECT COUNT(rating)
FROM ratings
WHERE rating = 10.0
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;-- 5. Titles and years of all Harry Potter movies, in chronological order (title beginning with &quot;Harry Potter and the ...&quot;)
SELECT title, year
FROM movies
WHERE title LIKE &quot;Harry Potter and the%&quot;
ORDER BY year;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;-- 6. Average rating of movies in 2012
SELECT AVG(rating)
FROM ratings
WHERE movie_id IN (
    SELECT id FROM movies WHERE year = 2012
)
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;-- 7. All movies and ratings from 2010, in decreasing order by rating (alphabetical for those with same rating)
SELECT movies.title, ratings.rating
FROM movies
JOIN ratings
ON movies.id = ratings.movie_id AND movies.year = 2010 AND ratings.rating &amp;gt; 0
ORDER BY ratings.rating DESC, title ASC;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;-- 8. Names of people who starred in Toy Story
SELECT name
FROM people
WHERE id IN(
    SELECT person_id
    FROM stars
    WHERE movie_id = (
        SELECT id
        FROM movies
        WHERE title = &apos;Toy Story&apos;
    )
);
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;-- 9. Names of all people who starred in a movie released in 2004, ordered by birth year
SELECT id, name
FROM people
WHERE id IN(
    SELECT person_id
    FROM stars
    WHERE movie_id IN(
        SELECT id
        FROM movies
        WHERE year = 2004
    )
)
ORDER BY birth;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;-- 10. Names of all directors who have directed a movie that got a rating of at least 9.0
SELECT name
FROM people
WHERE id IN (
    SELECT person_id
    FROM directors
    WHERE movie_id IN (
        SELECT movie_id
        FROM ratings
        WHERE rating &amp;gt;= 9.0
    )
);
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;-- 11. Titles of the five highest rated movies (in order) that Chadwick Boseman starred in, starting with the highest rated
SELECT title
FROM movies
JOIN ratings ON ratings.movie_id = movies.id
WHERE id IN (
    SELECT movie_id
    FROM stars
    WHERE person_id = (
        SELECT id
        FROM people
        WHERE name = &apos;Chadwick Boseman&apos;
    )
)
ORDER BY ratings.rating DESC
LIMIT 5;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;-- 12. Titles of all of movies in which both Jennifer Lawrence and Bradley Cooper starred
SELECT title
FROM movies
WHERE (
    id IN (
    SELECT movie_id
    FROM stars
    WHERE person_id IN (
        SELECT id
        FROM people
        WHERE name = &apos;Bradley Cooper&apos;
        )
    )
)
AND (
    id IN (
    SELECT movie_id
    FROM stars
    WHERE person_id IN (
        SELECT id
        FROM people
        WHERE name = &apos;Jennifer Lawrence&apos;
        )
    )
);
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;-- 13. Names of all people who starred in a movie in which Kevin Bacon also starred
SELECT name
FROM people
JOIN stars ON people.id = stars.person_id
JOIN movies ON movies.id = stars.movie_id
WHERE movies.id IN (
    SELECT movies.id
    FROM movies
    JOIN stars ON movies.id = stars.movie_id
    JOIN people ON stars.person_id = people.id
    WHERE people.name = &apos;Kevin Bacon&apos; AND people.birth = 1958
)
AND people.name != &apos;Kevin Bacon&apos;;
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Problem 3: &lt;a href=&quot;https://cs50.harvard.edu/x/psets/7/fiftyville/#fiftyville&quot;&gt;Fiftyville&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;The THIEF is: Bruce
The city the thief ESCAPED TO: New York City
The ACCOMPLICE is: Robin
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;-- Keep a log of any SQL queries you execute as you solve the mystery.
-- Get the description of the crime scene reports on that day and the street
SELECT description FROM crime_scene_reports
    WHERE year = 2025 AND month = 7 AND day = 28 AND street = &apos;Humphrey Street&apos;;
-- Theft of the CS50 duck took place at 10:15am at the Humphrey Street bakery. Interviews were conducted today with three witnesses who were present at the time – each of their interview transcripts mentions the bakery.
-- Littering took place at 16:36. No known witnesses.

--Get the transcript from the reporters
SELECT transcript FROM interviews WHERE year = 2025 AND month = 7 AND day = 28 AND transcript LIKE &quot;%bakery%&quot;;
-- Sometime within ten minutes of the theft, I saw the thief get into a car in the bakery parking lot and drive away. If you have security footage from the bakery parking lot, you might want to look for cars that left the parking lot in that time frame.
-- I don&apos;t know the thief&apos;s name, but it was someone I recognized. Earlier this morning, before I arrived at Emma&apos;s bakery, I was walking by the ATM on Leggett Street and saw the thief there withdrawing some money.
-- As the thief was leaving the bakery, they called someone who talked to them for less than a minute. In the call, I heard the thief say that they were planning to take the earliest flight out of Fiftyville tomorrow. The thief then asked the person on the other end of the phone to purchase the flight ticket.

SELECT bakery_security_logs.activity, bakery_security_logs.license_plate, people.name FROM bakery_security_logs
JOIN people ON bakery_security_logs.license_plate = people.license_plate
WHERE bakery_security_logs.year = 2025
AND bakery_security_logs.month = 7
AND bakery_security_logs.day = 28
AND bakery_security_logs.hour = 10
AND bakery_security_logs.minute &amp;gt;= 15
AND bakery_security_logs.minute &amp;lt;= 25;
/*
+----------+---------------+---------+
| activity | license_plate |  name   |
+----------+---------------+---------+
| exit     | 5P2BI95       | Vanessa |
| exit     | 94KL13X       | Bruce   | *
| exit     | 6P58WS2       | Barry   |
| exit     | 4328GD8       | Luca    |
| exit     | G412CB7       | Sofia   |
| exit     | L93JTIZ       | Iman    |
| exit     | 322W7JE       | Diana   | *
| exit     | 0NTHK55       | Kelsey  |
+----------+---------------+---------+
*/

SELECT people.name FROM people
JOIN bank_accounts ON bank_accounts.person_id = people.id
JOIN atm_transactions ON atm_transactions.account_number = bank_accounts.account_number
WHERE atm_transactions.year = 2025
AND atm_transactions.month = 7
AND atm_transactions.day = 28
AND atm_transactions.atm_location = &apos;Leggett Street&apos;
AND atm_transactions.transaction_type = &apos;withdraw&apos;;
/*
+---------+
|  name   |
+---------+
| Bruce   | *
| Diana   | *
| Brooke  |
| Kenny   |
| Iman    |
| Luca    |
| Taylor  |
| Benista |
+---------+
*/

UPDATE phone_calls
SET receiver = people.name
FROM people
WHERE phone_calls.receiver = people.phone_number;

UPDATE phone_calls
SET caller = people.name
FROM people
WHERE phone_calls.caller = people.phone_number;

SELECT caller, receiver FROM phone_calls
WHERE year = 2025
AND month = 7
AND day = 28
AND duration &amp;lt; 60;
/*
+---------+------------+
| caller  |  receiver  |
+---------+------------+
| Sofia   | Jack       |
| Kelsey  | Larry      |
| Bruce   | Robin      | *
| Kelsey  | Melissa    |
| Taylor  | James      |
| Diana   | Philip     | *
| Carina  | Jacqueline |
| Kenny   | Doris      |
| Benista | Anna       |
+---------+------------+
*/

SELECT id, origin_airport_id, destination_airport_id FROM flights
WHERE year = 2025
AND month = 7
AND day = 29
AND origin_airport_id = (
    SELECT id FROM airports
    WHERE city = &apos;Fiftyville&apos;
)
ORDER BY flights.hour ASC;
/*
+----+-------------------+------------------------+
| id | origin_airport_id | destination_airport_id |
+----+-------------------+------------------------+
| 36 | 8                 | 4                      | *
| 43 | 8                 | 1                      |
| 23 | 8                 | 11                     |
| 53 | 8                 | 9                      |
| 18 | 8                 | 6                      |
+----+-------------------+------------------------+
*/

SELECT city FROM airports
WHERE id = 4;
/*
+---------------+
|     city      |
+---------------+
| New York City |
+---------------+
*/

SELECT name FROM people
WHERE people.passport_number IN (
    SELECT passengers.passport_number from passengers
    WHERE flight_id = 36
);
/*
+--------+
|  name  |
+--------+
| Kenny  |
| Sofia  |
| Taylor |
| Luca   |
| Kelsey |
| Edward |
| Bruce  | *
| Doris  |
+--------+
*/
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>First Passage Of My Blog</title><link>https://tech.kinghua0629.com/posts/my-first-passage/</link><guid isPermaLink="true">https://tech.kinghua0629.com/posts/my-first-passage/</guid><description>This is my first post as an announcement.</description><pubDate>Tue, 17 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;pre&gt;&lt;code&gt;print(&quot;hello world&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Hey there,&lt;/p&gt;
&lt;p&gt;So glad you clicked your way here, becoming the very first visitor to this little corner of the web. This is my digital garden, freshly tilled and ready for planting.&lt;/p&gt;
&lt;p&gt;I imagine you’re a bit like me—mind often dotted with scattered thoughts, like afternoon light spots, bright and shimmering, yet hard to grasp; some questions swirling beneath the surface of everyday life, refusing to sink; and those “aha” moments that ache to be captured.&lt;/p&gt;
&lt;p&gt;Hence, here we are.&lt;/p&gt;
&lt;p&gt;Here’s what I’ll be sharing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Thoughts that made me pause&lt;/strong&gt; — about life, reading, or a corner of the world glimpsed by chance. Much like grasping the second law of thermodynamics, $$ΔS ≥ 0$$, which reminds me that disorder is the default, and all understanding and order require energy. I’m also fascinated by certain elegant mathematical truths, like &lt;strong&gt;Euler’s identity&lt;/strong&gt;: $$e^{i\pi} + 1 = 0$$. It connects the natural base, the imaginary unit, the ratio of a circle&apos;s circumference to its diameter, and the fundamental numbers 0 and 1 in one breathtaking equation—a quiet reminder that seemingly unrelated domains might share a beautifully unified logic beneath the surface.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Things I’ve tried and tested — the useful and the not-so-useful&lt;/strong&gt; — be it a method, a tool, or a perspective. They’ll often be presented like runnable code snippets, ready for you to execute or tweak:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# A simple function: extract the core from a messy list
def extract_essence(thoughts_list):
    # 1. Filter out pure emotional noise
    filtered = [t for t in thoughts_list if t not in [&quot;anxiety&quot;, &quot;procrastination&quot;]]
    # 2. Connect what remains to find the thread
    essence = &quot; -&amp;gt; &quot;.join(filtered)
    return essence

# Example, processing: [“confusion”, “reading”, “inspiration”, “procrastination”]
# Output: “confusion -&amp;gt; reading -&amp;gt; inspiration”
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The imperfect, real process&lt;/strong&gt; — the learning, the attempts, even the detours. I believe growth is rarely linear; it’s more like navigating a search function, sometimes requiring random walks to find the direction of steepest ascent. This journey might be metaphorically described by the &lt;strong&gt;second derivative&lt;/strong&gt;, the rate of change of the rate of change:
$$
f&apos;&apos;(x) = \frac{d^2 f}{dx^2}
$$&lt;/p&gt;
&lt;p&gt;We often focus on velocity (the first derivative), but it’s the acceleration (the second) that shapes the curve’s concavity. What seems like slow accumulation might be building toward a fundamental shift in direction.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You won’t find “absolute truth” here, only honest notes and open conversation. Picture a friend across the table, coffee still steaming, with sketches or a few lines of untested code on a napkin.&lt;/p&gt;
&lt;p&gt;If you, too, believe that &lt;strong&gt;thoughts deserve to be untangled, sharing builds connection, and sincere documentation carries its own weight&lt;/strong&gt;—then I think we already share a silent understanding. Like two particles becoming &lt;strong&gt;“quantum entangled”&lt;/strong&gt;, our states, however distant, may now correlate.&lt;/p&gt;
&lt;p&gt;This is the first post, a gentle beginning. If you’re willing, I’d love for us to walk this path together.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What’s a “problem” or “project” you’ve been turning over lately?&lt;/strong&gt; Is it about finding a definite solution, like solving an equation, or more about observing interesting patterns, like studying a chaotic system?&lt;/p&gt;
&lt;p&gt;Feel free to leave a note and tell me.&lt;/p&gt;
&lt;p&gt;— Your new friend&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Ziwen Hua&lt;/em&gt;&lt;/p&gt;
</content:encoded></item><item><title>我的第一篇文章</title><link>https://tech.kinghua0629.com/posts/%E6%88%91%E7%9A%84%E7%AC%AC%E4%B8%80%E7%AF%87%E6%96%87%E7%AB%A0/</link><guid isPermaLink="true">https://tech.kinghua0629.com/posts/%E6%88%91%E7%9A%84%E7%AC%AC%E4%B8%80%E7%AF%87%E6%96%87%E7%AB%A0/</guid><description>这是我的第一篇文章，同时也是公告</description><pubDate>Tue, 17 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;pre&gt;&lt;code&gt;print(&quot;hello world&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;嘿，你好呀。&lt;/p&gt;
&lt;p&gt;很高兴你能点开这里，成为这个小小空间的第一位访客。这里是我的数字自留地，一个刚刚松土、准备播种的地方。&lt;/p&gt;
&lt;p&gt;我猜，你和我一样——心里总有些散落的念头，像午后的光斑，明晃晃的，却抓不住形状；有些问题在生活的水面下打着旋儿，不肯沉底；有些“原来如此”的瞬间，渴望被记录下来。&lt;/p&gt;
&lt;p&gt;于是就有了这里。&lt;/p&gt;
&lt;p&gt;我会在这里写下：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;那些让我停顿的思考&lt;/strong&gt;——关于生活、阅读、或者偶然瞥见的世界一角。就像理解熵增定律 $$ΔS ≥ 0$$ 一样，它告诉我，混乱是常态，而所有秩序与理解都需要付出能量。我也着迷于一些简洁的数学真理，比如&lt;strong&gt;欧拉公式&lt;/strong&gt;：$$e^{i\pi} + 1 = 0$$。它用一个极简的等式，将自然底数、虚数单位、圆周率和0、1这两个基础整数联系起来——仿佛在提醒我们，看似无关的领域，底层可能共享着优美的统一逻辑。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;那些亲手验证过的好用与不好用&lt;/strong&gt;——可能是方法、工具，或者一个视角。它们会像可执行的代码片段一样被呈现，你可以直接运行或修改：&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# 一个简单的函数：从杂乱列表中提取核心项
def extract_essence(thoughts_list):
    # 1. 过滤掉纯粹的情绪噪音
    filtered = [t for t in thoughts_list if t not in [&quot;焦虑&quot;, &quot;拖延&quot;]]
    # 2. 连接剩下的，形成脉络
    essence = &quot; -&amp;gt; &quot;.join(filtered)
    return essence

# 例如，处理：[“困惑”， “阅读”， “灵感”， “拖延”]
# 输出会是： “困惑 -&amp;gt; 阅读 -&amp;gt; 灵感”
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;那些不完美但真实的过程&lt;/strong&gt;——学习、尝试、甚至走弯路的样子。我相信成长很少是线性的，它更像一个探索函数，有时需要随机游走，才能找到梯度上升的方向。这过程，或许可以用描述“变化之变化”的&lt;strong&gt;二阶导数&lt;/strong&gt;来隐喻：
$$
f&apos;&apos;(x) = \frac{d^2 f}{dx^2}
$$
我们常常关注速度（一阶导），但决定曲线凹凸形状的，往往是加速度（二阶导）。那些看似缓慢的积累，可能正酝酿着方向的根本改变。&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;这里不会有“绝对正确”，只有诚实的记录和开放的对话。就像一个朋友坐在对面，咖啡还冒着热气，而草稿纸上可能画着示意图，或者几行待调试的代码。&lt;/p&gt;
&lt;p&gt;如果你也相信：&lt;strong&gt;思考值得被梳理，分享能连接彼此，真诚的记录自有它的力量&lt;/strong&gt;——那么，我想我们已经有了最初的默契。就像两个粒子发生了 &lt;strong&gt;“量子纠缠”&lt;/strong&gt;，自此，遥远的状态也能彼此关联。&lt;/p&gt;
&lt;p&gt;这是第一篇，一个轻轻的开始。接下来的路，如果你愿意，我们可以一起走走看。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;你最近在思考什么“问题”或“项目”呢？&lt;/strong&gt; 是像求解方程一样寻找一个确切的解，还是像观察混沌系统一样，在探索其有趣的模式？&lt;/p&gt;
&lt;p&gt;欢迎随时留言告诉我。&lt;/p&gt;
&lt;p&gt;— 你的新朋友&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Ziwen Hua&lt;/em&gt;&lt;/p&gt;
</content:encoded></item></channel></rss>