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.
2
votes
1answer
18 views
Extending CGPoint to conform to Hashable
For Advent of Code Day 1, I found myself needing to use a tuple as a key in a dictionary. Seeing that I can't extend tuples in Swift, I decided to extend CGPoint ...
-4
votes
0answers
21 views
Unity post get check www requests with success callback and error callbacks [on hold]
im just wondering if any one could help point me in the right direction please??
ive found this code on here and i cant seem to figure out how to call the post function passing through parameters for ...
7
votes
3answers
410 views
Word Pattern challenge in LeetCode
I solved this problem from LeetCode:
Given a pattern and a string str, find if str follows the same
pattern.
Here follow means a full match, such that there is a bijection between
a letter ...
3
votes
1answer
36 views
Phonetic Alphabet Trainer
This is a little program I put together to help people learn the phonetic alphabet. Feel free to query the code.
...
5
votes
0answers
48 views
Elegant way to alter datasets with explicit filters
I would like to write a small helper to filter datasets. Each dataset is a dictionary and some filters I want to apply are common to all the datasets.
That my needs, I wrote this following pattern:
<...
4
votes
2answers
60 views
ConcurrentDictionary, Store Key and Compression
So i have a ConcurrentDictionary<int, string>
The "int" is merely the way i store the key, which i want more recommendations on.
Currently i do like this.
...
7
votes
1answer
110 views
Constant keys thread safe dictionary
I find that I use this pattern a lot where I have a dictionary which I would only read from and update and wouldn't add/remove keys.
In that case, using ...
1
vote
2answers
78 views
Finding the closest value and matching it with the correct item in the list
I have list values with their IDs like this:
ID Value
A 1.2
B 4.2
C 7.2
D 10.2
In C#, I want to find the ID with the closest value to a given value ...
3
votes
0answers
37 views
Decode HTML Entities in VBA using regex and dictionary
I receive HTML-encoded text that includes named and numbered entities, and I need the decoded HTML.
There were just too many bad solutions for this online.
I use regex pattern ...
3
votes
3answers
371 views
Simplify definition of a dictionary with default return value
I need a constant (dictionary with values and default return value if there are no defined value for a key).
Searching any ways to simplify the code.
Without a default value I can simply define a ...
2
votes
1answer
49 views
Dictionary Parser Class
I'm working on a parser library for substituting strings in dictionaries, with things like globals etc. Wanting to get opinions on the direction I'm taking and where I can improve the script. This ...
1
vote
2answers
92 views
Generation of Dictionary in Python
Is there a way to refactor the following Python code so that the number of lines in generation of the dictionary can be reduced?
...
3
votes
2answers
170 views
Dictionary populated on demand
I work with an embedded target that contains a list of commands and registers that may change from one device to another. So I need to build my commands list from metadata received from that ...
9
votes
1answer
105 views
Using generators to print the tree-like structure of a project
The goal of this code is to print the entity tree of a VHDL project. There are a readme and very minimal tests on the github repo.
I am trying to refactor the code to use generators in order to ...
5
votes
2answers
62 views
Python Cartesian Product in a constrained dictonary
I want to calculate the Cartesian product of n copies of a small list, marker=[0,1,2]. I want to use these Cartesian product ...
1
vote
1answer
49 views
VBA performance with Early Bind vs. Late Bind on called Sub-procedure
I was using early bind to reference the dictionary and realised that some users might not be willing to manually add the reference to use it and just consider the macro to be 'broken'.
I looked at ...
4
votes
2answers
67 views
A 'flexible' VBA approach to lookups using arrays, scripting dictionary and user input
In my previous post Optimise compare and match method using scripting.dictionary in VBA I wanted to address optimising the scripting.dictionary approach I was using and I feel I have achieved that (...
2
votes
1answer
73 views
Optimise compare and match method using scripting.dictionary in VBA
In my previous post I was looking for a better solution to write a single column of a 2D array into a worksheet besides looping between code and worksheet and finally managed to achieve that.
On ...
2
votes
1answer
107 views
GetHashCode of a Dictionary
There is a huge documentation about using and generating hashcodes for objects that will go into a dictionary, really few more if you try to look about hashcode of a dictionary.
No, the default ...
1
vote
2answers
74 views
Searching a dictionary
After some advice, which method do you think is better to use when searching a dictionary for the matching value(s)?
Method One
...
2
votes
1answer
70 views
Load txt to Scripting.Dictionary
This code load a 40MB txt into a dictionary. It runs in about 40 seconds (sometimes 20, no idea why). Is there a way to make it run under 4 seconds, or hopefully in 1 second?
...
3
votes
1answer
76 views
Comparing two lists under 6 columns with 32000 rows in excel vba using dictionary
I need to import 2 .s19 files to excel and then Compare across 6 Columns in Excel and store the output to a txt file. I have my data from column A to F. My current program doesn't store the data using ...
6
votes
1answer
56 views
Container (dict preserving key order, with attribute access)
This class is part of the Construct library.
Container is a dict that:
turns attribute access into key access so ...
2
votes
1answer
46 views
IEnumerable to typed Dictionary
Scenario
A portable controls/widgets library for Xamarin.Forms (PCL Profile 111) contains a combobox/dropdown/picker control where the ItemsSource property is an <...
1
vote
1answer
71 views
Nth Fibonacci number (Bottom-up with dict)
This is an algorithm that I wrote to get the nth Fibonacci number using bottom-up dictionary. How can I make this better/more efficient?
...
2
votes
1answer
62 views
2
votes
0answers
26 views
List of lists from file
I'm writing a sub-routine in AppleScript to get text from a file and insert that text in a list of lists forming a dictionary.
Text File:
a:b
c:d
e:f
Expected ...
4
votes
1answer
58 views
Generate dictionary of points on n-sphere
This is a long-shot, but my question is to simply optimize this particular function in some code I have written:
...
8
votes
3answers
995 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
766 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 ...
4
votes
1answer
263 views
Using a LinkedList type of adjacency list to create the word game: WordLadder
The user puts in a starting word and an ending word. My code creates a ladder between these words of words that are different by one letter.
Start: gain
End: fire
Output:
...
2
votes
1answer
166 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.
...
2
votes
2answers
143 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
53 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
98 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
91 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. ...
2
votes
1answer
90 views
Flatten a nested dict structure in Python
For some post-processing, I need to flatten a structure like this
...
6
votes
2answers
202 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
28 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
216 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
662 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
178 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
156 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
70 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
69 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
112 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
51 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
176 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:
...
1
vote
5answers
274 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 ...