A dictionary, in computer science, is a data structure that maps keys to values such that given a key its corresponding value can be efficiently retrieved.

learn more… | top users | synonyms (1)

8
votes
3answers
872 views

Word-counting script in C#

My goal is to read from standard input, break up the input into words (Unicode letters and apostrophes), case-insensitively, and produce a report to standard output, where each line is a word followed ...
7
votes
2answers
752 views

Looking for primes with all-different digits

I recently answered a question on Mathematics Stack Exchange, where I used a small Python program to check the following : For all 6-digit numbers, with all digits being different, choosing the ...
2
votes
1answer
45 views

Typescript/Javascript Dictionary Class

I recently implemented a dictionary class in typescript. I'm still new to javascript so I'm curious what people think about it. One Update ...
-3
votes
0answers
39 views

'Terminated due to time out'. Need help in optimising my code

I am trying to implement dictionary. I would appreciate if you find the flaws in my code rather than changing whole logic. Attaching the link of Problem https://www.hackerrank.com/challenges/30-...
2
votes
2answers
92 views

Concurrent bidirectional dictionary

I've been agonizing over this for an hour or two. I require a bidirectional dictionary that was thread safe. From what I understand about dictionaries, they're thread safe when being read from, but no ...
2
votes
0answers
46 views

AutoDictionary for object with a key property v2

I think I get it right now. This time I've implemented it with the IDictionary and added a few convenience methods. There is however one issue that without ...
5
votes
1answer
89 views

AutoDictionary for objects with a key property

The normal dictiory separates the key from the value... but what if the key is a part of the item it stores? It then forces you to enter the same things twice, once for the key and agian for the item. ...
4
votes
2answers
70 views

Python lazy dict with iterator in constructor

This question began as an off-topic answer to this question, but the code here serves a different goal. I wrote the following class for the purpose of populating a dict on demand from an iterator. ...
4
votes
3answers
933 views

Top 5 most common words in Python

I would like to hear feedbacks from an interviewer's perspective on how to improve the following code: ...
6
votes
2answers
177 views

Dictionary as context manager

