Search Results

Search found 14236 results on 570 pages for 'times square'.

Page 26/570 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • How to play the same Sound multiple times with overlap, using OpenAL or Finch?

    - by mystify
    Finch uses OpenAL. However, when I have an instance of Sound, and say -play, the sound plays. When I call -play multiple times one after another in a fast paced way, every -play makes the current sound playback of that sound stop and restart it. That's not what I want. Would I have to create multiple sources or buffers to get that working? Or would I just instantiate multiple Sounds with the same file?

    Read the article

  • How to implement a link that can get bonus for 5 times by different people on a Social Network?

    - by Jian Lin
    How can we generate a link that can be clicked on by 5 different people on a Social Network game, so that each of the five people can get a bonus? The link will be published as a "newsfeed" on the Social Network such as Facebook. The link shouldn't be easily "generated" by any people as a cheating method. Also, what database table(s) should be added to handle: 1) the bonus can be claimed up to 5 times 2) must be claimed by different people ?

    Read the article

  • F# - Facebook Hacker Cup - Double Squares

    - by Jacob
    I'm working on strengthening my F#-fu and decided to tackle the Facebook Hacker Cup Double Squares problem. I'm having some problems with the run-time and was wondering if anyone could help me figure out why it is so much slower than my C# equivalent. There's a good description from another post; Source: Facebook Hacker Cup Qualification Round 2011 A double-square number is an integer X which can be expressed as the sum of two perfect squares. For example, 10 is a double-square because 10 = 3^2 + 1^2. Given X, how can we determine the number of ways in which it can be written as the sum of two squares? For example, 10 can only be written as 3^2 + 1^2 (we don't count 1^2 + 3^2 as being different). On the other hand, 25 can be written as 5^2 + 0^2 or as 4^2 + 3^2. You need to solve this problem for 0 = X = 2,147,483,647. Examples: 10 = 1 25 = 2 3 = 0 0 = 1 1 = 1 My basic strategy (which I'm open to critique on) is to; Create a dictionary (for memoize) of the input numbers initialzed to 0 Get the largest number (LN) and pass it to count/memo function Get the LN square root as int Calculate squares for all numbers 0 to LN and store in dict Sum squares for non repeat combinations of numbers from 0 to LN If sum is in memo dict, add 1 to memo Finally, output the counts of the original numbers. Here is the F# code (See code changes at bottom) I've written that I believe corresponds to this strategy (Runtime: ~8:10); open System open System.Collections.Generic open System.IO /// Get a sequence of values let rec range min max = seq { for num in [min .. max] do yield num } /// Get a sequence starting from 0 and going to max let rec zeroRange max = range 0 max /// Find the maximum number in a list with a starting accumulator (acc) let rec maxNum acc = function | [] -> acc | p::tail when p > acc -> maxNum p tail | p::tail -> maxNum acc tail /// A helper for finding max that sets the accumulator to 0 let rec findMax nums = maxNum 0 nums /// Build a collection of combinations; ie [1,2,3] = (1,1), (1,2), (1,3), (2,2), (2,3), (3,3) let rec combos range = seq { let count = ref 0 for inner in range do for outer in Seq.skip !count range do yield (inner, outer) count := !count + 1 } let rec squares nums = let dict = new Dictionary<int, int>() for s in nums do dict.[s] <- (s * s) dict /// Counts the number of possible double squares for a given number and keeps track of other counts that are provided in the memo dict. let rec countDoubleSquares (num: int) (memo: Dictionary<int, int>) = // The highest relevent square is the square root because it squared plus 0 squared is the top most possibility let maxSquare = System.Math.Sqrt((float)num) // Our relevant squares are 0 to the highest possible square; note the cast to int which shouldn't hurt. let relSquares = range 0 ((int)maxSquare) // calculate the squares up front; let calcSquares = squares relSquares // Build up our square combinations; ie [1,2,3] = (1,1), (1,2), (1,3), (2,2), (2,3), (3,3) for (sq1, sq2) in combos relSquares do let v = calcSquares.[sq1] + calcSquares.[sq2] // Memoize our relevant results if memo.ContainsKey(v) then memo.[v] <- memo.[v] + 1 // return our count for the num passed in memo.[num] // Read our numbers from file. //let lines = File.ReadAllLines("test2.txt") //let nums = [ for line in Seq.skip 1 lines -> Int32.Parse(line) ] // Optionally, read them from straight array let nums = [1740798996; 1257431873; 2147483643; 602519112; 858320077; 1048039120; 415485223; 874566596; 1022907856; 65; 421330820; 1041493518; 5; 1328649093; 1941554117; 4225; 2082925; 0; 1; 3] // Initialize our memoize dictionary let memo = new Dictionary<int, int>() for num in nums do memo.[num] <- 0 // Get the largest number in our set, all other numbers will be memoized along the way let maxN = findMax nums // Do the memoize let maxCount = countDoubleSquares maxN memo // Output our results. for num in nums do printfn "%i" memo.[num] // Have a little pause for when we debug let line = Console.Read() And here is my version in C# (Runtime: ~1:40: using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; namespace FBHack_DoubleSquares { public class TestInput { public int NumCases { get; set; } public List<int> Nums { get; set; } public TestInput() { Nums = new List<int>(); } public int MaxNum() { return Nums.Max(); } } class Program { static void Main(string[] args) { // Read input from file. //TestInput input = ReadTestInput("live.txt"); // As example, load straight. TestInput input = new TestInput { NumCases = 20, Nums = new List<int> { 1740798996, 1257431873, 2147483643, 602519112, 858320077, 1048039120, 415485223, 874566596, 1022907856, 65, 421330820, 1041493518, 5, 1328649093, 1941554117, 4225, 2082925, 0, 1, 3, } }; var maxNum = input.MaxNum(); Dictionary<int, int> memo = new Dictionary<int, int>(); foreach (var num in input.Nums) { if (!memo.ContainsKey(num)) memo.Add(num, 0); } DoMemoize(maxNum, memo); StringBuilder sb = new StringBuilder(); foreach (var num in input.Nums) { //Console.WriteLine(memo[num]); sb.AppendLine(memo[num].ToString()); } Console.Write(sb.ToString()); var blah = Console.Read(); //File.WriteAllText("out.txt", sb.ToString()); } private static int DoMemoize(int num, Dictionary<int, int> memo) { var highSquare = (int)Math.Floor(Math.Sqrt(num)); var squares = CreateSquareLookup(highSquare); var relSquares = squares.Keys.ToList(); Debug.WriteLine("Starting - " + num.ToString()); Debug.WriteLine("RelSquares.Count = {0}", relSquares.Count); int sum = 0; var index = 0; foreach (var square in relSquares) { foreach (var inner in relSquares.Skip(index)) { sum = squares[square] + squares[inner]; if (memo.ContainsKey(sum)) memo[sum]++; } index++; } if (memo.ContainsKey(num)) return memo[num]; return 0; } private static TestInput ReadTestInput(string fileName) { var lines = File.ReadAllLines(fileName); var input = new TestInput(); input.NumCases = int.Parse(lines[0]); foreach (var lin in lines.Skip(1)) { input.Nums.Add(int.Parse(lin)); } return input; } public static Dictionary<int, int> CreateSquareLookup(int maxNum) { var dict = new Dictionary<int, int>(); int square; foreach (var num in Enumerable.Range(0, maxNum)) { square = num * num; dict[num] = square; } return dict; } } } Thanks for taking a look. UPDATE Changing the combos function slightly will result in a pretty big performance boost (from 8 min to 3:45): /// Old and Busted... let rec combosOld range = seq { let rangeCache = Seq.cache range let count = ref 0 for inner in rangeCache do for outer in Seq.skip !count rangeCache do yield (inner, outer) count := !count + 1 } /// The New Hotness... let rec combos maxNum = seq { for i in 0..maxNum do for j in i..maxNum do yield i,j }

    Read the article

  • What's the equivalent of use-commit-times for git?

    - by Ben W
    I need the timestamps of files on my local and on my server to be in sync. This is accomplished with Subversion by setting use-commit-times=true in the config so that the last modified of each file is when it was committed. Each time I clone my repository, I want the timestamps of files to reflect when they were last changed in the remote repository, not when I cloned the repo. Is there any way to do this with git?

    Read the article

  • TSQL, How to get smalldatetime's time between two smalldatetime's times ?

    - by eugeneK
    I have Table with two smalldatetime columns, where one is startTime and other one is endTime. I need to select all values from table which between times of both columns compared to getdate()' time. I'm using SQL-Server 2005. example startDate endDate value1 2/2/01 16:00 2/2/01 18:00 1 2/2/01 21:00 2/2/01 22:00 2 2/2/01 05:00 2/2/01 22:00 3 getdate() gives 2/2/2000 21:40 so i need to get value1 2 and 3 thanks in advance

    Read the article

  • Ways of breaking down SQL transactional/call data into reports -- 'square data'?

    - by RizwanK
    I've got a large database of call-traffic information (although the question could be answered with any generic data set.) For instance, a row contains : call endpoint server (endpoint_name) call endpoint status (sip_disconnect_reason) call destination (destination) call completed (duration) [duration 0 is completed] call account group (account_group) It's pretty easy to run SQL reports against the data, i.e. select count(*), endpoint_name from calls where duration0 group by endpoint_name select count(*),destination from calls where blah group by destination I've been calling this filtering or breakdown reports (I get the number of calls per carrier, etc.). Add another breakdown, and you've got two breakdowns, a la select count(*), endpoint_name, sip_disconnect_reason from calls where duration=0 group by endpoint_name, sip_disconnect_reason Of course, if you keep adding breakdowns, you end up making super-large reports and slicing your data so thin that you can't extract any trends from it. So my question is this : Is there a name for this sort of method of report writing? (I've heard words like squares, slicing and breakdown reports applied to them) --- I'm looking for a Python/Reporting toolkit that I can use to make these easier to generate for my end users. aside : Are there other ways of representing transactional data that might be useful rather than the above method? Thanks,

    Read the article

  • Implement animation in UIButton

    - by sasayins
    I'm new to cocoa and iphone programming and I want to implement an animation in UIButton. For example, I create a custom UIButton with a square image. Then when I press that UIButton, the square image will flip. Note that the square image is the image of the UIButton. [UIButton setImage:[UIImage imageNamed:@"square.png"]];

    Read the article

  • Why did my ASP.NET Web App stop showing AM in times?

    - by qntmfred
    I haven't made any code or configuration changes (that I know of) to my ASP.NET web application and this morning it suddenly stopped showing the AM in my displayed times. PM still shows up, just not AM. It's hosted on Windows Server 2003. I figured somehow the OS regional settings might have been changed somehow, but that doesn't appear to be the case. How could this have happened?

    Read the article

  • Count the number of times a string appears within a string...

    - by onekidney
    I simply have a string that looks something like this: "7,true,NA,false:67,false,NA,false:5,false,NA,false:5,false,NA,false" All I want to do is to count how many times the string "true" appears in that string. I'm feeling like the answer is something like String.CountAllTheTimesThisStringAppearsInThatString() but for some reason I just can't figure it out. Help?

    Read the article

  • sql UPDATE, a calculation is used multiple times, can it just be calculated once?

    - by Zachery Delafosse
    UPDATE `play` SET `counter1` = `counter1` + LEAST(`maxchange`, FLOOR(`x` / `y`) ), `counter2` = `counter2` - LEAST(`maxchange`, FLOOR(`x` / `y`) ), `x` = MOD(`x`, `y`) WHERE `x` `y` AND `maxchange` 0 As you can see, " LEAST(`maxchange`, FLOOR(`x` / `y`) ) " is used multiple times, but it should always have the same value. Is there a way to optimize this, to only calculate once? I'm coding this in PHP, for the record.

    Read the article

  • How to find validity of a string of parentheses, curly brackets and square brackets?

    - by Rajendra
    I recently came in contact with this interesting problem. You are given a string containing just the characters '(', ')', '{', '}', '[' and ']', for example, "[{()}]", you need to write a function which will check validity of such an input string, function may be like this: bool isValid(char* s); these brackets have to close in the correct order, for example "()" and "()[]{}" are all valid but "(]", "([)]" and "{{{{" are not! I came out with following O(n) time and O(n) space complexity solution, which works fine: Maintain a stack of characters. Whenever you find opening braces '(', '{' OR '[' push it on the stack. Whenever you find closing braces ')', '}' OR ']' , check if top of stack is corresponding opening bracket, if yes, then pop the stack, else break the loop and return false. Repeat steps 2 - 3 until end of the string. This works, but can we optimize it for space, may be constant extra space, I understand that time complexity cannot be less than O(n) as we have to look at every character. So my question is can we solve this problem in O(1) space?

    Read the article

  • MySQL - Calculate the net time difference between two date-times while excluding breaks?

    - by John M
    In a MySQL query I am using the timediff/time_to_sec functions to calculate the total minutes between two date-times. For example: 2010-03-23 10:00:00 - 2010-03-23 08:00:00 = 120 minutes What I would like to do is exclude any breaks that occur during the selected time range. For example: 2010-03-23 10:00:00 - 2010-03-23 08:00:00 - (break 08:55:00 to 09:10:00) = 105 minutes Is there a good method to do this without resorting to a long list of nested IF statements?

    Read the article

  • How do I find difference between times in different timezones in Python?

    - by JasonA
    Hi All, I am trying to calculate difference(in seconds) between two date/times formatted as following: 2010-05-11 17:07:33 UTC 2010-05-11 17:07:33 EDT time1 = '2010-05-11 17:07:33 UTC' time2 = '2010-05-11 17:07:33 EDT' delta = time.mktime(time.strptime(time1,"%Y-%m-%d %H:%M:%S %Z"))-\ time.mktime(time.strptime(time2, "%Y-%m-%d %H:%M:%S %Z")) The problem I got is EDT is not recognized, the specific error is "ValueError: time data '2010-05-11 17:07:33 EDT' does not match format '%Y-%m-%d %H:%M:%S %Z'" Thanks,

    Read the article

  • Javawebparts Ajaxparts: Using same Axis event multiple times in signle form.

    - by Bloodboiler
    I'm using Javawebparts Ajaxparts and would like to use one axis event multiple times in a form. Problem is that std:InnerHTML responseHandler takes its target html tag id in axis-config.xml so it seems impossible to reuse the definition when only thing that should change is the target tag id. Is there a way to set responseHandler parameters on the the page where it is used (in asix:event tag or someting)?

    Read the article

  • how to bind the same vector multiple times using R?

    - by hendrik
    question: how can i bind the same vector, lets say o=c(1,2,3,4) mutiple times to get a matrix like o=array(c(1,2,3,4,1,2,3,4,1,2,3,4), dim(c(4,3)) o [,1] [,2] [,3] [1,] 1 1 1 [2,] 2 2 2 [3,] 3 3 3 [4,] 4 4 4 in a nicer way then: o=cbind(o,o,o) and maybe more generalized (dublicate()?? I need this to specifiy colors for elements in textplot() thx a lot

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >