18
1
The Bible is one of the most influential books ever written, and commonly cited as the best selling book of all time. It was written by approximately 40 different authors over hundreds of years before being compiled into it's current form. But what's interesting about The Bible is the way it's divided up. It is split up into 2 different testaments, which are split up into 66 smaller books, which are each split up into smaller chapters, which are each split up into individual verses.
I thought it would be a fun challenge to try to encode the number of chapters in each book in the shortest code possible. So for today's challenge, you must write a program or function that takes one of the books as input, and outputs the number of chapters in that book according to The King James Version.
You may take IO in any reasonable format, for example reading/writing STDIN/STDOUT or a file, function arguments/return values, prompting the user, etc. are all allowed. The input will always be one of the 66 books of The Bible, and only lowercase. This means that if you are given any other input, undefined behavior is allowed. Since there are only 66 possible inputs and outputs, they are all provided here, according to Wikipedia's page on Bible chapters in The King James Version:
genesis 50
exodus 40
leviticus 27
numbers 36
deuteronomy 34
joshua 24
judges 21
ruth 4
1 samuel 31
2 samuel 24
1 kings 22
2 kings 25
1 chronicles 29
2 chronicles 36
ezra 10
nehemiah 13
esther 10
job 42
psalms 150
proverbs 31
ecclesiastes 12
song of solomon 8
isaiah 66
jeremiah 52
lamentations 5
ezekiel 48
daniel 12
hosea 14
joel 3
amos 9
obadiah 1
jonah 4
micah 7
nahum 3
habakkuk 3
zephaniah 3
haggai 2
zechariah 14
malachi 4
matthew 28
mark 16
luke 24
john 21
acts 28
romans 16
1 corinthians 16
2 corinthians 13
galatians 6
ephesians 6
philippians 4
colossians 4
1 thessalonians 5
2 thessalonians 3
1 timothy 6
2 timothy 4
titus 3
philemon 1
hebrews 13
james 5
1 peter 5
2 peter 3
1 john 5
2 john 1
3 john 1
jude 1
revelation 22
Since this challenge is about finding the optimal way to encode every book name and chapter count, using any builtins that give information about The Bible are not permitted. However, since it would be interesting to see which languages have such builtins, feel free to share a second non-competing version along with your answer. Fetching information from external sources is also not permitted (none of the standard loopholes are allowed, but I thought it would be useful to explicitly mention that one).
As usual, this is a code-golf challenge, so try to make the shortest possible program (measured in bytes) as you can. Have fun golfing!
3The output is not fixed, so why is this [tag:kolmogorov-complexity]? – LyricLy – 2017-10-02T23:23:48.067
3@LyricLy Because even though the output is not fixed, it is still about seeing the most efficient way to generate two different sets of data: 1) The names of the books (or a portion of the name long enough to recognize it) and 2) The corresponding number of chapters. – James – 2017-10-02T23:25:23.957
3you just see all the ones with a normal amount and then just psalms which is like HALF THE BIBLE – HyperNeutrino – 2017-10-02T23:35:43.763
@HyperNeutrino No, a lot if its "chapters" (individual psalms) are very short. There is only one long psalm, number 119, which is also The Bible's longest chapter. – Adám – 2017-10-02T23:37:36.153
@Adám I know most of them are really short and it's really not too much longer than other books :P but still it has like almost 3 times more than the otherwise maximum – HyperNeutrino – 2017-10-02T23:40:47.113
@HyperNeutrino Also, the chapter divisions were later Christian additions. The original (OT) texts do not have chapter numbering. – Adám – 2017-10-02T23:43:25.270
@Adám Hm that's interesting. Thanks for the info! :) – HyperNeutrino – 2017-10-02T23:51:51.463
4
I wanna
– totallyhuman – 2017-10-03T01:32:30.997enklact
my way out of this challenge but I can't...1@icrieverytim Provably impossible. The shortest book, Job is three characters and the first three columns are not unique. – James – 2017-10-03T01:37:12.587
3@DJMcMayhem You've forgotten the fact that there are not 66 unique letters. :P – totallyhuman – 2017-10-03T01:38:12.500
2@icrieverytim I do suppose that is a bigger and more obvious problem XD – James – 2017-10-03T01:52:56.233
2@icrieverytim Hahaha, enklact should be a new word in the PPCG dictionary xD – ETHproductions – 2017-10-03T02:34:47.587
Jelly compressed string that contains the data. I don't actually know Jelly (and I also made a few mistakes while encoding the data, but I don't know how to fix them without re-doing the whole thing) but maybe somebody can put this to good use. – LyricLy – 2017-10-03T04:39:57.550
1@ETHproductions to enklact (v): to implement a lookup table using a subsection consisting of unique elements. This could even be a me— oops, I almost said the m-word. :P – totallyhuman – 2017-10-03T06:04:19.203
3
There's no need to generate the names of books, or even sub-sections thereof. That half of the problem is near-perfect hashing rather than KC. Overall this type of question is one of the subtypes that least deserves the KC tag; @LyricLy, if you feel strongly then you could revive the issue on meta with a proposed name for this type of lookup question.
– Peter Taylor – 2017-10-03T07:03:57.547