fix Hollerith encoding

Submit

Your name:
File:
Open code-statistics:

Language is selected by the extension of the file. See the list of supported languages to know the extension of your language.

Problem

The CLC-INTERCAL compiler <i>sick</i> accepts not only ASCII (actually, LATIN1 or ISO-8859-1, in <i>iconv</i> command on my Termux), but also EBCDIC, extended Baudot, and a punched cards encoding Hollerith; CLC-INTERCAL program can be written in such many encodings, so it's pretty adaptable for many environments.

The problem is, however, that Hollerith character encoding is implemented incorrectly so we have to make source compatible with the implementation.

Here are sources that work on ACTUAL sick compiler, but when the software were to be updated, they won't work like they used to.
So your task is to update the source to correct Hollerith encoding so that it works when CLC-INTERCAL were updated.

<h2>How Hollerith encoding works</h2>
<ul>
<li>A pair of octets represents one character.</li>
<li>Each character is represented by twelve punch lines.</li>
<li>Each punch line is represented by a bit.</li>
<li>Two most significant bits on each octed are ignored.</li>
<li>Six rest bits on first octet contains punch line 12, 0, 2, 4, 6, 8.</li>
<li>Six rest bits on second octet represents line 11, 1, 3, 5, 7, 9.</li>
<li>A bit 1 means the line is punched while 0 means it is not.</li>
</ul>

<h2>How it is implemented</h2>
Lines 11 and 12 are swapped. Even those two lines were fixed back, the order of lines documented would not match with that of implementation.
Here is how it is implemented, from most to least significant bits.
Each hyphen means to be ignored.
Each number represents line number.

<table border>
<tr>
  <td>1st octet</td>
    <td>-</td>
    <td>-</td>
    <td>11</td>
    <td>8</td>
    <td>6</td>
    <td>4</td>
    <td>2</td>
    <td>0</td>
</tr>
<tr>
  <td>2nd octet</td>
    <td>-</td>
    <td>-</td>
    <td>12</td>
    <td>9</td>
    <td>7</td>
    <td>5</td>
    <td>3</td>
    <td>1</td>
</tr>
</table>

<h2>Problem</h2>
Given the string encoded in incorrectly implemented Hollerith character set, convert to the correct one.

<h3>How it should be corrected</h3>
Here is the correct Hollerith encoding (as on this problem). Note each hyphen means to be unchanged.

<table border>
<tr>
  <td>1st octet</td>
    <td>-</td>
    <td>-</td>
    <td>12</td>
    <td>0</td>
    <td>2</td>
    <td>4</td>
    <td>6</td>
    <td>8</td>
</tr>
<tr>
  <td>2nd octet</td>
    <td>-</td>
    <td>-</td>
    <td>11</td>
    <td>1</td>
    <td>3</td>
    <td>5</td>
    <td>7</td>
    <td>9</td>
</tr>
</table>

<h2>References</h2>
<ul>
<li><a href='https://groups.google.com/g/alt.lang.intercal/c/JFxcHOjY2lc'>My post on mailing list <i>alt.lang.intercal</i></a>. Discusses the bug of Hollerith character set.</li>
<li><a href='https://snapshot.debian.org/package/clc-intercal/1%3A1.0%7E4pre1.-94.-2-2/'>CLC-INTERCAL 1.-94.-2 Debian package</a>.</li>
<li></li>
</ul>

<h2>Disclaimer</h2>
This is just my idea of how the bug should be fixed.

<h2>Signature</h2>
-- 鳴神裁4.1号, 2021.10.21, 17:57 UTC+9.

If you have any suggestion or opinion, please post by any means; I may react to it to feedback for creating next problems.

Options

exec is denied

rejudge feature is enabled

now post-mortem time, all source codes will be revealed

Sample input:_

D`h@D`@dB`E@@h@pAB

Sample output:

d@B`d@`Dh@T@`B`APH

Sample input:_

@BPb@AD@@@PpCA@@T@Eh`HpPDdED@ddDCB@@BbPhDdPD@`AX`DHh@@`H`BAP

Sample output:

@HaH@PD@@@aAXP@@E@tB@bAadDTD`DDdXH@@hHaBdDAD`@PC@dbB@@@b@hPA

Sample input:_

R@AXPBS@x@EHM@U@DhL`T`aD

Sample output:

I@PCAHY@C`TBV@U@dBf@e@Pd

Ranking

Perl _

RankUserSizeTimeDateStatistics
1tails640.04572021/10/22 18:44:030B / 31B / 30B
2test1750.04462021/10/22 05:51:200B / ?B / ?B

Python _

RankUserSizeTimeDateStatistics
1lynn930.09362021/10/22 01:34:110B / 61B / 27B

Python3 _

RankUserSizeTimeDateStatistics
1btnlq860.13412021/10/22 03:30:360B / 49B / 32B

C _

RankUserSizeTimeDateStatistics
1tails910.04032021/11/01 15:22:185B / 41B / 44B
2鳴神裁4.1号1450.04052021/10/21 17:54:020B / 80B / 65B

gs2 _

RankUserSizeTimeDateStatistics
1tails150.20612021/10/27 21:42:496B / 7B / 0B
2whio180.20872021/10/27 00:38:148B / 7B / 1B

FerNANDo _

RankUserSizeTimeDateStatistics
1鳴神裁4.1号890.11982021/10/21 18:20:110B / 45B / 0B
2tails890.14512021/10/21 21:07:390B / 45B / 0B
3test1890.13432021/10/22 05:51:360B / ?B / ?B

Lazy-K _

RankUserSizeTimeDateStatistics
1tails5330.05112021/11/02 13:43:500B / 299B / 234B

z80 _

RankUserSizeTimeDateStatistics
1tails280.08062021/11/02 15:27:0619B / 5B / 4B

Language Ranking_

RankLangUserSizeScore
1gs2tails1510000
2z80tails285357
3Perltails642343
4Python3btnlq861744
5FerNANDo鳴神裁4.1号891685
6Ctails911648
7Pythonlynn931612
8Lazy-Ktails533281

return to the top page