Big numbers: Ultrafactorials Ultrafactorials
The ultrafactorials are a sequence of numbers which can be generated using the following function:
$$a(n) = n! ^ {n!}$$
The resulting values rise extremely quickly.
Side note: This is entry A046882 in the OEIS. Also related are the hyperfactorials, a still quite huge, but a bit smaller sequence: A002109
Your task
Your task is to implement these numbers into your language. Your program will calculate the sum of all ultrafactorials from 0 up to inclusive n.
Input
Your program may only take one input: a number, which resembles the last \$a(n)\$ ultrafactorial to be added to the sum. The Input is assured to be positive or 0.
Output
Your output is all up to you, as long as there's the visible sum of the numbers somewhere.
Rules

You can assume all integers, therefore integer input, and using integer counting loops to produce some results.

Test cases
Input: -1
Output: Any kind of error (because -1! is undefined), or no handling at all

Input: 0
Output: 1

Input: 1
Output: 2

Input: 2
Output: 6

Input: 3
Output: 46662
Challenge
This is code-golf, so the answer with the least length in bytes wins!

Mathematica, 19 bytes

Sum[n!^n!,{n,0,#}]&

Apologies for the extremely clear code  ;)


A challenge about colours Above, you can see an image full of different colours.

Click here for a hex-dump.

One possible way to generate this image is by using a linear gradient rotated 90 degrees, however, this may not be the only way.

Your task is to create a self-contained program that takes no input, and outputs an image with the same RGBA pixels as the above image, and in the exact same location, with the output image being in a file format that was created before this challenge, with the dimensions of the image being 4096x4096px, same as the original.

The shortest such program, scored in bytes, is the winner.

Cheating and standard loopholes are not allowed.

Processing, 197 195 bytes
void setup(){size(255,255);int r=255,a=r,g=0,b=0,i,j,k;background(a);for(i=0;i<a;k=i<43?g+=6:i<85?r-=6:i<a/2?b+=6:i<170?g-=6:i<213?r+=6:a>1?b-=6:0,i++)for(j=0;j<a;point(i,j++))stroke(r,g,b,a-j);}

This outputs the image in a 255x255 sized window
Explained
void setup(){            //this is required
  size(255,255);         //size of sketch
  int r=255,a=r,g=0,b=0,i,j,k; //declaring our vars
  background(a);         //set the background colour as white
  //for-loop for the x-coordinates, it also increments/decrements rgb values
  //  based on the x-coordinate
  for(i=0;i<a;k=i<43?g+=6:i<85?r-=6:i<a/2?b+=6:i<170?g-=6:i<213?r+=6:a>1?b-=6:0,i++)
    //for-loop for the y-coordinate (alpha)
    for(j=0;j<a;point(i,j++))   //2) then draw the point at the location
      stroke(r,g,b,a-j);        //1) set the colour of point
}

Edits

Used int instead of float
THIS SOLUTION IS INVALID DUE TO NEW RULES BEING ADDED. I WILL UPDATE ANSWER SOON


Convert human readable time interval to date components Challenge

Write the shortest program that converts a human readable time interval to date components of the form:

{±YEARS|±MONTHS|±DAYS|±HOURS|±MINUTES|±SECONDS}

Sample cases

Each test case is two lines, input followed by output:

1 year 2 months 3 seconds
{1|2|0|0|0|3}

-2 day 5 year 8months
{5|8|-2|0|0|0}

3day 9     years 4 seconds -5 minute 4 years 4 years -3seconds
{17|0|3|0|-5|1}

Rules

You can not use strtotime or any built-in function that does the whole job.
Shortest code wins (bytes)
You can print your output to stdout or a file, the result can also be returned by a function, it's up to you
The token can be in singular or plural form.
The components may be in a random order
There may be no white space between the number and the token
Sign is optional when the time interval is positive (input and output)
If a component appears more than once the values should be added
Each component has its own sign
The components should be handled separately (e.g. 80 minutes remains as 80 in the output)
The input is guaranteed to be lower case

Happy Golfing!


Words hidden in my phone number Telephones in the United States (and perhaps some other places) have letters associated with some of the numbers.

2 = A, B, C
3 = D, E, F
4 = G, H, I
5 = J, K, L
6 = M, N, O
7 = P, Q, R, S
8 = T, U, V
9 = W, X, Y, Z

No letters are associated with the number 0 or 1.

Your challenge: Given any phone number in seven-digit or ten-digit format, return English words or phrases into which it could be translated using the code above. Spaces do not matter.

So, for example
873-5377 can be translated to “useless” or “trek-err” and possibly a few others depending on your words list.

For the purposes of this contest,

All digits in the phone number must be used and must be translated into letters. This means that phone numbers containing 0s or 1s can not be translated.
If your operating system or programming environment has a built-in words list (/usr/share/dict/words or the equivalent), go ahead and use it. Otherwise, you can assume that a word list has been downloaded to a convenient directory. However, (a) no-preprocessing of the dictionary to limit it to seven and ten letter words or anything like that, and (b) you have to open the dictionary and load the words yourself; you can’t just pass a variable that contains a list of words.
If your dictionary includes proper nouns, it’s OK to have them in your output.
You can not assume that your input is an integer. The number 213-867-5309 might be input as (213) 867-5409 or 2138675309. Strip all non-numerical characters and make sure what’s left is a seven or ten-digit integer.
Your answer can be a function or a complete program, but no snippets.

FOR EXTRA CREDIT

You may implement a version of the code that replaces rule 1 with a more forgiving test — you may leave up to 2 numbers as numbers while changing all the other numbers to words. If you choose this path, the code must complete a comprehensive search and not do something trivial like leaving the first two numbers as numbers while doing word substitution on the rest. Obviously in this variation, phone numbers with up to two 0s and 1s may be translated.

Using the same test number as above, rule 6 gives us the answers "us-elf-77", "us-ekes-7", and others in addition to the answers above.

TEST NUMBERS

Show us what you get for 868-454-6523 and 323-454-6503.

SCORING

Shortest code wins, but if you’ve implemented rule 6 you can cut your length in half. I also plan to call out interesting solutions or solutions from verbose languages that might have won if their command names were shorter.

05AB1E, 207 bytes

þ"! ! ABC DEF GHI JKL MNO PQRS TUV WXYZ"S#sSèU
"€‚ƒ„…†‡ˆ‰Š‹ŒŽ•–—™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîï"©vyV®vYy«"“ÿ“".Vu}})
ʒg¹þgQ}
ʒ´vXNèyåˆ}¯P}
¹þg7Q¹þgTQ&i´¯}

Try it online!

(1) The first line of the code, will replace each number in the input with the corresponding set of possible letters.

þ                                              # Only digits of input.
 "! ! ABC DEF GHI JKL MNO PQRS TUV WXYZ"       # Push keypad letters.
                                        S#     # Split into list and on spaces.
                                          sS   # Split input into digits.
                                            èU # Push indexes of digits and store in X.

(2) The second line of the code, will push every possible dictionary word that is stored in 05AB1E. It accomplishes this by pushing all pairings of the dictionary encrypted characters and converting them to their dictionary stored equivalents. There are 100 unique dictionary characters, and 100*100 unique pairs of them. This means we are getting access to a total of 10,000 words from the 05AB1E dictionary.

(3) The third line of the code, will filter the dictionary by the length of the number of digits in the input.

(4) The fourth line of the code, will filter again the words from the dictionary which match the filter of possible letters outlined by line #1.

(5) The final line of the code, will simply return an empty array provided that the input was not 7 or 10 digits long after parsing.

Using no external libraries/files, this code can detect any word that is in the 05AB1E dictionary. More specifically, if the input is limited to 7 characters the following list:

["ABILITY", "ABRAHAM", "ABSENCE", "ACADEMY", "ACCEPTS", "ACCOUNT", "ACCUSED", "ACHIEVE", "ACQUIRE", "ACROBAT", "ACRYLIC", "ACTIONS", "ACTRESS", "ADAPTED", "ADAPTER", "ADAPTOR", "ADDRESS", "ADOPTED", "ADVANCE", "ADVERSE", "ADVISED", "ADVISOR", "AFFAIRS", "AFFECTS", "AFRICAN", "AGAINST", "AIRFARE", "AIRLINE", "AIRPORT", "ALABAMA", "ALBANIA", "ALBERTA", "ALCOHOL", "ALGEBRA", "ALGERIA", "ALLEGED", "ALLERGY", "ALLOWED", "ALREADY", "ALTERED", "AMATEUR", "AMAZING", "AMBIENT", "AMENDED", "AMERICA", "AMONGST", "AMOUNTS", "AMPLAND", "ANAHEIM", "ANALYST", "ANALYZE", "ANATOMY", "ANCIENT", "ANDORRA", "ANDREAS", "ANDREWS", "ANGELES", "ANIMALS", "ANOTHER", "ANSWERS", "ANTENNA", "ANTHONY", "ANTIGUA", "ANTIQUE", "ANTONIO", "ANXIETY", "ANYBODY", "ANYMORE", "ANYTIME", "APPAREL", "APPEALS", "APPEARS", "APPLIED", "APPLIES", "APPROVE", "AQUATIC", "ARCHIVE", "ARISING", "ARIZONA", "ARMENIA", "ARRANGE", "ARRIVAL", "ARRIVED", "ARRIVES", "ARTICLE", "ARTISTS", "ARTWORK", "ASPECTS", "ASSAULT", "ASSISTS", "ASSUMED", "ASSUMES", "ASSURED", "ATLANTA", "ATTACKS", "ATTEMPT", "ATTRACT", "AUCTION", "AUDITOR", "AUSTRIA", "AUTHORS", "AVERAGE", "AWARDED", "AWESOME", "BACKING", "BAGHDAD", "BAHAMAS", "BAHRAIN", "BALANCE", "BALLOON", "BANGBUS", "BANGKOK", "BANKING", "BANNERS", "BAPTIST", "BARBARA", "BARGAIN", "BARRIER", "BASKETS", "BATTERY", "BEACHES", "BEARING", "BEATLES", "BECAUSE", "BECOMES", "BEDDING", "BEDFORD", "BEDROOM", "BEIJING", "BELARUS", "BELFAST", "BELGIUM", "BELIEFS", "BELIEVE", "BELONGS", "BENEATH", "BENEFIT", "BENNETT", "BERMUDA", "BERNARD", "BESIDES", "BETTING", "BETWEEN", "BEVERLY", "BICYCLE", "BIDDING", "BIGGEST", "BILLING", "BILLION", "BINDING", "BIOLOGY", "BIZARRE", "BIZRATE", "BLANKET", "BLESSED", "BLOCKED", "BLOGGER", "BLOWING", "BLOWJOB", "BOATING", "BOLIVIA", "BONDAGE", "BOOKING", "BOOLEAN", "BORDERS", "BOROUGH", "BOTTLES", "BOULDER", "BOUQUET", "BOWLING", "BRACKET", "BRADLEY", "BRANDON", "BREASTS", "BRIDGES", "BRIEFLY", "BRISTOL", "BRITAIN", "BRITISH", "BRITNEY", "BROADER", "BROKERS", "BROTHER", "BROUGHT", "BROWSER", "BUDGETS", "BUFFALO", "BUILDER", "BUKKAKE", "BURNING", "BUTTONS", "CABINET", "CALCIUM", "CALGARY", "CALLING", "CAMERAS", "CAMERON", "CAMPING", "CANDLES", "CAPABLE", "CAPITAL", "CAPITOL", "CAPTAIN", "CAPTURE", "CARDIAC", "CARDIFF", "CAREERS", "CAREFUL", "CARRIED", "CARRIER", "CARRIES", "CARROLL", "CARTOON", "CASINOS", "CASTING", "CATALOG", "CAUSING", "CAUTION", "CEILING", "CENTERS", "CENTRAL", "CENTRES", "CENTURY", "CERAMIC", "CERTAIN", "CHAMBER", "CHANCES", "CHANGED", "CHANGES", "CHANNEL", "CHAPTER", "CHARGED", "CHARGER", "CHARGES", "CHARITY", "CHARLES", "CHARLIE", "CHARTER", "CHASSIS", "CHEAPER", "CHECKED", "CHELSEA", "CHESTER", "CHICAGO", "CHICKEN", "CHINESE", "CHOICES", "CHRONIC", "CIRCLES", "CIRCUIT", "CITIZEN", "CLAIMED", "CLARITY", "CLASSES", "CLASSIC", "CLEANER", "CLEANUP", "CLEARED", "CLEARLY", "CLIENTS", "CLIMATE", "CLINICS", "CLINTON", "CLOSELY", "CLOSEST", "CLOSING", "CLOSURE", "CLOTHES", "CLUSTER", "COACHES", "COASTAL", "COATING", "COLEMAN", "COLLECT", "COLLEGE", "COLLINS", "COLOGNE", "COLORED", "COLOURS", "COLUMNS", "COMBINE", "COMFORT", "COMMAND", "COMMENT", "COMMONS", "COMPACT", "COMPANY", "COMPARE", "COMPETE", "COMPILE", "COMPLEX", "COMPUTE", "CONCEPT", "CONCERN", "CONCERT", "CONCORD", "CONDUCT", "CONFIRM", "CONNECT", "CONSENT", "CONSIST", "CONSOLE", "CONSULT", "CONTACT", "CONTAIN", "CONTENT", "CONTEST", "CONTEXT", "CONTROL", "CONVERT", "COOKIES", "COOKING", "COOLING", "COPYING", "CORNELL", "CORNERS", "CORRECT", "COSTUME", "COTTAGE", "COUNCIL", "COUNSEL", "COUNTED", "COUNTER", "COUNTRY", "COUPLED", "COUPLES", "COUPONS", "COURAGE", "COURIER", "COURSES", "COVERED", "CREATED", "CREATES", "CREATOR", "CREDITS", "CRICKET", "CRITICS", "CROATIA", "CRUCIAL", "CRUISES", "CRYSTAL", "CUISINE", "CULTURE", "CUMSHOT", "CURIOUS", "CURRENT", "CUSTODY", "CUSTOMS", "CUTTING", "CYCLING", "DAMAGED", "DAMAGES", "DANCING", "DEALERS", "DEALING", "DEBORAH", "DECADES", "DECIDED", "DECIMAL", "DECLARE", "DECLINE", "DEFAULT", "DEFECTS", "DEFENCE", "DEFENSE", "DEFICIT", "DEFINED", "DEFINES", "DEGREES", "DELAYED", "DELETED", "DELIGHT", "DELIVER", "DEMANDS", "DENMARK", "DENSITY", "DEPENDS", "DEPOSIT", "DERIVED", "DESERVE", "DESIGNS", "DESIRED", "DESKTOP", "DESPITE", "DESTINY", "DESTROY", "DETAILS", "DETROIT", "DEUTSCH", "DEVELOP", "DEVIANT", "DEVICES", "DEVOTED", "DIAGRAM", "DIAMOND", "DIETARY", "DIGITAL", "DIPLOMA", "DISABLE", "DISCUSS", "DISEASE", "DISPLAY", "DISPUTE", "DISTANT", "DIVERSE", "DIVIDED", "DIVORCE", "DOCTORS", "DOLLARS", "DOMAINS", "DONATED", "DOUGLAS", "DRAWING", "DRESSED", "DRESSES", "DRIVERS", "DRIVING", "DROPPED", "DURABLE", "DYNAMIC", "EARLIER", "EARNING", "EASTERN", "ECLIPSE", "ECOLOGY", "ECONOMY", "ECUADOR", "EDITING", "EDITION", "EDITORS", "EDWARDS", "EFFECTS", "EFFORTS", "ELDERLY", "ELECTED", "ELECTRO", "ELEGANT", "ELEMENT", "ELLIOTT", "EMBASSY", "EMERALD", "EMPEROR", "ENABLED", "ENABLES", "ENDLESS", "ENEMIES", "ENGAGED", "ENGINES", "ENGLAND", "ENGLISH", "ENHANCE", "ENJOYED", "ENLARGE", "ENQUIRY", "ENSURES", "ENTERED", "ENTRIES", "EPISODE", "EQUALLY", "EROTICA", "ESCORTS", "ESSENCE", "ESTATES", "ESTONIA", "ETERNAL", "ETHICAL", "EVENING", "EVIDENT", "EXACTLY", "EXAMINE", "EXAMPLE", "EXCERPT", "EXCITED", "EXCLUDE", "EXECUTE", "EXHAUST", "EXHIBIT", "EXISTED", "EXPECTS", "EXPEDIA", "EXPENSE", "EXPERTS", "EXPIRED", "EXPIRES", "EXPLAIN", "EXPLORE", "EXPORTS", "EXPOSED", "EXPRESS", "EXTENDS", "EXTRACT", "EXTREME", "FABRICS", "FACTORS", "FACTORY", "FACULTY", "FAILING", "FAILURE", "FALLING", "FANTASY", "FARMERS", "FARMING", "FASHION", "FASTEST", "FATHERS", "FEATURE", "FEDERAL", "FEEDING", "FEELING", "FEMALES", "FERRARI", "FICTION", "FIFTEEN", "FIGHTER", "FIGURED", "FIGURES", "FILLING", "FILTERS", "FINALLY", "FINANCE", "FINDING", "FINDLAW", "FINGERS", "FINLAND", "FINNISH", "FIREFOX", "FISHING", "FISTING", "FITNESS", "FITTING", "FLIGHTS", "FLORIDA", "FLORIST", "FLOWERS", "FOCUSED", "FOCUSES", "FOLDERS", "FOLDING", "FOLLOWS", "FOOTAGE", "FOREIGN", "FORESTS", "FOREVER", "FORMATS", "FORMING", "FORMULA", "FORTUNE", "FORWARD", "FOUNDED", "FOUNDER", "FRAMING", "FRANCIS", "FREEBSD", "FREEDOM", "FREIGHT", "FRIENDS", "FUCKING", "FUJITSU", "FUNDING", "FUNERAL", "FURTHER", "FUTURES", "GABRIEL", "GADGETS", "GALLERY", "GARBAGE", "GARDENS", "GATEWAY", "GAZETTE", "GENERAL", "GENERIC", "GENESIS", "GENETIC", "GENUINE", "GEOLOGY", "GEORGIA", "GERMANY", "GETTING", "GILBERT", "GLASGOW", "GLASSES", "GLUCOSE", "GOURMET", "GRAMMAR", "GRANTED", "GRAPHIC", "GRATUIT", "GRAVITY", "GREATER", "GREATLY", "GREGORY", "GRENADA", "GRIFFIN", "GROCERY", "GROUNDS", "GROWING", "GUITARS", "HABITAT", "HALIFAX", "HAMBURG", "HAMPTON", "HANDJOB", "HANDLED", "HANDLES", "HANGING", "HAPPENS", "HARBOUR", "HARMFUL", "HARMONY", "HARVARD", "HARVEST", "HAZARDS", "HEADERS", "HEADING", "HEADSET", "HEALING", "HEALTHY", "HEARING", "HEATHER", "HEATING", "HEAVILY", "HEIGHTS", "HELPFUL", "HELPING", "HERSELF", "HEWLETT", "HIGHEST", "HIGHWAY", "HIMSELF", "HISTORY", "HITACHI", "HITTING", "HOBBIES", "HOLDERS", "HOLDING", "HOLIDAY", "HOLLAND", "HOPKINS", "HORIZON", "HORMONE", "HOSTELS", "HOSTING", "HOTMAIL", "HOTTEST", "HOUSING", "HOUSTON", "HOWEVER", "HUNDRED", "HUNGARY", "HUNTING", "HUSBAND", "HYGIENE", "HYUNDAI", "ICELAND", "IGNORED", "ILLEGAL", "ILLNESS", "IMAGINE", "IMAGING", "IMPACTS", "IMPLIED", "IMPLIES", "IMPORTS", "IMPOSED", "IMPROVE", "INCLUDE", "INDEXED", "INDEXES", "INDIANA", "INDIANS", "INDICES", "INDUCED", "INFANTS", "INITIAL", "INJURED", "INQUIRE", "INQUIRY", "INSECTS", "INSIDER", "INSIGHT", "INSTALL", "INSTANT", "INSTEAD", "INSULIN", "INSURED", "INTEGER", "INTENSE", "INTERIM", "INVALID", "INVITED", "INVOICE", "INVOLVE", "IRELAND", "ISLAMIC", "ISLANDS", "ISRAELI", "ITALIAN", "JACKETS", "JACKSON", "JAMAICA", "JANUARY", "JEFFREY", "JELSOFT", "JESSICA", "JEWELRY", "JOHNSON", "JOINING", "JOURNAL", "JOURNEY", "JUMPING", "JUSTICE", "JUSTIFY", "KARAOKE", "KATRINA", "KEEPING", "KENNEDY", "KENNETH", "KEYWORD", "KILLING", "KINGDOM", "KISSING", "KITCHEN", "KNIGHTS", "KNOWING", "LABELED", "LANDING", "LAPTOPS", "LARGELY", "LARGEST", "LASTING", "LATINAS", "LAUNDRY", "LAWSUIT", "LAWYERS", "LEADERS", "LEADING", "LEARNED", "LEASING", "LEATHER", "LEAVING", "LEBANON", "LECTURE", "LEGALLY", "LEGENDS", "LEISURE", "LENDERS", "LENDING", "LEONARD", "LESBIAN", "LESSONS", "LETTERS", "LETTING", "LEVITRA", "LEXMARK", "LIBERAL", "LIBERIA", "LIBERTY", "LIBRARY", "LICENCE", "LICENSE", "LICKING", "LIGHTER", "LIMITED", "LINCOLN", "LINDSAY", "LINKING", "LISTING", "LIVECAM", "LIVESEX", "LOADING", "LOCALLY", "LOCATED", "LOCATOR", "LOCKING", "LODGING", "LOGGING", "LOGICAL", "LONGEST", "LOOKING", "LOTTERY", "LUGGAGE", "MACHINE", "MADISON", "MADNESS", "MADONNA", "MAGICAL", "MAILING", "MAILMAN", "MANAGED", "MANAGER", "MANDATE", "MANUALS", "MAPPING", "MARILYN", "MARKERS", "MARKETS", "MARKING", "MARRIED", "MARTIAL", "MASSAGE", "MASSIVE", "MASTERS", "MATCHED", "MATCHES", "MATTERS", "MATTHEW", "MAXIMUM", "MEANING", "MEASURE", "MEDICAL", "MEDLINE", "MEETING", "MELISSA", "MEMBERS", "MEMPHIS", "MENTION", "MERCURY", "MESSAGE", "METHODS", "MEXICAN", "MICHAEL", "MIDWEST", "MILEAGE", "MILLION", "MINERAL", "MINIMAL", "MINIMUM", "MINOLTA", "MINUTES", "MIRACLE", "MIRRORS", "MISSILE", "MISSING", "MISSION", "MISTAKE", "MIXTURE", "MOBILES", "MODULAR", "MODULES", "MOLDOVA", "MOMENTS", "MONITOR", "MONSTER", "MONTANA", "MONTHLY", "MORNING", "MOROCCO", "MOTHERS", "MOUNTED", "MOZILLA", "MUSCLES", "MUSEUMS", "MUSICAL", "MUSLIMS", "MUSTANG", "MYANMAR", "MYSIMON", "MYSPACE", "MYSTERY", "NAMIBIA", "NATIONS", "NATURAL", "NAUGHTY", "NEAREST", "NEITHER", "NERVOUS", "NETWORK", "NEUTRAL", "NEWPORT", "NIAGARA", "NIGERIA", "NIPPLES", "NIRVANA", "NORFOLK", "NOTHING", "NOTICED", "NOTICES", "NOVELTY", "NOWHERE", "NUCLEAR", "NUMBERS", "NUMERIC", "NURSERY", "NURSING", "OAKLAND", "OBESITY", "OBJECTS", "OBSERVE", "OBVIOUS", "OCTOBER", "OFFENSE", "OFFERED", "OFFICER", "OFFICES", "OFFLINE", "OLYMPIC", "OLYMPUS", "ONGOING", "ONTARIO", "OPENING", "OPERATE", "OPINION", "OPPOSED", "OPTICAL", "OPTIMAL", "OPTIMUM", "OPTIONS", "ORDERED", "ORGANIC", "ORIGINS", "ORLANDO", "ORLEANS", "OUTCOME", "OUTDOOR", "OUTLETS", "OUTLINE", "OUTLOOK", "OUTPUTS", "OUTSIDE", "OVERALL", "PACIFIC", "PACKAGE", "PACKARD", "PACKETS", "PACKING", "PAINFUL", "PAINTED", "PANTIES", "PARENTS", "PARKING", "PARTIAL", "PARTIES", "PARTNER", "PASSAGE", "PASSING", "PASSION", "PASSIVE", "PATCHES", "PATENTS", "PATIENT", "PATRICK", "PATTERN", "PAYABLE", "PAYMENT", "PAYROLL", "PENALTY", "PENDANT", "PENDING", "PENGUIN", "PENSION", "PENTIUM", "PEOPLES", "PERCENT", "PERFECT", "PERFORM", "PERFUME", "PERHAPS", "PERIODS", "PERMITS", "PERSIAN", "PERSONS", "PHANTOM", "PHILIPS", "PHOENIX", "PHRASES", "PHYSICS", "PICKING", "PICTURE", "PIONEER", "PIRATES", "PISSING", "PLACING", "PLANETS", "PLANNED", "PLANNER", "PLASTIC", "PLAYBOY", "PLAYERS", "PLAYING", "PLEASED", "PLUGINS", "POCKETS", "PODCAST", "POINTED", "POINTER", "POKEMON", "POLYMER", "PONTIAC", "POPULAR", "PORSCHE", "PORTION", "POSSESS", "POSTAGE", "POSTERS", "POSTING", "POTTERY", "POULTRY", "POVERTY", "POWERED", "PRAIRIE", "PRAYERS", "PRECISE", "PREDICT", "PREFERS", "PREMIER", "PREMIUM", "PREPAID", "PREPARE", "PRESENT", "PRESSED", "PRESTON", "PREVENT", "PREVIEW", "PRICING", "PRIMARY", "PRINTED", "PRINTER", "PRIVACY", "PRIVATE", "PROBLEM", "PROCEED", "PROCESS", "PRODUCE", "PRODUCT", "PROFILE", "PROFITS", "PROGRAM", "PROJECT", "PROMISE", "PROMOTE", "PROPHET", "PROPOSE", "PROTECT", "PROTEIN", "PROTEST", "PROUDLY", "PROVIDE", "PUBLISH", "PULLING", "PURPOSE", "PURSUIT", "PUSHING", "PUTTING", "PUZZLES", "QUALIFY", "QUALITY", "QUANTUM", "QUARTER", "QUERIES", "QUICKLY", "QUIZZES", "RADICAL", "RAILWAY", "RAINBOW", "RAISING", "RALEIGH", "RANGERS", "RANGING", "RANKING", "RAPIDLY", "RATINGS", "RAYMOND", "REACHED", "REACHES", "READERS", "READILY", "READING", "REALITY", "REALIZE", "REALTOR", "REASONS", "REBATES", "REBECCA", "REBOUND", "RECEIPT", "RECEIVE", "RECIPES", "RECORDS", "RECOVER", "REDHEAD", "REDUCED", "REDUCES", "REFINED", "REFLECT", "REFORMS", "REFRESH", "REFUSED", "REGARDS", "REGIONS", "REGULAR", "RELATED", "RELATES", "RELEASE", "RELYING", "REMAINS", "REMARKS", "REMOVAL", "REMOVED", "RENEWAL", "RENTALS", "REPAIRS", "REPLACE", "REPLICA", "REPLIED", "REPLIES", "REPORTS", "REPRINT", "REQUEST", "REQUIRE", "RESERVE", "RESOLVE", "RESORTS", "RESPECT", "RESPOND", "RESTORE", "RESULTS", "RESUMES", "RETIRED", "RETREAT", "RETURNS", "REUNION", "REUTERS", "REVEALS", "REVENGE", "REVENUE", "REVERSE", "REVIEWS", "REVISED", "REWARDS", "RICHARD", "ROBERTS", "ROLLING", "ROMANCE", "ROMANIA", "ROUGHLY", "ROUTERS", "ROUTINE", "ROUTING", "ROYALTY", "RUNNING", "RUNTIME", "RUSSELL", "RUSSIAN", "SAILING", "SAMPLES", "SAMSUNG", "SATISFY", "SAVINGS", "SCANNED", "SCANNER", "SCHEMES", "SCHOLAR", "SCHOOLS", "SCIENCE", "SCORING", "SCRATCH", "SCREENS", "SCRIPTS", "SEAFOOD", "SEASONS", "SEATING", "SEATTLE", "SECONDS", "SECRETS", "SECTION", "SECTORS", "SECURED", "SEEKERS", "SEEKING", "SEGMENT", "SELLERS", "SELLING", "SEMINAR", "SENATOR", "SENDING", "SENEGAL", "SENIORS", "SENSORS", "SERIOUS", "SERVERS", "SERVICE", "SERVING", "SESSION", "SETTING", "SETTLED", "SEVENTH", "SEVERAL", "SHADOWS", "SHAKIRA", "SHANNON", "SHARING", "SHELTER", "SHEMALE", "SHERIFF", "SHERMAN", "SHIPPED", "SHOPPER", "SHORTER", "SHORTLY", "SHOWERS", "SHOWING", "SHUTTLE", "SIEMENS", "SIGNALS", "SIGNING", "SILENCE", "SILICON", "SIMILAR", "SIMPSON", "SINGING", "SINGLES", "SISTERS", "SITEMAP", "SITTING", "SKATING", "SKILLED", "SMALLER", "SMILIES", "SMOKING", "SOCIETY", "SOLARIS", "SOLDIER", "SOLOMON", "SOLVING", "SOMALIA", "SOMEHOW", "SOMEONE", "SOONEST", "SOURCES", "SPANISH", "SPATIAL", "SPEAKER", "SPECIAL", "SPECIES", "SPECIFY", "SPENCER", "SPIRITS", "SPONSOR", "SPRINGS", "SPYWARE", "STADIUM", "STANLEY", "STARTED", "STARTER", "STARTUP", "STATING", "STATION", "STATUTE", "STAYING", "STEPHEN", "STEVENS", "STEWART", "STICKER", "STOMACH", "STOPPED", "STORAGE", "STORIES", "STRANGE", "STREAMS", "STREETS", "STRETCH", "STRIKES", "STRINGS", "STRIPES", "STUDENT", "STUDIED", "STUDIES", "STUDIOS", "STUFFED", "STYLISH", "SUBJECT", "SUBLIME", "SUCCEED", "SUCCESS", "SUCKING", "SUGGEST", "SUICIDE", "SUMMARY", "SUNRISE", "SUPPORT", "SUPPOSE", "SUPREME", "SURFACE", "SURFING", "SURGEON", "SURGERY", "SURNAME", "SURPLUS", "SURVEYS", "SURVIVE", "SUSPECT", "SWEDISH", "SYMBOLS", "SYSTEMS", "TABLETS", "TACTICS", "TALKING", "TARGETS", "TEACHER", "TEACHES", "TEENAGE", "TELECOM", "TELLING", "TENSION", "TERRACE", "TERRAIN", "TESTING", "TEXTILE", "TEXTURE", "THEATER", "THEATRE", "THEOREM", "THERAPY", "THEREBY", "THEREOF", "THERMAL", "THOMSON", "THOUGHT", "THREADS", "THREATS", "THROUGH", "THUNDER", "TICKETS", "TIFFANY", "TIMOTHY", "TOBACCO", "TODDLER", "TONIGHT", "TOOLBAR", "TOOLBOX", "TOOLKIT", "TOPLESS", "TORONTO", "TORTURE", "TOSHIBA", "TOTALLY", "TOUCHED", "TOURING", "TOURISM", "TOURIST", "TOWARDS", "TRACKED", "TRACKER", "TRACTOR", "TRADING", "TRAFFIC", "TRAGEDY", "TRAILER", "TRAINED", "TRAINER", "TRANSIT", "TRAVELS", "TREATED", "TRIBUNE", "TRIBUTE", "TRIGGER", "TRINITY", "TRIUMPH", "TROUBLE", "TRUSTED", "TRUSTEE", "TSUNAMI", "TUESDAY", "TUITION", "TUNISIA", "TURKISH", "TURNING", "TWISTED", "TYPICAL", "UKRAINE", "UNIFIED", "UNIFORM", "UNKNOWN", "UNUSUAL", "UPDATED", "UPDATES", "UPGRADE", "UPSKIRT", "URUGUAY", "USUALLY", "UTILITY", "UTILIZE", "VACCINE", "VAMPIRE", "VANILLA", "VARIETY", "VARIOUS", "VARYING", "VATICAN", "VEHICLE", "VENDORS", "VENTURE", "VERIZON", "VERMONT", "VERSION", "VESSELS", "VETERAN", "VICTIMS", "VICTORY", "VIETNAM", "VIEWERS", "VIEWING", "VILLAGE", "VINCENT", "VINTAGE", "VIOLENT", "VIRTUAL", "VIRUSES", "VISIBLE", "VISITED", "VISITOR", "VITAMIN", "VOLTAGE", "VOLUMES", "WAITING", "WALKING", "WALLACE", "WANTING", "WARMING", "WARNING", "WARRANT", "WARRIOR", "WASHING", "WATCHED", "WATCHES", "WEAPONS", "WEARING", "WEATHER", "WEBCAMS", "WEBCAST", "WEBLOGS", "WEBPAGE", "WEBSITE", "WEBSTER", "WEDDING", "WEEKEND", "WEIGHTS", "WELCOME", "WELDING", "WELFARE", "WESTERN", "WHEREAS", "WHETHER", "WICHITA", "WILLIAM", "WILLING", "WINDOWS", "WINDSOR", "WINNERS", "WINNING", "WINSTON", "WISHING", "WITHOUT", "WITNESS", "WORKERS", "WORKING", "WORKOUT", "WORRIED", "WORSHIP", "WRAPPED", "WRITERS", "WRITING", "WRITTEN", "WYOMING", "YOUNGER", "ZEALAND"]

For 10 characters, you'd be able to detect:

["ABORIGINAL", "ABSOLUTELY", "ABSORPTION", "ACCEPTABLE", "ACCEPTANCE", "ACCESSIBLE", "ACCOMPLISH", "ACCORDANCE", "ACCOUNTING", "ACCREDITED", "ACCURATELY", "ACDBENTITY", "ACTIVATION", "ACTIVITIES", "ADAPTATION", "ADDITIONAL", "ADDRESSING", "ADJUSTABLE", "ADJUSTMENT", "ADMISSIONS", "ADOLESCENT", "ADVANTAGES", "ADVENTURES", "ADVERTISER", "AFFILIATED", "AFFILIATES", "AFFORDABLE", "AFTERWARDS", "AGGRESSIVE", "AGREEMENTS", "ALEXANDRIA", "ALGORITHMS", "ALLOCATION", "AMBASSADOR", "AMENDMENTS", "ANALYTICAL", "ANNOTATION", "ANTARCTICA", "ANTIBODIES", "APARTMENTS", "APPARENTLY", "APPEARANCE", "APPLIANCES", "APPLICABLE", "APPLICANTS", "APPRECIATE", "APPROACHES", "ARCHITECTS", "ARTIFICIAL", "ASSESSMENT", "ASSIGNMENT", "ASSISTANCE", "ASSOCIATED", "ASSOCIATES", "ASSUMPTION", "ATMOSPHERE", "ATTACHMENT", "ATTEMPTING", "ATTENDANCE", "ATTRACTION", "ATTRACTIVE", "ATTRIBUTES", "AUSTRALIAN", "AUTHORIZED", "AUTOMATION", "AUTOMOBILE", "AUTOMOTIVE", "AZERBAIJAN", "BACKGROUND", "BANGLADESH", "BANKRUPTCY", "BASKETBALL", "BEASTALITY", "BEHAVIORAL", "BENEFICIAL", "BESTIALITY", "BIOLOGICAL", "BIRMINGHAM", "BLACKBERRY", "BOUNDARIES", "BRITANNICA", "BURLINGTON", "BUSINESSES", "CALCULATED", "CALCULATOR", "CALIFORNIA", "CAMCORDERS", "CANDIDATES", "CAPABILITY", "CARTRIDGES", "CATEGORIES", "CHALLENGED", "CHALLENGES", "CHANCELLOR", "CHARACTERS", "CHARITABLE", "CHARLESTON", "CHRISTIANS", "CHRONICLES", "CIGARETTES", "CINCINNATI", "CITYSEARCH", "CLASSIFIED", "COLLEAGUES", "COLLECTING", "COLLECTION", "COLLECTIVE", "COLLECTORS", "COLUMNISTS", "COMMENTARY", "COMMERCIAL", "COMMISSION", "COMMITMENT", "COMMITTEES", "COMPARABLE", "COMPARISON", "COMPATIBLE", "COMPLAINTS", "COMPLEMENT", "COMPLETELY", "COMPLETING", "COMPLETION", "COMPLEXITY", "COMPLIANCE", "COMPONENTS", "COMPRESSED", "COMPROMISE", "CONCEPTUAL", "CONCERNING", "CONCLUSION", "CONDITIONS", "CONDUCTING", "CONFERENCE", "CONFIDENCE", "CONFIGURED", "CONNECTING", "CONNECTION", "CONNECTORS", "CONSIDERED", "CONSISTENT", "CONSISTING", "CONSORTIUM", "CONSPIRACY", "CONSTANTLY", "CONSTITUTE", "CONSTRAINT", "CONSULTANT", "CONSULTING", "CONTACTING", "CONTAINERS", "CONTAINING", "CONTINUING", "CONTINUITY", "CONTINUOUS", "CONTRACTOR", "CONTRIBUTE", "CONTROLLED", "CONTROLLER", "CONVENIENT", "CONVENTION", "CONVERSION", "CONVICTION", "COORDINATE", "COPYRIGHTS", "CORRECTION", "CORRUPTION", "COUNSELING", "CREATIVITY", "CUMULATIVE", "CURRENCIES", "CURRICULUM", "CUSTOMIZED", "DECORATING", "DECORATIVE", "DEFINITELY", "DEFINITION", "DELEGATION", "DELIVERING", "DEMOCRATIC", "DEPARTMENT", "DEPENDENCE", "DEPLOYMENT", "DEPRESSION", "DESCENDING", "DESCRIBING", "DESIGNATED", "DETERMINED", "DETERMINES", "DEVELOPERS", "DEVELOPING", "DIAGNOSTIC", "DICTIONARY", "DIFFERENCE", "DIFFICULTY", "DIMENSIONS", "DIRECTIONS", "DISABILITY", "DISCIPLINE", "DISCLAIMER", "DISCLOSURE", "DISCOUNTED", "DISCOVERED", "DISCRETION", "DISCUSSING", "DISCUSSION", "DISPATCHED", "DISPLAYING", "DISTRIBUTE", "DOCUMENTED", "DOWNLOADED", "EARTHQUAKE", "ECOLOGICAL", "EDITORIALS", "EFFICIENCY", "ELECTRICAL", "ELECTRONIC", "ELEMENTARY", "EMPLOYMENT", "ENCOURAGED", "ENCOURAGES", "ENCRYPTION", "ENDANGERED", "ENGAGEMENT", "ENROLLMENT", "ENTERPRISE", "EQUIVALENT", "ESPECIALLY", "ESSENTIALS", "ESTIMATION", "EVALUATING", "EVALUATION", "EVENTUALLY", "EVERYTHING", "EVERYWHERE", "EXCELLENCE", "EXCEPTIONS", "EXCITEMENT", "EXECUTIVES", "EXHIBITION", "EXPERIENCE", "EXPERIMENT", "EXPIRATION", "EXPLAINING", "EXPLICITLY", "EXPRESSION", "EXTENSIONS", "EXTRACTION", "FACILITATE", "FACILITIES", "FAVOURITES", "FEDERATION", "FELLOWSHIP", "FORMATTING", "FORWARDING", "FOUNDATION", "FRAGRANCES", "FREQUENTLY", "FRIENDSHIP", "FUNCTIONAL", "GENERATING", "GENERATION", "GENERATORS", "GEOGRAPHIC", "GEOLOGICAL", "GIRLFRIEND", "GOVERNANCE", "GOVERNMENT", "GRADUATION", "GREENHOUSE", "GREENSBORO", "GUARANTEED", "GUARANTEES", "GUIDELINES", "HARASSMENT", "HEADPHONES", "HEALTHCARE", "HELICOPTER", "HIGHLIGHTS", "HISTORICAL", "HORIZONTAL", "HOUSEHOLDS", "HOUSEWARES", "HOUSEWIVES", "HUMANITIES", "HUNTINGTON", "HYPOTHESIS", "IDENTIFIED", "IDENTIFIER", "IDENTIFIES", "IMMIGRANTS", "IMMUNOLOGY", "IMPORTANCE", "IMPOSSIBLE", "IMPRESSION", "IMPRESSIVE", "INCENTIVES", "INCOMPLETE", "INCREASING", "INCREDIBLE", "INDICATING", "INDICATION", "INDICATORS", "INDIGENOUS", "INDIVIDUAL", "INDONESIAN", "INDUSTRIAL", "INDUSTRIES", "INFECTIONS", "INFECTIOUS", "INFLUENCED", "INFLUENCES", "INITIATIVE", "INNOVATION", "INNOVATIVE", "INSPECTION", "INSTALLING", "INSTITUTES", "INSTRUCTOR", "INSTRUMENT", "INSULATION", "INTEGRATED", "INTERESTED", "INTERFACES", "INTERNSHIP", "INTERSTATE", "INTERVIEWS", "INTRODUCED", "INTRODUCES", "INVESTMENT", "INVITATION", "IRRIGATION", "JAVASCRIPT", "JOURNALISM", "JOURNALIST", "KAZAKHSTAN", "KILOMETERS", "LABORATORY", "LANDSCAPES", "LAUDERDALE", "LEADERSHIP", "LEGITIMATE", "LIKELIHOOD", "LIMITATION", "LIMOUSINES", "LITERATURE", "LITIGATION", "LOUISVILLE", "LUXEMBOURG", "MACROMEDIA", "MADAGASCAR", "MAINSTREAM", "MAINTAINED", "MANAGEMENT", "MANCHESTER", "MASTERCARD", "MEANINGFUL", "MECHANICAL", "MECHANISMS", "MEDICATION", "MEDITATION", "MEMBERSHIP", "METABOLISM", "MICROPHONE", "MILFHUNTER", "MILLENNIUM", "MINISTRIES", "MITSUBISHI", "MODERATORS", "MONITORING", "MONTGOMERY", "MOTIVATION", "MOTORCYCLE", "MOZAMBIQUE", "MULTIMEDIA", "MYSTERIOUS", "NATIONALLY", "NATIONWIDE", "NAVIGATION", "NETWORKING", "NEWSLETTER", "NEWSPAPERS", "NOMINATION", "NOTTINGHAM", "OBITUARIES", "OBJECTIVES", "OBLIGATION", "OCCASIONAL", "OCCUPATION", "OCCURRENCE", "OFFICIALLY", "OPERATIONS", "OPPOSITION", "ORGANIZING", "ORIGINALLY", "PAPERBACKS", "PARAGRAPHS", "PARAMETERS", "PARLIAMENT", "PARTICULAR", "PASSENGERS", "PERCENTAGE", "PERCEPTION", "PERFORMING", "PERIPHERAL", "PERMISSION", "PERSISTENT", "PERSONALLY", "PETERSBURG", "PHARMACIES", "PHENOMENON", "PHILOSOPHY", "PHOTOGRAPH", "PHYSICALLY", "PHYSICIANS", "PHYSIOLOGY", "PITTSBURGH", "POLYPHONIC", "POPULARITY", "POPULATION", "PORTSMOUTH", "PORTUGUESE", "POSSESSION", "POSTPOSTED", "POWERPOINT", "PREDICTION", "PREFERENCE", "PRESCRIBED", "PRESENTING", "PREVENTING", "PREVENTION", "PREVIOUSLY", "PRINCIPLES", "PRIORITIES", "PRIVILEGES", "PROCEDURES", "PROCEEDING", "PROCESSING", "PROCESSORS", "PRODUCTION", "PRODUCTIVE", "PROFESSION", "PROGRAMMER", "PROGRAMMES", "PROHIBITED", "PROJECTION", "PROJECTORS", "PROMOTIONS", "PROPERTIES", "PROPORTION", "PROTECTING", "PROTECTION", "PROTECTIVE", "PROVIDENCE", "PROVINCIAL", "PROVISIONS", "PSYCHIATRY", "PSYCHOLOGY", "PUBLISHERS", "PUBLISHING", "PUNISHMENT", "PURCHASING", "QUALIFYING", "QUANTITIES", "QUEENSLAND", "QUOTATIONS", "REASONABLE", "REASONABLY", "RECIPIENTS", "RECOGNISED", "RECOGNIZED", "RECOMMENDS", "RECORDINGS", "RECREATION", "RECRUITING", "REDUCTIONS", "REFERENCED", "REFERENCES", "REFLECTION", "REGARDLESS", "REGISTERED", "REGRESSION", "REGULATION", "REGULATORY", "RELATIVELY", "RELAXATION", "RELOCATION", "REMARKABLE", "REMEMBERED", "REPOSITORY", "REPRESENTS", "REPRODUCED", "REPUBLICAN", "REPUTATION", "REQUESTING", "RESEARCHER", "RESISTANCE", "RESOLUTION", "RESPECTIVE", "RESPONDENT", "RESPONDING", "RESTAURANT", "RESTRICTED", "RETIREMENT", "REVELATION", "REVOLUTION", "RICHARDSON", "SACRAMENTO", "SCHEDULING", "SCIENTIFIC", "SCIENTISTS", "SCREENSHOT", "SECURITIES", "SELECTIONS", "SEPARATELY", "SEPARATION", "SETTLEMENT", "SIGNATURES", "SIMPLIFIED", "SIMULATION", "SITUATIONS", "SOUNDTRACK", "SPECIALIST", "STATEMENTS", "STATIONERY", "STATISTICS", "STRATEGIES", "STRENGTHEN", "STRUCTURAL", "STRUCTURED", "STRUCTURES", "SUBJECTIVE", "SUBMISSION", "SUBMITTING", "SUBSCRIBER", "SUBSECTION", "SUBSEQUENT", "SUBSIDIARY", "SUBSTANCES", "SUBSTITUTE", "SUCCESSFUL", "SUFFICIENT", "SUGGESTING", "SUGGESTION", "SUNGLASSES", "SUPERVISOR", "SUPPLEMENT", "SUPPORTERS", "SUPPORTING", "SURPRISING", "SURROUNDED", "SUSPENSION", "SYSTEMATIC", "TECHNICIAN", "TECHNIQUES", "TECHNOLOGY", "TELEVISION", "TERRORISTS", "THEMSELVES", "THEREAFTER", "THOROUGHLY", "THREATENED", "THROUGHOUT", "THUMBNAILS", "THUMBZILLA", "TOURNAMENT", "TRACKBACKS", "TRADEMARKS", "TRADITIONS", "TRANSCRIPT", "TRANSEXUAL", "TRANSITION", "TRANSLATED", "TRANSLATOR", "TRAVELLING", "TREATMENTS", "TREMENDOUS", "ULTIMATELY", "UNDERLYING", "UNDERSTAND", "UNDERSTOOD", "UNDERTAKEN", "UNEXPECTED", "UNIVERSITY", "UZBEKISTAN", "VALIDATION", "VARIATIONS", "VEGETABLES", "VEGETARIAN", "VEGETATION", "VETERINARY", "VIETNAMESE", "VIOLATIONS", "VISIBILITY", "VOCABULARY", "VOCATIONAL", "VOLKSWAGEN", "VOLLEYBALL", "VOLUNTEERS", "VULNERABLE", "WALLPAPERS", "WARRANTIES", "WASHINGTON", "WATERPROOF", "WEBMASTERS", "WELLINGTON", "WIDESCREEN", "WIDESPREAD", "WILDERNESS", "WITHDRAWAL", "YUGOSLAVIA"]

It works for other lengths too, but I thought I'd specifically mention the ones within the spec that it will indeed work for. For example 227 results in:

["ABS", "BAR", "BBS", "CAP", "CAR", "CAS", "CBS"]

If the winner of this challenge is being chosen by shortest code, I can make this 140 bytes shorter if needed.


Generate lazy values Related: Program my microwave oven. Inspired by Generate lazy microwave input.

The lazy value of the non-negative integer N is the smallest of the integers that are closest to N while all their digits are identical.

Return (by any means) the lazy value of a given (by any means) N.

N ≤ the largest integer that your language represents in non-exponent form by default. 1000000 (A lot of interesting solutions are lost because of this too-high requirement.)

Test cases:

   0 →    0
   8 →    8
   9 →    9
  10 →    9
  16 →   11
  17 →   22
  27 →   22
  28 →   33
 100 →   99
 105 →   99
 106 →  111
 610 →  555
 611 →  666
7221 → 6666
7222 → 7777

The colleague in question proved that there will be no ties: Except for 9/11, 99/111, etc. for which one is shorter than the other, two consecutive valid answers are always an odd distance apart, so no integer can be exactly equidistant from them.

JavaScript (ES6), 31 bytes

n=>~-(n*9+4).toPrecision(1)/9|0

Directly computes the lazy value for each n.

Edit: Only works up to 277777778 due to the limitations of JavaScript's integer type. Alternative versions:

n=>((n*9+4).toPrecision(1)-1)/9>>>0

35 bytes, works up to 16666666667.

n=>((n=(n*9+4).toPrecision(1))-n[0])/9

38 bytes, works up to 944444444444443. But that's still some way short of 253 which is 9007199254740992.


Tips for golfing in Dart Dart is an object oriented programming language borrowing from both Java and Javascript. What general tips do you have for golfing in Dart? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Dart (e.g. "remove comments" is not an answer). Please post one tip per answer.

If a tip is similar to Java/JS, please link to the answer in the original language's thread as well if you can.

Taken mostly from Joey's Tips for Powershell

Variable declaration

Regular variable declaration takes 4 bytes (var) + 2 bytes/variable (i,).
You can declare variables as optional named parameters for your function and shave a few bytes.

f(){var i,j,k;} //Takes 15 bytes
g({i,j,k}){}  //Takes 12 bytes

Note: This doesn't work for non-constant values, for example:

f({i=List}){}  //Works
g({i=[]}){}  //Doesn't work

f({i=0,j=0}){}  //Works
g({i=0,j=i}){}  //Doesn't work


Rotate a diamond tiling Any regular hexagon can be tiled with diamonds, for instance like so (stolen from this question):

   ______
  /_/_/\_\
 /_/\_\/\_\
/\_\/_/\/_/\
\/_/\_\/_/\/
 \_\/_/\_\/
  \_\_\/_/

We'll consider the above a tiling of size 1 (since the diamonds' sides are made of one / or \ each). The same tiling of size 2 would look like:

      ____________
     /   /   /\   \
    /___/___/  \___\
   /   /\   \  /\   \
  /___/  \___\/  \___\
 /\   \  /   /\  /   /\
/  \___\/___/  \/___/  \
\  /   /\   \  /   /\  /
 \/___/  \___\/___/  \/
  \   \  /   /\   \  /
   \___\/___/  \___\/
    \   \   \  /   /
     \___\___\/___/

Your task is to rotate diamond tilings by a multiple of 60 degrees. The diamond tiling in the input can be in any size (and the size is not explicitly specified in the input). But it would always be a valid tiling, and all sides of the hexagon would have the same length.

These are the above examples rotated by 60 degrees clockwise:

   ______
  /_/\_\_\
 /\_\/_/\_\
/\/_/\_\/_/\
\/\_\/_/_/\/
 \/_/\_\_\/
  \_\/_/_/

      ____________
     /   /\   \   \
    /___/  \___\___\
   /\   \  /   /\   \
  /  \___\/___/  \___\
 /\  /   /\   \  /   /\
/  \/___/  \___\/___/  \
\  /\   \  /   /   /\  /
 \/  \___\/___/___/  \/
  \  /   /\   \   \  /
   \/___/  \___\___\/
    \   \  /   /   /
     \___\/___/___/

The input is a non-negative integer and a diamond tiling. Your program (or function) should rotate it by the integer * 60 degrees. You decide whether to rotate clockwise or counterclockwise, as long as it is consistent. Both the input and output shouldn't have extra leading or trailing spaces.

This is code-golf. Shortest code wins.

Related questions:

Rotate a Chinese checkerboard
Rotate a two-dimensional list by 45 degrees
Scale up a Diamond Tiling

JavaScript (ES6), 452 356 315 bytes

Where \n represents the literal newline character. Edit: Saved 96 bytes by realising that my algorithm doesn't need to know the number and size of diamonds separately, plus a few minor golfs that I missed the first time around. Saved 41 bytes by rearranging the code so that the destination was always the same pair of characters, plus a minor golf that I missed when converting to my previous algorithm.

r=
(s,n)=>(z=s.search`_`,l=(f,n=z*2+1)=>[...Array(n)].map(f),a=s.split`\n`,l(_=>(o=a.map(s=>[...s].fill` `),l((_,r)=>l((_,c)=>(d=z+c*2-r,a[s=z+r-c]&&(a[s][r+c]=='/'?o[r][d]=o[r][d+1]='_':0,a[s][r+c-1]=='\\'?o[r][d]='/':0),a[--s]&&(a[s][r+c]==`_`||a[s][r+c-1]==`_`?o[r][d+1]=`\\`:0)))),a=o.map(a=>a.join``)),n),a.join`\n`)
;

   ______
  /_/_/\_\
 /_/\_\/\_\
/\_\/_/\/_/\
\/_/\_\/_/\/
 \_\/_/\_\/
  \_\_\/_/

<input type=button value="Rotate!" onclick="i1.textContent = r(i1.textContent, 1)">

      ____________
     /   /   /\   \
    /___/___/  \___\
   /   /\   \  /\   \
  /___/  \___\/  \___\
 /\   \  /   /\  /   /\
/  \___\/___/  \/___/  \
\  /   /\   \  /   /\  /
 \/___/  \___\/___/  \/
  \   \  /   /\   \  /
   \___\/___/  \___\/
    \   \   \  /   /
     \___\___\/___/

<input type=button value="Rotate!" onclick="i2.textContent = r(i2.textContent, 1)">

Explanation: Considers each pair of output characters, which could be __, /_, _\, / or \, checking for the appropriate characters in the input which map to those output characters. Ungolfed:

function rotate(str, num) {
  // Measure the size using the indent of the _ in the first row.
  var size = str.indexOf('_');
  var arr = str.split('\n');
  while (num--) {
    // We build a character array to represent the output by turning the
    // input into a nested array and replacing everything with spaces.
    // Note that the output will have any trailing spaces from the input.
    var res = arr.map(s => Array.from(s).fill(' '));
    // Loop over a diamond that encloses the hexagon.
    for (var destrow = 0; destrow <= size * 2; destrow++) {
      for (var col = 0; col <= size * 2; col++) {
        var destcol = size + col * 2 - destrow;
        var srcrow = size + destrow - col;
        var srccol = destrow + col;
        // Map / to __, \ to / and __ to \.
        // We write __ first in case it gets overwritten by / or \.
        if (arr[srcrow]) {
          if (arr[srcrow][srccol] == '/') {
            res[destrow][destcol] = res[destrow][destcol + 1] = '_';
          }
          if (arr[srcrow][srccol - 1] == '\\') {
            res[destrow][destcol] = '/';
          }
        }
        // Need to check both positions in case one was overwritten.
        if (arr[srcrow - 1] &&
            (arr[srcrow - 1][srccol] == '_' || arr[srcrow - 1][srccol - 1] == '_')) {
          res[destrow][destcol + 1] = '\\';
        }
      }
    }
    arr = res.map(a => a.join(''));
  }
  return arr.join('\n');
}


Implement functional programming paradigms Your company is just getting started on a project, and for the first time you decided to go use a functional programming code-style. However your boss is really diffident and doesn't want to use built-in functions, and requires you to implement yourself the main functions. In particular you need to write the functions: Map, Nest, Apply, Range, Fold and Table in a language on your choice. The boss is a really busy man, and he wants to have the programs as short as possible, so he doesn't waste time reading. He also would like not for you to use loops, therefore you will have a 10% reduction on the byte count for not using loops.

The detailed requirements of the functions are below:

Map

The Map function takes two parameters: f and list where f is a function and list is a list of values. It should return the f applied to each element of list. Therefore it will work as such:

Map(f,{a,b,c})

returns

{ f(a), f(b), f(c) }

and

Map(f, {{a,b},{b,c}})

returns

{ f({a,b}), f({b,c})}

Nest

The Nest function takes three parameters as well: f, arg, times where f is a function, arg is its starting argument, and times is how many times the function is applied. It should return an expression with f applied times times to arg. Therefore it will work as such:

Nest(f, x, 3)

returns

f(f(f(x)))

and

Nest(f, {a,b}, 3)

returns

f(f(f({a,b})))

Apply

The Apply function takes two parameters: f and args where f is a function and args a list. It should apply f to the args. Therefore:

Apply(f, {a,b,c})

returns

f(a,b,c)

Range

The Range function takes one integerr and outputs the integers up to that number. Therefore:

Range(5)

returns

{ 1, 2, 3, 4, 5}

Fold

The Fold function takes three parameters f, arg, others where f is a function, arg is simple parameter, and others a list. It will work as such:

Fold(f, x, {a, b, c, d})

returns

f(f(f(f(x,a),b),c),d)

Table

The table functions should take a function f, and a parameter called iterator in the form: {iMin, iMax} where iMin and iMax are integers. You should apply f over the range specified. Therefore:

Table(f, {0, 5})

returns

{f(0), f(1), f(2), f(3), f(4), f(5)}

I've used the definition of these functions from the Mathematica functional programming page, so head there if you need any more guidance. Note that you will not need to implement all the version of the functions shown in that page, but only those written in this post.

Standard Loopholes are disallowed as usual.

In case your language does not allow functions to be passed as arguments, you need to implement this capability, and add it into your answer. However the byte-count of this operation will not be added to the total.

This is code golf so the shortest code wins. Good luck!!!

Haskell, many previous byte counts  127 * 0.9 = 114.3 bytes

f#(a:b)=f a:f#b;f#x=x
(f&x)0=x;(f&x)i=f$f&x$i-1
i=id
r x=i%(1,x)
(g?x)(a:b)=g(g?x$b)a;(g?x)y=x
f%(a,b)|a>b=[]|1<2=f a:f%(a+1,b)

No loops, just recursion.

# is map: (*2) # [1,2,3] -> [2,4,6]

& is nest: ((*2) & 3) 4 -> 48

i is apply: i (*2) 7 -> 14

r is range: r 4 -> [1,2,3,4]

? is fold: ((+) ? 0) [1,2,3,4] -> 10

% is table: (*2) % (2,4) -> [4,6,8]

As requested an ungolfed version with comments. Note, & and ? are ternary infix operators, which require additional parentheses when called or pattern matched.

f # (a:b) = f a : f#b        -- map on a list (a->head, b->tail) is f a in front of mapping f to b
f # x     = x                -- map on the empty list is the empty list
                             -- (non empty lists are caught in the line before)

(f & x) 0 = x                -- nesting zero times is x
(f & x) i = f $ f&x $ i-1    -- nesting i times is f (nesting one time less)

i=id                         -- apply in Haskell is just the identity function

r x = i % (1,x)              -- defined via the "table" of the identity function from 1 to x

(g ? x) (a:b) = g (g?x$b) a  -- folding g into a list (a->head, b->tail) is g applied to (folding g into b) and a
(g ? x) y     = x             -- folding the empty list is x
                             --  again, y must be the empty list, else it would have been handled by the previous line

f % (a,b)
  |a>b       = []                -- if iMin is greater than iMax, the table is empty
  |otherwise = f a : f%(a+1,b)   --  otherwise f a in front of the table with iMin increased by one

Thanks to @dfeuer and @Zgarb for some useful hints


Be as evil as possible Introduction

This is a follow-up of this challenge where you're taking the role of that person's evil twin. Being evil you don't want to maximize your share, but rather be as unfair as possible and you're not going to make it too obvious, that's why you came up with the following scheme:

You're going to tell the others that you want to be as fair as possible like your sibling and thus you're going to split the integer into pieces of equal length. So for each integer you will come up with the right amount of people such that the difference between the largest and the smallest piece is maximal.

For example if you're given the integer 6567 you could leave it as is, split it into two pieces 65,67 or four 6,5,6,7. This gives you the following maximal differences:

6567    -> max() = 0
65,67   -> max(|65-67|) = 2
6,5,6,7 -> max(|6-5|,|6-5|,|6-6|,|6-7|,|5-6|,|5-7|,|6-7|) = 2

Since you only want to be evil you don't prefer 67 over 7 and thus you will output either 2 or 4.

Another (less special case); given the integer 121131 you could split it like this:

121131      -> max() = 0
121,131     -> max(|121-131|) = 10
12,11,31    -> max(|12-11|,|12-31|,|11-31|) = 20
1,2,1,1,3,1 -> max(…) = 2

This time there's only one solution - namely 3 - since with three people the difference is maximal.

Challenge

Given an integer determine any possible way of being maximally evil and report the number of people needed to achieve this.

Rules

Input will always be ≥ 1
Input can be either an integer, list of digits or string
You don't have to handle invalid inputs

Testcases

You only need to report the resulting number of people needed, the possible partitions are only for illustration:

In -> splits (difference) -> Out
1 -> [1] (0) -> 1
10 -> [1,0] (1) -> 2
11 -> [11] or [1,1] (0) -> 1 or 2
12 -> [1,2] (1) -> 2
42 -> [4,2] (2) -> 2
101 -> [1,0,1] (1) -> 3
2222 -> [2222] or [22,22] or [2,2,2,2] (0) -> 1 or 2 or 4
6567 -> [65,67] or [6,5,6,7] (2) -> 2 or 4
123000 -> [123,000] (123) -> 2
123001 -> [123,001] (122) -> 2
121131 -> [12,11,31] (20) -> 3
294884 -> [294,884] (590) -> 2
192884729 -> [192,884,729] (692) -> 3
123456189012 -> [123456,189012] (65556) -> 2
123457117346 -> [1234,5711,7346] (6112) -> 3

Jelly,  16  14 bytes

Ṁ_Ṃ
sLÆD$ḌÇÞṪL

A monadic link taking a list of integers (the digits) and returning an integer.

Try it online! or see a test-suite

How?

Ṁ_Ṃ - Link 1, maximal difference: list of numbers
Ṁ   - maximum
  Ṃ - minimum
 _  - subtract

sLÆD$ḌÇÞṪL - Main link: list of numbers, theDigits  e.g. [1,2,3,0,0,1]
    $      - last two links as a monad:
 L         -   length                                    6
  ÆD       -   divisors                                  [1,2,3,6]
s          - split into chunks (vectorises)              [[[1],[2],[3],[0],[0],[1]],[[1,2],[3,0],[0,1]],[[1,2,3],[0,0,1]],[[1,2,3,0,0,1]]]
     Ḍ     - from decimal (vectorises)                   [[1,2,3,0,0,1],[12,30,1],[123,1],[123001]]
       Þ   - sort by:
      Ç    -   call last link (1) as a monad              3             29        122     0
           -                                         ... [[123001],[1,2,3,0,0,1],[12,30,1],[123,1]]
        Ṫ  - tail                                        [123,1]
         L - length                                      2


Efficient table-lookup computation The challenge: compute the day of the week from a MM-DD representation of a day in this year (2021).
However, you have to write your program in the following subset of Python: (I chose Python because it's popular and easy to understand even to the people who doesn't know the language. Obviously you can use another program in another language to generate the program, and you're encouraged to post the source code of that program)
# This is the input. For example this represents the date 2021-01-28.
m1 = "0"
m2 = "1"
d1 = "2"
d2 = "8"

T = {
# `T` is a dict
# * each key must be a string of digits [0-9]
# * each value must be a single digit.
"1234": "1",
"5678": "2",
}

# The main program code.
# Each line must have the format:
# <variable_name> = T[<string formed by concatenating string literals or other variables>]
# Example:
variable_1 = T["12" + m1 + "3" + "4"]
output = T[variable_1]

# This must be exactly one `print` statement like this at the end of the program
print(output)

Background: This is basically the only way Preproc (the C/C++ preprocessor) can parse tokens. See how Boost's BOOST_PP_INC_I macro is implemented.
More info:

You can (and should!) submit multiple programs in one answer if the method that you use to generate these programs are similar.
You can reassign variables, but doing that will not make your score better (than labeling each usage of the variables a_1, a_2, a_3, ....
To be clear (this is implied by the rules), you're not allowed to do x = "0" or x = y + z; only x = T[...] is allowed.
The output should be 0 if the day is Monday, 1 if the day is Tuesday, ..., 6 if the day is Sunday.
The program must not raise an error given valid input data.

Winning criteria
Let A about the number of entries in the dict T, and B be the number of assignment instructions (excluding the input assignment instructions to m1, m2, d1, d2 but including the final assignment to output).
You should minimize both A and B.
Note that you can make the length of the keys of the dict T arbitrarily long and it doesn't make the score worse; however it doesn't make the score better either.
Because there isn't a consensus on whether it's allowed to have 2 separate winning criteria, the method to calculate the score is described in this meta answer ("Solution 2"), with the board size 10000 10000. -- For example, if you have a program with A=100 and B=100, enter into the input of the score calculation program
10000 10000
100 100

and the calculated result is 1970199.
Recommended header format
## Score: (5, 1), (4, 2), (3, 3) -> 999, Combined score: 999, Combined score improvement: 99

Score: The (A, B) parameters of your generated program(s), and (optionally) the computed score of all your generated programs.
Combined score: the computed score of all the generated programs of the whole community (all answers posted so far)  (you can easily calculate the "combined score" by taking the most recent/best combined score answer, then modify the score-list to add your program's scores. Also you should add a link to the score calculation program with your generated programs' scores as input)
Combined score improvement: the difference between the most-recent computed score and the current combined score.

This is not a requirement, but just in case someone want to write a visualization/leaderboard script. (I intend to have it like this)
Table of all values
Program to verify submissions
Note that this program does not verify that the provided program is inside the subset, only if the output is valid.


Jelly, 8 bytes

ŒPIE$ÐfṪ

Try it online! or verify all test cases.

How it works

ŒPIE$ÐfṪ  Main link. Argument: A (list of integers)

ŒP        Powerset; generate all sublists of A, sorted by length.
     Ðf   Filter the powerset by the link to the left:
    $       Combine the two atoms to the left into a monadic link.
  I           Compute all increments.
   E          Test whether they're all equal.
          This returns all arithmetic subsequences, sorted by length.
       Ṫ  Tail; extract the last sequence.


Function clipboard: copy This challenge is related to some of the MATL language's features, as part of the May 2018 Language of the Month event. Associated challenge: Function clipboard: paste.

Introduction

MATL has several clipboards, where  you can store values (copy) to be retrieved later (paste). Some clipboards are automatic, which means that copying is automatically triggered by certain events. This challenge focuses on one of the automatic clipbards, called the function-input clipboard, or simply function clipboard.

This clipboard stores the inputs to the four most recent calls to normal, input-taking functions. Normal functions are the most common type of functions in MATL. Input-taking means that the function takes at least one input (functions that do not take any input are not considered by the function clipboard).

This is best explained with the following examples, which use two normal functions:

+, which pops two numbers from the stack and pushes their sum.
U, which pops one number and pushes its square.

Example 1:

3 2 + 6 + 12 4 U + +

produces the result 39. The code is interpreted as follows:

Number literals such as 3 or 12 get pushed to the stack
Functions such as + pop their inputs and push their outputs to the stack.

The function calls, in chronological order, are:

3 2 + gives 5
5 6 + gives 11
4 U gives 16
12 16 + 28
11 28 + gives 39.

The clipboard can be viewed as a list of four lists. Each inner list contains the inputs to a function call, with most recent calls first. Within each inner list, inputs are in their original order.

So after running the code the clipboard contents are (in Python notation):

[[11, 28], [12, 16], [4], [5, 6]]

Example 2:

10 20 U 30 +

leaves numbers 10 and 430 on the stack. The stack is displayed bottom to top at the end of the program.

The function calls are

20 U gives 400
400 30 + gives 430

Since there have been only two function calls, some of the inner lists defining the clipboard will be empty. Note also how 10 is not used as input to any function.

Thus, the clipboard contents after running the code are:

[[400, 30], [20], [], []]

Example 3 (invalid):

10 20 + +

is considered invalid, because an input to the second + is missing (in MATL this would implicitly trigger user input).

The challenge

Input: a string S with number literals, + and U, separated by spaces.

Output: the contents of the function clipboard after evaluating the string S.

Clarifications:

You may use any two consistent symbols to represent those functions, other than digits. Also, you can use any consistent symbol as separator, instead of space.
Only the two indicated functions will be considered.
The input string will contain at least one number literal and at least one function.
All numbers will be positive integers, possibly with more than one digit.
It is possible that some number literals are not used by any function, as in the example 2.
The input is guaranteed to be valid code, without requiring additional numbers. So a string as in example 3 will never occur.
Trailing empty inner lists in the output can be ommited. So the result in example 2 can be [[400, 30], [20]]
Any reasonable, unambiguous output format is acceptable. For example, a string with comma as inner separator and semicolon as outer separator: 400,30;20;;.

Additional rules:

Input and output can be taken by any reasonable means.
Programs or functions are allowed, in any programming language. Standard loopholes are forbidden.
Shortest code in bytes wins.

Test cases

Input
Output

3 2 + 6 + 12 4 U + +
[[11, 28], [12, 16], [4], [5, 6]]

15 3 4 + 2 U 8 + U +
[[7, 144], [12], [4, 8], [2]]

3 6 9 12 + + 10 8 U 6
[[8], [6, 21], [9, 12], []]

8 41 12 25 4 5 33 7 9 10 + + + + + + + +
[[41, 105], [12, 93], [25, 68], [4, 64]]

10 1 1 + U U U U U
[[65536], [256], [16], [4]]

Bash, 43 bytes

sed s/+/rdnFPrp+/g\;s/U/p2^/g|dc|tac|sed 4q

Try it online!
This prints the clipboard in the following format, note the usage of \x0F as the separator.
item_1\x0Fitem_2
item_3
.
.
item_m\x0Fitem_n

The key idea is to pass this into dc, a stack-based language, such that the required stack items will be printed.
The input is piped to sed where every + is replaced with rdnFPrp+, which in dc prints the second number on the stack followed by \x0F and then the top number before performing addition. sed also replaces every U with p2^, print the top stack element and square it.

The first substitution command s replaces all, as is denoted by the global flag g, +s with rdnFPrp+. In dc, r swaps the top two stack items, d duplicates the top item, n prints it without a newline, F pushes 15 onto the stack and P prints it as a character (which is the delimiter), r swaps again, p prints the top stack item and then + performs addition on the top two stack items.
We have another command, and in sed, commands are separated by either semicolons or newlines, of which the first option is chosen. Simply having ; will make bash interpret that as the end of the sed command, so it is escaped with a \.
In the last substitution command, U is replaced globally with p2^. In dc, p prints, and 2^ raises it to the second power.

The result of sed is eval'ed as dc code, printing the entire clipboard.

The pipe to dc makes dc interpret that as dc code. Now, the most recent calls are at the bottom and the older ones at the top.

Since the lines are in reverse order, tac (reverse cat) is used to fix that.
And finally, sed picks the first 4 lines from tac.

This is a shorter way of doing head -4. sed performs the commands to every line of the input one at a time. If there are no commands, nothing is done to the input, and it is returned as it is. 4q tells sed to perform the command q on line 4. When sed is processing line 4 of the input, the first three inputs have already been printed. The command q quits the program, so it prints the fourth line and quits, thus performing the equivalent of head -4.


Almost a Columbo episode Your task is to find two missing characters in a Columbo episode title.

Input

One of the 69 Columbo episode titles (as listed below), with exactly two characters replaced with *.

Example:

"Ran*om for a *ead Man"

Output

You may either return the full episode title, or just the two missing characters in any reasonable format, provided that the order of the characters is unambiguous.

Some valid outputs:

"Ransom for a Dead Man"
"sD"
["s", "D"]

Episodes

Please follow this link to get the unformatted list.

Prescription: Murder        Swan Song                             Murder, Smoke and Shadows
Ransom for a Dead Man       A Friend in Deed                      Sex and the Married Detective
Murder by the Book          An Exercise in Fatality               Grand Deceptions
Death Lends a Hand          Negative Reaction                     Murder: A Self Portrait
Dead Weight                 By Dawn's Early Light                 Columbo Cries Wolf
Suitable for Framing        Troubled Waters                       Agenda for Murder
Lady in Waiting             Playback                              Rest in Peace, Mrs. Columbo
Short Fuse                  A Deadly State of Mind                Uneasy Lies the Crown
Blueprint for Murder        Forgotten Lady                        Murder in Malibu
Etude in Black              A Case of Immunity                    Columbo Goes to College
The Greenhouse Jungle       Identity Crisis                       Caution: Murder Can Be Hazardous to Your Health
The Most Crucial Game       A Matter of Honor                     Columbo and the Murder of a Rock Star
Dagger of the Mind          Now You See Him...                    Death Hits the Jackpot
Requiem for a Falling Star  Last Salute to the Commodore          No Time to Die
A Stitch in Crime           Fade in to Murder                     A Bird in the Hand...
The Most Dangerous Match    Old Fashioned Murder                  It's All in the Game
Double Shock                The Bye-Bye Sky High IQ Murder Case   Butterfly in Shades of Grey
Lovely But Lethal           Try and Catch Me                      Undercover
Any Old Port in a Storm     Murder Under Glass                    Strange Bedfellows
Candidate for Crime         Make Me a Perfect Murder              A Trace of Murder
Double Exposure             How to Dial a Murder                  Ashes to Ashes
Publish or Perish           The Conspirators                      Murder With Too Many Notes
Mind Over Mayhem            Columbo Goes to the Guillotine        Columbo Likes the Nightlife

Clarifications and rules

Storing the list of episodes (or storing enough information to guess the missing characters) is part of the challenge. In other words, you don't get the list 'for free'. If using external files, their lengths must be added to your byte count.
Your program/function must support the titles exactly as listed above:

The case of each letter must match exactly.
The punctuation must also match exactly.
Etc...

All characters in the title may be replaced with *, not just letters. They might be contiguous.
You may expect another 'blank' character instead of *, as long as it does not appear anywhere in any title. (If so, please mention it in your answer.)

Ah, there's just one more thing. I almost forgot...

This is code-golf, so the shortest answer in bytes wins!

Test set

Here is a link to all 14252 possible inputs.

Stax, 294 bytes

ê(·▲[*▬è0↑u■<pá{∞♫┼¢]$Fò╦7τ}αzoN≡ù÷♥R♪♪éé#Ä↑♂¼y>Φp←E├Tì·æ≈ßÿOÄ╩%▼Åp}∞½É÷_~ï♦♪s○╨5╓ok½♪◄}§3vimεå╩p"G4ƒs┬]K╡àbá•Ä◄E°µte\τ╚¥∞LH¥êoc▐I/♥∞íJ{σ↓⌠╢§♥]8<µ6ε∩╠ån¥←A↨⌡↨▼♠áiåcTε╛ëJv⌡♂'┬û▒╟_E2↑☺│╚ê£-vç╘▬╒ì)#Φ¼∟æ∟q⌐▀☻7w_ì~Δc'Ω∙j≡┼Γó2"äV√n◘j≤╦╓ΘiL.,▲♂▌▼∞ccñó╘î←iaΩï)NCøAP┼b_ε☺Cam╥~αDM↕Aä<₧¿é■N/╞τQ╠Γù>b^S>◘á↑

Run and debug it

Here's the approach:

Consider each possible substitution of characters for asterisks.  I'm using upper and lower-case letters, plus the handful of punctuation marks.
Interpret each candidate as a base-91 integer.  Why 91?  It covers the span of possible characters in the input, it's prime, and it's 2 digits.  It just seems good.  I don't know if it's optimal.
Modulus by a carefully chosen denominator. (359473561)  Then check for a the existence of the result in the embedded hash array.  If there's a match, that's the correct substitution.

In order to verify that no incorrect result would be produced, I used a C# program to verify the output for all possible inputs.  It's not very portable, and it's quite long running.  I've been letting it search for more than 24 hours for candidate denominators so far, so it's not really suitable for TIO.  I'm running it in LINQPad.

const string AllChars = " ',-.:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
const int Base = 91;
const int InputCount = 14252;

void Main() {
    string filename = Path.Combine(Path.GetDirectoryName(Util.CurrentQueryPath), "titles.txt");
    var titles = File.ReadAllLines(filename);
    Console.WriteLine("Original titles: {0}", titles.Length);
    Console.WriteLine("All characters: {0}", AllChars.Length);

    var originalHashes = titles.Select(Hash).ToArray().Dump("Original hashes");

    BigInteger candidateMod = 359473561; //BigInteger.One * InputCount * AllChars.Length * AllChars.Length * titles.Length;
    BigInteger? bestMod = null;
    BigInteger failJump = 1;

    var candidateContainer = new DumpContainer(candidateMod).Dump("Candidate");
    var bestContainer = new DumpContainer(bestMod).Dump("Best");
    var rateContainer = new DumpContainer().Dump("Candidates / s");

    int tested = 0;
    var sw = Stopwatch.StartNew();

    while (true) {
        bool success = TestCandidateMod(candidateMod, titles, originalHashes);
        if (success) {
            bestContainer.Content = bestMod = BigInteger.Min(bestMod ?? candidateMod, candidateMod);
            candidateMod = candidateMod * 99 / 100; // reduce by 1%;
        }
        rateContainer.Content = ++tested * 1e3 / sw.ElapsedMilliseconds;
        candidateContainer.Content = --candidateMod;
    }
}

bool TestCandidateMod(BigInteger candidateMod, string[] titles, BigInteger[] originalHashes) {
    var moddedHashes = new HashSet<BigInteger>(originalHashes.Select(h => h % candidateMod));

    bool TitleIsOk(string title) {
        BigInteger originalHash = Hash(title);
        for (int i1 = 0; i1 < title.Length - 1; i1++) {
            BigInteger placeValue1 = BigInteger.Pow(Base, title.Length - i1 - 1);
            foreach (var c1 in AllChars) {
                int offset1 = c1 - title[i1];
                BigInteger hash1 = originalHash + placeValue1 * offset1;
                for (int i2 = i1 + 1; i2 < title.Length; i2++) {
                    BigInteger placeValue2 = BigInteger.Pow(Base, title.Length - i2 - 1);
                    foreach (var c2 in AllChars) {
                        int offset2 = c2 - title[i2];
                        if (offset1 == 0 && offset2 == 0) continue;

                        BigInteger hash2 = hash1 + placeValue2 * offset2;
                        if (moddedHashes.Contains(hash2 % candidateMod)) {
                            return false;
                        }
                    }
                }
            }
        }
        return true;
    }

    return titles.AsParallel().AsUnordered().All(TitleIsOk);
}

BigInteger Hash(string title) => title.Aggregate(BigInteger.Zero, (a, b) => a * Base + b);

Another note about the storage of the embedded hash values in the program.  The hashes are sorted prior to embedding in the array.  I'm using a stax feature called "crammed integer arrays" which is a way of efficiently representing integer arrays.  This representation is able to store differences between elements if that's more efficient, so pre-sorting the values saves some bytes.

Here's the unpacked representation with some minimal comments.

Vl" ',-.:"+:2   all pairs of replacement characters
f   filter
 ;'*/s\$1T  do replacement
 91|E   base-91 digits
 359473561% mod by denominator
 ">m\zR^ehBT}/!P*Nv:0N?s}FGN\:M.RT0r2VVm560$k;!yP<I*&R0_&q6wEcg8)&DsZ_!}&}Y&:Ngv&B::n!g6y &&eej...Z-&J..7!Rso36>y89:*iA*eNHGBmZ5!kiZ5*D(};*Xgkvwqn^(g?!kJib&g$ep!aDaA!Xw$_!w,2E.6NFG6DPat&(u4?28BIRu<bBL\S!ugPf!Ry;&T0\/^y\S{gu;!\0spo!^3!}X0l!i$L5&Z8@|!X4}p.LyU:X2M&PR6Y!k*,[F(&v&(ZJ5Jo0d!RN!hsDFvV.kI*{u@_!a<oGoqsG2}XhJ:2,"!
 #  count occurrences in crammed array


Transform number into 7-segment display pattern Given two arbitrary numbers A,B. Print number B as a Digital LED Pattern where A is the scale.

input:

1 2320451640799518

ouput:

 _  _  _  _     _     _     _  _  _  _  _     _
 _| _| _|| ||_||_   ||_ |_|| |  ||_||_||_   ||_|
|_  _||_ |_|  | _|  ||_|  ||_|  |  |  | _|  ||_|

input:

2 23

ouput:

 __  __
   |   |
 __| __|
|      |
|__  __|

Rules:

Use STDIN/STDOUT for input/output
Code with most up-votes wins. In case of Tie, shortest code will be accepted
Most up voted Answer will be accepted at 01/02/2014 (Accepted this answer with highest 12 votes)

Commodore 64 BASIC

PETSCII art rules :)

Output:


Find the inverse of a 3 by 3 matrix Challenge

Given nine numbers, a, b, c, d, e, f, g, h, i, as input which correspond to the square matrix:

$$\mathbf{M} = \begin{pmatrix}a& b& c\\ d& e& f\\ g& h& i\end{pmatrix}$$

Find the inverse of the matrix, \$\mathbf{M}^{-1}\$ and output its components.

Inverse Matrix

The inverse of a matrix 3 by 3 obeys the following equation:

$$\mathbf{MM}^{-1} = \mathbf{M}^{-1}\mathbf{M} = \mathbf{I} = \begin{pmatrix}1&0&0\\0&1&0\\0&0&1\end{pmatrix}$$

And can be calculated as:

$$\mathbf{M}^{-1} = \frac{1}{\det(\mathbf{M})}\mathbf{C}^T$$

Where \$\mathbf{C}\$ is the matrix of cofactors:

$$\mathbf{C}=\begin{pmatrix}ei-fh&fg-di&dh-eg\\ch-bi&ai-cg&bg-ah\\bf-ce&cd-af&ae-bd\end{pmatrix}$$

And \$\mathbf{C}^T\$ is the transpose of \$\mathbf{C}\$:

$$\mathbf{C}^T = \begin{pmatrix}ei-fh&ch-bi&bf-ce\\fg-di&ai-cg&cd-af\\dh-eg&bg-ah&ae-bd\end{pmatrix}$$

And \$\det(\mathbf{M})\$ is the determinant of \$\mathbf{M}\$:

$$\det(\mathbf{M}) = a(ei-fh)-b(di-fg)+c(dh-eg)$$

Worked Example

For example, let's say the input is 0, -3, -2, 1, -4, -2, -3, 4, 1. This corresponds to the matrix:

$$\mathbf{M} = \begin{pmatrix}0&-3&-2\\1&-4&-2\\-3&4&1\end{pmatrix}$$

Firstly, let's calculate what's known as the determinant using the formula above:

$$\det(\mathbf{M}) = 0(-4\times1-(-2)\times4) - (-3)(1\times1-(-2)\times-3) + (-2)(1\times4-(-4)\times-3) = 1$$

Next let's calculate the matrix of cofactors:

$$\mathbf{C} = \begin{pmatrix}-4\times1-(-2)\times4& -(1\times1-(-2)\times-3)&1\times4-(-4)\times-3\\-(-3\times1-(-2)\times4)&0\times1-(-2)\times-3&-(0\times4-(-3)\times-3)\\-3\times-2-(-2)\times-4&-(0\times-2-(-2)\times1)&0\times-4-(-3)\times1\end{pmatrix}$$

$$= \begin{pmatrix}4&5&-8\\-5&-6&9\\-2&-2&3\end{pmatrix}$$

We then need to transpose \$\mathbf{C}\$ (flip the rows and columns) to get \$\mathbf{C}^T\$:

$$\mathbf{C}^T = \begin{pmatrix}4&-5&2\\5&-6&-2\\-8&9&3\end{pmatrix}$$

Finally, we can find the inverse as:

$$\mathbf{M}^{-1} = \frac{1}{\det(\mathbf{M})}\mathbf{C}^T = \frac{1}{1}\begin{pmatrix}4&-5&2\\5&-6&-2\\-8&9&3\end{pmatrix}=\begin{pmatrix}4&-5&2\\5&-6&-2\\-8&9&3\end{pmatrix}$$

So the output would be 4, -5, -2, 5, -6, -2, -8, 9, 3.

Rules

The given matrix will always have an inverse (i.e. non-singular). The matrix may be self-inverse
The given matrix will always be a 3 by 3 matrix with 9 integers
The numbers in the input will always be integers in the range \$-1000 \leq n \leq 1000\$
Non-integer components of the matrix may be given as a decimal or a fraction

Examples

Input > Output
1, 0, 0, 0, 1, 0, 0, 0, 1 > 1, 0, 0, 0, 1, 0, 0, 0, 1
0, -3, -2, 1, -4, -2, -3, 4, 1 > 4, -5, -2, 5, -6, -2, -8, 9, 3
1, 2, 3, 3, 1, 2, 2, 1, 3 > -1/6, 1/2, -1/6, 5/6, 1/2, -7/6, -1/6, -1/2, 5/6
7, 9, 4, 2, 7, 9, 3, 4, 5 > -1/94, -29/94, 53/94, 17/94, 23/94, -55/94, -13/94, -1/94, 31/94

Winning

The shortest code in bytes wins.

MATL, 54 bytes

th3LZ)t,3:q&XdpswP]w-lw/GtY*tXdsGXdsUw-IXy*2/+GtXds*-*

Try it online!

Just to keep it interesting, doesn't use the inbuilt matrix division or determinant functions to do it.

Instead, computes the determinant using the Rule of Sarrus.

And the adjugate (transposed cofactor matrix) using Cayley–Hamilton formula.

