Choonz325
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Week 7 - Maps ## Team Team name: Academy Award Winning, Choccy Milk Drinking, Cross Dressing SIMPS In Yugoslavia With Honda Accords Date: 30/03/2022 yes(40%) Members Dawid: Dawid Swietlinski (518337) Cristi: Cristian Cimpeanu (524091) Mihnea: Mihnea Bastea (514541) Vlad: Vladislav Serafimov(509761) Steve: Stephen Cruz Wright(521476) | Role | Name | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | | **Facilitator** keeps track of time, assigns tasks and makes sure all the group members are heard and that decisions are agreed upon. | Mihnea | | **Spokesperson** communicates group’s questions and problems to the teacher and talks to other teams; presents the group’s findings. | Vlad | | **Reflector** observes and assesses the interactions and performance among team members. Provides positive feedback and intervenes with suggestions to improve groups’ processes. | Steve | | **Recorder** guides consensus building in the group by recording answers to questions. Collects important information and data. | Dawid | | **Additional** we had another person join our group this week so we have an additional space. We chose to make this member double check work done to assure quality in our work. | Cristi | ## Activities Make sure to have the activities signed off regularly to ensure progress is tracked. Download the provided project and open it in CLion. ### Activity 1: The ctype header file ```c int isalpha(int c); //Checks if character is alphabetic int isspace(int c); //Checks if character is white-space int ispunct(int c); //Checks if character is punctuation int islower(int c); //Checks if character is lowercase int isupper(int c); //Checks if character is uppercase int tolower(int c); //converts uppercase letters to lowercase. int toupper(int c); //converts lowercase letters to uppercase. ``` ### Activity 2: Count letters in a string ```c= unsigned long countLetters(unsigned long counts[static 26], const char* str) { unsigned long count = 0; for (int i = 0; str[i] != '\0'; ++i) { if (isalpha(str[i])){ //all this line does increment the letter ++counts[tolower(str[i]) - 'a']; ++count; } } return count; } int main(void){ unsigned long counts[26] = {0}; const char* text = "The Quick Brown Fox Jumps Over The Lazy Dog."; unsigned long total = countLetters(&counts[0], text); assert(35 == total); printCounts(&counts[0], false, true); } ``` ### Activity 3: Recognizing languages `FIX MEEEEEEEEE` ```c= bool is_in(int val, int *arr, int arr_size){ for (int i = 0; i < arr_size; ++i) { if (arr[i] == val) return true; } return false; } const char* makeSignature(unsigned long counts[static 26]){ static char arr[7] = {0, 0, 0, 0, 0, 0, '\0'}; int sizes[7] = {-1, -1, -1, -1, -1, -1}; int index = 0; //compare characters and find the current biggest for (int i = 0; arr[5] == 0; ++i) { for (int j = 0; j < 25; ++j) { //if the number is the biggest yet and the letter has bot occurred yet bool is_not_occurring = (arr[0] != j + 'a') || (arr[1] != j + 'a') || (arr[2] != j + 'a') || (arr[3] != j + 'a') || (arr[4] != j + 'a') || (arr[5] != j + 'a'); if ( is_not_occurring && !is_in(counts[j], sizes, 6) && counts[j] > counts[j-1]){ index = j; sizes[i] = counts[j]; } } arr[i] = index + 'a'; printf("%c", arr[i]); } return &arr[0]; } int main(void) { unsigned long counts1[26] = {15,3,4,5,16,6,7,8,9,7,6,3,2,11,14,1,2,12,13}; unsigned long counts2[26] = {16,4,7,5,20,7,4,3,14,5,9,1,2,18,6,12,9,13,9,15}; assert(strcmp("eaosrn", makeSignature(counts1)) == 0); assert(strcmp("enatir", makeSignature(counts2)) == 0); } ``` can s1 figure out the second part one of the functions they want us to call returns a struct and all the others use unsigned long arrays | File | Signature | Language | | ---------- | --------- | -------- | | alice0.txt | | | | alice1.txt | | | | alice2.txt | | | | alice3.txt | | | ### Activity 4: Find out: dictionaries around us - Students/Student numbers - Book content page - Products/Product IDs - Species/Their names - Tigers/Their stripe patterns ### Activity 5: Find out: dictionaries in other languages 1. C# - creating ```csharp var d = new Dictionary<string, string>; //one method ``` - adding ```csharp d.Add("a string", "another string") ``` - removing ```csharp d.Remove("a key"); ``` - retrieving ```csharp string value = d["a key"]; ``` 2. Python - creating - adding ```python d.get("a key") ``` - removing ```python d.popitem() //no other way of removing things ``` 3. Javascript XD - creating ```javascript var dict = new Object(); //or var dict_alt = []; ``` - adding ```javascript dict.push({ key: "keyName", value: "the value" }); ``` - removing ```javascript dict.push({ key: "a key", value: "a value" }); ``` - retrieving ```javascript var value = d["a key"]; ``` ### Activity 6: The ensureCapacity function ```c= // Internal function, called to resize a counter_t if needed bool _ensureCapacity(counter_t* counter, const size_t minimumCapacity){ size_t new_capacity = counter->capacity; while (minimumCapacity > new_capacity){ new_capacity = new_capacity * GROWTH_FACTOR + 1; } if (new_capacity > counter->capacity){ if (realloc(counter->data, new_capacity) != NULL){ counter->capacity = new_capacity; return true; } //in case of a bad realloc free (counter->data); } return false; } ``` ### Activity 7: insertAt function ```c= static bool _insertAt(counter_t* counter, const size_t index, const char* key, unsigned long value){ (void)index;// prevents unused-parameter error (void)key;// prevents unused-parameter error (void)value;// prevents unused-parameter error pair_t new_pair; new_pair.key = key; new_pair.value = value; if (_ensureCapacity(counter, counter->size + 1)) { memmove(counter + index + 1, counter + index, counter->size - index); counter->data[index] = new_pair; ++counter->size; } return false; } int main() { counter_t counter; initCounter(&counter, 0); insert(&counter, "Bob", 3); insert(&counter, "Dave", 4); insert(&counter, "Alice", 5); insert(&counter, "Eva", 3); insert(&counter, "Charlie", 7); assert(strcmp(counter.data[0].key, "Alice") == 0); assert(counter.data[0].value == 5); assert(strcmp(counter.data[1].key, "Bob") == 0); assert(counter.data[1].value == 3); assert(strcmp(counter.data[2].key, "Charlie") == 0); assert(counter.data[2].value == 7); assert(strcmp(counter.data[3].key, "Dave") == 0); assert(counter.data[3].value == 4); assert(strcmp(counter.data[4].key, "Eva") == 0); assert(counter.data[4].value == 3); assert(counter.size == 5); assert(counter.capacity >= counter.size); destroyCounter(&counter); } ``` ### Activity 8: Increment function ```c= (void)counter;// prevents unused-parameter error (void)key;// prevents unused-parameter error unsigned long god_val; if ((god_val = getOrDefault(counter, key, counter->size + 1)) == counter->size + 1){ if (insert(counter, key, 1)) return 1; } else{ return ++counter->data[god_val].value; } return 0; int main(void) { counter_t counter; initCounter(&counter, 0); increment(&counter, "Alice"); increment(&counter, "Alice"); increment(&counter, "Alice"); increment(&counter, "Bob"); increment(&counter, "Bob"); assert(counter.size == 2); assert(counter.data[0].value == 3); assert(counter.data[1].value == 2); destroyCounter(&counter); } ``` ### Activity 9: Find out: function `strtok` > `strtok(string, separators)` breaks down the string into substrings (tokens) based on certain separating characters. `string` is the string that needs to be broken down and `separators` is a string filled with the separating characters. The function returns a pointer to the first token ```c= void processLine(counter_t* counter, char* line) { //characters by which our string will be separated into tokens const char* sep = "\t (),.;:?!\"\n'"; //get a pointer to the first token char* token = strtok(line, sep); //while there is something left in line while (token) { //if the string is not empty increment the token key in counter (or add it) if (strlen(token)) increment(counter, token); //get the next token token = strtok(NULL, sep); } } ``` ### Activity 10: How many words? 1. How many time are the following words occurring in the "alice0.txt" document: "Alice", "the", "rabbit"? Alice: 404 the: 2526 rabbit: 6 2. How many unique words are there in the "alice0.txt" document? 26432 ## Looking back ### What we've learnt Language guessing. Python dictionaries lowkey suck. *highkey ### What were the surprises Surprisingly little errors ### What problems we've encountered All of them ### What was or still is unclear `"%lu"` or `"%lul"` for unsigned longs? ### How did the group perform? Yes

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully