Make a ;# interpreter

62

8

I recently created a new language called ;# (pronounced "Semicolon Hash") which only has two commands:

; add one to the accumulator

# modulo the accumulator by 127, convert to ASCII character and output without a newline. After this, reset the accumulator to 0. Yes, 127 is correct.

Any other character is ignored. It has no effect on the accumulator and should do nothing.

Your task is to create an interpreter for this powerful language!

It should be either a full program or a function that will take a ;# program as input and produce the correct output.

Examples

Output: Hello, World!
Program: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#au###h;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;h;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;o

Output: Fizz Buzz output
Program: link below

Output: !
Program: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#

Fizz Buzz up to 100

Leaderboard

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

/* Configuration */

var QUESTION_ID = 121921; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 48934; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });  
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];
  
  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>';
    });
    
    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });
    
  });
  
  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;
    
    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (/<a/.test(lang)) lang = jQuery(lang).text();
    
    languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang > b.lang) return 1;
    if (a.lang < b.lang) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}
body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="answer-list">
  <h2>Leaderboard</h2>
  <table class="answer-list">
    <thead>
      <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr>
    </thead>
    <tbody id="answers">

    </tbody>
  </table>
</div>
<div id="language-list">
  <h2>Winners by Language</h2>
  <table class="language-list">
    <thead>
      <tr><td>Language</td><td>User</td><td>Score</td></tr>
    </thead>
    <tbody id="languages">

    </tbody>
  </table>
</div>
<table style="display: none">
  <tbody id="answer-template">
    <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
<table style="display: none">
  <tbody id="language-template">
    <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>

caird coinheringaahing

Posted 2017-05-21T18:34:34.743

Reputation: 13 702

1Is it acceptable if an interpreter doesn't terminate its execution at the end of the input but instead keeps looping indefinitely without producing extra output? – Leo – 2017-05-22T09:26:15.503

5The second example makes me wonder about a program to encode a program to produce an output... recursive compilation! – frarugi87 – 2017-05-22T09:29:14.640

@Leo yes that's fine – caird coinheringaahing – 2017-05-22T14:46:34.427

How is the name of your language pronounced? – Reinstate Monica -- notmaynard – 2017-05-23T15:07:58.560

1@iamnotmaynard Semicolon Hash – caird coinheringaahing – 2017-05-23T15:09:07.613

2Maybe Wink Hash would be easier to say – James Waldby - jwpat7 – 2017-05-23T17:42:41.987

I've always thought that ';' was pronounced "ckhu", like clearing your thoat. So it would be "khushhh" :D – Finn O'leary – 2017-05-23T23:05:55.817

@iamnotmaynard How about slipwash? – Titus – 2017-08-28T13:28:54.803

Does the accumulator need to be set to 0 on a #, or is it sufficient to set it to a value that causes the next # to output \0? – None – 2018-09-11T21:02:06.020

Answers

20

Python 3, 69 68 bytes

-1 byte thanks to @WheatWizard

i=0
for c in input():
 i+=c==';'
 if'#'==c:print(end=chr(i%127));i=0

Try it online!

ovs

Posted 2017-05-21T18:34:34.743

Reputation: 21 408

1

You can save a byte by reversing your if. Try it online!

– Post Rock Garf Hunter – 2017-05-21T23:30:38.097

17

JavaScript (ES6), 76 82 80 bytes

s=>s.replace(/./g,c=>c=='#'?String.fromCharCode(a%(a=127)):(a+=(c==';'),''),a=0)

Demo

let f =

s=>s.replace(/./g,c=>c=='#'?String.fromCharCode(a%(a=127)):(a+=(c==';'),''),a=0)

console.log(JSON.stringify(f(";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;hafh;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;f;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;###ffh#h#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ffea;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#au###h;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;h;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;o")))
console.log(JSON.stringify(f(";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#")))

Recursive version, 82 77 bytes

Saved 5 bytes thanks to Neil

This one is likely to crash for large inputs such as the Fizz Buzz example.

f=([c,...s],a=0)=>c?c=='#'?String.fromCharCode(a%127)+f(s):f(s,a+(c==';')):""

Arnauld

Posted 2017-05-21T18:34:34.743

Reputation: 111 334

I think f(s,a+(c==';')) might knock three bytes off your recursive version. – Neil – 2017-05-22T08:52:20.013

@Neil It actually saves 5 bytes. :-) – Arnauld – 2017-05-22T11:10:05.407

I feel really silly now. I originally had a buggy version, and subtracted 2 bytes to fix the bug. But I had miscounted and the buggy version actually saved 7 bytes... – Neil – 2017-05-22T11:23:40.367

12

Retina, 336 63 67 65 66 62 59 bytes

T`;#-ÿ`¯_
;{127}|;+$

(^|¯)
¯
+T`-~`_-`[^¯]
T\`¯`

Try it online!

Readable version using hypothetical escape syntax:

T`;#\x01-ÿ`\x01¯_
;{127}|;+$

(^|¯)\x01\x01
¯\x02
+T`\x01-~`_\x03-\x7f`[^\x01¯]\x01
T\`¯`

Does not print NUL bytes, because TIO doesn't allow them in the source code. Also prints an extra newline at the end, but I guess it can't do otherwise. Trailing newline suppressed thanks to @Leo.

-273 (!) bytes thanks to @ETHproductions.

-2 bytes thanks to @ovs.

-3 bytes thanks to @Neil. Check out their wonderful 34-byte solution.

eush77

Posted 2017-05-21T18:34:34.743

Reputation: 1 280

1Oh my word. But can you not save a thousand bytes with +T`\x01-~`_\x03-\x7f`[^\x01¯]\x01? (including the unprintables as single chars, of course) – ETHproductions – 2017-05-21T23:41:50.987

@ETHproductions Of course you can. Thank you! :) – eush77 – 2017-05-21T23:51:16.870

1Currently the last letter is always in the output, even if there is no trailing # in the input. You can fix it by changing your second stage to (;{127}|;+$) – ovs – 2017-05-22T05:10:25.350

Can someone explain +T`-~`_-`[^¯] ? – ovs – 2017-05-22T07:25:02.907

@ovs Note that there're nonprintable characters in this line. It transforms (code N)(code 1) into (code N+1) using two ranges. – eush77 – 2017-05-22T08:39:10.463

@ovs Sorry, I added a readable version, and also fixed the bug you found. Thanks! – eush77 – 2017-05-22T09:09:36.130

1Do you need the +` on the third line? As you remove the entire match, there should be nothing left to replace in the second iteration. – ovs – 2017-05-22T09:14:58.447

Let us continue this discussion in chat.

– ovs – 2017-05-22T09:20:52.870

You can get rid of the final newline by adding a \ to the modifiers of the last stage – Leo – 2017-05-22T09:22:03.977

1I think I can do this in 34 bytes: T`;#\x01-ÿ`\x80\x7F_ \x80+$ (empty line) \+T`\x7Fo`\x01-\x80_`\x80[^\x80] (using hexadecimal escapes to represent unprintables). Outputs \x7F instead of nulls. – Neil – 2017-05-22T09:45:19.170

@Neil Impressive! Don't you think you should post this as a separate answer? – eush77 – 2017-05-22T09:56:35.297

@eush77 I wasn't sure how close it was to your answer; it might have looked like plaigirism. – Neil – 2017-05-22T10:30:13.537

12

Java 8, 100 bytes

s->{int i=0;for(byte b:s.getBytes()){if(b==59)i++;if(b==35){System.out.print((char)(i%127));i=0;}}};

Try it online!

Mas

Posted 2017-05-21T18:34:34.743

Reputation: 151

3Welcome to the site! :) – James – 2017-05-22T16:25:08.623

I added a link to an online interpreter with the FizzBuzz example for you (link text was too long to fit in a comment) – Jonathan Allan – 2017-05-22T20:26:57.610

Java uses UTF-16 for its programs. So, these aren't 100 bytes but 100 characters. – GeroldBroser reinstates Monica – 2017-05-23T12:50:51.937

Argh. I've been thinking far too long about how to beat this by splitting the String around # and ; and just using the length. I suspect it just becomes too long. – JollyJoker – 2017-05-23T14:54:31.670

@GeroldBroser Java source code can be 7-bit ASCII if you want to call this 87,5 bytes – JollyJoker – 2017-05-23T14:58:43.463

@JollyJoker Arguing with the JLS isn't among the best things a Java developer can do. – GeroldBroser reinstates Monica – 2017-05-23T16:34:36.027

@GeroldBroser Your link refers to Strings in Java, not Java source code. Java source code is usually UTF-8, and I believe UTF-16 is a syntax error. This answer is 100 bytes. – Una – 2017-05-23T18:19:49.027

@unascribed No, it doesn't. The first sentence in the section I linked reads "Programs are written using the Unicode character set.". String literals are covered in a diffferent section.

– GeroldBroser reinstates Monica – 2017-05-23T19:34:01.303

5@GeroldBroser Unicode is a character set: UTF-8 and UTF-16 are two encodings of that character set. ASCII source is perfectly valid as a Java program, and I have plenty of Java source files encoded in ASCII (which is also valid UTF-8, hence also a Unicode encoding). – None – 2017-05-23T20:24:23.467

@GeroldBroser The java compiler takes an -encoding parameter that accepts any of the supported charsets. The source code can be any of these.

– JollyJoker – 2017-05-24T08:54:04.843

