language-agnostic

Code Golf: Playing Tetris

喜夏-厌秋 提交于 2019-12-20 08:08:52
问题 Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. The basics: Consider the following tetrominoes and empty playing field: 0123456789 I O Z T L S J [ ] [ ] # ## ## ### # ## # [ ] # ## ## # # ## # [ ] # ## ## [ ] # [ ] [==========] The dimensions of the playing field are fixed. The numbers at the top are just here to indicate the column number (also see input). Input: 1

The best way to familiarize yourself with an inherited codebase

為{幸葍}努か 提交于 2019-12-20 08:04:58
问题 Stacker Nobody asked about the most shocking thing new programmers find as they enter the field. Very high on the list, is the impact of inheriting a codebase with which one must rapidly become acquainted. It can be quite a shock to suddenly find yourself charged with maintaining N lines of code that has been clobbered together for who knows how long, and to have a short time in which to start contributing to it. How do you efficiently absorb all this new data? What eases this transition? Is

Clustering Algorithm for Paper Boys

纵然是瞬间 提交于 2019-12-20 08:03:57
问题 I need help selecting or creating a clustering algorithm according to certain criteria. Imagine you are managing newspaper delivery persons. You have a set of street addresses, each of which is geocoded. You want to cluster the addresses so that each cluster is assigned to a delivery person. The number of delivery persons, or clusters, is not fixed. If needed, I can always hire more delivery persons, or lay them off. Each cluster should have about the same number of addresses. However, a

Clustering Algorithm for Paper Boys

僤鯓⒐⒋嵵緔 提交于 2019-12-20 08:03:33
问题 I need help selecting or creating a clustering algorithm according to certain criteria. Imagine you are managing newspaper delivery persons. You have a set of street addresses, each of which is geocoded. You want to cluster the addresses so that each cluster is assigned to a delivery person. The number of delivery persons, or clusters, is not fixed. If needed, I can always hire more delivery persons, or lay them off. Each cluster should have about the same number of addresses. However, a

Phonetically Memorable Password Generation Algorithms

浪子不回头ぞ 提交于 2019-12-20 08:00:54
问题 Background While at the Gym the other day, I was working with my combination lock, and realized something that would be useful to me as a programmer. To wit, my combination is three seperate sets of numbers that either sound alike, or have some other relation that makes them easy to remember. For instance, 5-15-25, 7-17-2, 6-24-5. These examples seem easy to remember. Question How would I implement something similar for passwords? Yes, they ought to be hard to crack, but they also should be

What's the difference between application layer and business logic layer?

為{幸葍}努か 提交于 2019-12-20 08:00:15
问题 What's the difference between application layer and business logic layer? I kind of understand that business layer provides business specific services and application layer couples business services and provides services to the end user (Web Service, UI, etc). Am I right? 回答1: That sounds about correct. The business layer implements the Domain Model in a boundary-technology-neutral way. In other words, it doesn't depend on any particular UI or service interface-related technology, such as web

Finding the optimum column and row size for a table with n elements and a given range for its proportion

做~自己de王妃 提交于 2019-12-20 03:42:29
问题 I am looking for an optimum way to create a table from n elements so that ideally there are no empty cells, but at the same time the proportion of the table dimensions columns / rows becomes as close to 1 as possible. Of course if n is a square number it is easy since then cols = rows = sqrt( n ); If n is a prime number it is also clear that there will be empty cells, so my current way to handle this is: rows = floor( sqrt(n) ); cols = ceil( n / rows ); For all other cases my plan is to get

Best practice regarding number of threads in GUI applications

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-19 21:47:58
问题 In the past I've worked with a number of programmers who have worked exclusively writing GUI applications. And I've been given the impression that they have almost universally minimised the use of multiple threads in their applications. In some cases they seem to have gone to extreme lengths to ensure that they use a single thread. Is this common? Is this the generally accepted philosophy for gui application design? And if so, why? [edit] There are a number of answers saying that thread usage

Precisely what owns the 'current working directory'?

最后都变了- 提交于 2019-12-19 19:47:12
问题 I'm aware what a working directory (wd) is and it's purpose (for writing software at least). What I don't understand is the ownership of the wd. Furthermore, I want to understand how the answer may vary between operating systems so any clarification on unusual behaviour on a particular OS would be appreciated. So firstly, where does the wd manifest itself? Is it within a process, and all threads created by that process share the same wd? If the wd gets modified by thread 'A', is the change

Why doesn't the bitwise & operator short-circuit?

寵の児 提交于 2019-12-19 18:23:53
问题 We all know that the logical && operator short circuits if the left operand is false , because we know that if one operand is false , then the result is also false . Why doesn't the bitwise & operator also short-circuit? If the left operand is 0 , then we know that the result is also 0 . Every language I've tested this in (C, Javascript, C#) evaluates both operands instead of stopping after the first. Is there any reason why it would be a bad idea the let the & operator short-circuit? If not,