Problem with Lua Golf Code

I play with this problem for code golf: https://www.spoj.pl/SHORTEN/problems/KAMIL/

I have a solution up to 55 characters:

  for l in io.lines () do print (2 ^ # l: gsub ("[^ TDLF]", "")) end

Now the shortest sent solution in Lua is 47 characters. I just can’t understand how to further reduce my production, and it drove me crazy. Does anyone have a clue for me? I tried working with io.read ("* a") to get rid of the loop, but that didn't help.

+4
source share
2 answers

Lua (54 characters)

repeat print(2^#io.read():gsub('[^TDLF]',''))until nil 

errors on completion, so maybe not normal

Otherwise, I spent some time experimenting with the second gsub return; but you always get one character with a return choice.

0
source

Perl 5 (28 characters)

A terrible start, I have to do much better for Perl. But I'm rusty. If I could initialize

 print 2**s/[TLDF]//g,$/for<> 

I know that you wanted Lua, but I notice that the site allows you to use all languages ​​except Perl 6. Therefore, I wanted to submit a record :-)

-3
source

All Articles