11
0
Write a program that defines a function that can check if a string variable called "anything you want or inputted by the user" is or not a piem. (piem = a story or poem in which the word lengths represent the digits of π (from Wikipedia))
Some examples:
myfunction("I am clearly wrong") # False
myfunction("How I want a drink, alcoholic of course, after the heavy lectures involving quantum mechanics") #True (Taken from Wikipedia)
myfunction("Law ' s fine") # True
You should delete any kind of punctuation or newline before processing. Pure code golf, the shortest wins
End date: evening of 1/10/2014
Various answers
- How many digits do we need to handle? More than 10
- As a matter of interest, how should 0's in PI be interpreted? Skipped or 10 letter words? As 10 letters words
- "a variable called piem" – so the name of the parameter must be piem? No, it hasn't, question text corrected
- A fun bonus might be a solution that is itself a piem If your solution is a piem you get *0.5 bonus
- For the sake of argument, is _ always punctuation? You can decide if it is punctuation or if it isn't
- It's unclear what is meant by "any kind of punctuation" I mean ,.'"?!;;()
- So digits should be counted? And Law's fine would be false? Digits should be treated as letters, Law's fine = False; Law ' s fine = True
Comments
- The APL solution should be counted in Bytes
- If your solution works for 100+ digits of pi you get *0.8 bonus
- Because of the great interest the end date is one day more in the future.
6How many digits do we need to handle? – marinus – 2014-09-28T09:18:47.960
1So digits should be counted? And
Law's fine
would be false? – Martin Ender – 2014-09-28T09:21:31.5505"a variable called piem" – so the name of the parameter must be
piem
? That renders all current answers incorrect. – Ingo Bürk – 2014-09-28T11:37:57.367Also, should new lines really be removed instead of treated like spaces. Because that means that
How\nI\nwant
yields false butA\nB\nC
yields true. – Martin Ender – 2014-09-28T13:08:24.6902A fun bonus might be a solution that is itself a piem. – britishtea – 2014-09-28T13:36:46.417
Validating for length (i.e.
[3,1,4,1,5,9,2,6,...]
) is interesting and a good challenge, but validating a piem, I think, requires that the string actually be a story or a poem. i.e. something with some sense or memorability to it. It will be interesting to see how that requirement is handled. For example, this, despite having appropriate length words, is not a piem in my opinion:"Bob I door I fence parameter an yellow fence red"
– Darren Stone – 2014-09-28T20:24:25.360I didn't mean to be overly negative in my previous comment -- I actually think this is a great challenge, particularly if the number of digits of pi is unconstrained. I just think this isn't really about piems, which require some degree of sense to be memorable. e.g. also not a piem:
"aaa a aaaa a aaaaa aaaaaaaaa aa aaaaaa aaaaa aaa"
– Darren Stone – 2014-09-28T20:32:55.0635As a matter of interest, how should 0's in PI be interpreted? Skipped or 10 letter words? – MickyT – 2014-09-29T01:38:51.183
1I don't see any mention of Unicode in the puzzle description... – Almo – 2014-09-29T13:42:47.433
3It's kind of a shame that you don't reply to very important questions, yet you already edited in an end date. – Ingo Bürk – 2014-09-29T14:53:25.543
@IngoBürk I now replied, look the question. – Caridorc – 2014-09-29T19:21:15.993