macos – What is ‘word left’ and ‘word right’ keycode in Karabiner-Elements?

On Mac OS system,
I modified the config file of complex map, but can’t find keycode of wordleft and wordright:

{
          "type": "basic",
          "from": {
            "key_code": "o",
            "modifiers": {
              "mandatory": [
                "command"
              ],
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "wordleft" # keycode is wrong
            }
          ]
        }

any suggestion? thanks

I usually work on any data Including data entry, data collection, excel, MS Word for $5

I usually work on any data Including data entry, data collection, excel, MS Word

Are You need a virtual assistant for data entry? if so, then you are in the right place. I will do any kind of data entry or data Entry Related job For You With Complete Satisfaction.


Data Entry

MS Word

Copy Paste Tasks

Data Capturing from the Websites

Virtual Assistant Tasks

JPEG to Excel

PDF to Excel

Email Marketing Lists

Email Searching

Contact me anytime If you need data entry work

.

c++ – LeetCode 212: Word Search II

I’m posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time!

Problem

Given a 2D board and a list of words from the dictionary, find all
words in the board.

Each word must be constructed from letters of sequentially adjacent
cell, where “adjacent” cells are those horizontally or vertically
neighboring. The same letter cell may not be used more than once in a
word.

Example:

Input:  board = (   
('o','a','a','n'),   
('e','t','a','e'),  
('i','h','k','r'),   
('i','f','l','v') 
) 
words =
("oath","pea","eat","rain")

Output: ("eat","oath") 

Note:

  • All inputs are consist of lowercase letters a-z.
  • The values of words are distinct.

Code

#include <vector>
#include <string>
#include <set>

class Solution {
    static constexpr unsigned int A_LOWERCASE = 'a';
    static constexpr unsigned int ALPHABET_SIZE = 26;

private:
    class TrieNode {
    public:
        std::vector<TrieNode *> children;
        bool is_word;

        TrieNode() {
            is_word = false;
            children = std::vector<TrieNode *>(ALPHABET_SIZE, NULL);
        }
    };

    class Trie {
    public:
        TrieNode *get_parent() {
            return parent;
        }

        Trie(const std::vector<std::string> &words) {
            parent = new TrieNode();

            for (unsigned int index = 0; index < words.size(); index++) {
                set_word(words(index));
            }
        }

        void set_word(const std::string &word) {
            TrieNode *curr = parent;

            for (unsigned int length = 0; length < word.size(); length++) {
                unsigned int index = word(length) - A_LOWERCASE;

                if (curr->children(index) == NULL) {
                    curr->children(index) = new TrieNode();
                }

                curr = curr->children(index);
            }

            curr->is_word = true;
        }

    private:
        TrieNode *parent;

    };

public:
    std::vector<std::string> findWords(std::vector<std::vector<char>> &board, std::vector<std::string> &words) {
        Trie *trie = new Trie(words);
        TrieNode *parent = trie->get_parent();
        std::set<std::string> found_words;

        for (unsigned int row = 0; row < board.size(); row++) {
            for (unsigned int col = 0; col < board(0).size(); col++) {
                depth_first_search(board, row, col, parent, "", found_words);
            }
        }

        std::vector<std::string> structured_found_words;

        for (const auto found_word : found_words) {
            structured_found_words.push_back(found_word);
        }

        return structured_found_words;
    }

private:

    static void depth_first_search(std::vector<std::vector<char>> &board, const unsigned int row, const unsigned int col, const TrieNode *parent, std::string word, std::set<std::string> &structured_found_words) {
        if (row < 0 || row >= board.size() || col < 0 || col >= board(0).size() || board(row)(col) == ' ') {
            return;
        }

        if (parent->children(board(row)(col) - A_LOWERCASE) != NULL) {
            word = word + board(row)(col);
            parent = parent->children(board(row)(col) - A_LOWERCASE);

            if (parent->is_word) {
                structured_found_words.insert(word);
            }

            char alphabet = board(row)(col);
            board(row)(col) = ' ';
            depth_first_search(board, row + 1, col, parent, word, structured_found_words);
            depth_first_search(board, row - 1, col, parent, word, structured_found_words);
            depth_first_search(board, row, col + 1, parent, word, structured_found_words);
            depth_first_search(board, row, col - 1, parent, word, structured_found_words);
            board(row)(col) = alphabet;
        }
    };
};

