Thursday, November 22, 2012

Solving the Rubik's Cube

I've been reading and practicing the rubik's cube for the past few years. When I was in grade school the rubik's cube had just come out. And a number of students could actually solve the cube. Which I thought was amazing, but I had never bothered to learn how to do so. What I find interesting is that a 3x3x3 cube has 43,252,003,274,489,856,000 possible configurations! Which is a good example of the almost infinite complexity that is the most basic structures we have all around us.

Over the Thanksgiving break I thought I'd write a program that could receive input of an unsolved Rubik Cube and output the moves required to solve the cube. I was thinking of various data structures to store the cube in a straight forward way. Here is what I was originally thinking for storing the pieces and positions:

public enum Cubies {
        WBO, WO, WOG, WG, WGR, WR, WRB, WB,
        BO, OG, GR, RB,
        YBO, YO, YOG, YG, YGR, YR, YRB, YB
    }

public enum Positions {
        WLR, WR, WRR, WML, WMR, WFL, WFM, WFR,
        BRE, BOE, RGE, OGE,
        YLR, YR, YRR, YML, YMR, YFL, YFM, YFR
    }

Here W=white, R=right/red, L=left, M=middle, F=front, B=blue,O=orange,G=green,Y=yellow

Then just have the actual cube stored as an array of strings that contain the actual color of each square. After struggling for a few hours on writing methods for createCube, printCube, TwistCube(Side), etc. I thought I'd google the code and found CubeTwister:

http://www.randelshofer.ch/cubetwister/

Which shows someone has been doing their homework in regard how to store the Rubik's Cube as a data structure. If you look at the ch.randelshofer.rubik.AbstractCube class you can see that the cube is stored as a number of int arrays. Here is one example:

    protected final static int[][] CORNER_TO_FACE_MAP = {
        {1, 0, 2}, // urf
        {4, 2, 0}, // dfr
        {1, 5, 0}, // ubr
        {4, 0, 5}, // drb
        {1, 3, 5}, // ulb
        {4, 5, 3}, // dbl
        {1, 2, 3}, // ufl
        {4, 3, 2}, // dlf
    };

0=right, 1=up, 2=front, 3=left, 4=down, 5=back

One of the most interesting integer arrays is a four dimensional


     Corner swipe table.
     First dimension: side part index.
     Second dimension: orientation.
     Third dimension: swipe direction
     Fourth dimension: axis, layermask, angle
   
                 +---+---+---+
                 |4.0|   |2.0|
                 +---     ---+
                 |     1     |
                 +---     ---+
                 |6.0|   |0.0|
     +---+---+---+---+---+---+---+---+---+---+---+---+
     |4.1|   |6.2|6.1|   |0.2|0.1|   |2.2|2.1|   |4.2|
     +---     ---+---     ---+---    +---+---     ---+
     |     3     |     2     |     0     |     5     |
     +---     ---+---     ---+---    +---+---     ---+
     |5.2|   |7.1|7.2|   |1.1|1.2|   |3.1|3.2|   |5.1|
     +---+---+---+---+---+---+---+---+---+---+---+---+
                 |7.0|   |1.0|
                 +---     ---+
                 |     4     |
                 +---     ---+
                 |5.0|   |3.0|
                 +---+---+---+

Thursday, November 15, 2012

Senior Developer = Mature Developer

I just read a few interesting articles regarding what a Senior Developer is:

http://www.kitchensoap.com/2012/10/25/on-being-a-senior-engineer/

Mature engineers do not shy away from making estimates, and are always trying to get better at it.

Mature engineers lift the skills and expertise of those around them.

Mature engineers make their trade-offs explicit when making judgements and decisions.


The Ten Commandments of Egoless Programming

