Wednesday, July 1, 2015

1HaskellADay June 2015 Problems and Solutions

June 2015

  • June 30th, 2015: Count Dracula has just enough time for a quickie, and today's #haskell problem http://lpaste.net/8137099602819022848 
    Count Dracula: "Vithd you, never a quickie ... alwayz a longie! Bla-blah-blaaaah!" ... and the solution http://lpaste.net/7601734639496986624
  • June 29th, 2015: Toodle-pip! Word-frequency of a novel purportedly written in 'Hinglish, don't you know!' http://lpaste.net/7805322136641339392 Today's #haskell problem That solution is SO my bag!http://lpaste.net/7435942974816518144
  • June 26th, 2015: THUGs hate code duplication. I bet you didn't know that about THUGs. #thuglife With today's #haskell problem, you do. http://lpaste.net/87111690633609216 The solution is awesome, because reasons. http://lpaste.net/3951774515419152384
  • June 25th, 2015: We solve today's #haskell problem like a Thug. A CANADIAN Thug http://lpaste.net/183406472317632512 … #ThugLife When a THUG wants a cup-o-joe, it just makes sense to give'm dat cup-o-joe when he throws down dat Hamilton http://lpaste.net/8960298568350957568 #thuglife
  • June 24th, 2015: Today's #haskell problem shows us Mad Dad is Sad ... http://lpaste.net/1360790418425380864 … ... AND CANADIAN! AND SO ARE YOU! #whendidthathappen
  • June 23rd, 2015: Banana Fish! I don't know what that means, but: http://lpaste.net/4698665561507233792 (I also don't know what map 'a'-"apple" 'b'-"banana" means, either). Dad even got the banana WITH TAXES! http://lpaste.net/51803352903712768 But is Dad happy? Oh, no! See today's problem (forthcoming)
  • June 22nd, 2015: A couple of range-like thingies for today's #haskell problem http://lpaste.net/9214672078085554176 'Thingies' is a technical term. Arrows for ranges? http://lpaste.net/3818460590272151552 Who knew that could be a 'thing'? (Again, technical term. It means: 'thing.')
  • June 19th, 2015: 
♫ Grease is the word,
is the word,
is the word,
that you heard,..
http://lpaste.net/5444203916235374592
... and is today's #haskell problem. #graph 
O! What a tangled web we weave! http://lpaste.net/1406493831142047744 Contracts between corporations #graph Using #neo4j to show complex interrelationships between corporations #haskell
  • June 18th, 2015: Graph owners of companies ... LIKE A BOSS for today's #haskell problem http://lpaste.net/8745167156892663808 def #NSFW-youtube-link: 
    Take this #graph and shove it; I don' work here anymore! A solution http://lpaste.net/497988783522709504

  • June 17th, 2015: What does Hannibal Lecter have to do with today's #Haskell problem? http://lpaste.net/3911201767555072000 Well, actually nothing. Good for name-dropping ;)
    Ooh! pritti colours! Lines and circles! ME. LIKEY! http://lpaste.net/1108939510487449600 Visualizing relations between companies and their employees in #neo4j #graph database #bigdata

  • June 16th 2015: Business. Commerce. Relationships. And the plot thickens for today's #haskell problem http://lpaste.net/2159896812155043840 You scratched my back, so the solution will scratch yours: http://lpaste.net/6209720607693602816
  • June 15th, 2015: We're told to 'mind our own business.' For today's #haskell problem, however, we don't. http://lpaste.net/409939376974331904 If all the world were 450 businesses ...huh, don't know how to end that couplet, so I'll just share the solution: http://lpaste.net/4134898821270339584
  • June 12th, 2015: Today's Haskell problem is really simple: http://lpaste.net/176873973089304576 Write a Haskell Database. ;)
  • June 11th, 2015: A mapping of a map of categories to various sets of symbols. Not at all a Graph. Nope. Not at all. http://lpaste.net/106990139309293568 So, forewarning: there is wootage to be found in the solution http://lpaste.net/1443717939034324992 
  • June 10th, 2015: FREE LATIN LESSONS with today's #haskell problem! AND curl, but as long as you don't sudo bash you should be okay ... http://lpaste.net/8023684639111512064
  • June 9th, 2015: LET'S PRETEND! that today is yesterday, huh? So 'today's #haskell problem is about Options Tradinghttp://lpaste.net/3308567286981328896 ... not really.
  • June 8th, 2015: Improving the accuracy of the stddev modifier is the topic for today's #haskell problem http://lpaste.net/2181777565994188800
  • June 5th, 2015: Today's #haskell problem is kinda from Haskell by Example http://lpaste.net/1846897956607754240 Maps don't love you like I love you 
