Search Results

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

Page 70/1194 | < Previous Page | 66 67 68 69 70 71 72 73 74 75 76 77  | Next Page >

  • Python - Check if numbers in list are factors of a number

    - by Zach
    Hey, I have a list of numbers (integers) (say, from 1 to 10). They're not necessarily consecutive, but they are in ascending order. I've prompted the user multiple times to enter a choice of the available numbers. When that number is entered, it is removed from the list along with any of its factors that may be there. I've prevented the user from selecting prime numbers. However, at some point in time, there may be non-prime numbers there, which have no factors remaining. I'm relatively new to Python, so I'm having trouble implementing: Checking if the number selected has no factors remaining (even if it is not prime). Checking if only prime numbers remain, or numbers without factors. I'm thinking of using for statements, but I'm not sure exactly how to implement them. Can anyone offer advice, or code? Thanks in advance... PS. In case anyone's wondering, I'm doing an implementation of the game of Taxman in Python.

    Read the article

  • How to get MAX value of a version-number (varchar) column in T-SQL

    - by Ogre Psalm33
    I have a table defined like this: Column: Version Message Type: varchar(20) varchar(100) ---------------------------------- Row 1: 2.2.6 Message 1 Row 2: 2.2.7 Message 2 Row 3: 2.2.12 Message 3 Row 4: 2.3.9 Message 4 Row 5: 2.3.15 Message 5 I want to write a T-Sql query that will get message for the MAX version number, where the "Version" column represents a software version number. I.e., 2.2.12 is greater than 2.2.7, and 2.3.15 is greater than 2.3.9, etc. Unfortunately, I can't think of an easy way to do that without using CHARINDEX or some complicated other split-like logic. Running this query: SELECT MAX(Version) FROM my_table will yield the erroneous result: 2.3.9 When it should really be 2.3.15. Any bright ideas that don't get too complex?

    Read the article

  • Using MyGeneration, doodads, and Oracle XE, is it possible to implement an "auto number primary key"

    - by Michael Rosario
    Hello world. Using MyGeneration, doodads, and Oracle XE, is it possible to implement an "auto number primary key" scheme? Problem facts: I am using Oracle XE. I have implemented the following table and trigger: CREATE TABLE "USERS" ( "ID" NUMBER(38,0), "USER_NAME" VARCHAR2(50), "PASSWORD" VARCHAR2(50), "EMAIL" VARCHAR2(100), CONSTRAINT "USERS_PK" PRIMARY KEY ("ID") ENABLE ) / CREATE OR REPLACE TRIGGER "BI_USERS" before insert on "USERS" for each row begin select "USERS_SEQ".nextval into :NEW.ID from dual; end; / ALTER TRIGGER "BI_USERS" ENABLE / MyGeneration / Doodads created the following stored proc... CREATE OR REPLACE PROCEDURE "XXX"."PI_USERS" ( p_ID IN USERS.ID%type, p_USER_NAME IN USERS.USER_NAME%type, p_PASSWORD IN USERS.PASSWORD%type, p_EMAIL IN USERS.EMAIL%type ) IS BEGIN INSERT INTO USERS ( ID, USER_NAME, PASSWORD, EMAIL ) VALUES ( p_ID, p_USER_NAME, p_PASSWORD, p_EMAIL ); END PI_USERS; The sequence and trigger combination is working fine. The BusinessEntity class in C# does not receive the new ID. Any recommended ways to allow the calling code receive the new record ID?

    Read the article

  • Programatically detect number of physical processors/cores or if hyper-threading is active on Window

    - by HTASSCPP
    I have a multithreaded c++ application that runs on Windows, Mac and a few Linux flavours. To make a long story short: Inorder for it to run at maximum efficiency I have to be able to instantiate a single thread per physical processor/core. Creating more threads than there are physical processors/cores degrades the performance of my program considerably. I can already correctly detect the number of logical processors/cores correctly on all three of these platforms. To be able to detect the number of physical processors/cores correctly I'll have to detect if hyper-treading is supported AND active. My question therefore is if there is a way to detect whether hyperthreading is supported AND ENABLED? If so, how exactly.

    Read the article

  • Large number array compression

    - by gatapia
    Hi All, I've got a javascript application that sends a large amount of numerical data down the wire. This data is then stored in a database. I am having size issues (too much bandwidth, database getting too big). I am now ready to sacrifice some performance for compression. I was thinking of implementing a base 62 number.toString(62) and parseInt(compressed, 62). This would certainly reduce the size of the data but before I go ahead and do this I thought I would put it to the folks here as I know there must be some outside the box solution I have not considered. The basic specs are: - Compress large number arrays into strings for JSONP transfer (So I think UTF is out) - Be relatively fast, look I'm not expecting same performance as I have now but I also don't want gzip compression either. Any ideas would be greatly appreciated. Thanks Guido Tapia

    Read the article

  • Can not read and save a number from/into an .plist

    - by Flocked
    Hello, I created a property list with the name propertys.plist. Then I wrote this: NSString *path = [[NSBundle mainBundle] bundlePath]; NSString *finalPath = [path stringByAppendingPathComponent:@"speicherung.plist"]; NSMutableArray *plistData = [[NSMutableArray arrayWithContentsOfFile:finalPath] retain]; int a = [plistData objectAtIndex:1]; NSLog(@"%i", a); // returns 41386032, but the right number is 0 a = a + 1; NSNumber *ff = [NSNumber numberWithInt:a]; [plistData insertObject:ff atIndex:1]; NSLog(@"%@", [plistData objectAtIndex:1]); // returns 41386033 [plistData writeToFile:finalPath atomically:YES]; My app always get the wrong number. Why?

    Read the article

  • Decrease DB requests number from Django templates

    - by Andrew
    I publish discount offers for my city. Offer models are passed to template ( ~15 offers per page). Every offer has lot of items(every item has FK to it's offer), thus i have to make huge number of DB request from template. {% for item in offer.1 %} {{item.descr}} {{item.start_date}} {{item.price|floatformat}} {%if not item.tax_included %}{%trans "Without taxes"%}{%endif%} <a href="{{item.offer.wwwlink}}" >{%trans "Buy now!"%}</a> </div> <div class="clear"></div> {% endfor %} So there are ~200-400 DB requests per page, that's abnormal i expect. In django code it is possible to use select_related to prepopulate needed values, how can i decrease number of requests in template?

    Read the article

  • Order by text and then by number

    - by Chaim Chaikin
    I have data like: Audio 1 File 10 Audio 2 Audio 3 File 11 Audio 13 Audio 22 File 20 Test 22 Audio 10 File 1 File 2 I need it order first by the text (i.e. Audio, File, Test) and then by number (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 etc.) The problem is that sorting it returns something like this: Audio 1 Audio 10 Audio 13 Audio 2 Audio 22 Audio 3 File 1 File 10 File 11 File 2 File 20 Test 22 While the result I want is: Audio 1 Audio 2 Audio 3 Audio 10 Audio 13 Audio 22 File 1 File 2 File 10 File 11 File 20 Test 22 If they were just numbers (i.e. without the audio, file, test) then I could just sort numerically. However, how can I sort here first by text and then by number.

    Read the article

  • Display a number on the screen

    - by Ni
    does anyone know how to display a number on the screen? I can load the data and create a x/y graph. Now instead of showing the graph, I load a data value from a text file, and I want to display that number on the screen. Does anyone know what function i can use? ....... NSString *data =[myText objectAtIndex:1]; ....... so now data = 1, i want to display the value of the 'data' which is 1 on the screen.

    Read the article

  • Using a dynamic number of checkboxes in a rails form

    - by TenJack
    I am trying to create a form with a dynamic number of checkboxes that each link to a string that is not a model number but is instead just a word. For examples: <% form_for(@words) do |f| %> <% ["apple","banana","orange"].each do |word| %> <%= f.check_box :word %> <%= f.submit %> <% end %> <% end %> So, if "apple" was checked, it would just send the string "apple" in the params. Anyone know how to do this?

    Read the article

  • Detect number of IDLE processors ruby

    - by Yannick Wurm
    Hello, I work on shared linux machines with between 4 and 24 cores. To make best use of them, I use the following code to detect the number of processors from my ruby scripts: return `cat /proc/cpuinfo | grep processor | wc -l`.to_i (perhaps there is a pure-ruby way of doing this?) But sometimes a colleague is using six or eight of the 24 cores. (as seen via top). How can I get an estimate of the number of currently unused processors that I can use without making anyone upset? Thanks!

    Read the article

  • Display a number on the screen Iphone SDK

    - by Ni
    does anyone know how to display a number on the screen/iphone simulator? I can load the data and create a x/y graph. Now instead of showing the graph, I load a data value from a text file, and I want to display that number on the screen. Does anyone know what function i can use? ....... NSString *data =[myText objectAtIndex:1]; ....... so now data = 1, i want to display the value of the 'data' which is 1 on the screen.

    Read the article

  • Program to find canonical cover or minimum number of functional dependencies

    - by Sev
    I would like to know if there is a program or algorithm to find canonical cover or minimum number of functional dependencies? For example: If you have: R = (A,B,C) <-- these are tables: A,B,C And dependencies: A ? BC B ? C A ? B AB ? C The canonical cover (or minimum number of dependencies) is: A ? B B ? C Is there a program that can accomplish this? If not, any code/pseudocode to help me write one would be appreciated. Prefer in Python or Java.

    Read the article

  • Maximum number of workable tables in SQL Server And MySQL

    - by Kibbee
    I know that in SQL Server, the maximum number of "objects" in a database is a little over 2 billion. Objects contains tables, views, stored procedures, indexes, among other things . I'm not at all worried about going beyond 2 billion objects. However, what I would like to know, is, does SQL Server suffer a performance hit from having a large number of tables. Does each table you add have a performance hit, or is there basically no difference (assuming constant amount of data). Does anybody have any experience working with databases with thousands of tables? I'm also wondering the same about MySQL.

    Read the article

  • HOW TO SElect line number in TextBox Multiline

    - by Alhambra Eidos
    Hi all, I have large text in System.Windows.Forms.TextBox control in my form (winforms), vs 2008. I want find a text, and select the line number where I've found that text. Sample, I have fat big text, and I find "ERROR en línea", and I want select the line number in textbox multiline. string textoLogDeFuenteSQL = @"SQL*Plus: Release 10.1.0.4.2 - Production on Mar Jun 1 14:35:43 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved. ** MORE TEXT **** Conectado a: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, Data Mining and Real Application Testing options WHERE LAVECODIGO = 'CO_PREANUL' * ERROR en línea 2: ORA-00904: ""LAVECODIGO"": identificador no v?lido INSERT INTO COM_CODIGOS * ERROR en línea 1: ORA-00001: restricción única (XACO.INX_COM_CODIGOS_PK) violada"; ** MORE TEXT **** Any sample code about it ? thanks in advanced,

    Read the article

  • assembly language programming (prime number)

    - by chris
    Prompt the user for a positive three digit number, then read it. Let's call it N. Divide into N all integer values from 2 to (N/2)+1 and test to see if the division was even, in which case N is instantly shown to be non-prime. Output a message printing N and saying that it is not prime. If none of those integer values divide evenly (remainder never is zero), then N is shown to be prime. Output a message printing N and saying that it is prime. Ask the user if he or she wants to test another number; if the user types "n" or "N", quit. If "y" or "Y", jump back and repeat. Comments in your code are essential. Hi. I am kinda in rush to do this.. please help me doing it. I'll be much appreciated. thank you

    Read the article

  • android get contact phone number

    - by ng93
    hi, im trying to get a contacts name and phone number from the contacts list. im using: contactname = Curser.getString(Curser.getColumnIndex(Contacts.DISPLAY_NAME)); to get their name and it works fine. But using: contactphone = Curser.getString(Curser.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); causes no warnings or errors and builds fine, yet force closes in both the emulator (2.1) and my htc desire (nexus one 2.2 rom/htc desire 2.1 rom). Any ideas how to fix it? oh and contactname and contactphone are both strings thanks, ng93

    Read the article

< Previous Page | 66 67 68 69 70 71 72 73 74 75 76 77  | Next Page >