I've created a class that implements customized addition, subtraction, etc. But for this class I'd like to have some additional parameters for these methods (__add__...
1
vote
0answers
24 views

Implement “at” lens for Data.Map

I've been working on adding an operation like Data.Lens.At.at to Data.Map. This uses an extremely fast, extremely small, and ...
9
votes
10answers
1k views

Writing an anagram efficiently

I know this question has been asked before now but in Python. Recently, I set out to write an anagram in C#. For instance, orchestra can be rearranged into carthorse and the anagram should not have ...
2
votes
2answers
158 views

Idiomatic word counting in Rust

My goal is to read from standard input, break up the input into words, case-insensitively, and produce a report to standard output, where each line is a word followed by a space followed by its count. ...
7
votes
2answers
272 views

Extracting values from dictionaries where the keys match

I have two Dictionaries with around 65,000 KeyValuePairs each. I used foreach and if-else statements to compare them and get values, but it goes very slow. How could I optimize my code and gain more ...
2
votes
1answer
103 views

Clustering similar tweets in a corpus

I am attempting to write a statistical program using an LDA model I've trained/created using Gensim. I am very new to Python and am a student level programmer. This current program is working and ...
2
votes
2answers
130 views

Take a result set and organize it into a dictionary

I'm trying to take a result set and organize it into a dictionary then assign the dictionary values to variables that are publicly accessible from my controller. My issue is I have to check if there ...
1
vote
2answers
53 views

Permute and count between nested dictionaries

Goal: Permute inner values between two dictionaries with matching outer key, Save permuatations in counter, Move to next outer key, update counter with new permutations. Problem: Many lookups on ...
1
vote
2answers
55 views

Matching lines in a CSV file with items in a dictionary

I was wondering if there was a better way of writing this... I have a CSV file (about 6640 lines). After reading through the file, the values for the DFN_Network ...
1
vote
1answer
103 views

A basic pure Python hash map using a tree

I would like feedback on my first attempt to understand how hash tables work. I've read some on how hash tables use modulo operations to find the location of a key. Can you help me understand, ...
0
votes
1answer
45 views

Match two dictionary keys efficiently in Python

I have two dictionaries that I need the keys to match and if they match i will get the value of the first dictionary and then get the value of 2nd dictionary and build a new dictionary out of those. ...
3
votes
3answers
163 views

Search in a big dictionary Python

I have a big Python dictionary with more then 150,000 keys every key has list value. This dictionary contains infinitive words as key and all grammatical forms of these words as values: ...
0
votes
4answers
96 views

Adding to a dictionary and skipping duplicate keys

What is the cleanest way to use dictionaries and protect against an unhandled ArgumentException if the key already exists in the dictionary? I'd like to say that I ...
2
votes
2answers
164 views

Dictionary app using WIn32

I'm creating a dictionary app using Win32 API. I stored the word meaning in a file called dictionary.dic in the following format: Word Meaning A The first letter B The second ...
40
votes
2answers
188 views

Counting all the vowels in a passage of text

My son just started high school and in Math, he was asked to do some stats homework. The exercise was to count all the vowels in a passage of text, then answer some questions about frequency. Out of ...
3
votes
2answers
113 views

Functions to merge dictionaries with a comparison

I have several functions for merging some dictionaries but over time I created a more general function that would make all these others obsolete if it weren't slower. I have the specialized (and ...
2
votes
1answer
32 views

Optimize performance of flatten function in python

I have to flatten a large number (>300k) dicts to write them to a csv file. Example: ...
2
votes
2answers
154 views

Insert rows in the datagridview with a dictionary

I would like to improve the function below without calling twice InserisciRigaNote. Before I fill my dictionary. When I compare ...
1
vote
3answers
367 views

Recursively Save Python Dictionaries to HDF5 Files Using h5py

I have a bunch of custom classes for which I've implemented a method of saving files in HDF5 format using the h5py module. A bit of background: I've accomplished ...
3
votes
2answers
79 views

Most efficient dict filter on key tuple?

I have a dict wherein a value needs to be retrievable by any one of several keys. It seemed that making multiple dictionaries or multiple entries in a single ...
3
votes
2answers
115 views

Dynamic class instancing (with conditional parameters and methods) based on a dictionary

In a RPG game I'm developing, after building a base Weapon class, instead of having many subclasses of Weapon, I want the ...
1
vote
1answer
69 views

Writing a Counter object to a CSV-file in Python 3

In Python 3.4, a Counter object called cnt like this: ...
4
votes
2answers
95 views

Dictionary lookup of non-nullable struct into nullable destination

I've got an IDictionary<SomeT, DateTime> that does not always contain the desired key-value pair. For that reason, a target method expects a ...
4
votes
3answers
79 views

Efficient dictionary printing

Here's what my task is: Dependant on the "Logged In" user, they'll have different access rights and will see different menus. I have tried using the .get() ...
4
votes
3answers
89 views

Load recurring (but not strictly identical) sets of Key, Values into a DataFrame from text files

I am reading text files that contain data from observations. The format is not Fixed Width or Delimited, so I built a generator ...
3
votes
2answers
334 views

Custom Implementation of ObservableDictionary

I recently found myself in need of an IDictionary<TKey,TValue> implementation that was observable from a WPF UI. Since the .Net framework does not provide ...
7
votes
2answers
97 views

Copying a Dictionary and Replace its Values

I have a custom dictionary where the values are numpy arrays. I would like to have a convenience function that creates a copy of its content except that the values are changed. If no value is passed, ...
11
votes
1answer
81 views

iterating over the values of a list of ordered dictionaries

I am facing the following problem: I have a special data structure that is a dictionary whose keys are integers (dimensions). The values are also dictionaries whose keys are strings (geometric types) ...
6
votes
2answers
71 views

Unicode-capable symbol table (N-way search tree with hash buckets)

As in my previous question, this module is coupled with its own testing framework. As a symbol-table for a Unicode-capable programming language interpreter, I decided to combine the 3 types of ...
3
votes
2answers
97 views

Compare dicts and record changes

My goal is to continually update an object and record any changes and the times they were made at. The input has to be JSON but the output/storage format doesn't. This function will check a JSON ...
1
vote
1answer
286 views

Test if a key exists anywhere in a nested object

I have complex objects containing nested objects. I need to check if a key exists anywhere in the nested object. I wrote this code as a makeshift solution. Is there any other way to search for the key?...
1
vote
1answer
49 views

A Simple SortableDictionary for JavaScript

First, I must humbly admit that I've been a developer for many years but I've almost never had to work as a front-end, Web UI developer. I've been given an opportunity to work for an organization as ...
3
votes
2answers
118 views

Mapping a user input string to a corresponding block of code

My idea is I can define a block of code (inline) that corresponds to an input string then can call that block of code when given that input. I'm used to this sort ...
2
votes
1answer
227 views

Calculating sum of values in each child of dictionary for QTreeView

There is data stored in JSON file with the following structure: goods_data = {"year" : {"month" : {"day" : {"01" : {"name" : "some item", "price" : "10.01", "category" : "root | first | sub first |...
1
vote
1answer
297 views

Dictionary GetValueOrDefault

I'm pretty sure there's no better way to do this but I thought a consensus on here might be nice. Let me know what you think. ...
4
votes
2answers
1k views

Wrapping tuples to be used as keys in a Dictionary

I'm currently working on a project where I have to map some objects to several properties. Basically I need a Dictionary with Tuples as keys and instances of MyClass as values. As using tuples can ...
1
vote
1answer
27 views

Reading XML files and finding pairs between the files

I read three files and parse a few individual fields from each row of the XML. Using these fields, I find the dictionaries that contain the same keys (ItemK and either SensorK for sensors or PointK ...
3
votes
2answers
82 views

Practice with dictionaries

Post a cursory read of this I implemented a simple dictionary and an interface to assign, replace, look up, and redefine its terms to apply the concepts. It's simple, but I'd still like to know any ...
1
vote
1answer
67 views

Wrapper class for adding elements to HashSet

I have many object of class Test. I want to be sure that among them, there are no two objects o1 and ...
2
votes
3answers
119 views

Grouping over a list of dictionaries

I am consuming data from an API that reads from a SharePoint list. The API is basically this: ...
5
votes
2answers
487 views

Counting words from standard input in Swift

I know Swift isn't exactly meant to be used to write your classic stdin to stdout scripts, and that Python, Ruby, Perl, bash, awk, and friends are much better in this area, but I'd still like to see ...