Hey, did you just make a map from a map and a multimap? http://lpaste.net/1944556995998646272 Is that even allowed? Yes, ... yes, it is.
  • June 4th, 2015: Peano's big TOE has a #haskell problem for you today, rollin' on the river http://lpaste.net/8694895204643110912 Types can be ... helpful in modeling solutions. Yeah. http://lpaste.net/6112991888283795456
  • June 3rd, 2015: As we're not going to do switch for today's #haskell problem (Why? BECAUSE I SAID SO), let's deredundancify an array. http://lpaste.net/2725173830396936192 An array by any other name is just a graph http://lpaste.net/6699309431617748992 ... hey, it's possible!
  • June 2nd, 2015: Today's #haskell problem is called 'twixt' and is inspired from a tweet by @jamestanton http://lpaste.net/4168110918607044608 Betwixt a rock and a prime place lies the solution http://lpaste.net/5331587919524134912
  • June 1st, 2015: These factorials are prime for ... primes. Erhm, yeah. http://lpaste.net/6303441488491577344 Today's #haskell problem from @jamestanton

Monday, June 29, 2015

Tabular and Visual Representations of Data using Neo4J

Corporate and Employee Relationships
Both Graphical and Tabular Results

So, there are many ways to view data, and people may have different needs for representing that data, either for visualization (in a graph:node-edges-view) or for tabulation/sorting (in your standard spreadsheet view).

So, can Neo4J cater to both these needs?

Yes, it can.

Scenario 1: Relationships of owners of multiple companies

Let's say I'm doing some data exploration, and I wish to know who has interest/ownership in multiple companies? Why? Well, let's say I'm interested in the Peter-Paul problem: I want to know if Joe, who owns company X is paying company Y for whatever artificial scheme to inflate or to deflate the numbers of either business and therefore profit illegally thereby.

Piece of cake. Neo4J, please show me the owners, sorted by the number of companies owned:

MATCH (o:OWNER)--(p:PERSON)-[r:OWNS]->(c:CORP)
RETURN p.ssn AS Owner, collect(c.name) as Companies, count(r) as Count 
ORDER BY Count DESC


Diagram 1: Owners by Company Ownership

Boom! There you go. Granted, this isn't a very exciting data set, as I did not have many owners owning multiple companies, but there you go.

What does it look like as a graph, however?

MATCH (o:OWNER)--(p:PERSON)-[r:OWNS]->(c:CORP)-[:EMPLOYS]->(p1) 
WHERE p.ssn in [2879,815,239,5879] 
RETURN o,p,c,p1


Diagram 2: Some companies with multiple owners

To me, this is a richer result, because it now shows that owners of more than one company sometimes own shares in companies that have multiple owners. This may yield interesting results when investigating associates who own companies related to you. This was something I didn't see in the tabular result.

Not a weakness of Neo4J: it was a weakness on my part doing the tabular query. I wasn't looking for this result in my query, so the table doesn't show it.

Tellingly, the graph does.

Scenario 2: Contract-relationships of companies 

Let's explore a different path. I wish to know, by company, the contractual-relationships between companies, sorted by companies with the most contractual-relationships on down. How do I do that in Neo4J?

MATCH (c:CORP)-[cc:CONTRACTS]->(c1:CORP) 
RETURN c.name as Contractor, collect(c1.name) as Contractees, count(cc) as Count 
ORDER BY Count DESC


Diagram 3: Contractual-Relationships between companies

This is somewhat more fruitful, it seems. Let's, then, put this up into the graph-view, looking at the top contractor:

MATCH (p:PERSON)--(c:CORP)-[:CONTRACTS*1..2]->(c1:CORP)--(p1:PERSON) 
WHERE c.name in ['YFB'] 
RETURN p,c,c1,p1


Diagram 4: Contractual-Relationships of YFB

Looking at YFB, we can see contractual-relationships 'blossom-out' from it, as it were, and this is just immediate, then distance 1 from that out! If we go out even just distance 1 more in the contracts, the screen fills with employees, so then, again, you have the forest-trees problem where too much data is hiding useful results with data.

Let's prune these trees, then. Do circular relations appear?

MATCH (c:CORP)-[:CONTRACTS*1..5]->(c1:CORP) WHERE c.name in ['YFB'] RETURN c,c1


Diagram 5: Circular Relationship found, but not in YFB! Huh!

Well, would you look at that. This shows the power of the visualization aspect of graph databases. I was examining a hot-spot in corporate trades, YFB, looking for irregularities there. I didn't find any, but as I probed there, a circularity did surface in downstream, unrelated companies: the obvious one being between AZB and MZB, but there's also a circular-relationship that becomes apparent starting with 4ZB, as well. Yes, this particular graph is noisy, but it did materialize an interesting area to explore that may very well have been overlooked with legacy methods of investigation.

Graph Databases.


BAM.

Saturday, June 20, 2015

Business Interrelations as a Graph