4 bytes shorter: s->{int i=0;for(int b:s.getBytes()){if(b==59)i++;if(b==35){System.out.printf("%c",i%127);i=0;}}} (careful with StackExchange's hidden characters). 1 byte is removed due to the fact that the final semicolon is not part of the answer; in TIO, just put a ; as first character of the "footer" section. Can be further golfed if you accept a char[] instead of a String. – Olivier Grégoire – 2017-08-11T09:49:02.767

1Entirely golfed, for 81 bytes as a Consumer<char[]>: s->{char i=0;for(int b:s){if(b==59)i++;if(b==35){System.out.print(i%=127);i=0;}}} – Olivier Grégoire – 2017-08-11T09:55:51.297

11

Japt, 18 bytes

®è'; %# d}'# ë ¯J

There's an unprintable \x7f char after %#. Test it online!

How it works

®   è'; %#   d}'# ë ¯  J
mZ{Zè'; %127 d}'# ë s0,J
                         // Implicit: operate on input string
mZ{           }'#        // Split the input at '#'s, and map each item Z to
   Zè';                  //   the number of semicolons in Z,
        %127             //   mod 127,
             d           //   turned into a character.
m              '#        // Rejoin the list on '#'. At this point the Hello, World! example
                         // would be "H#e#l#l#o#,# #W#o#r#l#d#!#" plus an null byte.
                  ë      // Take every other character. Eliminates the unnecessary '#'s. 
                    ¯J   // Slice off the trailing byte (could be anything if there are
                         // semicolons after the last '#').
                         // Implicit: output result of last expression

ETHproductions

Posted 2017-05-21T18:34:34.743

Reputation: 47 880

1D'oh, should have checked the answers! Just spent some time on this only to find you'd beaten me to the punch. q'# ®è'; u# dì¯J also works for the same score. – Shaggy – 2017-05-22T10:35:13.677

11

Python, 65 bytes

This is a golf of this earlier answer.

lambda t:''.join(chr(x.count(';')%127)for x in t.split('#')[:-1])

Try it online! Python2

Try it online! Python3

Explanation

This is a pretty straightforward answer we determine how many ;s are between each # and print the chr mod 127. The only thing that might be a little bit strange is the [:-1]. We need to drop the last group because there will be no # after it.

For example

;;#;;;;#;;;;;#;;;

Will be split into

[';;',';;;;',';;;;;',';;;']

But we don't want the last ;;; because there is no # after it to print the value.

Post Rock Garf Hunter

Posted 2017-05-21T18:34:34.743

Reputation: 55 382

1I was busy trying to get all tests in one TIO link. Was chr for chr except t and x. – Jonathan Allan – 2017-05-21T23:54:53.887

9

Röda, 44 39 38 bytes

5 bytes saved thanks to @fergusq

{(_/`#`)|{|d|d~="[^;]",""chr #d%127}_}

Try it online!

Anonymous function that takes the input from the stream.


If other characters do not have to be ignored, I get this:

Röda, 20 bytes

{(_/`#`)|chr #_%127}

user41805

Posted 2017-05-21T18:34:34.743

Reputation: 16 320

9

Python 3, 69 Bytes

Improved, thanks to @Wheat Wizard, @Uriel

print(''.join(chr(s.count(';')%127)for s in input().split('#')[:-1]))

MrGeek

Posted 2017-05-21T18:34:34.743

Reputation: 231

3Welcome to Programming Puzzles and Code Golf! The objective here is to make the code as short as possible (in bytes), so you need to include the byte count in the header :). – Adnan – 2017-05-21T20:13:15.683

Thanks for explaining, didn't know that. I'll work on it then. – MrGeek – 2017-05-21T20:15:02.397

2You can remove the space after the :s. – Pavel – 2017-05-21T21:02:29.340

2Also, ';'==c saves a space, but not using if statements at all would be even shorter. – Dennis – 2017-05-21T22:39:37.760

You can remove that space before the for to save one character. – Gábor Fekete – 2017-05-22T13:46:20.013

>

  • I get the feeling that this was adapted from my/Uriel's answer. If so, you should probably mention that. 2) you don't need the space between ) and for.
  • < – Post Rock Garf Hunter – 2017-05-22T13:46:36.880

    >

  • Thanks for the 2) tip.
  • Actually it was the first thing i wrote down, I just thought it was gonna take a lot of bytes, then I saw an answer looking like it, so I removed unnecessary [] Thanks to your answer.
  • < – MrGeek – 2017-05-22T13:55:15.533

    9

    ><>, 35 bytes

    >i:0(?;:'#'=?v';'=?0
    ^   [0o%'␡'l~<
    

    Try it online! Replace with 0x7F, ^?, or "delete".

    Main loop

    >i:0(?;:'#'=?v      
    ^            <
    

    This takes a character of input (i), checks if its less than zero i.e. EOF (:0() and terminates the program if it is (?;). Otherwise, check if the input is equal to # (:'#'=). If it is, branch down and restart the loop (?v ... ^ ... <).

    Counter logic

                  ';'=?0
                  
    

    Check if the input is equal to ; (';'=). If it is, push a 0. Otherwise, do nothing. This restarts the main loop.

    Printing logic

    >       '#'=?v      
    ^   [0o%'␡'l~<
    

    When the input character is #, pop the input off the stack (~), get the number of members on the stack (l), push 127 ('␡'), and take the modulus (%). Then, output it as a character (o) and start a new stack ([0). This "zeroes" out the counter. Then, the loop restarts.

    Conor O'Brien

    Posted 2017-05-21T18:34:34.743

    Reputation: 36 228

    3Poor ><>. It's sad :0( :( – caird coinheringaahing – 2017-05-22T06:41:10.287

    9

    Ruby, 41 35 34 characters

    (40 34 33 characters code + 1 character command line option)

    gsub(/.*?#/){putc$&.count ?;%127}
    

    Thanks to:

    • Jordan for suggesting to use putc to not need explicit conversion with .chr (6 characters)
    • Kirill L. for finding the unnecessary parenthesis (1 character)

    Sample run:

    bash-4.4$ ruby -ne 'gsub(/.*?#/){putc$&.count ?;%127}' < '2d{.;#' | od -tad1
    0000000    2  etb    d  nul  nul  nul  nul    {  nul  nul  nul
              50   23  100    0    0    0    0  123    0    0    0
    0000013
    

    Try it online!

    manatwork

    Posted 2017-05-21T18:34:34.743

    Reputation: 17 865

    Doh. Although I done C in my early years, I completely forgot putc(). Thank you, @Jordan – manatwork – 2017-12-16T16:33:06.563

    1

    To my own surprise, you can actually drop parentheses after count to save a byte

    – Kirill L. – 2018-08-10T11:35:44.027

    Nice catch, @KirillL., thank you. – manatwork – 2018-08-10T15:39:01.923

    This is not applying the modulo in the current version of Ruby on TIO. Does do so with gsub(/.*?#/){putc ($&.count ?;)%127}

    – Deadcode – 2020-01-23T13:19:58.220

    1Thank you, @Deadcode. BTW, gsub(/.*?#/){putc$&.count(?;)%127} is shorter. – manatwork – 2020-01-23T13:46:22.027

    7

    05AB1E, 16 15 14 bytes

    Code:

    '#¡¨ʒ';¢127%ç?
    

    Explanation:

    '#¡              # Split on hashtags
       ¨             # Remove the last element
        ʒ            # For each element (actually a hacky way, since this is a filter)
         ';¢         #   Count the number of occurences of ';'
            127%     #   Modulo by 127
                ç    #   Convert to char
                 ?   #   Pop and print without a newline
    

    Uses the 05AB1E-encoding. Try it online!

    Adnan

    Posted 2017-05-21T18:34:34.743

    Reputation: 41 965

    7

    Jelly, 13 bytes

    ṣ”#Ṗċ€”;%127Ọ
    

    Try it online!

    How it works

    ṣ”#Ṗċ€”;%127Ọ  Main link. Argument: s (string)
    
    ṣ”#            Split s at hashes.
       Ṗ           Pop; remove the last chunk.
        ċ€”;       Count the semicola in each chunk.
            %127   Take the counts modulo 127.
                Ọ  Unordinal; cast integers to characters.
    

    Dennis

    Posted 2017-05-21T18:34:34.743

    Reputation: 196 637

    1The word semicola doesn't exist it's semicolons. – Erik the Outgolfer – 2017-06-11T17:51:14.290

    @EriktheOutgolfer https://en.m.wiktionary.org/wiki/semicola

    – Dennis – 2017-06-11T17:52:44.623

    Hmm, weird word. – Erik the Outgolfer – 2017-06-11T17:53:54.707

    @EriktheOutgolfer Someone on Wiktionary was probably trying to make the Latin plural valid in English, but cola and semicola spellings should be proscribed.

    – Cœur – 2017-09-09T14:23:52.260

    7

    Retina 0.8.2, 34 32 bytes

    T`;#\x00-\xFF`\x7F\x00_
    \+T`\x7Eo`\x00-\x7F_`\x7F[^\x7F]|\x7F$
    

    Try it online! Includes test case. Edit: Saved 2 bytes with some help from @MartinEnder. Now uses TIO link with null byte support thanks to @Deadcode. Note: Code includes unprintables, which I have replaced with hex escapes in the post. Explanation: The first line cleans up the input: ; is changed to \x7F, # to \x00 and everything else is deleted. Then whenever we see an \x7F that is not before another \x7F, we delete it and cyclically increment the code of any next character. This is iterated until there are no more \x7F characters left.

    Neil

    Posted 2017-05-21T18:34:34.743

    Reputation: 95 035

    You can save a byte by combining the last two stages with \x80([^\x80]|$) in the last stage. – Martin Ender – 2017-05-23T09:19:58.777

    @MartinEnder Thanks! Annoyingly, \s+T`\x7Fo`\x01-\x80_`\x80(?!\x80).? also only saves one byte. – Neil – 2017-05-23T09:30:57.590

    Ah, but [^\x80]|\x80$ saves two bytes, I think. – Neil – 2017-05-23T09:33:00.523

    Ah nice, yeah the last one works. I had also tried the negative lookahead, but the s is annoying. – Martin Ender – 2017-05-23T09:33:44.797

    TIO does allow NULs, and the third test case works. – Deadcode – 2020-01-23T08:56:51.147

    @Deadcode Maybe I just didn't know how to paste them in, but it's been a while back, so TIO may have been updated since... – Neil – 2020-01-23T10:37:44.867

    6

    05AB1E, 25 21 19 bytes

    -2 bytes thanks to Adnan

    Îvy';Q+y'#Qi127%ç?0
    

    Explanation:

    Î                       Initialise stack with 0 and then push input
     v                      For each character
      y';Q+                 If equal to ';', then increment top of stack
           y'#Qi            If equal to '#', then
                127%        Modulo top of stack with 127
                    ç       Convert to character
                     ?      Print without newline
                      0     Push a 0 to initialise the stack for the next print
    

    Try it online!

    Okx

    Posted 2017-05-21T18:34:34.743

    Reputation: 15 025

    1I think you can replace i>} by +. – Adnan – 2017-05-21T19:58:15.973

    6

    R, 97 90 86 84 bytes

    A function:

    function(s)for(i in utf8ToInt(s)){F=F+(i==59);if(i==35){cat(intToUtf8(F%%127));F=0}}
    

    When R starts, F is defined as FALSE (numeric 0).

    Ungolfed:

    function (s)
        for (i in utf8ToInt(s)) {
            F = F + (i == 59)
            if (i == 35) {
                cat(intToUtf8(F%%127))
                F = 0
            }
        }
    

    Sven Hohenstein

    Posted 2017-05-21T18:34:34.743

    Reputation: 2 464

    Shouldn't this be R+pryr? – L3viathan – 2017-05-22T08:31:10.710

    @L3viathan Since pryr is an R package, it is still R code. – Sven Hohenstein – 2017-05-22T08:58:27.437

    It is R code, but it requires the installation of an additional library. – L3viathan – 2017-05-22T09:05:36.230

    @L3viathan Do you think my answer is invalid? Should I avoid using additional packages? – Sven Hohenstein – 2017-05-22T09:11:35.777

    No, I just think you should call the language something like "R + pryr", like it is usually done in other languages too. – L3viathan – 2017-05-22T09:12:27.063

    @L3viathan OK, I added the package name to the title. – Sven Hohenstein – 2017-05-22T09:37:21.520

    @RandomUser I decided to not use an additional package. – Sven Hohenstein – 2017-05-22T15:09:12.763

    I've never seen an R answer that used a library with its title as "R + library." Maybe somebody could explain the difference between that and using import in, say, python? – BLT – 2017-05-22T23:38:14.827

    2@BLT There is no difference. In my opinion it is no problem to use additional packages that were created before the challenge. This is true for all languages. In Python you have to use import while in R you can use :: to directly access function in packages. You can often see the use of additional packages here (e.g., for Python and Java). However, I changed my former post because I don't want to engage in discussion. – Sven Hohenstein – 2017-05-23T05:04:52.607

    you can swap i==59 with i>58 and i==35 with i<36 since we know those will be the only two values (-2 bytes)

    You can get rid of the braces surrounding the function body since it's one statement (in the for loop) (-2 bytes) – Giuseppe – 2017-05-24T13:22:36.057

    @Giuseppe Let me cite the OP: Any other character is ignored. It has no effect on the accumulator and should do nothing. Hence, I need exact comparison. Thanks for pointing out that I can remove the braces! – Sven Hohenstein – 2017-05-24T14:13:18.063

    6

    x86 machine code on MS-DOS - 29 bytes

    00000000  31 d2 b4 01 cd 21 73 01  c3 3c 3b 75 06 42 80 fa  |1....!s..<;u.B..|
    00000010  7f 74 ed 3c 23 75 eb b4  02 cd 21 eb e3           |.t.<#u....!..|
    0000001d
    

    Commented assembly:

    bits 16
    org 100h
    
    start:
        xor dx,dx       ; reset dx (used as accumulator)
    readch:
        mov ah,1
        int 21h         ; read character
        jnc semicolon
        ret             ; quit if EOF
    semicolon:
        cmp al,';'      ; is it a semicolon?
        jne hash        ; if not, skip to next check
        inc dx          ; increment accumulator
        cmp dl,127      ; if we get to 127, reset it; this saves us the
        je start        ; hassle to perform the modulo when handling #
    hash:
        cmp al,'#'      ; is it a hash?
        jne readch      ; if not, skip back to character read
        mov ah,2        ; print dl (it was choosen as accumulator exactly
        int 21h         ; because it's the easiest register to print)
        jmp start       ; reset the accumulator and go on reading
    

    Matteo Italia

    Posted 2017-05-21T18:34:34.743

    Reputation: 3 669

    5

    Python, 82 bytes

    lambda t:''.join(chr(len([g for g in x if g==';'])%127)for x in t.split('#')[:-1])
    

    Uriel

    Posted 2017-05-21T18:34:34.743

    Reputation: 11 708

    1@WheatWizard since you already posted this as an answer, I believe the right action for me would be to upvote it rather than update – Uriel – 2017-05-22T11:36:03.533

    4

    CJam, 27 bytes

    0q{";#"#") 127%co0 "S/=~}%;
    

    Explanation:

    0                            e# Push 0
     q                           e# Push the input
      {                          e# For each character in the input:
       ";#"#                     e#   Index of character in ";#", -1 if not found
            ") 127%co0 "S/       e#   Push this string, split on spaces
                          =      e#   Array access (-1 is the last element)
                           ~     e#   Execute as CJam code. ")" increments the accumulator,
                                 e#     and "127%co0" preforms modulo by 127, converts to character, pops and outputs, and then pushes 0.
                            }%   e# End for
                              ;  e# Delete the accumulator
    

    Alternative Solution, 18 bytes

    q'#/);{';e=127%c}%
    

    Explanation:

    q                   e# Read the whole input
     '#/                e# Split on '#'
        );              e# Delete the last element
          {             e# For each element:
           ';e=         e#   Count number of ';' in string
               127%     e#   Modulo by 127
                   c    e#   Convert to character code
                    }%  e# End for
    

    Esolanging Fruit

    Posted 2017-05-21T18:34:34.743

    Reputation: 13 542

    Business Cat That doesn't ignore invalid characters. – Esolanging Fruit – 2017-05-21T19:31:12.173

    why do you need ; to delete the accumulator? – caird coinheringaahing – 2017-05-21T19:36:09.653

    @RandomUser So it doesn't end up getting outputted at the end with the string. – ETHproductions – 2017-05-21T19:44:51.103

    4

    Processing.js (Khanacademy version), 118 bytes

    var n="",a=0;for(var i=0;i<n.length;i++){if(n[i]===";"){a++;}if(n[i]==="#"){println(String.fromCharCode(a%127));a=0;}}
    

    Try it online!

    As the version of processing used does not have any input methods input is placed in n.

    Christopher

    Posted 2017-05-21T18:34:34.743

    Reputation: 3 428

    You could technically forge your own input method with keyTyped=function(){ ... } :P – ETHproductions – 2017-05-21T19:18:35.730

    @ETHproductions This is a look of disgust. – Christopher – 2017-05-21T19:19:44.907

    @RandomUser yay! I have done it! I like to answer in Processing (check my answers) – Christopher – 2017-05-21T19:37:39.840

    2@RandomUser Not just 1000 rep.. but 2^10 rep ( ͡° ͜ʖ ͡°) – None – 2017-05-22T17:46:12.320

    @Midnightas Ohhh yeah – Christopher – 2017-05-22T18:03:04.520

    @RandomUser Aight – None – 2017-05-22T18:15:34.947

    Does processing.js force you to use ===? And it doesn't have semicolon insertion? – Esolanging Fruit – 2017-05-23T01:48:02.953

    @Challenger5 yes you need === and semicolon insertion? – Christopher – 2017-05-23T10:17:47.390

    4

    F#, 79 91 93 bytes

    let rec r a=function|[]->()|';'::t->r(a+1)t|'#'::t->printf"%c"(char(a%127));r 0 t|_::y->r a y
    

    Ungolfed

    let rec run acc = function
        | [] -> ()
        | ';'::xs ->
            run (acc + 1) xs
        | '#'::xs ->
            printf "%c" (char(acc % 127))
            run 0 xs
        | x::xs -> run acc xs
    

    Try it online!

    Edit: Was treating any other char than ';' as '#'. Changed it so that it's ignoring invalid chars.

    Alternative

    F#, 107 104 bytes

    let r i=
     let a=ref 0
     [for c in i do c|>function|';'->a:=!a+1|'#'->printf"%c"(!a%127|>char);a:=0|_->()]
    

    Use of reference cell saves 3 bytes

    Ungolfed

    let run i =
        let a = ref 0;
        [for c in i do
            match c with
            | ';' -> a := !a + 1
            | '#' ->
                printf "%c" (char(!a % 127))
                a := 0
            |_->()
        ]
    

    Try it online

    Brunner

    Posted 2017-05-21T18:34:34.743

    Reputation: 331

    4

    Plain TeX, 156 bytes

    \newcount\a\def\;{\advance\a by 1\ifnum\a=127\a=0\fi}\def\#{\message{\the\a}\a=0}\catcode`;=13\catcode35=13\let;=\;\let#=\#\loop\read16 to\>\>\iftrue\repeat
    

    Readable

    \newcount\a
    
    \def\;{
      \advance\a by 1
      \ifnum \a=127 \a=0 \fi
    }
    \def\#{
      \message{\the\a}
      \a=0
    }
    
    \catcode`;=13
    \catcode35=13
    
    \let;=\;
    \let#=\#
    
    \loop
      \read16 to \> \>
      \iftrue \repeat
    

    Uriel

    Posted 2017-05-21T18:34:34.743

    Reputation: 11 708

    Can it print characters symbolically? – eush77 – 2017-05-21T23:20:01.827

    4

    C (gcc), 58 bytes

    a;f(char*s){a+=*s^35?*s==59:-putchar(a%127);a=*s&&f(s+1);}
    

    Try it online! (Hint: click ▼ Footer to collapse it.)

    Dennis

    Posted 2017-05-21T18:34:34.743

    Reputation: 196 637

    4

    Perl, 25 bytes

    $_=chr(y%;%%%127)x/#/
    

    Run with perl -043pe (counted as 4 bytes, since perl -e is standard).

    Explanation: -043 sets the line-terminator to # (ASCII 043). -p iterates over the input “lines” (actually #-delimited strings, now). y%;%% counts the number of ; in each “line”. x/#/ makes sure that we don’t print an extra character for programs that don’t end in a # (like the third testcase). %127 should be fairly obvious. $_= is the usual boilerplate.

    Grimmy

    Posted 2017-05-21T18:34:34.743

    Reputation: 12 521

    Impressing one, though there is glitch: for ;;#;;; it outputs #5 instead of #2. – manatwork – 2017-05-22T15:24:34.993

    How did you get this result? echo -n ';;#;;;' | perl -043pe '$_=chr(y%;%%%127)x/#/' | xxd correctly outputs 00000000: 02 on my machine.

    If you left off the 043, or are using a codepage where # is not ASCII 043, that would explain your result. – Grimmy – 2017-05-22T15:27:28.377

    1Oops. Sorry, I had a typo in my test. Your code works perfectly. – manatwork – 2017-05-22T15:32:06.937

    4

    Labyrinth, 61 47 bytes

    _36},)@
    ;    {
    ; 42_-
    "#-  1
    _ ; 72
    _ ) %
    """".
    

    Try it online!

    Explanation

    color coded image of the solution code

    Code execution begins in the top left corner and the first semicolon discards an implicit zero off the stack and continues to the right.

    Orange

    • _36 pushes 36 onto the stack. This is for comparing the input with #
    • } moves the top of the stack to the secondary stack
    • , pushes the integer value of the character on the stack
    • ) increments the stack (if it's the end of the input, this will make the stack 0 and the flow of the program will proceed to the @ and exit)
    • { moves the top of the secondary stack to the top of the primary stack
    • - pop y, pop x, push x - y. This is for comparing the input with # (35 in ascii). If the input was # the code will continue to the purple section (because the top of the stack is 0 the IP continues in the direction it was moving before), otherwise it will continue to the green section.

    Purple

    • 127 push 127 to the stack
    • % pop x, pop y, push x%y
    • . pop the top of the stack (the accumulator) and output as a character

    From here the gray code takes us to the top left corner of the program with nothing on the stack.

    Green

    • _24 push 24 onto the stack
    • - pop x, pop y, push x-y. 24 is the difference between # and ; so this checks if the input was ;. If it was ; the code continues straight towards the ). Otherwise it will turn to the # which pushes the height of the stack (always a positive number, forcing the program to turn right at the next intersection and miss the code which increments the accumulator)
    • ; discard the top of the stack
    • ) increment the top of the stack which is either an implicit zero or it is a previously incremented zero acting as the accumulator for output

    From here the gray code takes us to the top left corner of the program with the stack with only the accumulator on it.

    Gray

    Quotes are no-ops, _ pushes a 0 to the stack, and ; discards the top of the stack. All of this is just code to force the control-flow in the right way and discarding anything extra from the top of the stack.

    Robert Hickman

    Posted 2017-05-21T18:34:34.743

    Reputation: 661

    Out of curiosity, how did you generate the explanation image? Did you create it yourself? – Stefnotch – 2018-08-05T09:16:57.440

    2@Stefnotch, I used a text editor to put a tab between each character and then pasted the code into Microsoft Excel which put each character into it's own cell. I selected all cells to give them equal width and height. Then I adjusted colors and borders and took a screenshot. – Robert Hickman – 2018-08-07T16:20:40.850

    3

    C, 65 64 60 bytes

    (-2 thanks to ceilingcat)

    c;f(char*s){for(c=0;*s;s++)c+=*s-35?*s==59:-putchar(c%127);}
    

    hvd

    Posted 2017-05-21T18:34:34.743

    Reputation: 3 664

    You'll need to initialize c to zero to make the function reusable.

    – Conor O'Brien – 2017-05-21T23:40:28.017

    @ConorO'Brien Fixed. Unfortunately I didn't manage to come up with anything shorter than simply adding in the c=0, and I wouldn't want to cheat by copying from Dennis's answer. – hvd – 2017-05-22T19:41:38.360

    @ceilingcat Thanks again, I was able to take off three more bytes after that. This does use a trick in Dennis's answer (checked after editing), but this time, so much time had passed that I had forgotten all about it and came up with it on my own. – hvd – 2018-09-17T10:59:06.453

    3

    MATL, 29 bytes

    ';#'&mXz!"@o?T}vn127\c&YD]]vx
    

    Input is a string enclosed in single quotes.

    Try it online!

    The FizzBuzz program is too long for the online interpreters; see it working offline in this gif:

    enter image description here

    Explanation

    The accumulator value is implemented as the number of elements in the stack. This makes the program slower than if the accumulator value was a single number in the stack, it but saves a few bytes.

    ';#'       % Push this string
    &m         % Input string (implicit). Pushes row vector array of the same size with 
               % entries 1, 2 or 0 for chars equal to ';', '#' or others, respectively
    Xz         % Remove zeros. Gives a column vector
    !          % Transpose into a row vector
    "          % For each entry
      @        %   Push current entry
      o?       %   If odd
        T      %     Push true. This increases the accumulator (number of stack elements)
      }        %   Else
        v      %     Concatenate stack into a column vector
        n      %     Number of elements
        127\   %     Modulo 127
        c      %     Convert to char
        &YD    %     Display immediately without newline
      ]        %   End
    ]          % End
    vx         % Concatenate stack and delete. This avoids implicit display
    

    Luis Mendo

    Posted 2017-05-21T18:34:34.743

    Reputation: 87 464

    3

    Alice, 22 bytes

    I!?';-n+?h$'@u%?'#-n$O
    

    Try it online!

    Explanation

    We keep on the stack only a single counter of how many ; we have encountered. When the stack is empty (e.g. at the start of the program) this is implicitly a 0.

    I!?';-n+?h$'@u%?'#-n$O
    I                      Push codepoint of next char from input
     !?                    store it on the tape and reload it right away
       ';-n+               add 1 to the counter if this char is a semicolon,
                           0 otherwise
            ?h$'           If the input char was -1 (EOF) execute the next command,
                           otherwise push its codepoint
                @          Terminate the program (or push 64)
                 u         Set all bits up to the most significant as equal to 1
                           this turns 64 (1000000b) into 127 (1111111b)
                  %        Compute modulo
                   ?       reload the input char from the tape
                    '#-n$O if it is a hash, pop the counter and print
                           the corresponding character
                           wrap back to the start of the line
    

    A shorter, but non-terminating version of this program can be found here.

    Leo

    Posted 2017-05-21T18:34:34.743

    Reputation: 8 482

    Confirmed it here

    – caird coinheringaahing – 2017-05-22T15:00:48.953

    Sorry for the bad formatting, I've posted this from my phone, I'll fix it as soon as I get my hands on a pc – Leo – 2017-05-22T15:01:35.860

    Programs have to terminate unless specified otherwise in the challenge. – Martin Ender – 2017-05-23T09:08:54.230

    You can save a byte by using a literal 0x7F instead of ~h though. – Martin Ender – 2017-05-23T09:11:49.103

    @MartinEnder made it terminating. I couldn't manage to insert a 0x7F in the code, but I think this alternative modification is more interesting anyway :) – Leo – 2017-05-23T09:38:46.067

    That's neat, but it doesn't work the way you think it does: $'@ skips the '@ entirely, because it's considered a single command. So the reason it terminates is that there's a zero underneath and the % ends the program, although it may take an additional iteration to get there if the program ends with semicolons. – Martin Ender – 2017-05-23T09:42:55.760

    3

    JS (ES6), 97 92 bytes

    c=>(a=0,y="",c.split``.map(x=>x=="#"?(a%=127,y+=String.fromCharCode(a),a=0):x==";"?a++:0),y)
    

    Tried to take a different approach than Shaggy's answer. Oh well.

    user69749

    Posted 2017-05-21T18:34:34.743

    Reputation:

    3

    ;#+, 59 bytes, noncompeting

    Language was made after this challenge.

    ;;;;;~+++++++>~;~++++:>*(~<:-+!(<-;->(;))::<+-::!(<#>)-:-*)
    

    Try it online! Input is terminated with a null byte.

    Explanation

    The generation is the same as from my Generate ;# code answer. The only difference here is is the iteration.

    Iteration

    *(~<:-+!(<-;->(;))::<+-::!(<#>)-:-*)
    *(                                *)   take input while != 0
      ~                                    swap
       <                                   read value from memory (;)
        :                                  move forward to the accumulator memory spot (AMS)
         -                                 flip Δ
          +                                subtract two accumulators into A
           !                               flip A (0 -> 1, else -> 0)
            (     (;))                     if A is nonzero, or, if A == ';'
             <                             read from AMS
              -;-                          increment
                 >                         write to AMS
                      ::                   move to cell 0 (#)
                        <                  read value from memory (#)
                         +                 subtract two accumulators into A
                          -                flip Δ
                           ::              move to AMS
                             !(   )        if A == '#'
                               <           read from AMS
                                #          output mod 127, and clear
                                 >         write to AMS
                                   -:-     move back to initial cell
    

    Conor O'Brien

    Posted 2017-05-21T18:34:34.743

    Reputation: 36 228

    3

    Bash + coreutils, 46 39 bytes

    tr -dc \;#|sed 'y/;/1/;s/#/.ZC7%P/g'|dc
    

    Try it online!

    Explanation

    (Thanks Cows Quack for -7 bytes!)

    The tr portion removes all extraneous characters (I could put this in the sed for exactly the same bytecount, but then it doesn't handle the linefeed character correctly, since sed leaves them in and dc only gets up to the first linefeed with ?)

    sed takes the rest and builds a dc program:

    Strings of ; become strings of 1 (a long literal)

    # becomes .ZC7%P (if this follows a string of 1, the . is a decimal point for a no-op. But if it's at the beginning of the program, or following another #, it's a literal 0. Then it takes the length of the number, mods it, and Prints the corresponding ASCII.)

    Sophia Lechner

    Posted 2017-05-21T18:34:34.743

    Reputation: 1 200

    You don't need to escape the ; inside '...' and can simply change dc -ez? to dc. Besides that, instead of ;'s adding 1 to the stack, you can group them together and get their length using Z to reach this https://tio.run/##S0oszvj/v6RIQTclWSHGWrmmODVFQb1Y31pLWT9aLTbKUNfZXDVAP129JiX5/39rkoEy6VoyEtMySNeVRhe3kWGJsnJaWoZyBl0sIyPY0lITSdeVSIYe5cRSYFhkDM5gIMNZ@QA.

    – user41805 – 2018-09-08T09:10:58.353

    @Cowsquack That's good, thank you! (and the dc -ez? was a consequence of needing an extra zero to start the program) But your program adds additional output to stderr in either the cases of consecutive # or input that doesn't end with # (in both cases, I mean after extraneous characters are removed). I don't know if there's a consensus, but I feel like the extra output invalidates the solution. I adapted your idea, though, and wound up at just one byte more than your suggestion without dc throwing errors! – Sophia Lechner – 2018-09-09T06:09:16.297

    According to this stderr can be ignored unless the challenge explicitly states as such, so that is very handy for dc. Also note that this current solution fails with consecutive #s because Z of 0 is 1, so it outputs 0x01 instead of 0x00 (I fell into that same trap as well, but my browser displays unprintables as their hexcodes so I caught that).

    – user41805 – 2018-09-10T09:00:01.000

    2

    C#, 110 108 103 101 98 bytes

    -2 bytes by removing braces, where unnecessary

    -5 bytes by removing else, from else if

    -2 bytes, thanks to TheLethalCoder

    -3 bytes, thanks to Andrew Piliser

    a=>{var b=0;var d="";foreach(var c in a){if(c==59)b++;if(c==35){d+=(char)(b%127);b=0;}}return d;};
    

    Anonymous function, returns the output.

    Horváth Dávid

    Posted 2017-05-21T18:34:34.743

    Reputation: 679

    1Compare c to an int to save 2 bytes. – TheLethalCoder – 2017-05-22T08:17:55.797

    1I don't think you need the +"", it works without it for me. – Andrew – 2017-05-22T17:54:50.253

    2

    QBIC, 48 66 57 bytes

    [_l;||D=_sA,a,1|┘b=b-(D=@;`)~D=@#`|b=b%127?chr$(b)';`┘b=0
    

    Explanation:

    [    |           FOR
     _l;|              the length of the cmd line arg A$
     D=_sA,a,1|      Take the next character out of the string as D$
    ┘                Syntactic linebreak
    b=b-(D=@;`)      If D$ == ";", this yields -1. Subtracting this from ACC reverses the sign
    ~D=@#`|          And if D$ == "#"
    b=b%127          Do the Modulo-print thingy
    ?chr$(b)';`
    ┘b=0             And reset the acc
    

    steenbergh

    Posted 2017-05-21T18:34:34.743

    Reputation: 7 772

    2

    JavaScript (ES6), 91 85 bytes

    ETH beat me to the punch with a variation on the Japt solution I was working on (that'll learn me to check the answers first!) so here's the JS solution I was using as the basis for it:

    s=>s.split`#`.slice(0,-1).map(x=>String.fromCharCode(--x.split`;`.length%127)).join``
    

    Try it

    f=
    s=>s.split`#`.slice(0,-1).map(x=>String.fromCharCode(--x.split`;`.length%127)).join``
    oninput=_=>o.innerText=f(i.value)
    o.innerText=f(i.value=";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#")
    <input id=i><pre id=o>

    Shaggy

    Posted 2017-05-21T18:34:34.743

    Reputation: 24 623

    You could use ~-x.split`;`.length%127 to get rid of the ||0 and the extra parens – ETHproductions – 2017-05-22T14:32:40.547

    Good thinking, @ETHproductions; thanks. I was so focused on golfing down the Japt version, I forgot to golf this version before posting it. – Shaggy – 2017-05-22T14:38:01.983

    You've done --x.split rather than ~-x.split. Is this intentional or a mistake? – caird coinheringaahing – 2017-05-22T15:04:46.147

    It was a misreading of what ETH posted without my glasses on, @RandomUser, but the result is the same, as you can see in the Snippet. – Shaggy – 2017-05-22T15:07:43.357

    Actually I can't see in the Snippet (on mobile) – caird coinheringaahing – 2017-05-22T15:13:39.083

    Here's a JSBin, @RandomUser: http://jsbin.com/dejinu/edit?js,console

    – Shaggy – 2017-05-22T15:24:56.033

    2

    Befunge-98, 38 bytes

    v+1$>';-!#;_
    >~:;|-#';#:_@
    ^   >$' %,
    

    Try it online!

    Note that the input is terminated with a null byte and there is an unprintable (ASCII 127) on the third line after '

    ovs

    Posted 2017-05-21T18:34:34.743

    Reputation: 21 408

    2

    Perl 6, 49 bytes

    {S:g/(<-[#]>*)(\#)?/{chr($0.comb(';')%127)x?$1}/}
    

    Sean

    Posted 2017-05-21T18:34:34.743

    Reputation: 4 136

    2

    Go, 104 102 bytes

    Yeeeeaaaaaaaaaah, Go.

    import."fmt"
    func f(c string){i:=0;for _,r:=range c{if';'==r{i++};if'#'==r{Print(string(i%127));i=0}}}
    

    Try it online!

    totallyhuman

    Posted 2017-05-21T18:34:34.743

    Reputation: 15 378

    2

    R, 66 bytes

    intToUtf8(nchar(gsub("[^;]","",el(strsplit(scan(,""),"#"))))%%127)
    

    Test:

    > intToUtf8(nchar(gsub("[^;]","",el(strsplit(scan(,""),"#"))))%%127)
    1: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;... <truncated>
    2: 
    Read 1 item
    [1] "Hello, World!"
    

    djhurio

    Posted 2017-05-21T18:34:34.743

    Reputation: 1 113

    2

    Pyth, 16 bytes

    smC%/d\;127Pcw\#
    

    Try it!

    explanation

    smC%/d\;127Pcw\#
                cw\#    ## split the input on '#'
               P        ## remove the last element (everything after the last #)
     m                  ## map over this list of strings (variable: d)
        /d\;            ## count the semicolons
       %    127         ## modulo 127
      C                 ## the character with that number
    s                   ## concat the list of characters
    

    imperative version I did for fun: J0FHwIqH\;=+J1)IqH\#pC%J127=J0

    KarlKastor

    Posted 2017-05-21T18:34:34.743

    Reputation: 2 352

    2

    Brainfuck, 135 bytes

    +[>+>>,>+++++[<------->-]<[<+>>++++[<------>-]<[<->[-]]<[>>>+<<<-]<->>[-]]<<[>>>--[>>+<<--]>[>->+<[>]>[<+>-]<<[<]>-]>[-]>.[-]<<<<<<-]<]
    

    Ungolfed

    Memory layout
    0   1   2   3   4   5   6   7
    1   f1  f2  in  tmp acc d   acc%d   
    
    flag1 indicates hash
    flag2 indicates semicolon
    
    +[      infinite loop
        >+      set flag1
        >>,     input
        >+++++[<------->-]<     subtract 35 (hash)
    
        [       not hash
            <+> set flag2
            >++++[<------>-]<   subtract 24 more (semicolon)
            [   not semicolon
                <-> clear flag2
                [-] clear input
            ]
            <   goto flag2
            [   semicolon
                >>>+<<<-    inc acc and clear flag2
            ]
            <-  clear flag1
            >>[-]   clear input
        ]
        <<      goto flag1
        [       hash
            >>>--[>>+<<--]> set d 127 and goto acc
            [>->+<[>]>[<+>-]<<[<]>-]    mod
            >[-]>       clear d and goto acc%d 
            .[-]        print and clear result
            <<<<<<- clear flag1
        ]
    <]
    

    Mika Lammi

    Posted 2017-05-21T18:34:34.743

    Reputation: 1 151

    2

    Cubix, 53 bytes

    #..Wc.@n.!0i?\?;u...'u;.'\.U;.\w;;U.;).;'%o;c;.!;.U;
    

    Contains one non-printable character, DEL, which is ASCII 127. If the accumulator is 0 and an ignored character is read in, an additional 0 is added to the stack so this runs the risk of stack overflow.

    Try it online! and Watch it online

    Cubified:

          # . .
          W c .
          @ n .
    ! 0 i ? \ ? ; u . . . '
    u ; . ' \ . U ; . \ w ;
    ; U . ; ) . ; '   % o ;
          c ; .
          ! ; .
          U ; .
    

    Giuseppe

    Posted 2017-05-21T18:34:34.743

    Reputation: 21 077

    2

    Chip, 179 bytes

     HGFEDCB
    ,\\///\/A
    `--v~.
       |z^.
     ,\#xZ<
    a^xx/'`.
     ,\#xZ~<
    b^xx/' |
     ,\#xZ~<
    c^xx/' |
     ,\#xZ~<
    d^xx/' |
     ,\#xZ~<
    e^xx/' |
     ,\#xZ~<
    f^xx/' |
     ,\#xZ~'
    g^x-/'HGFEDCB
    S÷^---\\/\\\/A
    

    (UTF8, so ÷ is \xc3\xb7)

    Try it online!

    The upper block with A-H and the slashes is detecting the semicolon character, and the similar lower block is detecting the hash. If other bogus characters needn't be handled, the whole thing would be somewhere around 133 bytes.

    The middle block does the following:

    Z's are the registers, one for each of the seven bits.

    The half-adders # allow for incrementing by 1 in case of a semicolon. If not a semicolon, increment by 0.

    If we get a hash, send the current register values to a-g, which outputs the desired character, and then reset the values to zero with the switches \.

    If the registers are 0b1111110 (126), as determined by the right two columns, the next increment results in zero due to the switches /.

    Phlarx

    Posted 2017-05-21T18:34:34.743

    Reputation: 1 366

    2

    SNOBOL4 (CSNOBOL4), 182 167 bytes

    	S =INPUT
    R	S NOTANY(';#') =	:S(R)
    K	K =
    T	S LEN(1) . C REM . S	:F(O)
    	K =IDENT(C,';') K + 1	:S(T)
    	&ALPHABET LEN(REMDR(K,127)) LEN(1) . A
    	Y =Y A	:(K)
    O	OUTPUT =Y
    END
    

    Try it online!

    Due to size limitations in this implementation of SNOBOL, it can only read in lines of 1024 characters at a time, discarding the rest. So it only manages to print Hello, Worl. Ah well.

    	S =INPUT				;*read input
    R	S NOTANY(';#') =Y	:S(R)		;*recursively remove non ;# characters
    K	K =0					;*counter
    T	EQ(SIZE(S)) :S(O)			;*if string is empty, goto output
    	S LEN(1) . C REM . S			;*set C to the first char, the REMainder to S
    	K =IDENT(C,';') K + 1	:S(T)		;*if C is identical to ';', increment C and goto T
    	&ALPHABET LEN(REMDR(K,127)) LEN(1) . A	;*get the K % 127th character, set it to A
    	Y =Y A	:(K)				;*append A to Y
    O	OUTPUT =Y				;*output Y
    END
    

    Giuseppe

    Posted 2017-05-21T18:34:34.743

    Reputation: 21 077

    2

    Haskell, 70 bytes

    (-7 thanks to BWO)

    n#(o:p)|o==';'=(n+1)#p|o=='#'=toEnum(mod n 127):0#p|1>0=n#p
    _#p=p
    (0#)
    

    Try it online!

    mrFoobles

    Posted 2017-05-21T18:34:34.743

    Reputation: 41

    Huh, I always thought you had to use a space to call a function. – mrFoobles – 2018-08-12T16:00:31.243

    1n#(o:p)|o=='#'=toEnum(mod n 127):0#p|o/=';'=n#p|w<-n+1=w#p works for 69 bytes. – ovs – 2018-08-12T17:22:25.000

    2

    F# (.NET Core), 71 bytes

    Seq.fold(fun a->function|';'->a+1|'#'->printf"%c"(a%127|>char);0|_->a)0
    

    Try it online!

    Jordan Osborn

    Posted 2017-05-21T18:34:34.743

    Reputation: 21

    2

    May I recommend adding a link to a service like Try It Online where we can see it in action? For example.

    – Οurous – 2018-09-05T22:51:10.737

    By using that functions curry you can drop the ses and shorten that to an anonymous function

    – Ørjan Johansen – 2018-09-06T01:37:19.470

    2

    Shakespeare Programming Language, 447 439 404 bytes

    ,.Ajax,.Ford,.Act I:.Scene I:.[Exeunt][Enter Ajax and Ford]Ajax:Open mind.Ford:Am I as big as the sum ofa pig twice twice the sum ofa pig a big big big big cat?If soyou be the sum ofyou a cat.Be you worse the sum ofa pig twice the cube ofa big big cat?If notyou zero.Am I as big as the sum ofa cat twice the sum ofa cat a big big big big cat?If soSpeak thy.If soYou zero.Am I nicer zero?If soLet usAct I.
    

    Try it online!

    -35 bytes thanks to Joe King!

    JosiahRyanW

    Posted 2017-05-21T18:34:34.743

    Reputation: 2 600

    404 bytes with proper termination – Jo King – 2018-09-10T00:51:06.193

    Y'know, I should've thought about wrapping the accumulator manually. – JosiahRyanW – 2018-09-10T01:37:12.690

    2

    Awk, 57 bytes

    BEGIN{RS="#"}RT=="#"{printf("%c",gsub(";","")%127)}

    Explanation:

    • BEGIN{RS="#"}: make # record delimeter
    • RT=="#": ignore the record without ending #
    • gsub(";","")%127: count ; and mod 127
    • printf("%c",_): print as ASCII

    no1xsyzy

    Posted 2017-05-21T18:34:34.743

    Reputation: 271

    1

    PHP, 84 79 70 1 + 63 = 64 bytes

    for(;$c=$argn[$i++];$a+=$c==";")$c^A^R||$a=~-print chr($a%127);
    

    Run as pipe with -nR

    Try it online!

    noahnu

    Posted 2017-05-21T18:34:34.743

    Reputation: 111

    1

    PHP, 61 Bytes

    for(;~$c=a^$argn[$i++];)$n+=$c^r?$c==Z:-$n*print chr($n%127);
    

    Try it online!

    PHP, 68 Bytes

    for(;a&$c=$argn[$i++];)$c!=";"?$c!="#"?:$n=1-print chr($n%127):++$n;
    

    Try it online!

    Jörg Hülsermann

    Posted 2017-05-21T18:34:34.743

    Reputation: 13 026

    2Doesn't work with 0. Fixed and slightly golfed: for(;~$c=a^$argn[$i++];)$c^r?$n+=$c==Z:print~$n=~chr($n%127);. – user63956 – 2017-05-22T06:10:04.567

    @user63956 It tooks a long time to understand how this works. Nice Thank You – Jörg Hülsermann – 2017-05-22T10:21:32.583

    1Yields warnings A non-numeric value encountered in PHP 7.1. Use $n+=$c^r?$c==Z:-$n*print chr($n%127); (same length) to fix. – Titus – 2017-05-22T13:47:18.710

    @Titus Done Thank You – Jörg Hülsermann – 2017-05-22T14:05:45.687

    1

    C, 74 72 70 bytes

    a;f(char*s){for(;*s;s++){if(*s==59)a++;if(*s==35)putchar(a%127),a=0;}}
    

    Test cases:

    Output: Hello, World!
    f(";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;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;;;;;###ffh#h#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ffea;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#au###h;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;h;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;o");
    
    Output: !
    f(";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#");
    

    MD XF

    Posted 2017-05-21T18:34:34.743

    Reputation: 11 605

    1

    C (gcc), 66 bytes

    a;f(char*c){for(a=0;*c;a+=*c==59,a=*c++==35&&putchar(a%127)?0:a);}
    

    Try it online!

    Conor O'Brien

    Posted 2017-05-21T18:34:34.743

    Reputation: 36 228

    1

    shortC, 51 bytes

    a;f(C*s){O;*s;s++){F*s==59)a++;F*s==35)Pa%127),a=0;
    

    MD XF

    Posted 2017-05-21T18:34:34.743

    Reputation: 11 605

    1

    J, 29 bytes

    [:u:127|[:+/"1[:';'&=;.1'#',]
    

    Try it online!

    Leaky Nun

    Posted 2017-05-21T18:34:34.743

    Reputation: 45 011

    The third test case outputs 2┴d{I, but I think it might be because of J's alphabet a. – miles – 2017-05-23T02:33:56.580

    1

    C, 56 54 bytes

    a;f(char*s){a+=*s-35?*s==59:-putch(a%127);*s&&f(s+1);}
    

    Solution is based on Dennis's one ("C (gcc), 58 bytes"), but with elimination of two characters a=

    Two more symbols can be taken off with substitution putchar with putch

    VolAnd

    Posted 2017-05-21T18:34:34.743

    Reputation: 296

    1a= is required to make the function reusable; since a is global, it has to be reset to 0. – Dennis – 2017-05-23T04:08:46.110

    putch is not standard C. – MD XF – 2017-05-23T21:19:30.057

    1

    Cheddar, 57 bytes

    @.split("#").head(-1).map(s->@"(s.count(";")%127)).join()
    

    Try it online!

    Leaky Nun

    Posted 2017-05-21T18:34:34.743

    Reputation: 45 011

    1

    Aceto, 38 31 bytes

    The program reads and processes one character at a time, so it will work with infinite ;# programs. Run with -F if you want immediate results (because buffering), but it works without it if the program is long enough.

      Ox%-12
      =_cpF7
    d'#'O
    ,;=|xIO
    

    , reads a character. We duplicate it and compare it with ;. If it's equal, we mirror to the right side (=|), drop (x) the duplicate, Increment the value on the stack (implicitly zero), and go back to the Origin.

    If it's not equal, we compare the copy with #. If that is equal, we mirror upwards (=_; somewhere in empty space above, but the next non-nop we read will be the 2). We push a 2 and a 7, compute 2^7 (F), and substract 1 (1-). We then do a modulo operation (%) convert it to a character, print it (without a newline) and go back to the Origin.

    If it's none of those characters, we drop the value on the stack (x) and go back to the Origin.

    L3viathan

    Posted 2017-05-21T18:34:34.743

    Reputation: 3 151

    1

    Gema, 63 characters

    \A=@set{a;0}
    \;=@incr{a}
    \#=@int-char{@mod{$a;127}}@set{a;0}
    ?=
    

    Sample run:

    bash-4.4$ gema '\A=@set{a;0};\;=@incr{a};\#=@int-char{@mod{$a;127}}@set{a;0};?=' < '2d{.;#' | od -tad1
    0000000    2  etb    d  nul  nul  nul  nul    {  nul  nul  nul
              50   23  100    0    0    0    0  123    0    0    0
    0000013
    

    manatwork

    Posted 2017-05-21T18:34:34.743

    Reputation: 17 865

    I do so love Gema answers. – Jordan – 2017-05-24T02:01:19.453

    1

    APL (Dyalog) , 25 bytes

    ⎕UCS 127|+/¨';'='#'(≠⊂⊢)⍞
    

    Try it online! Some of the longer test cases seem to have problems on TIO, but work fine offline.

     get text input

    '#'() apply the following tacit function with hash as left argument:

     the inequality

     partitions*

     the right argument (all the semicolons and hashes)

    ';'= equality to semicolon

    +/¨ sum each

    127| mod-127

    ⎕UCS Convert to corresponding Unicode character


    in versions up to 15.0, providing that ⎕ML←3 which is default on many systems. In version 16.0 and higher, just use .

    Adám

    Posted 2017-05-21T18:34:34.743

    Reputation: 37 779

    1

    PowerShell, 67 65

    -join$(switch("$input"|% t*y){';'{$a++}'#'{[char]($a%127);$a=0}})
    

    Fairly straightforward with not many surprising twists.

    • 2018-09-06: Shorter way of converting the string to a character array.

    Joey

    Posted 2017-05-21T18:34:34.743

    Reputation: 12 260

    Nice expression with switch. – mazzy – 2018-09-06T12:43:18.980

    1

    Clojure, 71 bytes

    #(for[i(re-seq #"[^#]*#"%)](print(char(mod(count(filter #{\;}i))127))))
    

    Splits into chunks by regex, counts how many ;s there are in each chunk.

    NikoNyrh

    Posted 2017-05-21T18:34:34.743

    Reputation: 2 361

    1

    Haxe, 145 136 bytes

    function(s){var a=0;for(i in 0...s.length){var c=s.charAt(i);if(c==';')a++;else if(c=='#'){Sys.print(String.fromCharCode(a%127));a=0;}}}
    

    -9 bytes thanks to Haxe's "inline function" (lambda) feature

    Don't think I've ever seen an answer given in Haxe before, probably because it's not very golfy, and not that well known.

    The code's really quite self-explanatory, here's the un-golfed version:

    function(s) {
        var a=0;
        for(i in 0...s.length) {
            var c=s.charAt(i);
            if(c==';') {
                a++;
            }
            else if(c=='#') {
                Sys.print(String.fromCharCode(a%127));
                a=0;
            }
        }
    }
    

    Skidsdev

    Posted 2017-05-21T18:34:34.743

    Reputation: 9 656

    1

    Rust, 109 bytes

    Rust was not created for golfing...

    fn f(s:&str){let mut a=0u8;for c in s.chars(){if c==';'{a+=1;}if c=='#'{a%=127;print!("{}",a as char);a=0;}}}
    

    Peter Lenkefi

    Posted 2017-05-21T18:34:34.743

    Reputation: 1 577

    1

    Rip, 33 chars

    0gDiW[D';EI[Pi0]'#EI[27pdMo0]gDi]
    

    Got around to testing this, and this works with the given examples.

    tomsmeding

    Posted 2017-05-21T18:34:34.743

    Reputation: 2 034

    1

    jq, 54 characters

    (49 characters code + 5 characters command line options)

    [scan(".*?#")|gsub("[^;]";"")|length%127]|implode
    

    Sample run:

    bash-4.4$ jq -Rrj '[scan(".*?#")|gsub("[^;]";"")|length%127]|implode' < '2d{.;#' | od -tad1
    0000000    2  etb    d  nul  nul  nul  nul    {  nul  nul  nul
              50   23  100    0    0    0    0  123    0    0    0
    0000013
    

    On-line test

    manatwork

    Posted 2017-05-21T18:34:34.743

    Reputation: 17 865

    1

    Mathematica, 81 bytes

    StringReplace[a=0;#,{";":>(a++;""),"#":>FromCharacterCode@Mod[a,a=0;127],_:>""}]&
    

    Pure function expecting a string argument.

    Explanation

    The basic evaluation procedure (it can be more complicated) for an expression in Mathematica is to evaluate the head of the epxression, then evaluate each of its arguments in order, then apply any definitions, then evaluate the entire expression again until nothing changes.

    So first we evaluate StringReplace (no-op). The first argument is a=0;#, which sets the accumulator a to 0 and returns the first argument (denoted #) to the function. The second argument is a list of string replacement rules, which are applied in order starting at the beginning of the string.

    If we encounter the substring ";", we replace it with (a++;""). Since we used :> instead of ->, this replacement expression is only evaluated whenever we actually find a match for ";". It (post-)increments a and returns the empty string, so finding a match for ";" effectively increments the accumulator and deletes the semicolon. In the case of a match, we move to the next position in the string, otherwise we check the next rule in the list.

    If we encounter the substring "#", we replace it with FromCharacterCode@Mod[a,a=0;127]. FromCharacterCode does what you expect, but Mod[a,a=0;127] can be tricky if you don't understand Mathematica's evaluation procedure. We evaluate Mod (no-op), then evaluate the first argument a to get the value of the accumulator. When we evaluate the second argument a=0;127, we reset the accumulator to 0 and return 127. Thus we end up with Mod[<a>,127], where <a> is whatever the value of a was before the expression started evaluating. The only way I can think of to get this to work by resetting the accumulator after calculating the modulus without introducing additional variables is something like "#":>Reap[Sow[FromCharacterCode[Mod[a,127]]];a=0][[2,1,1]]. Introducing another variable I could do something like "#":>(b=a;a=0;FromCharacterCode[b~Mod~127]).

    If we reach the last replacement rule, we replace any single character _ with the empty string "".

    ngenisis

    Posted 2017-05-21T18:34:34.743

    Reputation: 4 600

    1No builtin this time? – caird coinheringaahing – 2017-05-24T06:18:07.240

    1

    C# 7572 + 18 = 9390 Bytes

    using System.Linq;
    s=>string.Join("",s.Split('#').Select(p=>(char)(p.Count(c=>c==59)%127)))
    

    -3 Bytes thanks to @Charlie

    Ungolfed full program with test cases

    using System.Linq;
    
    class P
    {
        static void Main()
        {
            System.Func<string, string> f =
                s => string.Join("",                  //6. Combine results with empty string as separator
                    s.Split('#')                      //1. Split the input by #
                        .Select(                      //2. For each part
                            p => (char)(              //5. Convert to character
                                p.Count(c => c == 59) //3. Count of all ;
                                % 127)                //4. Mod 127
                        ));
    
            System.Console.WriteLine(f(";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;###ffh#h#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ffea;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#au###h;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;h;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;o"));
            System.Console.WriteLine(f(";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#"));
        }    
    }
    

    raznagul

    Posted 2017-05-21T18:34:34.743

    Reputation: 424

    I've just come up with this same answer by myself, only to see that you posted it before. You can save 3 bytes using Count instead of Sum. Note that the last ; does not count.

    – Charlie – 2018-09-06T09:13:44.393

    s.Split('#') gives an extra letter in the second example. Note that last substring has not # at end. – mazzy – 2018-09-06T13:12:44.553

    I made the same solution and then I found yours. You can save 6 bytes if you won't join the string, but create an array of chars with ToArray(). – Jirka Picek – 2020-01-23T10:11:10.827

    1

    Common Lisp, 89 bytes

    (do((a 0))(())(case(read-char)(#\;(incf a))(#\#(princ(code-char(mod a 127)))(setf a 0))))
    

    Try it online!.

    This is an actual interpreter.

    Renzo

    Posted 2017-05-21T18:34:34.743

    Reputation: 2 260

    1

    Proton, 66 bytes

    a=>''.join(map(len+((%)&127)+chr,a.rstrip(';').split('\#'))[to-1])
    

    Try it online!

    HyperNeutrino

    Posted 2017-05-21T18:34:34.743

    Reputation: 26 575

    This is the one of the first challenges you found to answer? :P – totallyhuman – 2017-08-17T19:45:41.647

    @totallyhuman hey why not :P – HyperNeutrino – 2017-08-17T19:57:09.227

    1

    Bash + coreutils + dc, 93 bytes

    tr ';#' '69'|tr -dc '69'|dc -e '?0sa[10~rdZ1<P]dsPx[6=Ala127%P0sa]sR[la1+saq]sA[lRxz0<M]dsMx'
    

    Try it online!

    First time submitting a multi-utility answer, so if I botched that let me know - but just treating it as bash seems the least generous in terms of byte count anyway.

    I thought this would be fun to do in dc, but obviously dc does not really care for strings, so the first thing to do was use tr to translate it into a new dialect, 69 which is just ;# only... well, sixes and nines. After doing that, we also use tr to delete everything that isn't a 6 or a 9 so that we don't have to account for errant characters in dc.

    With a giant number input into dc, we can make an interpreter. 0sa clears the accumulator, a. [10~rdZ1<P]dsPx uses the divide-returning-both-quotient-and-remainder command, ~ to break our big number into a stack full of individual commands. Jump to the end, the main macro [lRxz0<M]dsMx executes macro R until the stack is empty. Macro R is [6=Ala127%P0sa]sR, which tests if the top-of-stack is a 6 and runs macro A if so. Macro A has a quit command in it, which essentially makes the rest of R an else statement. This does the mod 127, Print ASCII, and reset accumulator a to zero operations. Meanwhile, macro A is just a simple increment operation for the accumulator: [la1+saq]sA.

    You can try just the dc portion online!

    brhfl

    Posted 2017-05-21T18:34:34.743

    Reputation: 1 291

    1

    Gol><>, 20 18 bytes

    Credit to Jo King.

    iE;:`#=q$o`;=+`~P%
    

    Try it online!

    How it works

    iE;:`#=q$o`;=+`~P%
                        Accumulator (m) is stored at the bottom
    iE;                 Take input (n) as char; halt if EOF
       :`#=q            If n == '#'... (preserving n on the top)
            $o            Output m as char, discarding it
              `;=+      If n == ';', increment m
                  `~P%  m = m % 127
                        Repeat indefinitely
    

    Previous submission, 20 bytes

    iE;:`#=Q$`~P%o|`;=?P
    

    Try it online!

    How it works

    iE;:`#=Q$`~P%o|`;=?P
    
                          Accumulator (m) is always stored at the bottom
    iE;                   Take input (n) as char, halt if EOF
       :`#=Q      |       If n == '#'... (preserving n on the top)
            $`~P%o        Swap m to the top, output m%127 as char
                   `;=?   If n == ';'... (discarding n; m is exposed to the top)
                       P  Increment m
                          Repeat indefinitely
    

    Bubbler

    Posted 2017-05-21T18:34:34.743

    Reputation: 16 616

    18 bytes – Jo King – 2018-09-06T13:07:57.253

    1

    Coconut, 59 bytes

    t->''.join(map(x->chr(x.count(';')%127),t.split('#')[:-1]))
    

    Try it online!

    JoshM

    Posted 2017-05-21T18:34:34.743

    Reputation: 379

    1

    Haskell, 66 bytes

    f s|(a,_:b)<-span(/='#')s=toEnum(mod(sum[1|';'<-a])127):f b|1<3=[]
    

    Try it online!

    • f takes a string s as input and looks for the first # with (a,_:b)<-span(/='#')s, which splits s in the part a before the first # and b everything after.
    • sum[1|';'<-a] counts the number of ; in a which is converted into the corresponding character by toEnum after taking it modulo 127.
    • f b recursively processes the rest of the string.
    • The pattern match (a,_:b)<-span(/='#')s fails if no # exists anymore, in which case in the second pattern guard 1<3=[] the empty list is returned.

    Laikoni

    Posted 2017-05-21T18:34:34.743

    Reputation: 23 676

    1

    Julia 1.0, 90 62 bytes

    i(s)=print.(Char.(count.(==(';'),split(s,"#")[1:end-1]).%127))
    

    Try it online!

    Rustem B.

    Posted 2017-05-21T18:34:34.743

    Reputation: 51

    1

    Backhand, 37 bytes

    }>_oi!{:0v] @! |{^:v-"%";"#""-"|{]~.
    

    Try it online!

    As usual with Backhand programs, I'm pretty sure this could be golfed further, but to do so would require some restructuring.

    Explanation

    Note that by default the pointer moves three steps at a time

    }>                 Start on the second character
        i  :  ]  ! |{  Get input and check if it is EOF
                @      Reflect and terminate if so
                      :  "  ;  "  - |{     Check if the character is a ;
                                       ~.  If so, pop the extra copy of the character
                          %  "    "  [    Increment by 1 and modulo by 127
                     ^ v    Decrement the pointer step value by one and then increment it again to skip the |{
     >_  !  0  And restart the loop
                                    |      If it is not a ;, reflect
                        -  "  #  "         Check if it is a #
             v   !   ^   Increment pointer and decrement again
    }>_o  !{    Output if the character was a # and restart the loop
    

    Jo King

    Posted 2017-05-21T18:34:34.743

    Reputation: 38 234

    1

    CJam, 18 bytes

    q'#/{';e=127%c}%);
    

    Try it online!

    Explanation

    q                  "Take the whole input as a single string";
     '#/               "Split the input string with hashes";
                       "This counts the empty results";
                       "According to the challenge empty results can only be";
                       "generated from trailing #'s";
        {         }%   "Map every ; sequence in the string:";
         ';e=          "Count the semicolons"
             127%      "Find the remainder of the length w/ 127";
                 c     "Convert to a character"
                    ); "There is a trailing null string designed for this check";
                       "If there isn't a trailing null string (i.e.)";
                       "program doesn't end with #, this removes the last item of the list";
                       "Implicit flatten the list & print as string";
    

    user85052

    Posted 2017-05-21T18:34:34.743

    Reputation:

    1

    C# (Visual C# Interactive Compiler), 66 bytes

    s=>s.Split('#').Select(x=>(char)(x.Count(y=>y==59)%127)).ToArray()
    

    Try it online!

    Jirka Picek

    Posted 2017-05-21T18:34:34.743

    Reputation: 171

    1

    APL, 41 bytes/chars

    {⎕AV[⍋⎕NXLATE 0][127|≢¨⌽⊂⍨⌽2=⍵(⊢⍳∩)';#']}
    

    Explanation:

    vector of ASCII characters

    {⎕AV[⍋⎕NXLATE 0]                          }
    

    select elements from that vector

    {                 [                         ]}
    

    keep only characters from the stream belonging to the set ';#'

    {                 [               ⍵(  ∩)';#']}
    

    find position of each character of the stream in the set ';#'

    {                 [               ⍵(⊢⍳ )';#']}
    

    0 where there's ';' and 1 where there's '#'

    {                 [             2=          ]}
    

    reverse the stream, partition beginning at every 1, reverse back; note that trailing ';'s get discarded this way

    {                 [       ⌽⊂⍨⌽            ]}
    

    length of each partition modulo 127

    {                 [127|≢¨                   ]}
    

    Popov

    Posted 2017-05-21T18:34:34.743

    Reputation: 101

    1

    Packed Pyth, 14 bytes

    Hex dump: AD 43 1F 7B 88 F8 43 4A BE 75 C7 6C 59 37

    Try it online!

    Pyth, 16 bytes

    VPcw\#pC%/N\;127
    

    Try it online!

    Python equivalent:

    for N in input().split('#')[:-1]:
        print(end=chr(N.count(';') % 127))
    

    Token by token explanation:

    VPcw\#pC%/N\;127
    V                 # for N in                        :
       w              #          input()                      # take one line of input
      c \#            #                 .split('#')
     P                #                            [:-1]      # discard last element
              N       #                N
             / \;     #                 .count(';')
            %    127  #                             % 127
           C          #            chr(                  )
          p           #  print(end=                       )   # print without trailing newline
    

    After doing this, I looked at the other Pyth answers and found that KarlKastor's also got 16 bytes. However, I believe my answer is more correct, as it does not print a trailing newline. Since every ;;;;;;;;;;# in the input results in outputting a newline, an extra one should not be added at the end.

    Funnily enough, we also both made an imperative version. Mine comes in at 25 bytes:

    VwIqN\;=%hZ127)IqN\#pC~Z0
    

    Try it online!

    Python equivalent:

    Z=0
    for N in input():
        if N==';': Z = (Z % 127) + 1
        if N=='#': print(end=chr(Z)); Z=0
    

    Deadcode

    Posted 2017-05-21T18:34:34.743

    Reputation: 3 022

    1

    Burlesque, 19 bytes

    '#;;{';CN127.%L[}\m
    

    Try it online!

    '#;;     # Split strings at #s
    {
     ';CN    # Count the number of ; in each
      127.%  # Mod 127
      L[     # Convert to char
    }\m      # Map and concatenate
    

    DeathIncarnate

    Posted 2017-05-21T18:34:34.743

    Reputation: 916

    1

    PHP, 56 75 bytes

    foreach(explode('#',$argn,-1)as$c)echo chr((count_chars($c,1)[59]??0)%127);
    

    Try it online!

    Thanks to @Umbrella for the nudge. Actually read the question and bug fixed.

    Guillermo Phillips

    Posted 2017-05-21T18:34:34.743

    Reputation: 561

    This will echo a non-printable character at the end. Pass -1 to explode to fix. – Umbrella – 2020-01-24T21:45:15.677

    1

    Prolog (SWI), 104 bytes

    It worked out to be shorter to write directly to stdout inside the predicate. The more idiomatic way of implementing something like this in Prolog would be to have third parameter for the predicate which would be the output from interpreting the program.

    +A:-string_codes(A,B),0+B.
    A+[E|T]:-E=35,!,C is A mod 127,put_code(C),0+T;E=59,!,B is A+1,B+T;A+T.
    _+[].
    

    Try it online!

    ankh-morpork

    Posted 2017-05-21T18:34:34.743

    Reputation: 1 350

    You can remove the mod by matching against 127+X (my prolog terminology might be off) – user41805 – 2020-01-24T17:20:30.823

    0

    F#, 165 162 bytes

    -3 bytes, thanks to Random User

    let g a=
     let mutable b=0
     let mutable d=""
     for c in a do
      if c=';' then
      b<-b+1
      elif c='#' then
      d<-[|d;string(char(b%127))|]|>Array.fold(+)""
      b<-0
     d
    

    It's basically a port of my C# answer.

    Horváth Dávid

    Posted 2017-05-21T18:34:34.743

    Reputation: 679

    2let golf a? golf?! Why? – caird coinheringaahing – 2017-05-21T19:38:34.107

    @RandomUser I don't know, but I shortened it. – Horváth Dávid – 2017-05-21T19:40:51.640

    0

    Actually, 20 bytes

    '#@s⌠';@c7╙D@%c⌡MdXΣ
    

    Try it online!

    Explanation:

    '#@s⌠';@c7╙D@%c⌡MdXΣ
    '#@s                  split on "#"
        ⌠';@c7╙D@%c⌡M     for each chunk:
         ';@c               count occurrences of ";"
             7╙D@%          mod by 127 (2**7-1)
                  c         convert to ASCII char
                     dX   discard last item
                       Σ  concatenate
    

    Mego

    Posted 2017-05-21T18:34:34.743

    Reputation: 32 998

    Breaks on test case #3 because it's discarding zero-length chunks. – Deadcode – 2020-01-23T13:35:39.703

    0

    Python 3, 66 bytes

    a=0
    for c in input():a-=a*(c=='#'!=print(end=chr(a%127)))-(c==';')
    

    Try it online!

    Dennis

    Posted 2017-05-21T18:34:34.743

    Reputation: 196 637

    0

    Java 8, 112 bytes

    This expression is a Consumer<String>, so it assumes s is a String.

    (s)->{int i=0;for(char c:s.toCharArray()){if(c==';')i++;else if(c=='#'){System.out.print((char)(i%127));i=0;}}};
    

    user47018

    Posted 2017-05-21T18:34:34.743

    Reputation:

    0

    Ruby, 71 50 bytes

    $*[0].split(?#).each{|p|$><<(p.count(?;)%127).chr}
    

    Edit: Complete rewrite. manatwork's solution is still shorter, but this does it a slightly different way!

    Chowlett

    Posted 2017-05-21T18:34:34.743

    Reputation: 221

    You can replace $><<(xxx).chr with putc xxx for -5 bytes. – Jordan – 2017-12-16T17:32:18.483

    0

    AHK, 83 bytes

    Loop,Parse,1
    {f:=A_LoopField
    If(f=";")
    i++
    If(f="#"){
    Send % Chr(Mod(i,127))
    i=0
    }}
    

    By default, Loop,Parse will parse each character individually.


    I had a 76 bytes version based on splitting the input on # but, as pointed out by manatwork as a comment, it'll print the very last section even without a # at the end.

    Loop,Parse,1,#
    Send % Chr(Mod(StrLen(RegExReplace(A_LoopField,"[^;]")),127))
    

    Engineer Toast

    Posted 2017-05-21T18:34:34.743

    Reputation: 5 769

    Sure this prints only on #? I mean, sure ;;#;;; will result #2 and not #2#3? – manatwork – 2017-05-22T13:15:21.967

    @manatwork Good point. I had to rewrite it at the expense of 7 bytes. Thanks. – Engineer Toast – 2017-05-22T13:42:33.443

    0

    Fourier, 32 bytes

    $(I~Q{59}{&A}Q{35}{A%127a0~A}&i)
    

    Try it on FourIDE!

    Enter the program between quotation marks.

    Explanation Pseudocode

    While i != Input length
        Q = Pop character off start of string and get char ASCII code
        If Q = 59 Then
            Increment A
        End If
        If Q = 35 Then
            Convert A mod 127 to character and Print
            A = 0
        End If
        Increment i
    End While
    

    Beta Decay

    Posted 2017-05-21T18:34:34.743

    Reputation: 21 478

    0

    Add $p=";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#"; to actually enjoy this tasty script. ($p is the input variable)

    PowerShell, 98 bytes

    [char[]]$p|%{if($_-eq';'){$o++}elseif($_-eq'#'){Write-Host -NoNewLine ([char]($o%127));[int]$o=0}}
    

    Try it online!

    Jeff Freeman

    Posted 2017-05-21T18:34:34.743

    Reputation: 221

    0

    java, 86 95 bytes

    this is a lambda expression assignable to a Consumer<String>

    s->{for(String t:s.split("#|[^#]*\\Z"))System.out.print((char)(t.split(";",-1).length-1%127));}
    

    Explanation:

    • split the input using # as the delimiter and ignore everything after the last match
    • for each substring, count the number of ;'s and output the count as a char

    Jack Ammo

    Posted 2017-05-21T18:34:34.743

    Reputation: 430

    0

    JavaScript (ES6), 71 Bytes

    p=>([...p].map(v=>v==";"?i++:b+=String.fromCharCode(i,i=0),i=0,b=""),b)
    

    This can probably be golfed, but I think the concept passing extra arguments to functions is one of the reasons why JavaScript is one of the more interesting languages to golf in.

    MayorMonty

    Posted 2017-05-21T18:34:34.743

    Reputation: 778

    This seems to insert spaces between each character of the output nor does it look like it ignores invalid characters. – Shaggy – 2017-05-29T12:05:12.923

    0

    Ly, 44 bytes

    0<i[[";"=[pp>1+<2$]p"#"=[pp>(127)%o0<2$]]i];
    

    Try it online!

    This submission does not work with the latest version of the Ly interpreter.
    A version that does work, for 43 bytes:

    ir[[";"=[pp>1+<2$]p"#"=[pp>(127)%o<2$]pp]];
    

    Try it online!

    LyricLy

    Posted 2017-05-21T18:34:34.743

    Reputation: 3 313

    0

    MaybeLater, 99 bytes

    s=read()wheni is*{if((S=s[i])!=u){if(S==";")a++if(S=="#"){writechra%127a=0}when0secondpass i++}}i=0
    

    Ungolfed & Commented

    input_string=read()                                 // Read the input from STDIN
    when index is *{                                    // When index updates...
        if((this_char=input_string[index])!=undefined){ // If it's not undefined (So we've iterated onto another entry)...
            if(this_char==";")                          // If this character is a ;
                accumulator++                           // Increment the accumulator (Which defaults to 0)
            if(this_char=="#"){                         // If it's # however
                write(chr(accumulator%127))             // Write the character value of the accumlator % 127, and reset the accumulator.
                accumulator=0
            }
            when 0 second pass                          // When 0 seconds pass, to prevent stack overflow, increment the index. Which loops.
                index++
        }
    }
                                                        // Start off the index.
    index = 0
    

    Try it online!

    ATaco

    Posted 2017-05-21T18:34:34.743

    Reputation: 7 898

    0

    Kotlin, 105 bytes

    Submission

    fun d(l:String):String=l.split("#").map{(it.length%127).toChar()}.joinToString("").removeSuffix("\u0000")
    

    TryItOnline

    Link

    Explanation

    • It splits the string into ; chunks
    • Then it changes them into characters
    • It joins them into a string
    • Then it removes the null byte from the end

    jrtapsell

    Posted 2017-05-21T18:34:34.743

    Reputation: 915

    0

    Pyth, 18 bytes

    My misunderstanding works anyways... hmm?

    Jcw"#"VtlJpC/@JN";
    

    Explanation:

    Jcw"#"        Split the input by "#" and store it in J
    VtlJ          For the length of J - 1...
     p            Print without newline...
      C/@JN";       Character from charcode (length of ';'s at the Nth position in J)
    

    Try it online!

    Stan Strum

    Posted 2017-05-21T18:34:34.743

    Reputation: 436

    Doesn't work. You need this. (Does Pyth have a constant tho?) – None – 2020-01-23T10:56:57.943

    0

    Clojure, 69 bytes

    #(reduce(fn[a c](case c\;(inc a)\#(do(print(char(mod a 127)))0)a))0%)
    

    A simple reduction over the code. Alters the accumulator accordingly for each character that's read.

    (defn interpret [code]
      (reduce (fn [acc chr]
                (case chr
                  \; (inc acc)
                  \# (do (print (char (mod acc 127))) ; Print the char,
                         0) ; then reset the accumulator
                  acc)) ; An ignored character; don't do anything
              0 ; The initial accumulator
              code))
    

    Carcigenicate

    Posted 2017-05-21T18:34:34.743

    Reputation: 3 295

    0

    Ahead, 26 bytes

    r  o%721$<
    ~>j@i:'#=n';=+~
    

    Try it online!

    snail_

    Posted 2017-05-21T18:34:34.743

    Reputation: 1 982

    0

    Noether, 42 bytes

    I~sL(si/~c{";"=}{!a}c{"#"=}{a127MBP0~a}!i)
    

    Try it online!

    Beta Decay

    Posted 2017-05-21T18:34:34.743

    Reputation: 21 478

    0

    Haskell, 73 bytes

    f[]a=""
    f(c:s)a|c==';'=f s(a+1)|c=='#'=toEnum(a`mod`127):f s 0|0<1=f s a
    

    AlexJ136

    Posted 2017-05-21T18:34:34.743

    Reputation: 251

    1

    It looks like you require f to be called with an additional argument, however the question only allows taking a string as argument. Therefore you need to add something like g x=f x 0, or by swapping the arguments just the anonymous function f 0: Try it online!

    – Laikoni – 2018-08-11T11:09:42.917

    1

    However you can save some bytes by replacing True with 0<1, moving f a[]="" to the last line and writing it as f a e=e and by replacing f by an infix operator.

    – Laikoni – 2018-08-11T11:13:58.857

    0

    Clojure, 65 bytes

    (fn[c](map #(char(mod((frequencies %)\;)127))(re-seq #"[^#]+"c)))
    

    Splits the code by '#', counts the number of ';', and turns the number (mod 127) into its ascii value

    Try it online!

    Lispy Louie

    Posted 2017-05-21T18:34:34.743

    Reputation: 289

    0

    Swift, 117 bytes

    func f(i:String){var a=0;for c in i{if c==";" {a+=1}else{print(Character(UnicodeScalar(a%127)!),terminator:"");a=0}}}
    

    Expanded out:

    func f(i: String) {
        var a = 0
        for c in i {
            if c==";" {
                a += 1
            } else {
                print(Character(UnicodeScalar(a%127)!),terminator:"")
                a=0
            }
        }
    }
    

    Run it online

    Ezekiel Elin

    Posted 2017-05-21T18:34:34.743

    Reputation: 121

    0

    Pascal (FPC), 134 133 122 bytes

    var c:char;a:word;begin repeat read(c);if c='#'then begin write(chr(a mod 127));a:=0 end;if c=';'then Inc(a)until eof end.
    

    Try it online!

    Assumes non-empty input.

    AlexRacer

    Posted 2017-05-21T18:34:34.743

    Reputation: 979

    0

    brainfuck, 201 bytes

    +[>>,[>+>+<<-]>>>----[>+<----]>----[-<<->>]+<<[>>-<<[-]]>>[-<<<[-]<<+[->>+>+<<<]>>>>>--[<+>--]<[-<->]<[[-]<[->>+<<]>][-]<[-]>>[-<<<<+>>>>]>]<<<[>--[>--<+++++++]>-[<+>-]<[-<->]<[[-]-]+[[-]<<.[-]>>]]<<<]
    

    Try it online! As a note, this will take 60 seconds to finish because the program will never halt, so it will stop after the Tio 60 second timeout.

    How it works

    This works differently than the given algorithm. Instead of using mod it just wraps to 0 after counting 127 semicolons.

    +[                              'while true
        >>,                         'read input
        [>+>+<<-]                   
        >>>----[>+<----]>----       
        [-<<->>]+<<[>>-<<[-]]>>     'if(input == ';')
        [                       
            -<<<[-]<<+              'increment counter 
            [->>+>+<<<]
            >>>>>--[<+>--]<
            [-<->]  
            <[                      'if(counter == 127) counter = 0
                [-]<[->>+<<]>
            ]
            [-]<[-]                 
            >>[-<<<<+>>>>]>
        ]
        <<<[                        'if(input != 59)
            >--[>--<+++++++]>-      
            [<+>-]          
            <[-<->]     
            <[                      'if(input == '#')
                [-]-                
            ]
            +[                      
                [-]                 
                <<.[-]>>            'print counter as ascii and clear tape
            ]
        ]
        <<<         
    ]
    

    Prismo

    Posted 2017-05-21T18:34:34.743

    Reputation: 121

    0

    Forth (gforth), 77 bytes

    : f 0 tuck do over i + c@ '# - ?dup if 24 = - else 127 mod emit 0 then loop ;
    

    Try it online!

    Code Explanation

    : f            \ start a new word definition
      0 tuck       \ put 0 on the top of the stack and stick a copy behind the second stack item
      do           \ begin a counted loop from 0 to string length - 1
        over i +   \ get the address of the next character
        c@ '# -    \ get the next character's ascii value and subtract ascii # (35)
        ?dup       \ if result is not 0, duplicate
        if         \ if result is true (not 0)
          24 = -   \ check if result = 24, and subtract -1 from accumulator if it is (0 otherwise)
        else       \ else (if result was equal to 35)
          127 mod  \ get accumulator mod 127
          emit 0   \ output accumulator and replace with 0
        then       \ end if
      loop         \ end loop
    ;              \ end word definition
    

    reffu

    Posted 2017-05-21T18:34:34.743

    Reputation: 1 361

    0

    PHP, 84 bytes

    First attempt 144 133 bytes

    I was able to remove 11 by using all ternary conditions, this required adding some ( ) to cement in the operation order. PHP has a weird thing with that.

    function f($s,$i,$c,$r){echo''==($a=$s[$i])?$r:('#'==$a?f($s,++$i,0,$r.=chr($c%127)):(';'==$a?f($s,++$i,++$c,$r):f($s,++$i,$c,$r)));}
    

    Test it like this:

    error_reporting(0);
    
    $strings =[';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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strings as $s){
        f($s,0,0,''); echo "\n";
    }
    
    function f($s,$i,$c,$r){echo''==($a=$s[$i])?$r:('#'==$a?f($s,++$i,0,$r.=chr($c%127)):(';'==$a?f($s,++$i,++$c,$r):f($s,++$i,$c,$r)));}
    

    Output

    Hello, World!
    ;#
    2d����{���
    !
    

    Sandbox

    Notes/Explanation

    This is a recursive function. Most of the space savings comes from using ternary conditionals,short variable names and grouping some of the setters into the aforementioned conditions. It takes 4 input arguments and sets 1 local variable:

    Arguments/Variables

    $s - the ;# string to parse.

    $i - the iterator, to keep track of the current position in the string, starts at 0.

    $c - the register keeps the count of ; prior to #, starts at 0.

    $r - the results, the output of the parser, starts as an empty string.

    Expanded version:

    function f($s,$i,$c,$r){
        if( '' == ( $a = $s[$i] ) ){
             echo $r;
        }else{
            if( '#' == $a ){
                f( $s, ++$i, 0, $r.=chr( $c % 127 ));
            }else{
                if( ';' == $a ){
                    f( $s, ++$i, ++$c, $r);
                }else{
                    f( $s, ++$i, $c, $r);
                }
            }
        }
    }
    

    Update attempt 2, 77 84 Bytes (PHP < 7)

    Had to add aomw to fix a bug with it having an empty element in the array at the end.

     function f($s){foreach(split('#',$s)as$a)echo!$a?'':chr(substr_count($a,';')%127);}
    

    You can change split to explode to make it compatible with PHP7, but add 2 bytes. Test it the same as above, produces the same output.

    Sandbox2

    Expanded version:

    function f($s){
         $array = split('#',$s)
         foreach($array as $a){
            if(!$a){
               echo '';
            }else{
               $count = substr_count($a,';');
               echo chr($count%127);
            }
         }
    }
    

    It's shorter, simpler, and should be faster. The key to this one was substr_count which I already know about but didn't think of right away, as I was a bit rushed for time on the first attempt. After thinking about it some, I came up with this and almost cut it in half. Not bad!

    Basically it splits it on the # and then counts the occurrences of ; in each array item and outputs the character that generates.

    Cheers!

    ArtisticPhoenix

    Posted 2017-05-21T18:34:34.743

    Reputation: 329

    0

    Powershell, 67 bytes

    See also Joey's answer

    -join($args-split'#|[^#]*$'|%{[char]((($_-split';').Count-1)%127)})
    

    Test script:

    $f = {
    
        -join($args-split'#|[^#]*$'|%{[char]((($_-split';').Count-1)%127)})
    
    }
    
    $c00 = [char]0x0000
    $c23 = [char]0x0017
    
    @(
        ,($c00,'#')
        ,('',';;;;;;')
        ,("2$($c23)d$c00$c00$c00$c00{$c00$c00$($c00)",';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;hafh;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;f;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;###ffh#h#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ffea;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#au###h;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;h;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;o')
        ,('Hello, World!', ';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#')
        ,(';#', ';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#')
        ,('!', ';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#')
    ) | %{
        $e,$s = $_
        $r = &$f $s
        "$($e-eq$r): $r"
    }
    

    Output:

    True:
    True:
    True: 2d    {
    True: Hello, World!
    True: ;#
    True: !
    

    Explanation:

    -join(                                   #
        $args-split'#|[^#]*$'|%{             # extract strings tailed by # symbol from arguments
            [char](                          #
                (($_-split';').Count-1)%127  # count ; symbol in each extracted string, get remain by 127
            )                                # convert int to char
        }                                    #
    )                                        # join all chars
    

    mazzy

    Posted 2017-05-21T18:34:34.743

    Reputation: 4 832

    0

    VBA (Excel) 103 Bytes

    Function a(b)
      For Each c In Split(b,"#")
        a=a &Chr((Len(c)-Len(Replace(c,";","")))Mod 127)
      Next
    End Function
    

    Un-golfed With Comments:

    Function fromSemiHash(myString)    'SemiHash is how I think it should be pronounced :D
        'For each string in myString split by hashes
        For Each littleString In Split(myString,"#")
            'Append the char from((the length of everything minus length of everything but ;'s) mod 127)
            toSemiHash = toSemiHash & Chr((Len(littleString) - Len( Replace( littleString , ";" ,""))) Mod 127)
        Next littleString
    End Function
    

    seadoggie01

    Posted 2017-05-21T18:34:34.743

    Reputation: 181

    0

    Kotlin, 77 bytes

    {Regex(";*#").findAll(it).fold(""){a,v->a+((v.value.length-1)%127).toChar()}}
    

    Try it online!

    snail_

    Posted 2017-05-21T18:34:34.743

    Reputation: 1 982

    0

    Whitespace, 119 bytes

    [S S S N
    _Push_0][N
    S S N
    _Create_Label_LOOP][S N
    S _Duplicate_top][S N
    S _Duplicate_top][T N
    T   S _Read_STDIN_as_character][T   T   T   _Retrieve][S N
    S _Duplicate_input][S S S T S S S T T   N
    _Push_35][T S S T   _Subtract][N
    T   S S N
    _If_0_Jump_to_Label_PRINT_CHAR][S S S T T   T   S T T   N
    _Push_59][T S S T   _Subtract][N
    T   S T N
    _If_0_Jump_to_Label_INCREASE][N
    S N
    N
    _Jump_to_Label_LOOP][N
    S S S N
    _Create_Label_PRINT_CHAR][S N
    N
    _Discard_top][S S S T   T   T   T   T   T   T   N
    _Push_127][T    S T T   _Modulo][T  N
    S S _Print_as_character][S S S N
    _Push_0][N
    S N
    N
    _Jump_to_Label_LOOP][N
    S S T   N
    _Create_Label_INCREASE][S S S T N
    _Push_1][T  S S S _Add][N
    S N
    N
    _Jump_to_Label_LOOP]
    

    Letters S (space), T (tab), and N (new-line) added as highlighting only.
    [..._some_action] added as explanation only.

    Try it online (with raw spaces, tabs and new-lines only).

    Pseudo-code:

    Integer i = 0
    Label LOOP:
      Character c = STDIN as character
      If(c == '#'):
        Jump to Label PRINT_CHAR
      If(c == ';'):
        Jump to Label INCREASE
      Jump to Label LOOP
    
    Label PRINT_CHAR:
      i = i modulo-127
      Print i as character to STDOUT
      i = 0
      Jump to Label LOOP
    
    Label INCREASE:
      i = i + 1
      Jump to Label LOOP
    

    Kevin Cruijssen

    Posted 2017-05-21T18:34:34.743

    Reputation: 67 575

    0

    JavaScript (Node.js), 86 bytes

    s=>[...s].map(e=>e==";"?++i:e=="#"?z+=String.fromCharCode(i%127,i=0)[0]:0,i=0,z="")&&z
    

    Try it online!

    ggorlen

    Posted 2017-05-21T18:34:34.743

    Reputation: 121

    This is not applying the modulo by 127. – Deadcode – 2020-01-23T09:26:47.043

    Fixed -- thanks! – ggorlen – 2020-01-23T15:01:46.773

    0

    Stax, 12 bytes

    î╟°♪ƒ▌○«*G<╠
    

    Run and debug it

    recursive

    Posted 2017-05-21T18:34:34.743

    Reputation: 8 616