Appropriate, even if old…I’ve seen it referenced as coming from The Psychology of Computer Programming, written in 1971, but I don’t actually see it in the text. Regardless, here are The Ten Commandments of Egoless Programming, found on @wyattdanger‘s blog post on receiving advice from his dad:
  1. Understand and accept that you will make mistakes. The point is to find them early, before they make it into production. Fortunately, except for the few of us developing rocket guidance software at JPL, mistakes are rarely fatal in our industry. We can, and should, learn, laugh, and move on.
  2. You are not your code. Remember that the entire point of a review is to find problems, and problems will be found. Don’t take it personally when one is uncovered. (Allspaw note – related: see below, number #10, and the points Theo made above.)
  3. No matter how much “karate” you know, someone else will always know more. Such an individual can teach you some new moves if you ask. Seek and accept input from others, especially when you think it’s not needed.
  4. Don’t rewrite code without consultation. There’s a fine line between “fixing code” and “rewriting code.” Know the difference, and pursue stylistic changes within the framework of a code review, not as a lone enforcer.
  5. Treat people who know less than you with respect, deference, and patience. Non-technical people who deal with developers on a regular basis almost universally hold the opinion that we are prima donnas at best and crybabies at worst. Don’t reinforce this stereotype with anger and impatience.
  6. The only constant in the world is change. Be open to it and accept it with a smile. Look at each change to your requirements, platform, or tool as a new challenge, rather than some serious inconvenience to be fought.
  7. The only true authority stems from knowledge, not from position. Knowledge engenders authority, and authority engenders respect – so if you want respect in an egoless environment, cultivate knowledge.
  8. Fight for what you believe, but gracefully accept defeat. Understand that sometimes your ideas will be overruled. Even if you are right, don’t take revenge or say “I told you so.” Never make your dearly departed idea a martyr or rallying cry.
  9. Don’t be “the coder in the corner.” Don’t be the person in the dark office emerging only for soda. The coder in the corner is out of sight, out of touch, and out of control. This person has no voice in an open, collaborative environment. Get involved in conversations, and be a participant in your office community.
  10. Critique code instead of people – be kind to the coder, not to the code. As much as possible, make all of your comments positive and oriented to improving the code. Relate comments to local standards, program specs, increased performance, etc.

Tuesday, September 25, 2012

Core Job Skills Need To Learn Young and Continue as An Adult


These skills should be continuously worked on even as an adult.

From:
http://oedb.org/library/beginning--online-learning/21-critical-job-skills-you-should-instill-in-your-kid?fb_action_ids=10151001742065178&fb_action_types=og.likes&fb_source=aggregation&fb_aggregation_id=246965925417366

21 Critical Job Skills You Should Instill In Your Kid

Today's job market is more competitive than ever, and it's not likely to change for the next generation. That means that today's kids really have to be on the ball when it comes to developing critical job skills, and parents have a responsibility to be a major part of that development. Developing job skills in your kids sounds like a big, scary job, but it can be as easy as giving them the opportunity to make their own choices, learn about teamwork, and bounce back from change. Read on to learn about 21 of the most important, but easy-to-teach, job skills you should focus on with your children to give them a head start in life.


How to make friends:

The job market is hyper-competitive, making networking more important now than ever. So often, it's all about your connections and who you know when it comes to landing the perfect (or any) job. Teach your kids how to make friends, giving them not just the opportunity to be around other kids, but the chance to choose their own friends and the freedom to interact without a lot of parental hovering. This will allow them to learn about healthy personal interaction and give them confidence to meet and connect with new people as they grow.


How to make a good impression:

Kids need to know how to dress for an interview and make a great impression. Teaching kids how to present themselves professionally is an important life skill. You can do this by encouraging them to make their own fashion choices while guiding and offering advice.


How to be resilient:

Setbacks happen in real life, especially at work. By teaching kids how to bounce back, you can prepare them to find success no matter what they're up against. Teach this important skill by allowing them to fail, while offering encouragement to pick up and try again. Show them that failure isn't the end of the road, just a momentary setback.


How to write well:

So many adults today lack basic writing skills, even though writing is more important now than ever in today's information age. With excellent writing skills, your child can get ahead in work and in life. Encourage writing from a young age by reading with them frequently, providing writing activities, and setting a good example as a writer.


How to solve problems:

It seems there's always a fire to put out at work, making problem solvers incredibly useful in today's workforce. Raise a child who knows how to handle sticky situations, and they'll be poised to take on the world. The key to raising a problem solver is giving them the opportunity to deal with their own problems. Offer guidance, but allow your child the pleasure of figuring it out for themselves. It may be hard to watch, but tackling a problem independently can give your child confidence to take on even more difficult tasks.


How to tackle projects:

Work is often an endless series of tasks and projects. You can help prepare your child for successfully tackling projects by sharing them with him or her. Let them see how to do it while you're working together, and help build their confidence to take on more projects independently.


How to stand up to bullies:

Bullies are everywhere, even in the modern workplace. Kids (and adults) who are well-equipped to stand up to bullies can be more productive and happy. Teach your kids how to respond assertively and avoid becoming a victim.


How to be organized:

No one respects a professional that can't get it together. Building organizational skills can be incredibly powerful for kids to learn as they grow into responsible adults. Parents can help teach organization skills from a young age, developing schedules, checklists, and responsibility calendars.


How to connect it all together:

Knowledge is important, but even more important is the ability to pull all of your knowledge together and make connections between concepts. Anyone can Google for an answer; only the truly valuable can link ideas together. Encourage this life skill by playing sorting games and discussing how different things you've learned all work together.
How to be decisive:

Leaders have to make good decisions, and learning to be decisive from a young age can be very valuable. Teaching the skill of decision making is as easy as allowing children the opportunity to make decisions for themselves. Choose age-appropriate decisions like choosing their own clothing or deciding what to pack for lunch.


How to be independent:

Workers who can't take care of themselves can be a drain on the workplace. Employers would much rather have an employee that can be independent and take care of themselves than one that needs help every step of the way. You can teach your child how to be independent by offering opportunities to step out on their own. Encourage time away from home, like overnight school trips and camps that will allow them to explore their abilities without the help of Mom or Dad.


How to work in a team:

Teamwork and collaboration are essential parts of work life, and at some point, your kids are going to have to learn how to work and play well with others. Kids can learn the value of teamwork by playing team sports, joining clubs, and participating in group activities.


How to dream:

Kids are naturally creative and curious, but as we grow, we often lose this skill that can help us to be more innovative and accomplished. Encourage your children to talk about their dreams. Ask them what they want to be when they grow up, and give them the tools and freedom necessary to tinker, explore, and follow through on their visions.


How to manage money:

Without basic financial sense, even a good paycheck won't go far. Teach your child how to properly manage money, and they'll be able to pursue a job they love, no matter what the pay is. Parents can teach good financial lessons by allowing children to manage money on a small scale, making them responsible for paying bills, saving, and discussing financial management.


How to manage time:

Time management is an essential skill at work. Can't get enough done, and you'll never get ahead. You might even get fired! Teaching kids how to stay on top of their time is so important, and can be started at an early age. Create a schedule together with your kids, and let them be involved in planning the activities they'll be doing. This helps even young kids better understand the value of time.


How to relate to others:

Your kids will inevitably work with other people, some of whom will be very different from them. It's important that they learn how to listen to and understand others, respecting how they feel and accepting them even if they are different. Parents can teach children empathy by explaining and showing them how to respect people, animals, and property. Turn moments of acting out into teaching opportunities, explaining that breaking things may hurt your feelings.


How to be responsible:

In the workforce, you're ultimately responsible for something, and workers who are able to take ownership of what they're in charge of tend to get ahead. Kids can learn how to be responsible by tackling tasks that they're in charge of. Parents can assign specific tasks to kids, explaining that they're in charge of making sure a certain chore at home gets done. This helps them learn how to be responsible and accountable, excellent skills for work and life.


How to speak in public:

Many kids are scared of public speaking, but as adults, it's an essential skill they'll have to master. Whether giving presentations or speaking up in a meeting, they'll have to get up and speak in front of a crowd at some point. Teach kids how to become comfortable with public speaking by giving them plenty of opportunities to speak with an audience, and offer encouragement.


How to negotiate:

Whether it's for a salary or a major contract, your kids will have to negotiate some day. Building this skill can be incredibly valuable, allowing them to negotiate successfully in their favor. Kids can learn about the art of the deal by negotiating with parents. Coming to an agreement on curfew, chores, allowance, and other issues is a great opportunity for kids to learn how to negotiate.

How to be flexible:

Change happens all the time, especially in today's workplace. Layoffs, mergers, new bosses, and changing roles can sometimes be a little intimidating, but those who can roll with the punches tend to come out on top. Being flexible is something you can teach your kids, perhaps most effectively by example. Show your kids that you're not afraid of change and that you can adapt to new things as they come along. When your family experiences change, walk them through it and explain how it can be an exciting opportunity.

How to teach themselves:

Self-education is an essential skill for today's workforce. As the world's employment needs change, so do our skills, and the people who are willing to change and learn new skills to keep up with new needs will find more opportunities. Adults who embrace exploration and self-learning will have no problem keeping up, as learning new things is something they enjoy doing. As a parent, you can help raise a self-learner by encouraging curiosity, sharing self-learning opportunities, and making it easy for kids to get access to educational materials that interest them.

Friday, July 6, 2012

A Software Architect

http://coderwall.com/p/lbda2q

A software architect lives to serve the engineering team -- not the other way around.

A software architect is a mentor.

A software architect is a student.

A software architect is the code janitor. Happily sweeping up after the big party is over.

A software architect helps bring order where there is chaos, guidance where there is ambiguity, and decisions where there is disagreement.

A software architect codes the parts of the system that are the most precious and understands them through and through.

A software architect creates a vocabulary to enable efficient communication across an entire company.

A software architect reads far more code than he or she writes -- catching bugs before they manifest as systems change.

A software architect provides technological and product vision without losing sight of the present needs.

A software architect admits when he or she is wrong and never gloats when right.

A software architect gives credit where it is due and takes pride simply in a job well done.

Java Localization

I have been working with various languages and found that double byte languages are a little difficult to work with in javascript and java. In which many of the common functions and methods do not natively work with double byte languages such as Chinese, Korean, etc.

native2ascii -encoding UTF-8 urlescaped_ascii.txt utf8file.txt

this command will work with latin based languages, but not chinese

Thursday, June 21, 2012

What is a good developer?

What is a good developer? The following two rules of thumb are what I hold true:

  1. Good developers are found by speaking to others who you know are good and who they recommend.
  2. You don't truly know how someone is until you have worked with them for 3 to 6 months.

I have interviewed hundreds of developers in the past and found that many people will ace the interview and speak very well. But then when they start working they will start to have a difficult time applying what they have said to actually getting work done. Then when speaking with them on progress and work they will have excuses, etc. Often a good developer will be a lousy interviewee. In which a good developer will speak poorly or have a difficult time responding to questions.

Also many people will have their ups and downs at work as they have personal events taking place outside of work. Some weeks developers will get a lot done, and then other weeks they will be slow. It isn't until you have worked with someone for months that you can then get an overall assessment of their work performance.

I have worked with numerous developers from China, India, Israel, Russia, Great Britain, France, and USA. I have found that each cultural group has their own way of getting things done and communicating. To be a good developer require just two important aspects:

  1. Communication
  2. Getting Work Done
Each work team will have its own personal dynamics for how work is being delegated and completed. Some people will work well in certain environments and others will work poorly in other environments.



Tuesday, May 22, 2012

Why I hate Windows 7

  • The personal folder created for your user has 'My Documents' and 'Documents' folders created. Which then becomes confusing as to which directory has my files in it...
  • When I open the Windows Explorer, as I click on directories, I continuously see the new hourglass circle, which gives the impression Windows 7 is much slower then Vista, XP, etc.
  • The auto-wireless tool will auto connect to a network. And then will not allow you to switch networks.

Monday, May 14, 2012

Development Tools

Mythicsoft - Agent Ransack

Great article on the benefits of using emacs:

http://www.insightdatascience.com/blog/emacs_for_data_science.html

Love Emacs! Glad I learned emacs back in 1999. I had been a hardcore VI user, and felt emacs didn't have anything I couldn't do in VI. But with the lisp dev environment tied to emacs, I can customize the hell out of the editor. Also I have found that I can customize the text and rendering of code in lots of different ways.


Python vs Java

Wrote some python couple of weeks ago and wanted to document the items I thought were compelling compared to java:

1. Less syntax

2. String operations more intuitive

3. Function calling versus method signatures

4. Package Runtime

Wednesday, March 28, 2012

Robots - Device Device Device

What would be needed to have humans leave Earth and explore the universe?

My thought is that we would need robots that can do many of the mundane things we do today. So that we (humans) can focus on exploration. We need them to do our cleaning, cooking, and most importantly, building and maintaining our buildings and vehicles.

So what is needed to get to that?

We need a 'device' that can make Robots.

That 'device' needs to be build upon itself.

So I think we first would need a device that can make devices.

But then that is work also! So we would need a second level of redundancy in this device building idea. A device that can make devices that make devices.