language-agnostic

Removal of every 'kth' person from a circle. Find the last remaining person

做~自己de王妃 提交于 2020-01-22 05:06:38
问题 As part of a recent job application I was asked to code a solution to this problem. Given, n = number of people standing in a circle. k = number of people to count over each time Each person is given a unique (incrementing) id. Starting with the first person (the lowest id), they begin counting from 1 to k. The person at k is then removed and the circle closes up. The next remaining person (following the eliminated person) resumes counting at 1. This process repeats until only one person is

What are some tricks that a processor does to optimize code?

与世无争的帅哥 提交于 2020-01-20 18:11:40
问题 I am looking for things like reordering of code that could even break the code in the case of a multiple processor. 回答1: Wikipedia has a fairly comprehensive list of optimization techniques here. 回答2: The most important one would be memory access reordering. Absent memory fences or serializing instructions, the processor is free to reorder memory accesses. Some processor architectures have restrictions on how much they can reorder; Alpha is known for being the weakest (i.e., the one which can

Explain the difference between a data *structure* and a data *type* [closed]

假如想象 提交于 2020-01-19 06:34:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . While trying to answer What is the difference between a composite data type and a data structure? I realized that while I have a clear idea of what a data type is , and how it is not the same thing as a data structure , I cannot put the difference into words. If you were teaching an intro CS course, how would

How Could One Implement the K-Means++ Algorithm?

末鹿安然 提交于 2020-01-19 06:33:12
问题 I am having trouble fully understanding the K-Means++ algorithm. I am interested exactly how the first k centroids are picked, namely the initialization as the rest is like in the original K-Means algorithm. Is the probability function used based on distance or Gaussian? In the same time the most long distant point (From the other centroids) is picked for a new centroid. I will appreciate a step by step explanation and an example. The one in Wikipedia is not clear enough. Also a very well

How Could One Implement the K-Means++ Algorithm?

大城市里の小女人 提交于 2020-01-19 06:32:05
问题 I am having trouble fully understanding the K-Means++ algorithm. I am interested exactly how the first k centroids are picked, namely the initialization as the rest is like in the original K-Means algorithm. Is the probability function used based on distance or Gaussian? In the same time the most long distant point (From the other centroids) is picked for a new centroid. I will appreciate a step by step explanation and an example. The one in Wikipedia is not clear enough. Also a very well

Extract email and name with regex

喜你入骨 提交于 2020-01-19 05:33:45
问题 What would be the regular expressions to extract the name and email from strings like these? johndoe@example.com John <johndoe@example.com> John Doe <johndoe@example.com> "John Doe" <johndoe@example.com> It can be assumed that the email is valid. The name will be separated by the email by a single space, and might be quoted. The expected results are: johndoe@example.com Name: nil Email: johndoe@example.com John <johndoe@example.com> Name: John Email: johndoe@example.com John Doe <johndoe

What are some useful or interesting infinite generators? [closed]

烂漫一生 提交于 2020-01-17 06:54:37
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . What are some clever uses for infinite generators? I've seen lots of seemingly trivial examples like "list all even numbers" , but I assume there must be others that have more applicability to real-world scenarios. Concrete examples (in any language that support generators)

What are some useful or interesting infinite generators? [closed]

陌路散爱 提交于 2020-01-17 06:54:12
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . What are some clever uses for infinite generators? I've seen lots of seemingly trivial examples like "list all even numbers" , but I assume there must be others that have more applicability to real-world scenarios. Concrete examples (in any language that support generators)

Configurable level editor

隐身守侯 提交于 2020-01-17 03:03:18
问题 I am looking after a level editor easy to use and configurable, so I can use for my own application/engine. Is there something like that? 回答1: Check out Nitro Level Editor - it's XML based and fit for virtually any 2D game or application. http://code.google.com/p/nle/ 来源: https://stackoverflow.com/questions/3530533/configurable-level-editor

Configurable level editor

回眸只為那壹抹淺笑 提交于 2020-01-17 03:02:25
问题 I am looking after a level editor easy to use and configurable, so I can use for my own application/engine. Is there something like that? 回答1: Check out Nitro Level Editor - it's XML based and fit for virtually any 2D game or application. http://code.google.com/p/nle/ 来源: https://stackoverflow.com/questions/3530533/configurable-level-editor