$$ {\displaystyle \operatorname {adj} (\mathbf {A} )={\frac {1}{2}}\left((\operatorname {tr} \mathbf {A} )^{2}-\operatorname {tr} \mathbf {A} ^{2}\right)\mathbf {I} _{3}-\mathbf {A} \operatorname {tr} \mathbf {A} +\mathbf {A} ^{2}.} $$

Commented code:

% Finding determinant
th    % concatenate the matrix to itself sideways
3LZ)  % chop off the last column (since the Rule of Sarrus doesn't need it)
t     % duplicate this matrix (say S)
,     % do this twice:
  3:q&Xd  % get the first three diagonals of S
  ps      % multiply each diagonal's values and add the results
  wP      % switch and flip the matrix (to get the popposing diagonals next time)
]w    % close loop, switch to have correct order of sums
-     % subtract - we now have the determinant
lw/   % invert that

% Finding adjugate using Cayley–Hamilton formula
GtY*  % A^2 term (last term of the formula)
tXds  % trace(A^2) for term 1 of formula
GXdsU % (trace(A))^2 for term1 of formula
w-    % (trace(A))^2 - trace(A^2)
IXy*  % multiply that by the identity matrix
2/    % divide that by 2 - term 1 complete
+
GtXds* % A*trA for term 2 of formula
-      % subtract to get adj(A)

*      % multiply by the inverse of determinant we found earlier
       % implicit output

We could go even more insane purer by replacing the matrix multiplication GtY* done for \$ A^2 \$, with something like 3:"Gt!@qYS*!s] 3$v t&v 3:K-&Xd (Try it on MATL Online).

The more direct and obvious way:

4 bytes

-1Y^

Try it online!

(-1 byte thanks to @Luis Mendo.)

-1 - Push the literal -1

Y^ - Raise input to that power (implicit input, implicit output)


Implement swap encoding Swap encoding is an encoding method where you iterate through a string, reversing sections of it between pairs of identical characters.
The basic algorithm
For each character in the string:
Check: Does the string contain the character again, after the instance you found?
If so, then modify the string by reversing the section between the character and the next instance, inclusive.
Otherwise do nothing.
Example
Start with the string 'eat potatoes'.
e is found again, so reverse that section: eotatop taes
o is found again, so reverse that section (doing nothing as it is palindromic)
t is found again, so reverse that section (doing nothing as it is palindromic)
a is found again, so reverse that section: eotat potaes
t is found again, so reverse that section: eotatop taes
None of 'op taes' are found again, so eotatop taes is our final string!
Your challenge
Your challenge is to make a program or function that takes a string as input and returns it encoded as above. Capital letters and lowercase letters are treated as different, and all characters, including spaces, can be swapped.
Testcases
Sandbox for Proposed Challenges => SahC Pr foropox dbosenallednges
Collatz, Sort, Repeat => CoS ,ztrollaepeR ,tat
Write a fast-growing assembly function => Wrgnufa ylbme asa f g-tesstcnoritiwoin
Decompress a Sparse Matrix => Dera aM ssrtapmocese Sprix
Rob the King: Hexagonal Mazes => Rog: Kinob eH lagnaM thezaxes
Determine if a dot(comma) program halts => Detoc(tlamarommi finerp ha mrgod a) ets
Closest Binary Fraction => CloinosestiB Fry tcaran
Quote a rational number => Qunatebmuoiton re al ar
Solve the Alien Probe puzzle => SorP Alveht en eilzzup elobe

Yes I just took the titles of various sandboxed challenges for the testcases.
My reference implementation is available here if anyone wants it.
This is actually an encoding as reverse(swap(reverse(string))) decodes it.

JavaScript (ES6), 67 bytes

f=([c,...a])=>c?c+f([...a.splice(0,a.indexOf(c)).reverse(),...a]):a

Try it online!
How?
a.splice(0, n) removes and returns the first \$n\$ entries in a[] if \$n\ge1\$ or removes nothing and returns an empty array if \$n<1\$. If c is not found in a[], a.indexOf(c) returns \$-1\$ and we just pass a[] unchanged to the next iteration.


Legalize Reversed Date Input:

A Date (containing dd, MM and yyyy). A date-object, or three separate integers are also valid as input.

Output:

Each part (dd, MM and yyyy) individually reverted and than rounded to the nearest valid date.

For example (in the format dd-MM-yyyy):
21-10-2016 becomes 12-01-6102

Challenge rules:

Only dd, MM, yyyy is valid, but the order and which separate-symbols you use is your own choice.
So these are some valid format examples: dd-MM-yyyy; MM/dd/yyyy; yyyy MM dd; ddMMyyyy, etc.
And these are some invalid format examples: dd MMM yyyy; dd-MM-'yy; etc.
You can also choose to just input a Date-object if your language supports it or three separate integer parameters, instead of the string representing a date.
Please state which date-format you've used! (And the input and output must be in the same format.) It is also allowed to output a Date-object, as long as it can handle all test cases and the challenge rule below.
The Julian to Gregorian Calendar transition is ignored for this challenge. So 1582 is just a valid reversed year for 2851.
See Challenge info / tips for all valid years, months and days.
Since you cannot have February as reversed of any other month, you don't have to worry about leap years.

All reversed years, months and days:

