If I set a layout on a JFrame with setLayout and then retrieve it with getLayout then I get a different LayoutManager. What is going on here??
public class Lay {
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
java.awt.Container contain...
I found a piece of code that I was writing for interview prep few months ago.
According to the comment I had, it was trying to solve this problem:
Given some dollar value in cents (e.g. 200 = 2 dollars, 1000 = 10 dollars),
find all the combinations of coins that make up the dollar value.
There are only penny, nickel, dime, and quarter....
I'm creating a puzzle game that, while playable by hand for easy levels, is meant to be solved by computer programs for harder ones. The puzzle is a flood fill on a hexagonal board. You can try a prototype here.
Here is how the puzzle works: by choosing a color from the top, you perform a flood fill starting from the upper-left tile. ...
I've encountered a website that uses a 50-digit decimal integer ID in a URL query string, which seems a little excessive.
The smallest 50-digit decimal number is 1.0 x 10^49, otherwise known as:
1000000000
0000000000
0000000000
0000000000
0000000000
How many bits would the binary representation contain?
How would you approach conver...
Using recursion, find an index that cuts an array in two parts so that both parts have equal sum.
Cut means to cut like with a knife. All the cells with index <= to the result must be equal in their sum to the all the cells with index > to the result. No cells can be left off or be part of both sides.
The arrays contains arbitrary inte...
Four men have to cross a bridge at night.Any party who crosses, either one or two men, must carry the flashlight with them. The flashlight must be walked back and forth; it cannot be thrown, etc. Each man walks at a different speed. One takes 1 minute to cross, another 2 minutes, another 5, and the last 10 minutes. If two men cross to...
This is one of the boring academic OOP questions, but it is not a homework. I got the question from a newbie programmer about one of those stupid textbooks examples about OOP.
Imagine that you are designing a Square class and a Cube class, which should inherit which?
I see a relationship, but what it is, I can not really see!
Could yo...
Hello,
this evening I tried to solve a wood puzzle so I wondered which is the best way to find a solution to this kind of problem programmaticaly..
The aim is to combine a set of solids (like tetris pieces in three dimensions) together combining a shape in a feasable way that takes care of the fact that pieces can be attached or slided...
I am mentioning a few questions which are usually the part of interviews, I dont understand what is the intent behind then. Of course one might argue, just to see how you think, or how you react, but isn't it better if you ask a more meaningful puzzle, at least for which you can be sure of answer, or justify unanimously. For example, see...
are there any sites where we have to solve puzzles using php scripts? Similar to PythonChallenge?
I am aware of most of the programming challenge sites, idea is to find a site which helps to discover the strength and speciality of PHP Scripting the way PythonChallenge does by it's wiki's for each level.
...
Are there any websites or blogs with programming challenges specifically for R users?
...
Question: given an integer number n, print the numbers from 1 up to n2 like this:
n = 4
result is:
01 02 03 04
12 13 14 05
11 16 15 06
10 09 08 07
How do you solve it (apart from the solution provided in the link below)?
http://www.programmersheaven.com/mb/CandCPP/81986/81986/problem-in-making-ap-c++-program/?S=B20000
I'm looking ...
There have been many questions related to what one should ask interviewees, what you should ask a company you're interviewing at, etc. I searched and I don't think this one is a duplicate. Also, community wiki from the start.
So here goes: What is the most interesting (challenging, fun, original, useful) brainteaser or puzzle question y...
Assume a game in which one rolls 20, 8-sided die, for a total number of 8^20 possible outcomes. To calculate the probability of a particular event occurring, we divide the number of ways that event can occur by 8^20.
One can calculate the number of ways to get exactly 5 dice of the value 3. (20 choose 5) gives us the number of orders o...
Hi,
I'm trying to build an app that is a code breaking puzzle for the user. I've followed sample code on how to add a decimal to the numeric keypad and it works great. I would like to expand this so the whole keyboard is filled with custom images.
Is it possible to have a piece of code that when the user presses on a symbol the iPhone...
Hi StackOverflow,
Although it is not very programming related but I think SO could be of some assistance:
A zeroless pandigital number of base 10 is a number with all the
distinct digits 1,2,3,4,5,6,7,8,9.
For example, the first zeroless pandigital number of base 10 is 123456789.
Find a zeroless pandigital number of base 10 such that...
Hi!
I'm a relative novice at C# and am thoroughly stuck! I need to make a sliding puzzle where numbered tiles are to be rearranged in order by using a blank space, i.e.
1 2 3
4 5 6
7 8
I have no idea where to start!
Thanks for your time!
...
Question
I would like to be able to use a single regex (if possible) to require that a string fits [A-Za-z0-9_] but doesn't allow:
Strings containing just numbers or/and symbols.
Strings starting or ending with symbols
Multiple symbols next to eachother
Valid
test_0123
t0e1s2t3
0123_test
te0_s1t23
t_t
Invalid
t__t
____
0123012...
I have a system that requires a unique 6-digit code to represent an object, and I'm trying to think of a good algorithm for generating them. Here are the pre-reqs:
I'm using a base-20 system (no caps, numbers, vowels, or l to prevent confusion and naughty words)
The base-20 allows 64 million combinations
I'll be inserting potentially...
I'm working on a program to solve the n queens problem (the problem of putting n chess queens on an n x n chessboard such that none of them is able to capture any other using the standard chess queen's moves). I am using a heuristic algorithm, and it starts by placing one queen in each row and picking a column randomly out of the column...