I,m new to this forum and hope to find a hint or answer to the next hypothetical problem:
There are 9 boxes. Three rows of three. I pick one as a start. From that start i have to combine it with three more boxes. The start box included so a total of 4. The combination has to be that the boxes are all connect to each other with at least one side. So a max combination/permutation search won't work i'll guess? Then i get combinations that are not allowed.
Just need a hint where/how to start.
Define the boxes and their spatial relationshiop as
0 1 2
3 4 5
6 7 8
With only 9 boxes, you'll have 9! / (5! * 4!) == 126 possible combinations.
You could enumerate them all and filter out the invalid ones.
given a combination (4 integers, each a box number)
it's invalid if it doesn't contain the box you picked randomly
it's invalid if any member isn't +/- 1 or +/3 of any other member
I use NumericTextBoxFor to show amount in my application.
I need to show 20 digits.
Can I accomplish it using NumericTextBoxFor?
I've been trying "max", but kendo just give 16 digits.
#(Html.Kendo().NumericTextBoxFor(model => model.To)
.Max(999999999999999999) //just 16 digits
.Spinners(false)
)
I tried to set 88888888888888888888 but it shows me 88888888888888885248.
Since the actual logic takes place client side, you are most likely getting funny results because the maximum value you can store in a JavaScript Number is 9,007,199,254,740,992. After that, it is representing it as an exponent and losing precision.
I tried doing this max test on the Kendo web site, I did see the value you were talking about, but when you click in the input box it turns to 88888888888888890000, which makes sense if it is turning it into an exponent.
See this and this for more information.
Also an alternative to max value, you could also try a Kendo mask docs here
I am given a task to develop a small library which needs to be able to read PDF417 barcode located on the back of the Driver's License card and parse the data out to our custom object.
However I need to know what data types are these Data types denoting?
4/ANS, 10/ANS, 5/ANS, etc.
The complete documentation can be found at: http://www.dol.wa.gov/external/docs/barcodeCalibration-basic.pdf
Guessing here, but <field length>/ANS, where A is alphabetic, N numeric and S spaces?
For example, 3/A is 3 alphabetic characters like USA.
Funny that weight and sex are both 1/N, but the example given (2 in both cases) fits my hypothesis.
The Washington spec is based on the AAMVA standard here:
http://www.aamva.org/DL-ID-Card-Design-Standard/
The 2013 ID Card Design Standard is here: http://www.aamva.org/WorkArea/DownloadAsset.aspx?id=4435
The PDF 417 barcode specifications start on page 51 (65) of that document. On page 58 (72) they list the type definitions: "A=alpha A-Z, N=numeric 0-9, S=special, F=fixed length, V=variable length"
6 A/N means it is a 6 digit or spaced (A)lpha/(N)umeric variable. For example 5'7" could be expressed as a variable that would fit the format as "067 in" (quotation marks only enclosing the actual variable. Very common definition of terms usually found in Database programming. Your variable will always be 6 characters long (including the space character)--3 alpha ( in) and 3 numeric (067).
When a user goes to edit a number, I want to format a number to have a thousands separator in one case (and a percentage sign in another) but I want to be able to show absolutely all available digits of precision.
When the number is being displayed, its format is simply {0:0,0;-0,0; - }, (or {0:0,0.00;-0,0.00; - } to show two decimal places), but when my control goes into edit mode, I want to switch to displaying something very similar, but showing all available digits of precision. Is there any way to do this short of creating a format string that looks like this?
{0:0,0.#############################;-0,0.###...
I want to do something similar with percentages. I want to displayed value to be {0:0.00 %;-0.00 %; - } until the user activates the cell for editing, at which time the format should still be a percentage, but showing more digits of precision if they exist in the underlying value.
Thanks
This question is similar to yours. (The answer is that it's not possible with the .NET built-in custom numeric formatting.)
In this code I am debugging, I have this code snipit:
ddlExpYear.SelectedItem.Value.Substring(2).PadLeft(2, '0');
What does this return? I really can't run this too much as it is part of a live credit card application. The DropDownList as you could imagine from the name contains the 4-digit year.
UPDATE: Thanks everyone. I don't do a lot of .NET development so setting up a quick test isn't as quick for me.
It takes the last two digits of the year and pads the left side with zeroes to a maximum of 2 characters. Looks like a "just in case" for expiration years ending in 08, 07, etc., making sure that the leading zero is present.
This prints "98" to the console.
class Program
{
static void Main(string[] args)
{
Console.Write("1998".Substring(2).PadLeft(2, '0'));
Console.Read();
}
}
Of course you can run this. You just can't run it in the application you're debugging. To find out what it's doing, and not just what it looks like it's doing, make a new web application, put in a DropDownList, put a few static years in it, and then put in the code you've mentioned and see what it does. Then you'll know for certain.
something stupid. It's getting the value of the selected item and taking the everything after the first two characters. If that is only one character, then it adds a '0' to the beginning of it, and if it is zero characters, the it returns '00'. The reason I say this is stupid is because if you need the value to be two characters long, why not just set it like that to begin with when you are creating the drop down list?
It looks like it's grabbing the substring from the 3rd character (if 0 based) to the end, then if the substring has a length less than 2 it's making the length equal to 2 by adding 0 to the left side.
PadLeft ensures that you receive at least two characters from the input, padding the input (on the left side) with the appropriate character. So input, in this case, might be 12. You get "12" back. Or input might be 9, in which case, you get "09" back.
This is an example of complex chaining (see "Is there any benefit in Chaining" post) gone awry, and making code appear overly complex.
The substring returns the value with the first two characters skipped, the padleft pads the result with leading zeros:
string s = "2014";
MessageBox.Show(s.Substring(2).PadLeft(2, 'x')); //14
string s2 = "14";
MessageBox.Show(s2.Substring(2).PadLeft(2, 'x')); //xx
My guess is the code is trying to convert the year to a 2 digit value.
The PadLeft only does something if the user enters a year that is either 2 or 3 digits long.
With a 1-digit year, you get an exception (Subsring errs).
With a 2-digit year (07, 08, etc), it will return 00. I would say this is an error.
With a 3-digit year (207, 208), which the author may have assumed to be typos, it would return the last digit padded with a zero -- 207 -> 07; 208 -> 08.
As long as the user must choose a year and isn't allowed to enter a year, the PadLeft is unnecessary -- the Substring(2) does exactly what you need given a 4-digit year.
This code seems to be trying to grab a 2 digit year from a four digit year (ddlexpyear is the hint)
It takes strings and returns strings, so I will eschew the string delimiters:
1998 -> 98
2000 -> 00
2001 -> 01
2012 -> 12
Problem is that it doesn't do a good job. In these cases, the padding doesn't actually help. Removing the pad code does not affect the cases it gets correct.
So the code works (with or without the pad) for 4 digit years, what does it do for strings of other lengths?
null: exception
0: exception
1: exception
2: always returns "00". e.g. the year 49 (when the Jews were expulsed from rome) becomes "00". This is bad.
3: saves the last digit, and puts a "0" in front of it. Correct in 10% of cases (when the second digit is actually a zero, like 304, or 908), but quite wrong in the remainder (like 915, 423, and 110)
5: just saves the 3rd and 4th digits, which is also wrong, "10549" should probably be "49" but is instead "54".
as you can expect the problem continues in higher digits.
OK so it's taking the value from the drop down, ABCD
Then it takes the substring from position 2, CD
And then it err, left pads it with 2 zeros if it needs too, CD
Or, if you've just ended X, then it would substring to X and pad to OX
It's taking the last two digits of the year, then pad to the left with a "0".
So 2010 would be 10, 2009 would be 09.
Not sure why the developer didn't just set the value on the dropdown to the last two digits, or why you would need to left pad it (unless you were dealing with years 0-9 AD).