17
4
Inspired by an old manual...
The challenge
I define the ath suffix vector of b as the boolean list of length a with b trailing truthy values.
Write a program or function that, given a and b by any means, returns the ath suffix vector of b by any means.
Now this may seem trivial, but here is the catch: Your score is the byte count plus the earliest year your solution would have worked.
Rules
All standard rules apply, except that languages and language versions that were released after this challenge, may also be used.
Output using whatever representation of boolean values that your language uses, e.g. 1
/0
, True
/False
, TRUE
/FALSE
, "True"
/"False"
, etc.
Output using whatever representation of lists that your language uses, e.g. 0 0 1
, [False,False,True]
, (FALSE;FALSE;TRUE)
, {"False","False","True"}
, etc.
You may assume that a ≥ b is always true and that they are of an appropriate data type.
Test cases
Given a = 7 and b = 3, return 0 0 0 0 1 1 1
Given a = 4 and b = 4, return [True,True,True,True]
Given a = 2 and b = 0, return (FALSE;FALSE)
Given a = 0 and b = 0, return {}
Example solution and scoring
I might want to submit the solution {⌽⍺↑⍵⍴1}
using Dyalog APL. That would be a bytecount of 8. This is a dynamic function, which works from version 8.1 of Dyalog APL, released in 1998, so my total score is 2006. My submitted answer should look something like:
# Dyalog APL 8.1, 1998 + 8 = 2006
{⌽⍺↑⍵⍴1}
Optional explanation...
Recommended: Link to documentation showing when the features you used were released.
Lowest score wins!
14I'm deeply concerned about the verifiability of the answers. – Dennis – 2016-03-10T15:33:06.457
@Dennis Same. For example I am fairly confident that my answer would have worked on the first Prolog interpreters but I actually can't easily check it. – Fatalize – 2016-03-10T15:35:44.053
1@Dennis I understand you concern. However, 1) the answers will mostly be very simple, and thus could be verified by hand – not requiring an actual running system, and 2) some users have taken to linking to documentation of their claim. – Adám – 2016-03-10T15:36:06.480
8I'm not so sure "verified by hand" is necessarily going to work for some answers - the past is a foreign place, and sometimes initial versions of things can lack things that feels commonplace today... – Sp3000 – 2016-03-10T15:55:16.500
1@Sp3000 Maybe, but this is all for fun anyway, and with 8 answers and 9 upvotes in 1.5h, I think this challenge is fun enough accept that someone might cheat. Maybe some extra research on the eventual winner... – Adám – 2016-03-10T16:03:47.480
@Nᴮᶻ If a release is dated on 31 December, that may be interpreted as the following year depending on locale (see drolex's comment to my answer). Can Github date be used as the official date (whatever locale the Github server is using)? Should I add
1
to the score just in case? – Luis Mendo – 2016-03-10T17:01:14.770SMP, 1983+94=2077:
{[0]:{[0]:{},[2]:"(FALSE;FALSE)"},[3]:{[7]:"0 0 0 0 1 1 1"},[4]:{[4]:"[True,True,True,True]"}}
Moral of the story: don't mix output formats. – CalculatorFeline – 2016-03-10T17:10:42.170@CatsAreFluffy What? – Adám – 2016-03-10T17:14:12.443
I'd suggest using one array format for the test cases. – CalculatorFeline – 2016-03-10T17:15:11.563
1@CatsAreFluffy The idea was to show that any of those formats are valid. I think the cases are few and simple enough that ease of copy-paste'ing isn't an issue. – Adám – 2016-03-10T17:16:24.297
There's an answer that displays the string
{}
for the empty list. However, in TI-BASIC,{}
doesn't represent anything; it throws an error when evaluated. Is this valid? – lirtosiast – 2016-03-10T22:23:36.2571
Hang on, working on an answer using http://history-computer.com/Babbage/NextDifferentialEngines/Scheutz.html.
– msh210 – 2016-03-11T19:49:02.720:-)
Things to avoid when writing challenges. – cat – 2016-03-13T02:40:51.723
This is an old challenge, but it isn't explicitly stated: is a lower score better? – caird coinheringaahing – 2018-04-12T12:34:09.013
@cairdcoinheringaahing Yes. – Adám – 2018-04-12T12:54:37.273