|
I know how to look up this week number:
(SELECT DATEPART(wk, GETDATE()))
I need to know the syntax of getting the week number compare to another table: SYNTAX:
SELECT THISWEEK -- WEEK NUMBER DATA FROM dbo.DATETABLE WHERE THISWEEK = (DATEPART(wk, GETDATE...
Started by Kombucha on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Select distinct thisweek from datetable where thisweek = datepart(wk, getdate())
Is equivalent to saying:
select distinct thisweek from datetable where ... .
You have more than the necessary amount of parens, but it does no harm .
That's the correct syntax.
|
|
Suppose I have a sequence of numbers: {n, n+1, n+2, ... n + m}
Without storing the numbers ahead of time I want to create a function f(), which given the sequence {1,2,3,...m} will spit out the original set in a random (or at least pseudo random) order...
Started by grieve on
, 12 posts
by 12 people.
Answer Snippets (Read the full thread at stackoverflow):
Use that index to select and then remove....
Then, use a random number to pick a new index value in the range of the list's current size.
Have a look at Fisher-Yates
[Edit] Ok, based on your update, the problem you face is this: You don't.
|
|
I'm looking for a PRNG (pseudo randomness) that you initially seed with an arbitrary array of bytes.
Heard of any?
Started by John Leidegren on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
The first one attacks.
In-the-middle preimage attacks against SHA-2 with a reduced number of rounds.
|
Ask your Facebook Friends
|
I'm working on an application where I need to generate unique, non-sequential IDs. One of the constraints I have is that they must consist of 3 digits followed by 2 letters (only about 600k IDs). Given my relatively small pool of IDs I was considering...
Started by Sean McSomething on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Basically, take a 32 or 64-bit integer, and find a large number that is....
Use a finite group.
You could generate a random ID conforming as well pre-fill the table to look for free IDs.
You get to zz then increment the number part.
|
|
Using c# regex I'm trying to match things in quotes which aren't also in brackets while also ignoring any white space:
"blah" - match ("blah") - no match ( "blah") - no match ( "blah") - no match
I've got (unescaped):
"(?<=[^(]\s")(.*?)"
which works...
Started by Patrick on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Look behinds....
\s* will match any number of whitespace characters a parenthesis.
("[^"]*") will match a quoted string, and capture it's content .
Then \s* will match any number of whitespace characters.
Parenthesis before the string.
|
|
Hello,
Recently I discovered, that if I need to see if variable is even ( or odd ), I could just see if last bit of variable equals 0. This discovery, when implemented, replaced few modulo 2 calculations and thus, whole function ran faster.
Are there ...
Started by zeroDivisible on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
It may be good.
Jammed together
(say, to do it all in less number of source code bytes) is no good.
|
|
I have a list of constant numbers. I need find the closest number to x, in the list of the numbers.
Any ideas on how to implement this alogrithm?
Thank You.
Started by Alon on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
Each search....
It can be done using SortedList :
Blog post on finding closest number to query it for the closest number then the best choice is to use List and use naive algorithm to query it for the closest number.
And its neighbors.
|
|
Multiplying two binary numbers takes n^2 time, yet squaring a number can be done more efficiently somehow. (with n being the number of bits) How could that be?
Or is it not possible? This is insanity!
Started by Jess on
, 13 posts
by 13 people.
Answer Snippets (Read the full thread at stackoverflow):
The number of multiplication operations....
To multiply is even.
Do you mean multiplying a number by a power number is a power of two everything is totally simple once you know the power.
I don't believe either of your assertions are true.
|
|
I have an array of java objects.
Each object stores two longs that define a number range. I already have a guarantee that for all the objects in the range, the number ranges don't overlap. I want a quick of finding a particular object in the array, given...
Started by tomdee on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
GreatestLowerBound is the ....
If a number x is in a range in a item in the array, do a search in the array for the first item k();
rangeMap.GreatestLowerBound(i) will now return the number of ranges that a given integer i belongs to ( i.e.
|
|
I have a decimal number (let's call it goal ) and an array of other decimal numbers (let's call the array elements ) and I need to find all the combinations of numbers from elements which sum to goal.
I have a preference for a solution in C# (.Net 2.0...
Started by Sam Meldrum on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
This will change the way you implement your algorithm (in order .
Thank you for the pointers to wikipedia number larger than Goal - Sum).
Interesting answers.
Complexity in the number of elements is low.
|