We look at a practical application of Graph Theory to take a complex representation of information and distill it to something 'interesting.' And by 'interesting,' I mean: finding a pattern in the sea of information otherwise obscured (sometimes intentionally) by all the overwhelming availability of data.

We'll be working with a graph database created from biz.csv, so to get this started, load that table into neo4j:

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///[...]/biz.csv" AS csvLine
MERGE (b1:CORP { name: csvLine.contractor })
MERGE (b2:CORP { name: csvLine.contractee })

MERGE (b1)-[:CONTRACTS]->(b2)

We got to a graph of business interrelations this past week (see, e.g.: http://lpaste.net/5444203916235374592) showing who contracts with whom, and came to a pretty picture like this from the Cypher query:

MATCH (o:OWNER)--(p:PERSON)-[]->(c:CORP) RETURN o,p,c

diagram 1: TMI

That is to say: the sea of information. Yes, we can tell that businesses are conducting commerce, but ... so what? That's all well and good, but let's say that some businesses want to mask how much they are actually making by selling their money to other companies, and then getting it paid back to them. This is not an impossibility, and perhaps it's not all that common, but companies are savvy to watch dogs, too, so it's not (usually) going to be an obvious A -[contracts]-> B -[contracts] -> A relationship.

Not usually, sometimes you have to drill deeper, but if you drill too deeply, you get the above diagram which tells you nothing, because it shares too much information.

(Which you never want to do ... not on the first date, anyway, right?)

But the above, even though noisy, does show some companies contracting with other companies, and then, in turn being contracted by some companies.

So, let's pick one of them. How about company 'YPB,' for example? (Company names are changed to protect the modeled shenanigans)

MATCH (c:CORP)-[:CONTRACTS]->(c1:CORP) WHERE c.name='YPB' RETURN c, c1

diagram 2: tier 1 of YPB

So, in this first tier we see YPB contracting with four other companies. Very nice. Very ... innocuous. Let's push this inquiry to the next tier, is there something interesting happening here?

MATCH (c:CORP)-[:CONTRACTS*1..2]->(c1:CORP) WHERE c.name='YPB' RETURN c, c1

diagram 3: tier 2 of YPB

Nope. Or what is interesting is to see the network of businesses and their relationships (at this point, not interrelationships) begin to extend the reach. You tell your friends, they tell their friends, and soon you have the MCI business-model.

But we're not looking at MCI. We're looking at YPB, which is NOT MCI, I'd like to say for the record.

Okay. Next tier:

MATCH (c:CORP)-[:CONTRACTS*1..3]->(c1:CORP) WHERE c.name='YPB' RETURN c, c1

diagram 4: tier 3 of YPB

Okay, a little more outward growth. Okay. (trans: 'meh') How about the next tier, that is to say: tier 4?

MATCH (c:CORP)-[:CONTRACTS*1..4]->(c1:CORP) WHERE c.name='YPB' RETURN c, c1

diagram 5: tier 4 of YPB

So, we've gone beyond our observation cell, but still we have no loop-back to YPB. Is there none (that is to say: no circular return to YPB)? Let's push it one more time to tier 5 and see if we have a connection.

MATCH (c:CORP)-[:CONTRACTS*1..5]->(c1:CORP) WHERE c.name='YPB' RETURN c, c1


diagram 6: tier 5 with a (nonobvious) cycle of contracts

Bingo. At tier 5, we have a call-back.

But from whom?

Again, we've run into the forest-trees problem in that we see we have a source of YPB, and YPB is the destination, as well, but what is the chain of companies that close this loop. We can't see this well in this diagram, as we have so many companies. So let's zoom into the company that feeds money back to YPB and see if that answers our question.

MATCH (c:CORP)-[:CONTRACTS]->(c1:CORP)-[:CONTRACTS]->(c2:CORP)-[:CONTRACTS]->(c3:CORP)-[:CONTRACTS]->(c4:CORP)-[:CONTRACTS]->(c5:CORP) WHERE c.name='YPB' AND c5.name='GUB' RETURN c, c1, c2, c3, c4, c5

diagram 7: cycle of contracts from YPB

Aha! There we go. By focusing our query the information leaps right out at us. Behold, we're paying Peter, who pays Paul to pay us back, and it's there, plain as day.

Now, lock them up and throw away the key? No. We've just noted a cyclical flow of contracts, but as to the legality of it, that is: whether it is allowed or whether this is fraudulent activity, there are teams of analysts and lawyers who can sink their mandibles into this juicy case.

No, we haven't determined innocence or guilt, but we have done something, and that is: we've revealed an interesting pattern, a cycle of contracts, and we've also identified the parties to these contracts. Bingo. Win.

The problem analysts face today is diagram 1: they have just too much information, and they spend the vast majority of their time weeding out the irrelevant information to winnow down to something that may be interesting. We were presented with the same problem: TMI. But, by using graphs, we were able to see, firstly, that there are some vertices (or 'companies') that have contracts in and contracts out, and, by investigating further, we were able to see a pattern develop that eventually cycled. My entire inquiry lasted minutes of queries and response. Let's be generous and say it took me a half-hour to expose this cycle.

Data analysts working on these kinds of problems are not so fortunate. Working with analysts, I've observed that:

  1. First of all, they never see the graph: all they see are spreadsheets,
  2. Secondly, it takes days to get to even just the spreadsheets of information
  3. Third, where do they go from there? How do they see these patterns? The learning curve for them is prohibitive, making training a bear, and niching their work to just a few brilliant experts and shunting out able-bodied analysts who are more than willing to help, but just don't see the patterns in grids of numbers
With the graph-representation, you can run into the same problems, but 
  1. Training is much easier for those who can work with these visual patterns,
  2. Information can be overloaded, leaving one overwhelmed, but then one can very easily reset to just one vertex and expand from there (simplifying the problem-space). And then, the problem grows in scope when you decide to expand your view, and if you don't like that expanse, it's very easy either to reset or to contract that view.
  3. An analyst can focus on a particular thread or materialize that thread on which to focus, or the analyst can branch from a point or branch to associated sets. If a thread is not yielding interesting results, then they can pursue other, more interesting, areas of the graph, all without losing one's place.
The visual impact of the underlying graph (theory) cannot be over-emphasized: "Boss, we have a cycle of contracts!" an analyst says and presents a spreadsheet requires explanation, checking and verification. That same analysis comes into the boss' office with diagram 7, and the cycle practically leaps off the page and explains itself, that, coupled with the ease and speed of which these cycles are explored and materialized visually makes a compelling case of modeling related data as graphs.

We present, for your consideration: graphs.



Models presented above are derived from various Governmental sources include Census Bureau, Department of Labor, Department of Commerce, and the Small Business Administration.

Graphs calculated in Haskell and stored and visualized in Neo4J

Friday, June 5, 2015

May 2015 1HaskellADay problems and solutions

May 2015
  • May 29th, 2015: The President of the United States wants YOU to solve today's #haskell problem http://lpaste.net/5394990454380953600 Super-secret decoder ring sez: http://lpaste.net/4232036193933459456
  • May 28th, 2015: So, you got the for-loop down. Good. Now: how about the 'no'-loop. HUH? http://lpaste.net/419764621470072832 Ceci n'est pas un for-loop http://lpaste.net/4585222543073345536
  • May 27th, 2015: For today's #haskell problem we look at Haskell by Example and bow before the mighty for-loop! http://lpaste.net/188189811754926080 The for-loop solution. I count even. http://lpaste.net/3919145189309939712 *groans
  • May 26th, 2015: TMI! So how to distinguish the stand-outs from the noise? Standard deviations FTW! http://lpaste.net/7326574484482162688 for today's #haskell problem. First rule: don't lose! http://lpaste.net/5153008470756163584
  • May 25th, 2015: We look at monad transformers to help in logging http://lpaste.net/8301304912738779136 for today's #haskell problem. Ooh! What does the log say? (that foxy log!) http://lpaste.net/109687 Ooh! Ouch! Bad investment strategy! Onto the next strategy!
  • May 22nd, 2015: Tomorrow's another day for today's #haskell problem http://lpaste.net/8939124091818868736 #trading Huh! http://lpaste.net/5738095651988701184 we get very similar returns as from previously essayed. Well, now we are confident of a more accurate model.
  • May 21st, 2015: For today's #haskell problem http://lpaste.net/1900634933852897280 we talk of categories (not 'The'), so we need a cat-pic: LOL
    Is 'parfait' a Category? http://lpaste.net/3432870087273480192 … If so, I would eat categories every day! 


  • May 20th, 2015: Let's view a graph as, well, a #neo4j-graph for today's #haskell problem http://lpaste.net/8344081425502306304 Ooh! Pretty Graph(ic)s! http://lpaste.net/621084277097889792 
  • May 19th, 2015: "Lemme put that on my calendar," sez the trader http://lpaste.net/7002659561530195968 for today's #haskell problem So ... next Monday, is that a #trading day? #inquiringmindswanttoknow http://lpaste.net/729791673181143040
  • May 18th, 2015: So, what, precisely, does a bajillion clams look like? We find out by doing today's #haskell problem http://lpaste.net/3228618210228043776 #trading #clams Were those cherry clams? No: apple http://lpaste.net/6731000367502327808
  • May 15th, 2015: We learn that π is a Π-type in today's #haskell problem of co-constants http://lpaste.net/2567253109898215424 (#typehumour) 'I' like how Id is the I-combinator http://lpaste.net/7574047523665346560
  • May 14th, 2015: Today's #haskell problem brings out the statistician in you that you didn't know you had. Hello, Standard Deviations! http://lpaste.net/3520547034257948672 Wow, rational roots? Sure, why not? And: 'σ'? ... so cute! http://lpaste.net/8056787266321776640
  • May 13th, 2015: Today's #haskell problem teaches us that variables ... AREN'T! http://lpaste.net/7856430804354727936 Well, if variables aren't, then they certainly do. Except in Haskell – A solution to this problem is posted at http://lpaste.net/767712970229678080
  • May 12th, 2015: For Today's #haskell problem we look at values and their types, but NOT types and their values, please! http://lpaste.net/7773498464792477696 *glares* taf, tof, tiff, tough solution today http://lpaste.net/7739074628332552192
  • May 11th, 2015: Hello, world! Haskell-style! http://lpaste.net/7162836591558262784 -- A solution to this 'Hello, world!'-problem is posted at http://lotz84.github.io/haskellbyexample/ex/hello-world
  • Octo de Mayo, 2015: Strings not enumerable in Haskell? Balderdash! Today's #haskell problem http://lpaste.net/7204216668719939584 Today we produce not only one, but two solutions to the enumerable-strings problem http://lpaste.net/5041390572904906752 #haskell 
  • Septo de Mayo, 2015: When all your Haskell documentation is gone, whom do you call? The web crawler, SpiderGwen! to the rescue! http://lpaste.net/4022946512970448896 
    We CURL the HTML-parsing solution at http://lpaste.net/6475977888209305600
  • Sexo de Mayonnaise, 2015: @BenVitale Offers us a multi-basal ('basel'? 'basil'?) palindromic number-puzzle for today's #haskell problem http://lpaste.net/858675562900619264
  • Cinco de Mayo, 2015: May the #maths be with you. Always. http://lpaste.net/8062431866961002496 Today's #haskell problem, we learn that 5 is the 6th number. Happy Cinco de Mayo! Pattern-matching, by any other name, would still smell as sweet #lolsweet http://lpaste.net/7419804910079705088 A solution to today's #haskell problem.
  • May 4th, 2015: "There is no trie, my young apprentice!" Today's #haskell problem proves Master Yoda wrong. FINALLY! http://lpaste.net/179758090873208832 So ... I 'trie'd ... *GROAN!* http://lpaste.net/5961897275272724480 A solution to today's 'trie'ing #haskell problem 
  • May 1st, 2015: (Coming up to) Today's #haskell problem is 'slightly' more challenging than yesterday's problem (forall, anyone?) http://lpaste.net/1400137464227561472 Existential Quantification, For(all) The Win! http://lpaste.net/4400237442641166336

Thursday, April 30, 2015

April 2015 1HaskellADay Problems and Solutions

April 2015
  • April 30th, 2015: "SHOW ME DA MONAY!" http://lpaste.net/3352992723589136384 for today's #haskell problem 
    Simple? Sure! Solution? Yes. http://lpaste.net/7331259237240143872
  • April 29th, 2015: We take stock of the Stochastic Oscillator http://lpaste.net/8447434917217828864 for today's #haskell problem #trading We are so partially stoched for a partial solution for the Stochastic Oscillator http://lpaste.net/4307607333212520448 
  • April 28th, 2015: Today's #haskell puzzle as a ken-ken solver http://lpaste.net/6211501623257071616 a solution (beyond my ... ken) is defined at http://lpaste.net/929006498481176576
  • April 27th, 2015: Rainy days and Mondays do not stop the mail, nor today's #haskell problem! http://lpaste.net/6468251516921708544 The solution posted at http://lpaste.net/6973841984536444928 … shows us view-patterns and how to spell the word 'intercalate'.
  • April 24th, 2015: Bidirectionally (map) yours! for today's #haskell problem http://lpaste.net/1645129197724631040 A solution to this problem is posted at http://lpaste.net/540860373977268224 
  • April 23rd, 2015: Today's #haskell problem looks impossible! http://lpaste.net/6861042906254278656 So this looks like this is a job for ... KIM POSSIBLE! YAY! @sheshanaag offers a solution at http://lpaste.net/131309 .
  • April 22nd, 2015: "I need tea." #BritishProblems "I need clean data" #EveryonesPipeDream "Deletia" today's #haskell problem http://lpaste.net/2343021306984792064 Deletia solution? Solution deleted? Here ya go! http://lpaste.net/5973874852434542592
  • April 21st, 2015: In which we learn about Tag-categories, and then Levenshtein distances between them http://lpaste.net/2118427670256549888 for today's #haskell problem Okay, wait: is it a group of categories or a category of groups? me confused! A solution to today's #haskell at http://lpaste.net/8855539857825464320
  • April 20th, 2015: Today we can't see the forest for the trees, so let's change that http://lpaste.net/3949027037724803072 A solution to our first day in the tag-forest http://lpaste.net/4634897048192155648 ... make sure you're marking your trail with breadcrumbs!
  • April 17th, 2015: No. Wait. You wanted line breaks with that, too? Well, why didn't you say so in the first place? http://lpaste.net/8638783844922687488 Have some curry with a line-breaky solution at http://lpaste.net/8752969226978852864
  • April 16th, 2015: "more then." #okaythen Sry, not sry, but here's today's #haskell problem: http://lpaste.net/6680706931826360320 I can't even. lolz. rofl. lmao. whatevs. And a big-ole-blob-o-words is given as the solution http://lpaste.net/2810223588836114432 for today's #haskell problem. It ain't pretty, but... there it is
  • April 15th, 2015: Poseidon's trident or Andrew's Pitchfork analysis, if you prefer, for today's #haskell problem http://lpaste.net/5072355173985157120
  • April 14th, 2015: Refining the SMA-trend-ride http://lpaste.net/3856617311658049536 for today's #haskell problem. Trending and throttling doesn't ... quite get us there, but ... solution: http://lpaste.net/9223292936442085376
  • April 13th, 2015: In today's #haskell problem we learn zombies are comonadic, and like eating SMA-brains. http://lpaste.net/8924989388807471104 Yeah. That. Hold the zombies, please! (Or: when $40k net profit is not enough by half!) http://lpaste.net/955577567060951040
  • April 10th, 2015: Today's #haskell problem delivered with much GRAVITAS, boils down to: don't be a dumb@$$ when investing http://lpaste.net/5255378926062010368 #KeepinItReal The SMA-advisor is REALLY chatty, but how good is it? TBD, but here's a very simple advisor: http://lpaste.net/109712 Backtesting for this strategy is posted at http://lpaste.net/109687 (or: how a not so good buy/sell strategy give you not so good results!)
  • April 9th, 2015: A bit of analysis of historical stock data http://lpaste.net/6960188425236381696 for today's #haskell problem A solution to the SMA-analyses part is posted at http://lpaste.net/3427480809555099648 
  • April 8th, 2015: MOAR! MOAR! You clamor for MOAR real-world #haskell problems, and how can I say no? http://lpaste.net/5198207211930648576 Downloading stock screens Hint: get the screens from a web service; look at, e.g.: https://code.google.com/p/yahoo-finance-managed/wiki/YahooFinanceAPIs A 'foldrM'-solution to this problem is posted at http://lpaste.net/2729747257602605056
  • April 7th, 2015: Looking at a bit of real-world #haskell for today's stock (kinda-)screen-scraping problem at http://lpaste.net/5737110678548774912 Hint: perhaps you'd like to solve this problem using tagsoup? https://hackage.haskell.org/package/tagsoup *GASP* You mean ... it actually ... works? http://lpaste.net/1209131365107236864 A MonadWriter-y tagsoup-y Monoidial-MultiMap-y solution
  • April 6th, 2015: What do three men teaching all of high school make, beside today's #haskell problem? http://lpaste.net/667230964799242240 Tired men, of course! Thanks, George Boole! Three Men and a High School, SOLVED! http://lpaste.net/7942804585247145984
  • April 3rd, 2015: reverseR that list like a Viking! Rrrrr! for today's problem http://lpaste.net/8513906085948555264 … #haskell Totes cheated to get you the solution http://lpaste.net/1880031563417124864 used a library that I wrote, so, like, yeah, totes cheated! ;)
  • April 2nd, 2015: We're breaking new ground for today's #haskell problem: let's reverse lists... relationally. And tag-type some values http://lpaste.net/389291192849793024 After several fits and starts @geophf learns how to reverse a list... relationally http://lpaste.net/7875722904095162368 and can count to the nr 5, as well
  • April 1st, 2015: Take a drink of today's #haskell problem: love potion nr9 http://lpaste.net/435384893539614720 because, after all: all we need is love, la-di-dah-di-da! A solution can be found au shaque d'amour posted at http://lpaste.net/6859866252718899200

Wednesday, April 1, 2015

March 2015 1HaskellADay Problems and Solutions


March 2015
  • March 31st, 2015: Today's #haskell exercise has us looking for a really big pandigital prime http://lpaste.net/6128183741660528640 ... like: REALLY big. Maybe.
  • March 30th, 2015: A little math-problem to ease us into the week, suggested by @jamestanton http://lpaste.net/845208190432837632 3 consecutive integers that are co-composed
  • March 27th, 2015: Today's #haskell problem is unification of multiple free variables http://lpaste.net/370356889654919168 We find this to be 'CoSimple.' 34 lines (and a new n-to-1 data mapping-type) defining not a 'CoSimple' unifier but now an 'UnSimple' one. http://lpaste.net/8114086012700852224 Ugh!
  • March 26th, 2015: Unification is interesting! http://www.cs.uu.nl/research/techreps/repo/CS-2008/2008-027.pdf (Functional Unification paper) Let's look at the unification-problem for today's #haskell problem http://lpaste.net/1572781401336446976 We define simple unification (of up to one free logic variable) in a module called unification.simple, oddly enough. http://lpaste.net/5064654031335456768
  • March 25th, 2015: In Old Norse, words end with 'R' (not all). For today's #Haskell problem, relations end with 'R' http://lpaste.net/8067966125595426816 Where I learn to speak Old Norse with a slightly better accent: unifying lists with headR and tailR http://lpaste.net/4854317134819360768 with unifyLists
  • March 24th, 2015: For today's #haskell problem we learn that 'kayso' is a word, and we edge a bit more toward pure relational calculushttp://lpaste.net/5312260085655797760 A solution to this relational-calculus problem that is defined over Data/Control logic modules: http://lpaste.net/5718036917765799936
  • March 23rd, 2015: WHO KNEW a chance meeting with @webyrd at the POPL06 would lead to today's #haskell problem? http://lpaste.net/7445712320312901632 μBikini I mean: μKanren And the solution implies that monadic-list states are logic programming? http://lpaste.net/8325001449901654016 Perhaps.
  • March 19th, 2015: We now learn signal spreads ... like ... margarine! for today's #haskell problem http://lpaste.net/4389894538622140416
  • March 18th, 2015: For today's #haskell problem we learn that Jupiter's moon Europa is made from Froyo, and custard! Mmmm! http://lpaste.net/127272
  • March 17th, 2015: No quaternions were harmed in today's #haskell π-problem IN SPACE! http://lpaste.net/7134990338598371328
  • March 16th, 2105: In space, no one can here you scream "@NASA" (nor anything else for that matter. Today's #haskell problem http://lpaste.net/7238728062383161344
  • March 14th, 2015: Happy π day! A plain-text version of these NASA π-in-space puzzles are available at http://lpaste.net/7533371868384854016
  • March 13th, 2015: Okay, ladies and gentlemen, today, in honor of tomorrow being π day, let's take a #coercive #logic break and π it up! http://lpaste.net/7075392225642807296
  • March 12th, 2015: I wonder if the suitor's surname is Quinehttp://lpaste.net/5006337360527360000 for today's #haskell problem #coercive #logic
  • March 10th, 2015: For today's #haskell problem, we wonder if Balikaya is Aharmanite or Mazdaysian http://lpaste.net/6972955679380209664 #scheherazade #coercive #logic
  • March 9th, 2015: In which Iskandar is asked Kamar's Children's ages in Scheherazade's #haskell metapuzzle http://lpaste.net/8990755663210610688 #coercive #logic 
  • March 6th, 2015: Champernowne's constant for today's #haskell problem http://lpaste.net/6911025218794291200 Please let me know if you can NOT access this problem: I've marked it private as previous ones are being modified in place. DON'T DO THAT!  In which we show @geophf triumphs with brütish-forcisms for today's #haskell solution http://lpaste.net/2944338052937416704
  • March 5th, 2015: For today's #haskell problem, we ponder why they aren't calledLEFT-triangles. Is it a plot? http://lpaste.net/121797 Leftist triangles are subject to the (IO) State (monad) ... geddit? #sigh never mind anyway, solution: http://lpaste.net/122143 Or, put another way: in which we see @geophf can not have a function type that includes -> Int -> ... AND, we really need MapReduce here!
  • March 4th, 2015: Truncatable primes (11 in all) are asking to be solved in today's projecteuler.com #haskell problem http://lpaste.net/121528 This @1HaskellADay problem turned into a _TWO_day solution! Worth it? Why, yes, after redesigning _TWO_ libraries! http://lpaste.net/122503
  • March 3rd, 2015: There's more than a 1-in-a-million chance there are 'sum' double palindromic numbers in today's #haskell problem http://lpaste.net/121470 The solution was not too hard, M. Euler! http://lpaste.net/121471
  • March 2nd, 2015: What-what! abcde * fghij is equal to ... well, something, it appears. http://lpaste.net/121421 and the prob1, prob2 winners are ...http://lpaste.net/121466 A solution to today's #haskell problem.

Sunday, March 1, 2015

February 2015 1HaskellADay Problems and Solutions


February 2015
  • February 27th, 2015: Let's put all our primes in a circle, shall we? http://lpaste.net/121154 Ah, how cute! Today's #haskell problem suggested by @jamestanton @bretthall defines a solution, with some analysis, at http://lpaste.net/121292
  • February 26th, 2015: Okay, check this! Today's #haskell problem is as easy as 1, 2, 3! http://lpaste.net/121250 An easy as π solution is posted at http://lpaste.net/121273 ... mmm! π! But is it apple π or ... raspberry π? #couldntresist
  • February 25th, 2015: I'd like moccha sprinkles on my double capicua, please. http://lpaste.net/121153 No. Wait. Today's #haskell problem suggested by a tweet from @OnThisDayinMath
  • February 24th, 2015: Not satisfied with a simple square-from-square problem @BenVitale takes it up a notch and asks us to cube dat square! http://lpaste.net/121060 We have one solution out of 20k squares posted at http://lpaste.net/121150 : [(39204,39304)]
  • February 23rd, 2015: I hereby christen this week a fun-with-numb3rs week, and start us off by learning that 'easierest' is a word, http://lpaste.net/121034, just like 'ginormous.' And the winner is...no, wait! Ladies and gentlemen, we have MULTIPLE winners! http://lpaste.net/121052 Good thing the solution isn't the Lotto No, wait. The problem statement wasn't read carefully by the solution-poster. I blame that wicked, wicked @geophf! Bad geophf! Bad! ;)
  • February 20th, 2015: It's a #Borderlands2 Truxican Standoff for you to resolve in today's #haskell problem http://lpaste.net/120819 The solution is simple really: just a projection into a monad category in order to do some monoidal deduction is all! http://lpaste.net/120916
  • February 19th, 2015: For today's #haskell problem we learn that 'AEKL' is a word in English http://lpaste.net/120775 (no, it's not, actually) A megalokaryocyte-solution is posted at http://lpaste.net/120816 (now, that's a common word ... NOT! ;)
  • February 18th, 2015: Instead of doing today's #haskell problem, let's go ice skating. No, let's do BOTH! http://lpaste.net/120722 Okay, a loquacious solution? garrulous? Yes. Once one cuts through all the attempts, it's a simple solution, too: http://lpaste.net/120873 ... and updated the solution with the monoidal guarantee-by-implication that the result is unique (instead of just hoping it is) #coercivelogic
  • February 17th, 2015: For today's #haskell problem we are asked to 'fix' our monetary problems (or the library, at least) http://lpaste.net/120630 Made Data.Monetary.USD a Fractional instance http://lpaste.net/109653 and eliminated floating point creep #haskell #money #precision 
  • February 16th, 2015: Getting a jump-start on the day with two really, really hard math problems for today's #haskell problem http://lpaste.net/120560 A solution in which we learn a baseball costs a nickel ... IN WHICH CENTURY? http://lpaste.net/120560
  • February 13th, 2015: Today's SCARY #haskell problem comes by way of @OnThisDayinMath http://lpaste.net/120422 Tonight's late-night movie, Friday the 13th, part III http://lpaste.net/120466 as the solution to today's #haskell problem.
  • February 12th, 2015: Gurer ner gvzrf jura ... yeah. That. http://lpaste.net/120388 Today's #haskell problem, thanks to @KenKenPuzzle The solution shows us that it's INTENSE unscrambling words http://lpaste.net/120407
  • February 11th, 2015: Change adds up quickly in today's #haskell problem http://lpaste.net/120320 So, but ... does that mean programming is like ... maths? Nah! http://lpaste.net/120333 A solution to today's #haskell problem
  • February 10th, 2015: The price of a letter (or of all letters of the alphabet) http://lpaste.net/120236 is the question for today's haskell problem. In the solution we learn the geophfmeister is down-low on the B.I.G. 323, yo! http://lpaste.net/120294
  • February 9th, 2015: 'Oh, no!' ... just another Manic Monday ... AND today's #haskell problem http://lpaste.net/120196 Oh, noes! Mr. Bill!http://lpaste.net/120208 A solution to the oh, no!-problem.
  • February 6th, 2015: It's Friday! Friday! Hava #haskell problem on Friday! Fun-fun-fun! Lookin' forward to the weekend! http://lpaste.net/120087 Groovin' to aRebecca Black solution at http://lpaste.net/120095
  • February 5th, 2015: Triangles and Squares as numbers http://lpaste.net/120037 for today's Haskell problem. A Triangulated-squares solution is provided by @bretthall at http://lpaste.net/120040
  • February 4th, 2015: Three birds in the hand is better than today's #haskell problem http://lpaste.net/119926 an ornithologist's delight inspired by @KenKenPuzzle. The solution, using MultiMaps, PartitionedSets, and Arrows is (@geophf-obviously) "WOOT! WOOT! WOOT!" http://lpaste.net/120065
  • February 3rd, 2015: We entertain a foolish attempt at a #haskell problem, and then we get serious with six sewing seamstresses http://lpaste.net/119867 A silly seamstress solution is posted at http://lpaste.net/119888 
  • February 2nd, 2015: Today's #haskell exercise is all about the #SuperBowl! (No, it's not, but that makes for good copy), or 110, 210, ... http://lpaste.net/119791 The moral (and solution) to this story is: Don't eat cheerios seasoned with basil. http://lpaste.net/119823 Or something like that. Inspired by @bretthall solution, I expanded to include last-3-of-4 digits for solutions to bases 4,5,6 @jamestanton