|
Lets say I have guessed a lottery number of:
1689
And the way the lottery works is, the order of the digits don't matter as long as the digits match up 1:1 with the digits in the actual winning lottery number.
So, the number 1689 would be a winning lottery...
Started by KingNestor on
, 15 posts
by 15 people.
Answer Snippets (Read the full thread at stackoverflow):
Code would look something like:
for(int i=....
Since you only look at each digit once, that's O(N).
Of appearances of each digit (into two different 10 element arrays)? After you'd done the totaling, compare the counts of each digit.
|
|
8 | * 7 | * 6 | * 5 | * 4 | * * 3 |* * * * * * 2 |* * * * *** ** * * 1 |* * *** **** * * + 012345678901234567890123456
how would you print numbers from the least significant digits to the most significant digits (like the numbers shown on the x-axis)?...
Answer Snippets (Read the full thread at stackoverflow):
If (i == 0) output_digit(0) else while (i != 0) output_digit(i % base)....
If temp isn't 0 produces the least-significant before the most-significant .
The next digit to print is temp % 10
Divide 10 into temp.
Put the number in a temp.
|
|
Is there an algorithm that can calculate the digits of a repeating-decimal ratio without starting at the beginning?
I'm looking for a solution that doesn't use arbitrarily sized integers, since this should work for cases where the decimal expansion may...
Started by caffiend on
, 6 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
To its decimal represenation and left pad it with zeros to a total length of p the i-th digit after the decimal point is the (i mod p)-th digit of the paded decimal representation (i = 0 is the first digit after the decimal point....
|
Ask your Facebook Friends
|
I am writing a function that transliterates UNICODE digits into ASCII digits, and I am a bit stumped on what to do if the string contains digits from different sets of UNICODE digits. So for example, if I have the string "\x{2463}\x{24F6}" ("④⓶"). Should...
Started by Chas. Owens on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
I'm sure Joel wrote about "premature implementation" in a blog article sometime recently, but... .
I suggest that you should also write another function to do #4, but only when the requirement appears, and not before .
Your current function appears to do #1.
|
|
I want to get the single digits from two digits.for example if 36 I need to store 3 and 6 in different variables.Is it possible?
Started by vinothkumar on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
How about the rest of that? Well, for that you have .
Think about what 36 really is, if you break it down, its 3 * 10 + 6 , right?
So the first digit round that you get 3, which is the first digit.
|
|
My credit card processor requires I send a two-digit year from the credit card expiration date. Here is how I a currently processing:
I put a DropDownList of the 4-digit year on the page. I validate the expiration date in a DateTime field to be sure that...
Started by Mike Wills on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
Why not have the original drop down on the page be a 2 digit value only? Credit cards only.
Handle it.
|
|
Hi,
in my web application i want to validate that user can enter only digits and the digit may be a integer or decimal how can i write the regular expression for this. help me thank you
Started by Surya sasidhar on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
<asp:RegularExpressionValidator ID="rgx" ControlToValidate="txtControl" runat="server" ErrorMessage="*" Display="Dynamic" ValidationExpression="[0-9]*\.?[0-9]*"></asp:RegularExpressionValidator> ValidationExpression="[0-9]*\.?[....
Try this...
|
|
I need to find two adjacent repeating digits in a string and replace with a single one. How to do this in Java. Some examples:
123345 should be 12345 77433211 should be 74321
Started by askgelal on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Expression mathing two repeating digits (x being the digit)
[x]{2}(?!=[x])
I finally did it myself.
|
|
This is a question of best practices. I have a utility that takes in a two digit year as a string and I need to convert it to a four digit year as a string. right now I do
//DOB's format is "MMM (D)D YY" that first digit of the day is not there for numbers...
Started by Scott Chamberlain on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
The Java implementation handles this by assuming a range of 80 years behind and 20 .
A two-digit code.
|
|
I have a large css file and i want to convert all 6 digit hex code into shorthand 3 digit. Is there any online or offline tool to do so.
my purpose is to reduce css file size without making something wrong.
any other tips would be be appreciated to reduce...
Started by jitendra on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Characters; finds instances of 6 hex digits enclosed by # and ; removes every second digit; throughout.
|