Pi Day: Determine if a list of words is correct Pilish
05AB1E, 15 13 bytes
€gT0:©JÅ?®àg*
Thanks to @KirillL. for bringing to my attention that the input as a list of strings is allowed, saving 2 bytes by removing the split on spaces.
Takes the list of words as first input, and the PI-digits joined together to a single string as second input. Outputs 0
for incorrect; 1
for Basic; 2
for Standard.
Try it online or verify all test cases.
Explanation:
€g # Get the length of each word in the (implicit) input-list of string
T0: # Replace all 10 with 0
© # Store this list in the register (without popping)
J # Join everything together
Å? # Check if the (implicit) PI-input starts with this (1/0 for truthy/falsey)
®à # Push the list from the register again, and pop and push its maximum
g # Get the length of this maximum
* # And multiply it with the result from the check
# (after which the result is output implicitly)
Java (JDK), 122 bytes
t->p->{int x=1,L,l;for(var s:t.split(" "))x=(l=s.length())==(L=p.get())|L<1&l>9?x:L*10+(L=p.get())==l&L*x>0?2:0;return x;}
Try it online!
Returns 1
for basic, 2
for standard and 0
for incorrect.
Credits
- -6 bytes thanks to Kevin Cruijssen