Boggle solver – Updated (with Trie)

Here is an update to my previous boggle solver. The new version has an almost instantaneous output, removing the need to limit the length of words being searched for.

Any comments on my general coding implementation or layout would be appreciated.

Python v3.7

"""Boggle game solver"""   class Trie:     """Trie class to speed up programme by stopping exploration of non-existent prefixes"""      def __init__(self):         """Initialise the trie"""         self.child = {}      def insert(self, word):         """Insert word into trie"""         current = self.child         for char in word:             if char not in current:                 current[char] = {}             current = current[char]      def search(self, word):         """Search the trie"""         current = self.child         for char in word:             if char not in current:                 return False             current = current[char]         return True   def words_from(board, row, column, running_string, list_words):     """Calculate all possible words from a given starting position [row, column]"""     if row in (4, -1) or column in (4, -1):         return     # Search the Trie     if not trie.search(running_string):         return     if board[row][column] != "-":         new_string = running_string + board[row][column]         board[row][column] = "-"         # Add new word         if len(new_string) >= 3:             list_words.append(new_string.lower())         # Find next word         next_move = [             (1, 1),             (-1, -1),             (1, -1),             (-1, 1),             (1, 0),             (0, 1),             (-1, 0),             (0, -1),         ]         for dx, dy in next_move:             words_from(board, row + dx, column + dy, new_string, list_words)         board[row][column] = new_string[-1]         return list_words   def get_permutations(board):     """Get all permutations """     set_permutations = set()     # Build Trie     global trie     trie = Trie()     with open("en-dict.txt", "r", encoding="utf8") as file:         for line in file:             trie.insert(line)     #Search for words from each starting position     for row in range(4):         for column in range(4):             # Search for words             words = words_from(board, row, column, running_string="", list_words=[])             if words:                 for word in words:                     set_permutations.add(word)             words = None     return sorted(list(set_permutations))  def dictionary_check(set_permuations):     """Check set_permutations for valid English words"""     dictionary = {}     with open("en-dict.txt", "r", encoding="utf8") as file:         for line in file:             dictionary[line.strip()] = 0      counter = 0     for word in set_permuations:         if word.lower() in dictionary:             counter += 1             print(word)     print(f"======\n{counter} words")   def find_words(board):     """Find words on the boggle board"""     set_permutations = get_permutations(board)     print("\nPerforming dictionary check....")     dictionary_check(set_permutations)   def build_board(string):     """Build board from string"""     if len(string) != 16:         print("Error. Must enter 4*4 grid (16 characters)")         return     board = [[*string[0:4]], [*string[4:8]], [*string[8:12]], [*string[12:16]]]     find_words(board)   if __name__ == "__main__":     string_board = "playthiswordgame"     build_board(string_board) 

App was updated without my approval

I have on my phone (galaxy note4) preinstalled samsung web browser application. I didn’t update it via Google play because I don’t use this app. But a week ago I found that this app was updated without my approval because apps icon was changed. I haven’t ever launch this app. How it is possible that app was updated without my approval?!

PHP EXCEL issue in data import with updated excel format .xlxs

I’m using PHPexcel library to import data from excel file to MySQL by using Ajax and PHP. It works fine with the old format excel file sample.xls (The Excel 97 – Excel 2003).

But I want to import data from sample.xlsx format. PHPexcel not working with this format.

I searched but can’t find a solution. Any help will be highly appreciated.

Not able to join worker nodes using kubectl with updated aws-auth configmap

I’m setting up AWS EKS cluster using terraform from an EC2 instance. Basically the setup includes EC2 launch configuration and autoscaling for worker nodes. After creating the cluster, I am able to configure kubectl with aws-iam-authenticator. When I did

kubectl get nodes  

It returned

No resources found

as the worker nodes were not joined. So I tried updating aws-auth-cm.yaml file

apiVersion: v1 kind: ConfigMap metadata:   name: aws-auth   namespace: kube-system data:   mapRoles: |     - rolearn: <ARN of instance role (not instance profile)>       username: system:node:{{EC2PrivateDNSName}}       groups:         - system:bootstrappers         - system:nodes 

with IAM role ARN of the worker node. And did

kubectl apply -f aws-auth-cm.yaml 

It returned

ConfigMap/aws-auth created

Then I understood that role ARN configured in aws-auth-cm.yaml is the wrong one. So I updated the same file with the exact worker node role ARN.

But this time I got 403 when I did kubectl apply -f aws-auth-cm.yaml again.

It returned

Error from server (Forbidden): error when retrieving current configuration of: Resource: “/v1, Resource=configmaps”, GroupVersionKind: “/v1, Kind=ConfigMap” Name: “aws-auth”, Namespace: “kube-system” Object: &{map[“apiVersion”:”v1″ “data”:map[“mapRoles”:”- rolearn: arn:aws:iam::XXXXXXXXX:role/worker-node-role\n username: system:node:{{EC2PrivateDNSName}}\n groups:\n – system:bootstrappers\n – system:nodes\n”] “kind”:”ConfigMap” “metadata”:map[“name”:”aws-auth” “namespace”:”kube-system” “annotations”:map[“kubectl.kubernetes.io/last-applied-configuration”:””]]]} from server for: “/home/username/aws-auth-cm.yaml”: configmaps “aws-auth” is forbidden: User “system:node:ip-XXX-XX-XX-XX.ec2.internal” cannot get resource “configmaps” in API group “” in the namespace “kube-system”

I’m not able to reconfigure the ConfigMap after this step.

I’m getting 403 for commands like

kubectl apply kubectl delete kubectl edit  

for configmaps. Any help?

Which label is better for a blog article – Last updated or last modified

In the context of a blog where you have the date of the Blog article Title, author and date. There can be another date used to show when the last update of the article is. Is there a consideration or more appropriate label

Last Modified vs Last Updated

Classically I have thought Last modified is semantically accurate but I don’t know if there is a reason for this or might it be the wrong label.

Setup Ubuntu 18.04 to send email after apt-get has updated packages?

I recently upgraded my server from 14.04 to 18.04. This went reasonably smoothly but there is one small issue that annoys me. I do not get an email anymore when I have run apt-get upgrade.

It used to be the case that I got an email when it finished about which packages were updated – but not anymore.

Does apt-get send an email when done? To which address?

As info: I have apticron installed and get those mails fine.

I tried to forward the mail to root via /home/root/.forward and this seems to work fine in a manual test.

Thanks for any insight.

Best regards, Koen