Map Character to Characters Most Frequently Found With it (in list of strings)

For an interview, I was tasked with writing a program that consumes a list of strings, and produces a mapping between every character in the list, and the characters found most frequently with it (let’s call them Companion Characters).

For example, if it was given ["aabc", "bcdddd", "cde"], it would return {a=[b, c], b=[c], c=[b, d], d=[c], e=[c, d]}. a maps to b, c because they were together in the first word, b maps to c because they were together in two words ("aabc" and "bcddd"), while a and d were only with it for one word, etc.

To solve it, I used two HashMaps – One which mapped every character to a map of companion characters, to integers (the number of times found), and another which mapped character to the list of companion characters found most frequently with it. My code (which compiles and works) is below.

import java.util.*;  public class MaxMap {    private Map<Character, Map<Character, Integer>> charMap;    private Map<Character, List<Character>> maxMap;     public MaxMap() {        charMap = new HashMap<>();        maxMap = new HashMap<>();    }     public void computeMap(List<String> strs) {        for(String str: strs) {            //Will contain all of the starting letters encountered in the string            Set<Character> seenOriginal = new HashSet<>();            for(int i = 0; i < str.length(); i++) {                char original = str.charAt(i);                if(!charMap.containsKey(original)) {                    charMap.put(original, new HashMap<>());                }                //Haven't yet calculated the mappings for this character - and dups don't matter                if(!seenOriginal.contains(original)) {                    seenOriginal.add(str.charAt(i));                    Set<Character> seenMapping = new HashSet<>();                    for(int j = 0; j < str.length(); j++) {                        //This is the same character, or a character previously encountered.                        if(i == j || str.charAt(i) == str.charAt(j) || seenMapping.contains(str.charAt(j))) continue;                        char added = str.charAt(j);                        seenMapping.add(added);                        int num = charMap.get(original).getOrDefault(added, 0);                        num++;                        charMap.get(original).put(added, num);                        setMaxMapping(original, added);                    }                }            }        }    }     public void setMaxMapping(char original, char added) {        List<Character> current = maxMap.getOrDefault(original, new ArrayList<>());        int oldCount = 0;        if(current.size() > 0) {            oldCount = charMap.get(original).get(current.get(0));            //Special case, in case the first char in list was the one adjusted            if(current.get(0) == added) {                oldCount--;            }        }         int addedCount = charMap.get(original).get(added);        if(addedCount > oldCount) {            current = new ArrayList<>(Arrays.asList(added));        } else if (addedCount == oldCount) {            current.add(added);        }        maxMap.put(original, current);    }     public Map<Character, List<Character>> getMaxMap() {        return this.maxMap;    } } 

The main class which constructed and called it is

import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map;  public class Main {     public static void main(String[] args) {         List<String> strings = new ArrayList<>(Arrays.asList("aabc", "bcdddd", "cde"));         MaxMap mm = new MaxMap();         mm.computeMap(strings);         System.out.println(mm.getMaxMap());     } } 

I didn’t get the job, because my code wasn’t optimal enough. How should I improve it?

Error: Characters found after SQL Statement

I am currently trying to insert a new row of information into a table, and am using the sql view inside of MS Access. When I run this code:

SELECT * FROM VersionReleases;  INSERT INTO   VersionReleases(CurrentVersionID, PreviousVersionID, ScriptID, ReleaseDate) VALUES   (555, 556, 1543, 2018); 

It gives me an error specified in title, and I can’t understand why. Would appreciate some guidance, thanks a bunch.

How much less secure is a password with a repetitive pattern of characters?

I want to make sure my password is very difficult to bruteforce but also easy to remember and convenient.

So my idea is to just use a short password and repeat it a few times like this:


How much less secure is this compared to using a password that is totally random, all else being equal (same length, same letters, numbers used)? E.g.


Or are both options equally hard to bruteforce?

Also assume that the password is not part of a dictionary.

Advice on TWO troublesome players and their characters

(Kinda ranty and long but i got a lot of problems with them, sorry)

So, background info, myself and a group of 4 friends have started playing Dungeons and Dragons 5th Edition. Everyone is a first time player and the DM is a first time DM. Both myself and the DM watch D&D streams while the others, to my knowledge, don’t so we have slightly more knowledge on the mechanics of D&D and how to play it well in comparison to the others. We are playing Lost Mine of Phandelver. Now our two troublesome players are a Tiefling Wizard (named Q) and a Shifter Rogue (named Ajax), the former of the two being the worst. The problem with the pair of them is that they are constantly derailing the campaign and getting our party into trouble.

Ajax can be a bit of a pain in the ass, particularly when he’s drunk, but as i said before, Q’s is the main problem. Q has and will:

  • Pickpocket’s both NPCs and PCs, particularly my character, a Bard Gnome, named Pickett. She is constantly trying to either take money from Pickett or is trying to steal a Jade Frog we found in the treasure cave of Cragmaw Hideout. She will try over and over again to pickpocket Pickett and she only stops when the DM tells her that its not going to work anymore or when another character hits her, which starts a fight.

  • She threatens to eat Pickett or Kite (a goblin we kidnapped and then adopted from Cragmaw Hideout). Because both of the characters are small and she is a tiefling, she threatens to attack and eat them if they start to annoy her. She has also contemplated eating a tavern owner and a tavern server as well as a merchant.

  • Pickett can’t play instruments in Q’s presence otherwise she threatens to break the instrument or break/consume something else e.g. Pickett had to stop playing her accordion otherwise Q would drink all the ale in the proficiencies cart we were escorting.

  • She loves starting fights with Ajax. They are basically at each others throats all the time, and their fighting almost got us kicked out of an inn, that we were staying at, because she attacked Ajax with a ray of frost and sent him flying out of their room, down the stairs and onto the tavern floor below, (it was only thanks to an extremely high persuasion role by our half-elf druid that we were able to stay).

  • She basically doesn’t want to play the game. Whenever we have to do something important plot-wise, e.g go looking for our missing friend/employer, take proficiencies to a traders, clear out a band of goblins because an important NPC asked us to etc. she doesn’t want to do it. She didn’t want to look for our friend (you know, the entire plot of Lost Mine of Phandelver!!), she wanted to take the proficiencies or steal them once we handed them over, and she wanted to leave the band of goblins alone and move on. It is infuriating.

There is more (so much more) but you get the idea, she cares more about creating chaos than actually playing the game. And for myself and the DM, it is starting to become annoying.

Ajax, is slightly better, but he makes really weird decisions that result in us all getting into trouble. And he also responds to all of Q’s prompts to fight. The problems they both share are acting without thinking, acting without consulting the party (like at all), creating chaos for entertainment and also a fair bit of meta gaming and failed attempts at fudging rolls (particularly on Q’s part). This leaves both myself and the druid to clean up their messes. Pickett has been reduced to a healer who is constantly using up all her spell slots to heal Ajax, Q or some poor bystander who got injured while they were fighting. And our Druid has been reduced to a negotiator who convinced people not to in-prison us or kick us out because of their actions.

Myself and the DM are starting to become very irritated with them both because we are no longer enjoying the game, which is rather upsetting and we don’t know what to do. We want them to stop, or at least tone it down so we can actually play the game but we don’t want to hurt their feelings because they are genuinely having fun with all of it. And as i said before they are my friends, two very close friends, and i would hate to taint our friendship because of a game, but it is starting to become unbearable. Giving them the benefit of the doubt, they are both first time players who know very little about D&D and about tabletop rpg’s in general. But the DM has corrected them several time that meta gaming is not allowed, that we are supposed to be a team and shouldn’t be mean to one another and that this is not an evil campaign, and yet they still continue.

I can’t even play my own character properly!! Pickett was supposed to be happy and bubbly with the belief that life is beautiful and as someone who doesn’t get irritated easily. Instead she is jaded, irritable and just a very good actor towards non-party members. It is really upsetting me that i can’t even play her properly because i can’t keep up her persona when they keep messing around all the time.

Oh and as a side note, this is after our second session. SECOND SESSION!! They got worse in the second one to a point that i am asking other people what to do about them!

What can i do to get them to stop? Or tone it down at least!

$8500 Value Female Characters Challenge


Hello, everyone. I wanted to let you know that even though our 3D:Interior Challenge hasn’t ended yet, CGTrader is bringing you another challenge: Female Characters. This challenge has the largest value prize pool ($ 8,500) of all previous challenges!
All you need to do to enter the challenge is design a female character model and submit it to either one of the two…

$ 8500 Value Female Characters Challenge

Stacking Labels characters Question?

I need help to find information about how to use stack separators for words. I am GIS Specialist and I work with maps. I have some maps that I need to split the words to create stack two lines.

Are there stacking separators online that can I find that can help me out ?

Here is the example of what I am taking about:

enter image description here

enter image description here

Here you see the pictures that I need to put Stacking Separator input so the text can split to make the Stacked Labels into two lines ?

I am using ArcGIS Desktop 10.5.1 .

How can I slowdown the characters to speed 0?

using System.Collections; using System.Collections.Generic; using UnityEngine;  public class AnimatorController : MonoBehaviour {     public Animator[] animators;     public Transform target;     public float speed = 1f;      // Use this for initialization     void Start()     {         for (int i = 0; i < animators.Length; i++)         {             animators[i].SetFloat("Walking Speed", speed);         }     }      // Update is called once per frame     void Update()     {         float distanceFromTarget = Vector3.Distance(animators[2].transform.position, target.position);         if (distanceFromTarget < 15)         {             float speed = (distanceFromTarget / 15) / 1;             for (int i = 0; i < animators.Length; i++)             {                 animators[i].SetFloat("Walking Speed", speed);             }         }          if(distanceFromTarget < 1)         {             for(int i = 0; i < animators.Length; i++)             {                 animators[i].SetFloat("Walking Speed", 0);             }         }     } } 

This part of the slowdown is working fine:

float distanceFromTarget = Vector3.Distance(animators[2].transform.position, target.position);             if (distanceFromTarget < 15)             {                 float speed = (distanceFromTarget / 15) / 1;                 for (int i = 0; i < animators.Length; i++)                 {                     animators[i].SetFloat("Walking Speed", speed);                 }             } 

I tried to add this part to make the characters stop:

if(distanceFromTarget < 1)             {                 for(int i = 0; i < animators.Length; i++)                 {                     animators[i].SetFloat("Walking Speed", 0);                 }             } 

But they never stop. They are slowing down then continue walking slow and then the speed moving up again once they are getting away from the target.

I want them to slowdown when the distance is 15 and less and once animators[2] distance is 1 from target stop.

Screenshot of the Animator: The two soldiers have the same animator controller the other character have it’s own controller all of them have the same states and parameters and same settings:


WordPress displays HTML Special characters while sharing post on Social Networks

i am developing a wordpress website.

In wordpress, When i tried to share Post to any social network, it displays special characters like “&#8217”.

for example if post content is this “To me hair dressing means shape. it’s very important that the foundations should be right.”

& if you share it on twitter, tweet will be like this “To me hair dressing means shape. it&#8217s very important that the foundations should be right. “

what should i do to prevent this?

DHIS 2.30 is displaying some icons and buttons with corrupted characters

I have installed DHIS2 2.30 on tomcat 9 with PostgreSQL. I have a problem with the display.

For example, when I go to ‘Maintenance’, the button for ‘Add’ and ‘List’ are not showing right. They are showing corrupted characters. The same thing is happening on that page with the ‘Metadata group editor’ icon at the top right.

When I go to the demo site, the display is correct. How can I fix this?

enter image description here