Reference

LeetCode has a template for answering questions. There is usually a class named Solution with one or more public functions which we are not allowed to rename. For this question, the template is:

class Solution {
public:
    vector<string> findWords(vector<vector<char>>& board, vector<string>& words) {
        
    }
};

How to get consistent spacing from the body to the footer in Microsoft Word?

I am writing here to see if anyone can help me out with a spacing issue at the bottom of pages in Microsoft Word.

It appears that the spacing between the body and the footer changes on different pages. For example, sometimes Word allows an extra line of the body paragraph to fit onto the page while in other instances it simply pushes it onto the next page, thus making the spacing inconsistent across pages.

Is there any way to systematically make the spacing uniform by setting limits in the settings?

I’ve attached a few screenshots that demonstrate this inconsistency in spacing across pages to help show what I’m talking about.
Screenshot One

Screenshot Two

How to use Toggle Field Code to halve the "PAGE" & "NUMPAGES" variables – (Microsoft Word)

I want to have my footer count every second page

(so that when I print doubled sided paper, each sheet of paper will be counted as 1 page)

_

Normally page footers would look like; page 1, page 2, page 3, page 4, page 5

I have different odd and even footers so mine looks like; page 1, page 3, page 5

I want my footers to increment every 2nd page and look like; page 1, page 2, page 3

_

I was hoping that if I entered "Page {={PAGE/2}} of {={NUMPAGES/2}}" into the footer it would work but I can’t seem to get around syntax errors or bookmark undefined errors.

turing machines – Determine if the following problem is decidable or not : Does the read–write head of a TM with the input w leave the word w?

It is not clear if your language $L$ contains the pars $langle T, wrangle$ or if $w$ is fixed and $L$ only contains Turing machines.
In any case the answer is the same.

Let $T$ be a (single tape) TM that does not leave the word $w$. Let $Q$ and $Gamma$, be the set of states and the tape alphabet of $T$.

The number of possible configurations of $T$ can be upper bounded as a function of $|w|$, $|Q|$, and $|Gamma|$ and this upper bound $B_T$ is computable.

To decide $L$ it suffices to simulate $T$ for $B_T$ steps.
If $T$ ever leaves the word $w$ you can reject. Otherwise either $T$ halted without leaving $w$, or $T$ is stuck in an infinite loop that does not leave $w$. In both cases you can accept.

visual studio – C# analyzer to inspect word wrap alignment

VS 2019 offers a quick fix to reformat a terribly wrapped string expression called Wrap and align expression.

Terribly wrapped string expression

Not aligned wrapped string expression

Quick fix offered by VS 2019

Quick fix offered by VS 2019

Result after using the quick fix

Properly aligned wrapped string expression

So far so good. But is there also a setting that fires a warning for wrong wrapped string expressions? Preferably, in the form of a roslyn analyzer offered as a NuGet package. A VS extension would work as well, as long it is free to use. ReSharper is not an option for me.

graph – Word Chain using DFS Java

Problem

For given list of words check if all the words can be arrange to form a chain. Any word can be linked to the next if the last char matches with the first character of the another Word. For eg . (hello, org, games, salvin) is valid chain.

Code

import java.util.*;
import java.util.stream.*;
public class Solution {
    
    private char lastChar(String s)
    {
        return s.charAt(s.length() -1);
    }

    private char firstChar(String s)
    {
        return s.charAt(0);
    }
    Map<String, List<String>> map;
    public List<String> graph(List<String> list)
    {
       map = new HashMap<>();
        
        // complete graph
        for (String string : list) {


            map.put(string, new ArrayList<>());
        }

        for (String string : list) {
            List<String> tmp = list.stream().filter(e-> !e.equals(string)).collect(Collectors.toList());
            map.get(string).addAll(tmp);
        }
        // System.out.println(map);

        Set<String> visited = new HashSet<>();
        List<String> path = new ArrayList<>();
        F: for (String curr : list) {
            visited.add(curr);
            path.add(curr);
            dfs(curr, visited,path); 
            // System.out.println(path);
            if(path.size() >= map.size())
            {
               break F;
            // return path;
            }    
            // System.out.println(path);
            path.clear();
            visited.clear();
        }
        // System.out.println(new ArrayList(visited));
        // System.out.println("->"+path);
        return path;
    }

