Search Results

Search found 29841 results on 1194 pages for 'random number generator'.

Page 52/1194 | < Previous Page | 48 49 50 51 52 53 54 55 56 57 58 59  | Next Page >

  • Oneliner to count the number of tabs in each line of a file

    - by JasonHorner
    I have a file that is tab delimited. I would like a powershell script that counts the number of tabs in each line. I came up with this: ${C:\tabfile.txt} |% {$_} | Select-String \t | Measure-Object | fl count it yields 3, Which is the number of lines in the file. any pointers to what I'm doing wrong? I would like it to print a single number for each line in the file.

    Read the article

  • PHP MYSQL Add up number of entries in single table and display in HTML

    - by Derek
    I have a table called activities which contains a number of activities for projects (for example 6 activities are related to one project). On a manage projects page, you can see the projects, and I have one column which needs to display the number of tasks associated with the project (in that particular row). So basically, I need a query or PHP calculation that can add up the number of tasks for the project and then display this number dynamically! I know exactly what I need, just do not know how to implement it. Any help is much appreciated! Thanks.

    Read the article

  • Change Number Format

    - by gsembilan
    I have a lot lines contains XXXXXXXXX number format. I want change number XXXXXXXXX to XX.XXX.XXX.X XXXXXXXXX = 9 digit random number Anyone can help me? Thanks in advance

    Read the article

  • convert an integer number into an array

    - by droseman
    Hi, I am trying to convert an integer number in C into an array containing each of that number's digits i.e. if I have int number = 5400 how can I get to int numberArray[4] where numberArray[0] = 0; numberArray[1] = 0; numberArray[2] = 4; numberArray[3] = 5; Any suggestions gratefully received --dave

    Read the article

  • Get name given a phone number on the iPhone

    - by ganti
    I'm using a TextField where the user types a phone number. When the TextField changes, it should check if this number is already in the phonebook and display the name. So far, my only way is to parse all names and number in a Dict and read it from there. Is there a simpler, more efficient and sophisticated way to do that?

    Read the article

  • Get name given by phone number on the iPhone

    - by ganti
    I'm using a TextField where the user types a phone number. When the TextField changes, it should check if this number is already in the phonebook and display the name. So far, my only way is to parse all names and number in a Dict and read it from there. Is there a simpler, more efficient and sophisticated way to do that?

    Read the article

  • Binding hudson build number in C# project

    - by Sukan
    Hi, Is there a way to bind the hudson successful build's number in the C# WPF application? Meaning, on running the exe after building I want to show the build number say 10 in my application somewhere. In project configuration file, I have used ${BUILD_NUMBER}, that a hudson understands and creates a build with the revision number. If I build the Project revision # 10, I get 10.exe. Can I have something that will show this number somewhere in my application? Hope I am clear. Please help.

    Read the article

  • How to generate a transaction number?

    - by 001
    I was thinking of formatting it like this TYYYYMMDDNNNNNNNNNNX (1 character + 19 digits) Where T is type YYYY is year MM is month DD is day N is sequencial number X is check digit The problem is, how do I generate the sequencial number? since my primary key is not an auto increment integer value, if it was i would use that, but its not. EDIT can I have the sequencial number resets itself after 1 day (24hours). P201012080000000001X <-- first transaction of 2010/12/08 P2010120810000000002X <--- second transaction of 2010/12/08 P201012090000000001X <--- First transaction of 2010/12/09 (X is the check digit)

    Read the article

  • Maximum number of bytes that can be sent on a TCP connection

    - by iamrohitbanga
    I initially assumed that since tcp has a sequence number field of 32 bits and each byte sent on a tcp connection is labeled with a unique number, maximum number of bytes that can be sent on a tcp connection is about 2^32-1 or 2^32-2 (which?). but now I feel that since TCP is a sliding window protocol, the wraparound of sequence numbers during the connection should not have an affect on the maximum number of bytes that can be sent over a tcp connection as long as the when wraparound occurs the old packet is no longer in the network (it is sent after 2*MSL). What is the correct answer?

    Read the article

  • What does this number mean?

    - by FinalDestiny
    I have one number that has something related to the currentdate : 634101448539930000 634101448627430000 (this information was took 9 seconds later than the first one) I have many codes like this and I need to know what those number means. It's something related to the current time, because the new information has always a bigger number than the older ones. Please if anybody could help me, thanks

    Read the article

  • Lexer written in Javascript?

    - by Phobis
    I have a project where a user needs to define a set of instructions for a ui that is completely written in javascript. I need to have the ability to parse a string of instructions and then translate them into instructions. Is there any libraries out there for parsing that are 100% javascript? Or a generator that will generate in javascript? Thanks!

    Read the article

  • How to get number of delete using NHibernate IStatistics

    - by epitka
    I am trying to get the number of delete statements issued during the session, so I enabled statistics generation and I got a reference to it through SessionFactory.Statistics. But I don't see a way to get the global number of deletes. I can get the statistics for the entity, but I have one many-to-many mapped relationship that does not materialize in an entity, everything is done through a table that is not mapped to an entity. Is there a way to get this number?

    Read the article

  • Reading TCP Sequence Number Before Sending a Packet

    - by Sadeq Dousti
    I'm writing a C/C++ client-server program under Linux. Assume a message m is to be sent from the client to the server. Is it possible for the client to read the TCP sequence number of the packet which will carry m, before sending m? In fact, I'd like to append this sequence number to m, and send the resulting packet. (Well, things are more complicated, but let's keep it that simple. In fact, I'd like to apply authentication info to this sequence number, and then append it to m.) Moreover, is it possible for the server to read the TCP sequence number of the packet carrying m?

    Read the article

  • Code Golf: Countdown Number Game

    - by Noldorin
    Challenge Here is the task, inspired by the well-known British TV game show Countdown. The challenge should be pretty clear even without any knowledge of the game, but feel free to ask for clarifications. And if you fancy seeing a clip of this game in action, check out this YouTube clip. It features the wonderful late Richard Whitely in 1997. You are given 6 numbers, chosen at random from the set {1, 2, 3, 4, 5, 6, 8, 9, 10, 25, 50, 75, 100}, and a random target number between 100 and 999. The aim is to make use the six given numbers and the four common arithmetic operations (addition, subtraction, multiplication, division; all over the rational numbers) to generate the target - or as close as possible either side. Each number may only be used once at most, while each arithmetic operator may be used any number of times (including zero.) Note that it does not matter how many numbers are used. Write a function that takes the target number and set of 6 numbers (can be represented as list/collection/array/sequence) and returns the solution in any standard numerical notation (e.g. infix, prefix, postfix). The function must always return the closest-possible result to the target, and must run in at most 1 minute on a standard PC. Note that in the case where more than one solution exists, any single solution is sufficient. Examples: {50, 100, 4, 2, 2, 4}, target 203 e.g. 100 * 2 + 2 + (4 / 4) e.g. (100 + 50) * 4 * 2 / (4 + 2) {25, 4, 9, 2, 3, 10}, target 465 e.g. (25 + 10 - 4) * (9 * 2 - 3) {9, 8, 10, 5, 9, 7), target 241 e.g. ((10 + 9) * 9 * 7) + 8) / 5 Rules Other than mentioned in the problem statement, there are no further restrictions. You may write the function in any standard language (standard I/O is not necessary). The aim as always is to solve the task with the smallest number of characters of code. Saying that, I may not simply accept the answer with the shortest code. I'll also be looking at elegance of the code and time complexity of the algorithm! My Solution I'm attempting an F# solution when I find the free time - will post it here when I have something! Format Please post all answers in the following format for the purpose of easy comparison: Language Number of characters: ??? Fully obfuscated function: (code here) Clear (ideally commented) function: (code here) Any notes on the algorithm/clever shortcuts it takes.

    Read the article

  • Convert string from getline into a number

    - by haskellguy
    I am trying to create a 2D array with vectors. I have a file that has for each line a set of numbers. So what I did I implemented a split function that every time I have a new number (separated by \t) it splits that and add it to the vector vector<double> &split(const string &s, char delim, vector<double> &elems) { stringstream ss(s); string item; while (getline(ss, item, delim)) { cout << item << endl; double number = atof(item.c_str()); cout << number; elems.push_back(number); } return elems; } vector<double> split(const string &s, char delim) { vector<double> elems; split(s, delim, elems); return elems; } After that I simply iterate through it. int main() { ifstream file("./data/file.txt"); string row; vector< vector<double> > matrix; int line_count = -1; while (getline(file, row)) { line_count++; if (line_count <= 4) continue; vector<double> cols = split(row, '\t'); matrix.push_back(cols); } ... } Now my issues is in this bit here: while (getline(ss, item, delim)) { cout << item << endl; double number = atof(item.c_str()); cout << number; Where item.c_str() is converted to a 0. Shouldn't that be still a string having the same value as item? It works on a separate example if I do straight from string to c_string, but when I use this getline I end up in this error situation, hints?

    Read the article

  • Random syntactical error in my php code that I can't find

    - by user348538
    Ordinarily I hate coming here with newbie code questions but nobody can find the error with this code. Maybe you guys can :-) <?php defined('SYSPATH') or die('No direct script access.'); /** * to interact with photos * * @author Max Padraig Wolfgang Bucknell-Leahy */ class Model_Photos { private $apiKey = '12664498208a1380fe49fb1b5a238ef0'; private $secret = '03d43dee65a34513'; private $perms = 'read'; private $sigString = 'test'; private $apiSig = md5($_sigString); private $authArray = array('api_key' => $apiKey, 'perms' => $perms, 'api_sig' => $apiSig); private $authArrayImploded = implode('&', $authArray); private $authLink = 'http://www.flickr.com/services/auth/?' . $authArrayImploded; public function get_photos($number = 5) { if(file_exists(APPPATH . 'cache/main_cache.xml') { echo $authLink; } else { echo 'not so good'; /** */ } } } $class = new Model_Photos; $class->get_photos; the error is: Parse error: syntax error, unexpected '(', expecting ',' or ';' in /home/p14s9nnd/public_html/testing.php on line 15 Thank you in advance and sorry Regards, Max

    Read the article

  • java phone number validation....

    - by user69514
    Here is my problem: Create a constructor for a telephone number given a string in the form xxx-xxx-xxxx or xxx-xxxx for a local number. Throw an exception if the format is not valid. So I was thinking to validate it using a regular expression, but I don't know if I'm doing it correctly. Also what kind of exception would I have to throw? Do I need to create my own exception? public TelephoneNumber(String aString){ if(isPhoneNumberValid(aString)==true){ StringTokenizer tokens = new StringTokenizer("-"); if(tokens.countTokens()==3){ areaCode = Integer.parseInt(tokens.nextToken()); exchangeCode = Integer.parseInt(tokens.nextToken()); number = Integer.parseInt(tokens.nextToken()); } else if(tokens.countTokens()==2){ exchangeCode = Integer.parseInt(tokens.nextToken()); number = Integer.parseInt(tokens.nextToken()); } else{ //throw an excemption here } } } public static boolean isPhoneNumberValid(String phoneNumber){ boolean isValid = false; //Initialize reg ex for phone number. String expression = "(\\d{3})(\\[-])(\\d{4})$"; CharSequence inputStr = phoneNumber; Pattern pattern = Pattern.compile(expression); Matcher matcher = pattern.matcher(inputStr); if(matcher.matches()){ isValid = true; } return isValid; } Hi sorry, yes this is homework. For this assignments the only valid format are xxx-xxx-xxxx and xxx-xxxx, all other formats (xxx)xxx-xxxx or xxxxxxxxxx are invalid in this case. I would like to know if my regular expression is correct

    Read the article

  • How to find the largest square in the number (Java)

    - by Ypsilon IV
    Hello everyone, I want to find the largest square in the number, but I am stuck at some point. I would really appreciate some suggestions. This is what I've done so far: I take the number on the input, factorize into prime numbers, and put the sequence of prime numbers to ArrayList. Numbers are sorted, in a sense, thus the numbers in the sequence are increasing. For example, 996 is 2 2 3 83 1000 is 2 2 2 5 5 5 100000 is 2 2 2 2 2 5 5 5 5 5 My idea now is to count number of occurrences of each elements in the sequence, so if the number of occurrences is divisible by two, then this is the square. In this way, I can get another sequence, where the right most element divisible by two is the largest square. What is the most efficient way to count occurrences in the ArrayList? Or is there any better way to find the largest square? Many thanks in advance!

    Read the article

< Previous Page | 48 49 50 51 52 53 54 55 56 57 58 59  | Next Page >