What is the total number of comparisons necessary to locate all the n sorted distinct integers in an array using binary search, I think it is nlogn, but I am not sure. What do u guys think?
How can I insert in a database the number of days of the year and at the same time insert in the same record the month, day of the month, and the day of the week?
This is my table:
tabela/coluna.Dias_ano(registo 1...365)
Year:=StrToInt(ano.Text);
diasano.Text:= IntToStr( DaysInAYear(Year) );
diasAno| Mes |diames |dia semana |
1 | janeiro | 1 |Segunda |
2 | janeiro | 2 | Terça |
...
365 | Dezembro | 31 | Segunda
I have some unit tests that need an X11 display so I plan to start Xvfb before running them, but to start Xvfb I will need a free display number to connect it to. My best guess is to see what's free in /tmp/.X11-unix but I'm not sure how to handle the race if many tests try to start simultaneously.
sshd must do this, does anyone know how?
I'm using a MySQL database and accessing it through Java.
PreparedStatement prep1 = this.connection.prepareStatement("UPDATE user_table
SET Level = 'Super'
WHERE Username = ?");
prep1.setString(1, username);
The update statement above works fine however I'd like to get the number of rows affected with this statement. Is this possible please?
Hi, I am writing a function in which I need to read a string contains floating point number and turn it back to Rational. But When I do toRational (read input :: Double), it will not turn for eg: 0.9 into 9 % 10 as expected, but instead 81..... % 9007...
Thx
If I want to pass a number of values for the ParamArray arglist via an array, how do I do it? From what I've read so far, on VBA, it appears that I need to explicitly list the values that I want to pass. But what if there are potentially different numbers of values to pass, so I do not know in advance how many I'll want to pass to the function? Is there not some way of using an array (a one-dimensional array) with a variable dimension?
in JavaScript, the typical way to round a number to N decimal places is something like:
function round_number(num, dec) {
return Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
}
However this approach will round to a maximum of N decimal places while I want to always round to N decimal places. For example "2.0" would be rounded to "2".
Any ideas?
Hi,
I have a check out form where number of products can be "n". So how i can know how many input fields are in the form and take input from it?
Thanks
Hi
I am trying to use the following regular expression to check whether a string is a positive number with either zero decimal places, or 2:
^\d+(\.(\d{2}))?$
When I try to match this using preg_match, I get the error:
Warning: preg_match(): No ending delimiter '^' found in /Library/WebServer/Documents/lib/forms.php on line 862
What am I doing wrong?
I want to save and restore the window position of my WPF application. I want to make the code robust to use with multiple monitors who's number and relative location can change (I want to avoid opening my application off-screen when the monitor configuration has changed inbetween invocations).
I know of the Screen class in System.Windows.Forms, but I don't want to take a dependency on that assembly just for this feature.
What is the efficient way to search highest number of cells in big table with numerous colspan (merge cells ** colspan should be ignored so in below example highest number of cells is 4 in first row). Is it js/jquery with reg expression or just the loop with bubble sorting. I got one link as below explainig use of regex is it ideal way ... can someone suggest pseudo code for this.
High cpu consumption due to a jquery regex patch
<table width="156" height="84" border="0" >
<tbody>
<tr style="height:10px">
<td width="10" style="width:10px; height:10px"/>
<td width="10" style="width:10px; height:10px"/>
<td width="10" style="width:10px; height:10px"/>
<td width="10" style="width:10px; height:10px"/>
</tr>
<tr style="height:10px">
<td width="10" style="width:10px; height:10px" colspan="2"/>
<td width="10" style="width:10px; height:10px"/>
<td width="10" style="width:10px; height:10px"/>
</tr>
<tr style="height:10px">
<td width="10" style="width:10px; height:10px"/>
<td width="10" style="width:10px; height:10px"/>
<td width="10" style="width:10px; height:10px" colspan="2"/>
</tr>
<tr style="height:10px">
<td width="10" style="width:10px; height:10px" colspan="2"/>
<td width="10" style="width:10px; height:10px"/>
<td width="10" style="width:10px; height:10px"/>
</tr>
</tbody>
</table>
When one "Fills right in excel" , the Column name updates
eg.
1st cell
is
=A2
If I fill right the next cell will be =B2
But rather than the column incrementing I want to increment the row number
so 1st cell is
=A2
The cell on its right is
=A3
how do i do that?
I have an input field on a webpage that contains a credit-card number. What is the best way of preventing the browser from caching this value?
Any solution needs to work on a large selection of browsers.
I have a number of textboxes that will be displayed with their existing values. I want my servlet to be able to get all their values and then update the database with the the values that have changed.
How do I get the values? Is there some way to put them into a HashMap with the id or name as the key and the value of the textbox as the value for the key?
Hi All,
I am trying to create a console application that reads number from a file all underneath each other like so:
101
9
and then outputs into another file the closest palindrome number. So far what I have is not quite rightm i.e. I don't think I can put the class inside a method which is a bit more Java I was wandering if anyone could help at all?
Thanks :)
namespace PalidromeC
{
class Program
{
static public void Main(string[] args)
{
#region WriteAnswers
try
{
StreamWriter sw = new StreamWriter("C://Temp/PalindromeAnswers.txt");
sw.WriteLine("Answers");
sw.Close();
}//try
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}//catch
#endregion
#region ReadFile
try
{
string numbers;
StreamReader sr = new StreamReader("C://Temp/Palindrome.txt");
numbers = sr.ReadLine();
while (numbers != null)
{
Console.WriteLine(numbers);
numbers = sr.ReadLine();
}//while
sr.Close();
Console.ReadLine();
}//try
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}//catch
#endregion
NearPalindromeFinder f = new NearPalindromeFinder();
int palindrome = f.findNearPalindrome(n);
Console.WriteLine("Nearest Palindrome = " + palindrome);
}//main
public static void testFindNearestPalindrome(int n)
{
class NearPalindromeFinder
{
int findNearPalindrome(int start)
{
if (testPalindrome(start))
return start;
else
{
int neg = start;
int pos = start;
for (int i = 0; i < start; i++)
{
if (testPalindrome(start-i))
{
neg = start-i;
break;
}//if
if (testPalindrome(start+i))
{
pos = start+i;
break;
}//if
}//for
return (start == neg) ? pos : neg;
}//else
}//findNearPalindrome
bool testPalindrome(int start)
{
if (start == 0 || start == 1)
return true;
String str = String.valueOf(start);
String rev = new
if (str.equals(rev))
return true;
else
return false;
}//testPalindrome
}//NearPalindromeFinder class
}//testFindNearestPalindrome
}//Program Class
I have an unknown number of functions in my python script (well, it is known, but not constant) that start with site_...
I was wondering if there's a way to go through all of these functions in some main function that calls for them.
something like:
foreach function_that_has_site_ as coolfunc
if coolfunc(blabla,yada) == true:
return coolfunc(blabla,yada)
so it would go through them all until it gets something that's true.
thanks!
Hello,
I've used an array of strings to populate a DataGridView.
How do I go about finding the most frequently occurring number?
Or, even better, order them by most frequently occuring?
Thank You.
Hi All,
RAID6 is intended to provide fault tolerance in the event 2 disks fail.
What is the minimum number of disks required to implement RAID6?
thanks
Hii...
I want to find out the number of Pocket PC devices(In my Case they are RFID reader's).Is there any way to do thi using RAPI in C#.net?can you please help me out....
I have a mysql database which allocate:
iid, name, description, url, namecategory, idcategory, nametopic, idtopic
How can i know the number of entries that has categoryid=1 and topicid=1?
I've try
$result = mysql_query("SELECT COUNT(id) FROM videos WHERE categoryid=1 AND topicid=1")
But it hasn't worked!
Hi ,
I have generated a Google map key by login as a [email protected] . Is there any restriction in generating the number of keys for each user. Since we have 2 different domains and i need to generate key for that too.
Actually i am not sure about of how many keys the person who used this id has created..
And is there any way to find of how many keys had already been created for the same account previously???
Hi,
I have a 2 tex file which I am converting to pdf and then merging the 2 pdf.
My problem is I want to define footer for each pdf without the page numbers.
\thispagestyle{fancy}
\rfoot{text}
but it gives me the page number.
How do I efficiently create a rock-scissors-paper game for n elements,
where n is any odd number =3.
In other words, I want a non-transitive complete ordering of n elements
such that each element is greater than (n-1)/2 other elements and each
element is lesser than (n-1)/2 other elements.