    void dfs(String curr, Set<String> visited, List<String> path)
    {
        if(visited.size() >= map.size()) 
            return;

        // path.add(curr);
        List<String> neighbors = map.get(curr);
        for(String s: neighbors)
        {
            if( lastChar(curr) == firstChar(s) && !visited.contains(s))
            {
                path.add(s);
                visited.add(s);
                dfs(s, visited,path);
            }
        }
    }



    public static void main(String() args) {
        

        WordList obj = new WordList();
        // "Hello","org","games","salvin"
        obj.graph(Arrays.asList("salvin", "org", "hello", "games"));
       // Alice Emilia Aashish Hendricks Somi Isha 
        List<String> lis = Arrays.asList("alice" ,"mmilia", "taashish" ,"khenndricks" ,"jsomi", "zisha");
        lis.sort(Comparator.naturalOrder());
        // List<String> lis = Arrays.asList("Alice","A")
        // Collections.shuffle(lis);
        // System.out.println(lis);
        // obj.graph(lis);
        System.out.println(obj.graph(lis));

        // obj.nextPermutation(lis);
        lis = Arrays.asList("james","sera","amen","nehak","kily","yen");
        Collections.sort(lis);
        // System.out.println(lis);
        System.out.println(obj.graph(lis));

    }
}

Review

I would like review on

  • Efficiency
  • Code Quality
  • Efficient use of library functions
  • Performance

Also let me know if I can use any java 8 functions for specific task without hard coding it.

thanks.

c++ – LeetCode 1320: Minimum Distance to Type a Word Using Two Fingers

I’m posting my C++ code for LeetCode’s 1320. If you have time and would like to review, please do so. Thank you!

Problem

  • You have a keyboard layout as shown above in the XY plane, where each English uppercase letter is located at some coordinate, for
    example, the letter A is located at coordinate (0,0), the letter
    B is located at coordinate (0,1), the letter P is located at
    coordinate (2,3) and the letter Z is located at coordinate
    (4,1).

  • Given the string word, return the minimum total distance to type such string using only two fingers. The distance between coordinates
    (x1,y1) and (x2,y2) is |x1 - x2| + |y1 - y2|.

  • Note that the initial positions of your two fingers are considered free so don’t count towards your total distance, also your two fingers
    do not have to start at the first letter or the first two letters.

Example 1:

Input: word = “CAKE” Output: 3

Explanation:

Using two fingers, one optimal way to type “CAKE” is:

  • Finger 1 on letter ‘C’ -> cost = 0
  • Finger 1 on letter ‘A’ -> cost = Distance from letter ‘C’ to letter ‘A’ = 2
  • Finger 2 on letter ‘K’ -> cost = 0
  • Finger 2 on letter ‘E’ -> cost = Distance from letter ‘K’ to letter ‘E’ = 1

Total distance = 3

Constraints:

  • 2 <= word.length <= 300
  • Each word(i) is an English uppercase letter.

enter image description here

Accepted C++

#include <vector>
#include <string>
#include <algorithm>

class Solution {
    const unsigned short int ALPHABET_LEN = 26;
    const unsigned short int WIDTH = 6;
    const unsigned char A_LETTER = 'A';
public:

    std::size_t minimumDistance(const std::string word) {
        const std::size_t length = word.size();
        std::vector<int> dp(ALPHABET_LEN);
        int max_decrease = 0;
        int total_distance = 0;

        for (std::size_t index = 0; index < length - 1; index++) {
            const int second = word(index) - A_LETTER;
            const int third = word(index + 1) - A_LETTER;

            for (std::size_t first = 0; first < ALPHABET_LEN; first++) {
                dp(second) = std::max(dp(second), dp(first) + coordinates(second, third) - coordinates(first, third));
            }

            max_decrease = std::max(max_decrease, dp(second));
            total_distance += coordinates(second, third);
        }

        return total_distance - max_decrease;
    }

private:
    unsigned short coordinates(unsigned short left, unsigned short right) {
        return std::abs(left / WIDTH - right / 6) + std::abs(left % WIDTH - right % WIDTH);
    }
};

Reference

On LeetCode, there is a class usually named Solution with one or more public functions which we are not allowed to rename.