The year can always be reversed without a problem, reaching from 0001 (reversed of 1000) to 9999 (remains 9999). (So 0000 isn't a valid input, and there are also no test cases for it.)
The only months you'll have reversed are: January (reversed from October / 10); October (reversed from January / 01); November (remains November / 11); and December (reversed from every other month / 02-09, 12).
The only days you'll have reversed are: 01 (reversed from 10), 02 (reversed from 20), 03 (reversed from 30), 10 (reversed from 01), 11 (remains 11), 12 (reversed from 21), 13 (reversed from 31), 20 (reversed from 02), 21 (reversed from 12), 22 (remains 22), 30 (reversed from 03 or the same as 31 for November!), 31 (reversed from 04-09 / 13-19 / 23-29).

General rules:

This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return statements/output, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code.
Also, please add an explanation if necessary.

Test cases (dd-MM-yyyy as format):

21-07-2016   ->   12-12-6102
12-11-1991   ->   21-11-1991
01-01-2000   ->   10-10-0002
27-08-1875   ->   31-12-5781
18-12-2010   ->   31-12-0102
13-01-1981   ->   31-10-1891
04-11-1671   ->   30-11-1761  // Semi-tricky case, since November has 30 days
28-11-2036   ->   30-11-6302  // Semi-tricky case, since November has 30 days
14-06-1855   ->   31-12-5581
30-10-9999   ->   03-01-9999
01-01-2851   ->   10-10-1582

CJam, 24 bytes

qS/Wf%[_1=:=31^sCs].e<S*

I/O format is dd mm yyyy.

Try it online!

Same byte count, I/O format mm dd yyyy:

qS/Wf%_0=:=1231^s2/.e<S*

Try it online!

Explanation

qS/     e# Read input, split around spaces.
Wf%     e# Reverse each component.
[       e# Set marker for new list.
  _1=   e#   Duplicate reversed strings, extract reversed month.
  :=    e#   Check for equality of the characters. This gives 1 for
        e#   November (11) and 0 for everything else.
  31^   e#   XOR the result with 31, giving 30 for November and 31
        e#   for everything else.
  s     e#   Convert the result to a string, "30"/"31".
  Cs    e#   Push 12, convert to string, "12".
]       e# Wrap "30"/"31" and "12" in a list.
.e<     e# Element-wise minimum. This clamps the day and month to their
        e# respective maxima.
S*      e# Join the result with spaces.

The other version works similarly, except that we start from the integer 1230 or 1231 before converting it to ["12" "30"]  or ["12" "31"].


Reimplement the wc coreutil This challenge is similar to this old
one, but with some unclear
parts of the spec hammered out and less strict I/O requirements.

Given an input of a string consisting of only printable ASCII and newlines,
output its various metrics (byte, word, line count).

The metrics that you must output are as follows:

Byte count. Since the input string stays within ASCII, this is also the
character count.
Word count. This is wc's definition of a "word:" any sequence of
non-whitespace. For example, abc,def"ghi" is one "word."
Line count. This is self-explanatory. The input will always contain a
trailing newline, which means line count is synonymous with "newline
count." There will never be more than a single trailing newline.

The output must exactly replicate the default wc output (except for the file
name):

llama@llama:~$ cat /dev/urandom | tr -cd 'A-Za-z \n' | head -90 > example.txt
llama@llama:~$ wc example.txt
  90  165 5501 example.txt

Note that the line count comes first, then word count, and finally byte count.
Furthermore, each count must be left-padded with spaces such that they are all
the same width. In the above example, 5501 is the "longest" number with 4
digits, so 165 is padded with one space and 90 with two. Finally, the
numbers must all be joined into a single string with a space between each
number.

Since this is code-golf, the shortest code in bytes will win.

(Oh, and by the way... you can't use the wc command in your answer. In case that wasn't obvious already.)

Test cases (\n represents a newline; you may optionally require an extra
trailing newline as well):

"a b c d\n" -> "1 4 8"
"a b c d e f\n" -> " 1  6 12"
"  a b c d e f  \n" -> " 1  6 16"
"a\nb\nc\nd\n" -> "4 4 8"
"a\n\n\nb\nc\nd\n" -> " 6  4 10"
"abc123{}[]()...\n" -> " 1  1 16
"\n" -> "1 0 1"
"   \n" -> "1 0 4"
"\n\n\n\n\n" -> "5 0 5"
"\n\n\na\nb\n" -> "5 2 7"

Perl, 49 bytes

Added +3 for -an0

Input on STDIN or 1 or more filenames as arguments.
Run as perl -an0 wc.pl

wc.pl:

/\z/g;pos=~//;printf"%@+d %@+d $`
",y/
//,~~@F

Explanation:

-n0      slurps the whole input into $_ and says we will do our own printing
-a       tells perl to split the input on whitespace into array @F
/\z/g    Matches the absolute end of the input. g modifier so the position
         is remembered in pos which will now contain the input length
pos=~//  An empy regex repeats the last succesful match, so /\z/ again.
         After that $` will contain the the number of input characters and
         the array @+ will contain the length of this number
printf   All preparation is complete, we can go print the result
"%@+d"   will become e.g. %6d if the number of characters is a number of
         length 6, so lines and words will get printed right aligned
         in a field of length 6.
$`       $` we can directly interpolate since it won't contain a %
y/\n//   Count the number of newlines in $_
~~@F     The array of words @F in scalar context gives the number of words


Create a Fanatic bot for Stack Exchange sites Your challenge today is to cheat at badges!

You will build a bot that will connect to a Stack Exchange site, log in as you, visit the /questions page, visit a question, and then visit 9 other questions in the "related" sidebar (because that seems sufficient to count as "activity," and I need to standardize on something).

This bot must go through this process once every day, without any input or actions from the user. It should be able to be left running, and the user should be able to never touch the computer, and the consecutive days count will still be incremented. After "visiting" the site, it must print "visited".

You will assume that the user is using the Stack Exchange-provided OpenID.

The input of the program will be the site URL, SE OpenID email, and SE OpenID password. For example:

https://stackoverflow.com/ doorknob@doorknob.doorknob password

You can input these however you would like.

Your program must work for a minimum of:

https://stackoverflow.com/
https://meta.stackoverflow.com/
https://superuser.com/
https://codegolf.stackexchange.com/

(Just to make sure it is universal.)

This is code-golf, so the shortest code in bytes will win!

Ruby, 456 characters

require'mechanize'
s,*e=gets.split
a,o=Mechanize.new,'http://openid.stackexchange.com/'
a.agent.http.verify_mode=OpenSSL::SSL::VERIFY_NONE
l=a.get(o+'account/login').forms[0]
l.email,l.password=e
a.submit l,l.buttons[0]
g=a.get(s+'/users/login').forms.find{|f|f.action=='/users/authenticate'}
g.openid_identifier=o
a.submit g,g.buttons[-1]
loop{p=a.get s+'/questions'
10.times{p=p.links.find{|i|i.href=~/^\/questions\/\d/}.click}
puts'visited'
sleep 86400}

Ungolfed version:

require 'mechanize'

site, email, password = gets.split

agent = Mechanize.new
agent.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE

login_form = agent.get('http://openid.stackexchange.com/account/login').forms.first
login_form.email = email
login_form.password = password
agent.submit login_form, login_form.buttons.first
puts 'logged in with SE openid'

site_login_form = agent.get(site + '/users/login').forms.find {|form| form.action == '/users/authenticate' }
site_login_form.openid_identifier = 'http://openid.stackexchange.com/'
agent.submit site_login_form, site_login_form.buttons.last
puts 'logged in to site'

loop {
    page = agent.get(site + '/questions')
    10.times do page = page.links.find{|link| link.href =~ /^\/questions\/\d/ }.click; end
    puts 'visited'
    sleep 60 * 60 * 24
}


Tips for golfing in Io What general tips do you have for golfing in Io? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Io (e.g. "remove comments" is not an answer). Please post one tip per answer.

Higher-level function shorthand
This seems like a pretty interesting golfing point. E.g.

list(1,2,3)map(i,i+1)print

However, Io is pretty permissive on not specifying the counter; the map body can be used as a point-free function, as Io tries to fill in the operand of this expression. This can be golfed into

list(1,2,3)map(+1)print

Due to the helpful work of the language creator, you can even do this to reduces!
list(1,2,3)reduce(a,b,a*b)

Can easily be reduced into:
list(1,2,3)reduce(*)

(Unfortunately, I still haven't managed to understand how exactly this works, so I never managed to make the expression more complex.)


Triangles of Hexagons Suppose an infinite tiling of hexagons composed of |/\ characters.

 / \ / \ / \ / \
|   |   |   |   |
 \ / \ / \ / \ /  etc.
  |   |   |   |
   \ / \ / \ /

Given input n > 0, output a triangular portion of that tiling as depicted in the below examples, anchored with a _ in the middle of a hexagon:

n=1
\_/

n=2
\/ \/
 \_/

n=3
\  |  /
 \/ \/
  \_/

n=4
\/ \ / \/
 \  |  /
  \/ \/
   \_/

n=5
\  |   |  /
 \/ \ / \/
  \  |  /
   \/ \/
    \_/

n=6
\/ \ / \ / \/
 \  |   |  /
  \/ \ / \/
   \  |  /
    \/ \/
     \_/

n=7
\  |   |   |  /
 \/ \ / \ / \/
  \  |   |  /
   \/ \ / \/
    \  |  /
     \/ \/
      \_/

n=8
\/ \ / \ / \ / \/
 \  |   |   |  /
  \/ \ / \ / \/
   \  |   |  /
    \/ \ / \/
     \  |  /
      \/ \/
       \_/

and so on

Rules

Leading/trailing newlines or other whitespace are optional, provided that the characters line up appropriately.
Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
Output can be to the console, saved as an image, returned as a list of strings, etc.
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Python 2, 86 bytes

i=k=input()
while i:i-=1;print(" "*(k+~i)+"\\"+i*' /  |\  '[i%2::2])[:k-~i]+"_/"[i>0:]

Try it online!

One of Erik’s tricks allowed me to golf 3 bytes! Saved 3 bytes thanks to Jonathan Allan.

How this works

First off, this gets input from STDIN and assigns it to two separate variables i and k. Then, while the variable i is truthy, we decrement it and generate the strings accordingly; this is a shorthand for looping from the input - 1 all the way down to 0.

Generating the Strings

I'll split this into more parts:

First off, getting the leading spacing is achieved with " "*(k+~i). Since i is mapped through the range (input, 0], we must subtract it from k (our safely stored original input), decrement and repeat a space that many times.
+"\\" - Adds the character "\" to the spaces above.
' /  |\  '[i%2::2] - Generates our two strings, namely "/ \ " and "  | ", in the following manner:

If i is odd, i % 2 is 1, thus [i%2::2] returns each 2 characters of our larger string, starting at index 1 (0-indexed).
If i is even, i % 2 is 1, thus the mechanism above does the same except it starts at index 0.

+~-i* - Repeats the string generated above, either "/ \ " or "  | ", i-1 times, and appends it to the other strings. The benefit of the bitwise operator (~ - Bitwise Complement, Equivalent to i subtracted from -1) is that it doesn't require parenthesis in this context.
[:k-~i] - Gets all the characters of the strings concatenated above until index k-~i = k - (-1 - i) = k + 1 + i.
+"_/"[i>0:] - This only adds "/" if i ≥ 1, else it appends _/.

Full example / execution details

Let's grab an example of how things work for an input of 4:

i=k=input()        # i and k are assigned to 4.
while i:           # Starts the loop. The initial value of i is 4.
i-=1;              # Decrement i. i is now 3.
" "*(k+~i)         # A space repeated k - 1 - i = 4 - 1 - 3 = 0 times.
+"\\"              # Plus the character "\". CS (Current string): "\".
' /  |\  '[i%2::2] # The string ' /  |\  '[3%2::2] = ' /  |\  '[1::2] = "/ \ ".
i*                 # ^ repeated i = 3 times: "/ \ / \ / \ ".
+                  # And concatenate. CS: "\/ \ / \ / \ "
[:k-~i]            # Get the characters of ^ up to index k + 1 + i = 4 + 1 + 3 = 8.
                   # CS: "\/ \ / \".
+"_/"[i>0:]        # Append "_/"[i>0:] = "_/"[3>0:] = "_/"[1:] = "/".
                   # CS: "\/ \ / \/".
print              # Output the result "\/ \ / \/".
while i:           # i is truthy (> 0), thus we loop again.
i-=1;              # Decrement i. i becomes 2.
" "*(k+~i)         # " " repeated 4 - 2 - 1 = 1 time.
+"\\"              # Plus "\". CS: " \".
' /  |\  '[i%2::2] # ' /  |\  '[2%2::2] = ' /  |\  '[::2] = "  | ".
+i*                # Repeat i = 2 times and append: "  | ". CS: " \  |  |".
[:k-~i]            # CS up until k + 1 + i = 4 + 2 + 1 = 7. CS: " \  |  ".
+"_/"[i>0:]        # Append "/". CS: " \  |  /".
print              # Outputs the CS: " \  |  /".
while i:           # i is truthy (> 0), thus we loop again.
i-=1;              # Decrement i. i is now 1.
" "*(k+~i)         # " " repeated 4 - 1 - 1 = 2 times.
+"\\"              # Plus "\". CS: "  \".
' /  |\  '[i%2::2] # ' /  |\  '[2%2::2] = ' /  |\  '[::2] = "/ \ ".
+i*                # Repeat i = 1 time and append: "/ \ ". CS: "  \/ \ ".
[:k-~i]            # CS up until k + i + 1 = 4 + 2 = 6. CS: "  \/ \".
+"_/"[i>0:]        # Append "/". CS: "  \/ \/".
print              # Outputs the CS: "  \/ \/".
while i:           # i is truthy (> 0), thus we loop again.
i-=1;              # Decrement i. i is now 0.
" "*(k+~i)         # " " repeated 4 - 1 - 0 = 3 times.
+"\\"              # Plus "\". CS: "   \".
' /  |\  '[i%2::2] # ' /  |\  '[1%2::2] = ' /  |\  '[1::2] = "  | ".
+i*                # Repeat i = 0 times and append: "   \". CS: "   \".
[:k-~i]            # CS up until k + i + 1 = 4 + 0 + 1 = 5. CS: "   \".
+"_/"[i>0:]        # Append "_/" (because i > 0 is False since i == 0). CS: "  \_/".
print              # Outputs the CS: "  \_/".
while i:           # i == 0, hence the condition is falsy and the loop ends.
                   # Program terminates.


Hexagolf: Validagons Challenge

Given an ASCII art shape, you must find out whether the shape is a regular hexagon or not.

Hexagons

A regular hexagon is defined using two rules:

It has six sides
Each side has equal numbers of characters

For example, the following shape is regular but it doesn't have six sides and so is not a regular hexagon:

B a a h
s a i d
y o u r
g a o t

Similarly, the following shape has six sides but has sides of different lengths and so is not a regular hexagon:

  * *
 * * *
* * * *
 * * *
  * *

However, the following shape has six sides and all of the sides have the same number of characters, so it is a regular hexagon:

  T h e
 h e x a
g o n s a
 r e c o
  m i n

Rules

Output should be a truthy or a falsey value (truthy if the shape is a regular hexagon, falsey if not).

The shapes will only ever contain printable ASCII characters.

The border of the shape will never contain spaces. If it does, you can return falsey.

There can be arbitrary amounts of whitespace before and/or after the shape.

All angles in the shape may not be equal for example, the following shape is valid input:

  . . .
   . . .
. . . . .
 . . . .
  . . .

It will return a falsey value.

All shape inputs will be on a space separated grid. Hexagonal input will be on a staggered grid (each line is offset from the next).

Examples

Truthy

The following shapes should return truthy values:

 # _
+ + +
 9 :

  5 6 7
 8 9 0 1
2 3 4 5 6
 7 8 9 0
  1 2 3

    t h i s
   i       s
  a         h
 e           x
  a         g
   o       n
    ! ! ! !

    5 6 7
   8 9 0 1
  2 3 4 5 6
   7 8 9 0
    1 2 3

Falsey

The following should return falsey values

r e c t a
n g l e s

  h e l l o
 w o r l d s
t h i s i s b
 e t a d e c
  a y n o w

  *
 * *
* * *

  .....
 .......
.........
 .......
  .....

This shape is not on a space separated grid and is not staggered.

   * * * *
  ---------
 * * * * * *
-------------
 * * * * * *
  ---------
   * * * *

5 6 7
8 9 0 1
2 3 4 5 6
7 8 9 0
1 2 3

For single character inputs, your program may output either truthy or falsey:

&

Winning

The shortest program in bytes wins.

R, 184 bytes

Golfed, could probably be golfed by a few bytes

function(m){e=min;f=max;l=length;v=which(m!=" ",T);a=v[,1];n=l(v[a==1,2]);u=(v[a==e(a),2]);all(u==v[a==f(a),2])&all(c(e(d<-v[a==ceiling(f(v[,1])/2),2]),f(d))==c(u[1]-n+1,u[l(u)]+n-1))}

Ungolfed, very messy, more like half way golfed

f=function(m) {
  v = which(m!=" ",T)
  a = v[,1]
  n = length(v[a==1,2])
  u=(v[a==min(a),2])
  c1 = all(u==v[a==max(a),2])
  d = v[a==ceiling(max(v[,1])/2),2]
  c2 = all(c(min(d), max(d))==c(u[1]-n+1,u[length(u)]+n-1))
  c1 & c2
}

Since the input format is unspecified, Input needs to be specified in an R array format, looking something like this.

         [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
[1,] " "  " "  "5"  " "  "6"  " "  "7"  " "  " "
[2,] " "  "8"  " "  "9"  " "  "0"  " "  "1"  " "
[3,] "2"  " "  "3"  " "  "4"  " "  "5"  " "  "6"
[4,] " "  "7"  " "  "8"  " "  "9"  " "  "0"  " "
[5,] " "  " "  "1"  " "  "2"  " "  "3"  " "  " "

Here is a generator function that generates the input. The generator doesn't generate an object that is fed into hexagon check function, but rather the code specifying the array (effectively the same thing). So this should not count as parsing the text. Remember that I'm not inputting text, but rather an array structure.

generate = function(x) {
  s = strsplit(strsplit(x, "\n")[[1]], "")
  m = max(sapply(s, length))
  dput(do.call(rbind, lapply(s, function(x) c(x, rep(" ", m-length(x))))))
}

For example, the generated code would be: structure(c(" ", " ", "2", " ", " ", " ", "8", " ", "7", " ", "5", " ", "3", " ", "1", " ", "9", " ", "8", " ", "6", " ", "4", " ", "2", " ", "0", " ", "9", " ", "7", " ", "5", " ", "3", " ",
"1", " ", "0", " ", " ", " ", "6", " ", " "), .Dim = c(5L, 9L
)) which is identical to array(c(" ", " ", "2", " ", " ", " ", "8", " ", "7", " ", "5", " ", "3", " ", "1", " ", "9", " ", "8", " ", "6", " ", "4", " ", "2", " ", "0", " ", "9", " ", "7", " ", "5", " ", "3", " ", "1", " ", "0", " ", " ", " ", "6", " ", " "), dim = c(5, 9))

Hopefully this input method is in compliance with the rules.

Here are the test cases

x1 =
"  5 6 7
 8 9 0 1
2 3 4 5 6
 7 8 9 0
  1 2 3"

x2 =
" # _
+ + +
 9 :"

x3 =
"    t h i s
   i       s
  a         h
 e           x
  a         g
   o       n
    ! ! ! !"

x4 ="    5 6 7
   8 9 0 1
  2 3 4 5 6
   7 8 9 0
    1 2 3"

x5 = "r e c t a
n g l e s"

x6 = "  h e l l o
  w o r l d s
t h i s i s b
 e t a d e c
  a y n o w"

x7 ="  *
 * *
* * *"

x8 ="   .....
  .......
.........
  .......
   ....."

Generate input arrays

sapply(mget(paste("x", 1:8, sep = "")), generate)

Test for hexagon

sapply(.Last.value , f)

   x1    x2    x3    x4    x5    x6    x7    x8
 TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE


(Re)Implementing Tetris In the spirit of re-implementing classic video games, I would like to invite the community to create their best implementation of Tetris.

For reference, a screenshot of the official NES version of Tetris.

Required Features

A reasonable scoring system must be in place, which rewards multi-line clears more than single-line clears. The current score must be visible at all times.
The next piece that will appear must be indicated in some manner.
The distribution of the seven tetrominoes should be fairly even (i.e. pseudo-randomly chosen).
The user must have the ability to rotate the current piece in both directions, as well as accelerate its descent.
When the game has ended, it should be clearly indicated that the game is over.
The source code must be structured and easily understandable.

Optional Features

Advancing falling speed after a certain number of clears (i.e. increasing difficulty level), and advancing score per line clear, proportional to speed.
Gravity. You may choose to implement the 'classic' gravity, in which blocks can remain floating over gaps, or you may choose to implement 'flood fill' gravity, in which blocks which have been separated from their original tetromino via line clears may fall into open gaps.
High scores with name input.
Animation after line clears, and/or after obtaining a new high score.

Limitations

Any libraries used (jQuery, PyGame, etc.) should be freely available.
Source code size must not exceed 4096 bytes, excluding whitespace and comments. Any external resources (data files, images, etc.) will be added to the code length, excluding any files which are generated, such as for high scores.
I realize that this is a rather arbitrary restriction; my primary goal is to discourage copy-pasting of existing implementations, and to encourage brevity and self-containment.

Winning Criteria

This challenge will be judged as a popularity contest, meaning that the submission with the most upvotes will be selected as the winner. When upvoting, I encourage users to upvote any and all submissions which they feel adequately meet the above stated requirements.

The winner will be chosen no sooner than 2 weeks after the first valid solution. Additionally, I will be granting a bounty to the winner, roughly proportional to the number of upvotes this question receives (10 * #votes rounded upwards to the nearest 50). Should there be a tie after the 2 week period has expired, the competition period will be extended by one week. Should there still be a tie, I reserve the right to place the final vote.

Please ask for any clarifications. May the best implementation win!

Try: http://tetris.muehe.org

Update There's a global high score. Enjoy beating it or - alternatively - hacking it :-)

CoffeeScript and HTML version, should fulfill the requirements to the best of my knowledge (and I have never really played Tetris).

$ make stats
4095

Github https://github.com/henrik-muehe/tetris

Features

Exponential scoring
Next piece indicator
Fair randomness
Rotation, move and drop down
Game over indication
Highscore with server backend that should not be that easily fakeable.


Determine if a number is divisible by 13 (without using 13 itself) Your challenge, should you choose to accept it, is to create a function or a program that outputs "yes" if a given number is divisible by 13 and outputs "no" if it isn't.

Rules:
 - You're not allowed to use the number 13 anywhere.
 - No cop-out synonyms for 13 either (like using 15 - 2).
 - Bonus points will be awarded for not using modulus, additional bonus for not using division.

Scoring:
 - Your score will be the number of bytes in your code (whitespace not included) multiplied by your bonus.
 - If you didn't use modulus, that bonus is 0.90; if you didn't use division, that bonus is 0.90.
 - If you didn't use either, that bonus is 0.80.
 - The lower your score, the better.

The input will always be an integer greater than 0 and less than 2^32.
Your output should be a simple "yes" or "no".

Clarifications:
 - Using some roundabout method of generating the number 13 for use is acceptable.  Simple arithmetic synonyms like (10 + 3) are not allowed.
 - The function or program must literally output "yes" or "no" for if the given number is divisible by 13.
 - As always, clever solutions are recommended, but not required.

Java (score 60.8 59.2)

void t(int n){System.out.print(Math.cos(.483321946706122*n)>.9?"yes":"no");}

Score: (76 - 2 whitespace) chars * 0.8 = 59.2