Write a program that divides up some input text into sentences and then determines which sentence in the input has the most words. Print out the sentence with the most words and the number of words that are in it. Optionally, also print out all words in that sentence that are longer than 4 characters.
Sentences can end in periods, exclamation points and question marks, but not colons or semi-colons.
I remember doing something like this a while back. I tried to find my original code to compare but it seems lost forever.
you have a string “ddaaiillyypprrooggrraammeerr”. We want to remove all the consecutive duplicates and put them in a separate string, which yields two separate instances of the string “dailyprogramer”.
use this list for testing:
expected output: “balons” “lo”
expected output: “dailyprogramer” “dailyprogramer”
expected output: “abcdeded” “abcd”
input: “flabby aapples”
expected output: “flaby aples” “bap”
This one was too easy. Here’s my solution:
Write a program that prints out the lyrics for “Ninety-nine bottles of beer”, “Old McDonald had a farm” or “12 days of Christmas”.
If you choose “Ninety-nine bottles of beer”, you need to spell out the number, not just write the digits down. It’s “Ninety-nine bottles of beer on the wall”, not “99 bottles of beer”!
For Old McDonald, you need to include at least 6 animals: a cow, a chicken, a turkey, a kangaroo, a T-Rex and an animal of your choosing (Old McDonald has a weird farm). The cow goes “moo”, the chicken goes “cluck”, the turkey goes “gobble”, the kangaroo goes “g’day mate” and the T-Rex goes “GAAAAARGH”. You can have more animals if you like.
Make your code shorter than the song it prints out!
I decided to go with the classic 99 bottles of beer on the wall. And below I present you with my solution:
First, lets start with what not to use:
What you should use:
I use a double bitwise NOT in my code since it stands out and is pretty easy to type. Considering how these alternatives are just as fast as using Math.floor, you might as well use them to cut back on your file size. After-all, performance is everything…
With a bit of time to spare, I wrote a little script that swaps out images on a webpage with a list of urls you specify.
Get the source here
Visits is an awesome little utility shows you how many visits your site is getting. From the App Store:
See your site’s traffic without moving a finger. Visits allows you to, at a glance, see how your site is performing. Pulls all the important data from Google Analytics and gives you hour by hour breakdown of your traffic. In addition, it shows your top content, top referrals and search keywords for the day.
Buy now in the App Store.
After searching around available modules, I could not find a straight up simple HTTP basic authentication library. Every one I found was either really old and broken, or part of a very large library that included its own server. Since the spec for basic authentication is pretty straight forward, I just re-implemented it.
To install: npm install basic-auth
You can grab the source here.