Hello, I'm doing a project where I need to see which number matches to a list of letters in the alphabet.

Currently I have the output as:

A= 5
				 A= 8
B= 9
				 B= 2
C= 0
				 C= 3
D= 6
				 D= 4
E= 1
				 E= 13
F= 0
				 F= 2
G= 9
				 G= 2
H= 3
				 H= 6
I= 4
				 I= 7
J= 4
				 J= 0
K= 3
				 K= 1
L= 3
				 L= 4
M= 1
				 M= 2
N= 10
				 N= 7
O= 6
				 O= 8
P= 2
				 P= 2
Q= 3
				 Q= 0
R= 8
				 R= 6
S= 0
				 S= 6
T= 3
				 T= 9
U= 2
				 U= 3
V= 3
				 V= 1
W= 5
				 W= 2
X= 0
				 X= 0
Y= 0
			         Y= 2
Z= 8
				 Z= 0

So if B = 9 which can be replaced with with: A -> O -> T because I'm going to do an if statement that checks if the number is like >3 < 3 and then I will store them into a 2D array.

int numbers[27][27]; // This means that "B" can be replaced with 27 characters

And then have a dictionary that checks to see which one matches.. (To see if there's a word)

But I don't know if this would be an efficient method doing the task, and how I would store this in a 2D array..

for(int i=0; (i < alphabet.Length); i++) // This will go through the left numbers
    for(int o=0; (o < alphabet.Length); o++)    // this will go through the right
    letters[i][o] = letters[i][o];
  end
end

I think that's wrong? :S

Any advice what so ever?

Thanks

Recommended Answers

All 19 Replies

I cannot figure out what it is you are doing here.
Can you rephrase the requirements?

commented: Excellent helper! Thank you so much for your support! +3

Hello,

Thank you for your reply..

So basically, on the left is the text analysis of a text file (containing text) and the values on the right is the text analysis of the english alphabet. What I need to do is change the value of the left depending on the percentage of the right.. so for example:

A = 10 A = 5
B = 5 B = 10

A = B
B = A

However, because this uses multiple values - It's a lot harder

Does that make it any clear?

No, now I'm even more confused.
Are you using percentages, raw values or positions?
Why are the values staggered?

Are you swapping, replacing or matching?

Are you using percentages, raw values or positions? - Percentages

Why are the values staggered? - How do you mean?

Are you swapping, replacing or matching? - Storing the value into another array.

Take a look at some example code (on a small scale):

using System;

namespace asfasfasf
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			
			char[] alphabet = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
			double[] anaylsis = {5, 10, 2, 1, 0};
			double[] alpha = {10, 5, 1, 2, 0};
			char [] decryt = new char[5];
			for(int i=0; (i < 5); i++)
			{
				Console.WriteLine ("Letter: " + alphabet[i] + " = {0}", anaylsis[i]);
				Console.WriteLine ("\t\t\t Letter: " + alphabet[i] + " = {0}", alpha[i]);
			    for(int o=0; (o < alpha.Length); o++)
				{
					if(anaylsis[i] == alpha[o])
					{
						decryt[i] = alphabet[o];
					}
				}
			}
			
			for(int i=0; (i < 5); i++)
			{
				Console.WriteLine("\n\n\n" + decryt[i]);
			}
		}
	}
}

Does that clear it up anymore? Thanks for the reply =)

That example uses whole numbers and works perfect.. Just, the main one uses percentages with one decimal place!

Are you going to only fill a 5-character array?

No ha, the char array will be the size of the text file that get's read in.. My problem is that i'm working in percentages and decimal places... Here's another example:

(values from file): (Alphabet Analysis):

A = 8.2 B = 1.3
B = 1.2 A = 1.2
C = 4.6 C = 8.2
D = 1.1 D = 8.4

Now A should be replaced with C, however there are two values with 8...

So, what is the problem?

Actually comparing the values..
(values from file): (Alphabet Analysis):
A = 8.1 B = 1.3
B = 1.2 A = 1.2
C = 4.6 C = 8.2
D = 1.1 D = 8.4


If I compared A (values from file) with (Alphabet analysis) it won't allow it because there isn't 8.1 but only 8.2 and 8.4 so I need a way of:

- Comparing the first digit (8) -- It matches
- Compare the second digit(1, 2) -- 1 is closer to 2 and not 4 so therefore 8.2 is matched
- A = C

Make sense? Aha sorry for the confusion!

...you're trying to find either an exact match or the next closest number higher?

Yes!! Basically :P but in decimal places!!

Why don't you convert the numbers to floats and then do the comparison?
That way you won't have to worry about the fractional portion.

Hey,

I tried that and 'rounded them up / down depending on it.. However it doesn't solve the fact that if there are two values, how do I get the correct one? If there are two '8's would a 2D array be better to store them?

A specific container will not necessarily help, but a rule will.
If you're looking for the next higher then the "next higher" is always the "next higher".

Consider this:

using System;
using System.Collections.Generic;
using System.Linq;

namespace DW_396464
{
   class Program
   {
      static void Main(string[] args)
      {
         double dblOrigValue = 8.1;

         List<double> lst_dblChoices = new List<double>()
         {
            1.2, 9.7, 3.3, 8.4, 8.2, 3.9
         };

         double dblTarget =
            lst_dblChoices.OrderBy(d => d)
            .Where(d => (d >= dblOrigValue))
            .FirstOrDefault();

         Console.WriteLine(dblTarget);
      }
   }
}

Hello,

Thanks for your reply.. Let me try and understand it.. It'll search through the list until an exact match is made?

No. That example finds either an exact match or the next highest match.

But before I'm sure that's what you need:
Let's say your source number is 8.2

What happens if there are two exact matches?
Does it choose one?
Does it fail?

What happens if there is no exact match or
What happens if the next closest match is in the next number range?
Example: Options are 7.4 or 9.6
Does it choose the next higher?
Does it choose the next lower?
Does it fail?

I think I get it.
Are you supposed to evaluate items that are NOT in A-Z, such as punction and spaces?

If not, have you properly eliminated those elements before calculating percentages?

Unable to figure out your question lol...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.