I came across this interesting programming challenge and couldn't help but dig in and solve it for myself. The solution below is a re-write of the approach I found in this book. My first (less efficient) solution involved a breadth first traversal of a histogram "graph" storing visited & filled cells in a HashSet.
The follow up question to this is even more interesting:
"Solve this problem with an algorithm that accesses A's elements in order and can read an element only once. Use minimal additional space."
Showing posts with label java. Show all posts
Showing posts with label java. Show all posts
Wednesday, April 23, 2014
Saturday, September 7, 2013
Developing Trackpad: An 18 second Vine documentary
My goal was simple. I wanted to be able to control my Mac's mouse from my Nexus 7. These following Vines document an evening's attempt at that.
Check out the android app here.
Accompanying scala Play service here.
Phase 1 - Basic Android application. Just getting set up.
Phase 2 - Server setup. My mouse now speaks http.
Phase 3 - Hook server up to application. World's hackiest wireless mouse.
Check out the android app here.
Accompanying scala Play service here.
Sunday, March 3, 2013
Babel-hose: Real-time Twitter translations
"Now the whole world had one language and a common speech." -- Genesis 11:1
-> Check it out on github <-
This was a weekend project of mine which combined Twitters streaming API and Bing translator allowing you to understand what's happening everywhere in the world in real time in your native language. This project leverages the recently released hosebird framework for easy access to the sample and filter streams.
Getting started with the Bing translator API
Bing Translator is the best freely available machine translation API that I know of. If you're interested in getting set up to use the API to make your own translation enabled apps, follow this guide.
Create an Azure marketplace account
1- Go to http://datamarket.azure.com/ and login using a Microsoft live account. If you don't have one, you'll need to create one beforehand. You can do that here.
2- Complete the registration:
3- Once logged in, head on over to the bing translator subscription page and select the free 2,000,000 character/month subscription package.
4- If you go back to your account page under "My data" you should see the following:
Create an Azure application
Once you have an Azure marketplace account with a subscription to Bing translator, the last step is to create an application. By doing this, you'll have a client key and secret you can use to call the API.
1- Head on over to the application registration page. Once there, fill out all the necessary information. For Bing translator, you won't be using a redirect uri (even though it's mandatory). You can put any valid URI you want to complete the form. ** Before hitting submit, copy the Client secret and Client ID. We'll need these later.
2- If you go back to the application registration page, you should see your app show up:
Call the API
Using the client key and secret from above, you have all you need to call the API. If you're going to be implementing a client to call the API yourself, you'll need to first authenticate in order to get an access token, then use that in the header of your requests for authorization.
I wrote some sample code(here) that retrieves the access token, before realizing there was a really great client for the translator written already called microsoft-translator-java-api. Here is some sample java code using this library which takes care of authentication and translation requests under the covers:
Here is a more involved project that involves Twitters streaming api and bring translator:
- List of supported languages
- API Documentation along with C# and PHP examples
Bonne Chance! Que la force soit avec vous.
Subscribe to:
Posts (Atom)







