Note: The below code is for VB.NET
Note 2: Ignore
Conversions.ToDouble, They don't really matter here
I have been given the following algorithm:
IF [Conversions.ToDouble(1) + 5 ] + [ Conversions.ToDouble(7) * 2 ] = 25
AndAlso [Conversions.ToDouble(2) * 3 ] + [ Conversions.ToDouble(5) + 7 ] = 34
AndAlso [Conversions.ToDouble(3) * 5 ] + [ Conversions.ToDouble(9) + 2 ] = 31
AndAlso [Conversions.ToDouble(4) * 2 ] + [ Conversions.ToDouble(6) + 2 ] = 20
AndAlso [Conversions.ToDouble(8) * 4 ] + [ Conversions.ToDouble(10) + 2 ] = 28
AndAlso [Conversions.ToDouble(11) + 5 ] + [ Conversions.ToDouble(18) * 3 ] = 34
AndAlso [Conversions.ToDouble(12) * 2 ] + [ Conversions.ToDouble(15) + 2 ] = 19
AndAlso [Conversions.ToDouble(13) * 3 ] + [ Conversions.ToDouble(20) + 4 ] = 27
AndAlso [Conversions.ToDouble(14) * 2 ] + [ Conversions.ToDouble(19) + 4 ] = 26
AndAlso [Conversions.ToDouble(16) * 3 ] + [ Conversions.ToDouble(17) + 4 ] = 30
AndAlso [Conversions.ToDouble(21) * 3 ] + [ Conversions.ToDouble(24) + 3 ] = 27
AndAlso [Conversions.ToDouble(22) * 4 ] + [ Conversions.ToDouble(23) + 1 ] = 28
AndAlso [Conversions.ToDouble(25) = 5 ] Then TRUE
The numbers (1,2,3,4,...) above show nth Character of ENCODED String
Basically, the Program compares User given string to the algorithm given above and returns true if it matches the pattern else false
The catch is that the input box only accepts first character as X only
The program only Accepts the following Characters which is encoded in numbers before comparing:
- W = 1
- X = 2
- Y = 3
- U = 4
- & = 5
- ? = 6
- = = 7
- B = 8
- > = 9
When the user enters a String it is converted to ENCODED using the above algorithm then compared using the conditions given at start.
But i am not understanding how to make even the first condition true:
Take this first case:
[Conversions.ToDouble(1) + 5 ] + [ Conversions.ToDouble(7) * 2 ] = 25
This means
ENCODED form of 1st Character + 5ADDED TOENCODED form of 7th Character * 2SHOULD BE 25
Assuming both as x , we get x = 20/3 Which can't be represented by any given characters above.
Trial-error method would take me years to find appropriate Characters for even one condition.
I have been programming in different languages for years, and this thing is not popping in my mind. I have no idea how to begin writing a Suitable String matching the above algorithm.
How is this done? Any ideas?
Aucun commentaire:
Enregistrer un commentaire