Lazy word problems











up vote
9
down vote

favorite
2












Summary



A teacher was told to prepare word problems for the students. She is given a list of equations and told to write them as the corresponding word problem. However, she is very lazy, so she doesn't put much creativity into it. Instead, she simply writes it literally. For example, when she reads 1+1, she writes one plus one, 47 * 2 would turn into forty seven times two, and 56.2 / 7.4 would become fifty six point two divided by seven point four.



Write some code to help this lazy teacher out.



Details




  • Numbers may include a decimal point and a negative sign.

  • Numbers should be written in the short scale. (i.e., 1,000,000,000 is one billion)

  • Numbers can go up to 999,999,999,999,999,999 (nine hundred ninety nine quadrillion...nine hundred ninety nine).

  • Groups of zeros must be left out. e.g. 1,000,000 is one million not one million zero thousand zero hundred.

  • There can be arbitrarily many digits past the decimal point.

  • Digits after the decimal point must be listed digit by digit. e.g. 12.34 is twelve point three four not twelve point thirty four.

  • Two numbers are always separated by an operator.

  • The valid operators are plus (+), minus (-), times (*), and divided by (/).

  • There are no parentheses.

  • Numbers such as 1234 may optionally include an and in their output, as in one thousand two hundred *and* thirty four.

  • Commas and whitespace on the input may be ignored.


Examples



Input: 24 + 65

Output: twenty four plus sixty five



Input: 3.33333 - 0

Output: three point three three three three three minus zero



Input: 3.6 * 18.18 / 999.0

Output: three point six times eighteen point one eight divided by nine hundred ninety nine point zero



Input: 1-1

Output: one minus one



Input: 1+-1

Output: one plus negative one



Input: 1,000,000,000 + 0.2

Output: one billion plus zero point two



Input: 123,000,456,789,012,345.6789

Output: one hundred twenty three quadrillion four hundred fifty six billion seven hundred eighty nine million twelve thousand three hundred forty five point six seven eight nine



Input: -4.3 * 7

Output: negative four point three times seven



Input: -1-1--1

Output: negative one minus one minus negative one










share|improve this question




















  • 1




    Could you add something like 123,456,789,012,345.6789 to the examples? It should cover a lot of test cases.
    – maxb
    15 hours ago






  • 2




    Can we use minus instead of negative?
    – Jo King
    15 hours ago






  • 1




    Can we assume that the input won't have whitespace in it? Alternatively, can the output have multiple spaces between words?
    – Jo King
    15 hours ago








  • 3




    For Mathematica: again there is a builtin, but / is over and negative number is minus, so it needs some manipulation.
    – user202729
    15 hours ago








  • 3




    Converting integers to English words
    – user202729
    15 hours ago















up vote
9
down vote

favorite
2












Summary



A teacher was told to prepare word problems for the students. She is given a list of equations and told to write them as the corresponding word problem. However, she is very lazy, so she doesn't put much creativity into it. Instead, she simply writes it literally. For example, when she reads 1+1, she writes one plus one, 47 * 2 would turn into forty seven times two, and 56.2 / 7.4 would become fifty six point two divided by seven point four.



Write some code to help this lazy teacher out.



Details




  • Numbers may include a decimal point and a negative sign.

  • Numbers should be written in the short scale. (i.e., 1,000,000,000 is one billion)

  • Numbers can go up to 999,999,999,999,999,999 (nine hundred ninety nine quadrillion...nine hundred ninety nine).

  • Groups of zeros must be left out. e.g. 1,000,000 is one million not one million zero thousand zero hundred.

  • There can be arbitrarily many digits past the decimal point.

  • Digits after the decimal point must be listed digit by digit. e.g. 12.34 is twelve point three four not twelve point thirty four.

  • Two numbers are always separated by an operator.

  • The valid operators are plus (+), minus (-), times (*), and divided by (/).

  • There are no parentheses.

  • Numbers such as 1234 may optionally include an and in their output, as in one thousand two hundred *and* thirty four.

  • Commas and whitespace on the input may be ignored.


Examples



Input: 24 + 65

Output: twenty four plus sixty five



Input: 3.33333 - 0

Output: three point three three three three three minus zero



Input: 3.6 * 18.18 / 999.0

Output: three point six times eighteen point one eight divided by nine hundred ninety nine point zero



Input: 1-1

Output: one minus one



Input: 1+-1

Output: one plus negative one



Input: 1,000,000,000 + 0.2

Output: one billion plus zero point two



Input: 123,000,456,789,012,345.6789

Output: one hundred twenty three quadrillion four hundred fifty six billion seven hundred eighty nine million twelve thousand three hundred forty five point six seven eight nine



Input: -4.3 * 7

Output: negative four point three times seven



Input: -1-1--1

Output: negative one minus one minus negative one










share|improve this question




















  • 1




    Could you add something like 123,456,789,012,345.6789 to the examples? It should cover a lot of test cases.
    – maxb
    15 hours ago






  • 2




    Can we use minus instead of negative?
    – Jo King
    15 hours ago






  • 1




    Can we assume that the input won't have whitespace in it? Alternatively, can the output have multiple spaces between words?
    – Jo King
    15 hours ago








  • 3




    For Mathematica: again there is a builtin, but / is over and negative number is minus, so it needs some manipulation.
    – user202729
    15 hours ago








  • 3




    Converting integers to English words
    – user202729
    15 hours ago













up vote
9
down vote

favorite
2









up vote
9
down vote

favorite
2






2





Summary



A teacher was told to prepare word problems for the students. She is given a list of equations and told to write them as the corresponding word problem. However, she is very lazy, so she doesn't put much creativity into it. Instead, she simply writes it literally. For example, when she reads 1+1, she writes one plus one, 47 * 2 would turn into forty seven times two, and 56.2 / 7.4 would become fifty six point two divided by seven point four.



Write some code to help this lazy teacher out.



Details




  • Numbers may include a decimal point and a negative sign.

  • Numbers should be written in the short scale. (i.e., 1,000,000,000 is one billion)

  • Numbers can go up to 999,999,999,999,999,999 (nine hundred ninety nine quadrillion...nine hundred ninety nine).

  • Groups of zeros must be left out. e.g. 1,000,000 is one million not one million zero thousand zero hundred.

  • There can be arbitrarily many digits past the decimal point.

  • Digits after the decimal point must be listed digit by digit. e.g. 12.34 is twelve point three four not twelve point thirty four.

  • Two numbers are always separated by an operator.

  • The valid operators are plus (+), minus (-), times (*), and divided by (/).

  • There are no parentheses.

  • Numbers such as 1234 may optionally include an and in their output, as in one thousand two hundred *and* thirty four.

  • Commas and whitespace on the input may be ignored.


Examples



Input: 24 + 65

Output: twenty four plus sixty five



Input: 3.33333 - 0

Output: three point three three three three three minus zero



Input: 3.6 * 18.18 / 999.0

Output: three point six times eighteen point one eight divided by nine hundred ninety nine point zero



Input: 1-1

Output: one minus one



Input: 1+-1

Output: one plus negative one



Input: 1,000,000,000 + 0.2

Output: one billion plus zero point two



Input: 123,000,456,789,012,345.6789

Output: one hundred twenty three quadrillion four hundred fifty six billion seven hundred eighty nine million twelve thousand three hundred forty five point six seven eight nine



Input: -4.3 * 7

Output: negative four point three times seven



Input: -1-1--1

Output: negative one minus one minus negative one










share|improve this question















Summary



A teacher was told to prepare word problems for the students. She is given a list of equations and told to write them as the corresponding word problem. However, she is very lazy, so she doesn't put much creativity into it. Instead, she simply writes it literally. For example, when she reads 1+1, she writes one plus one, 47 * 2 would turn into forty seven times two, and 56.2 / 7.4 would become fifty six point two divided by seven point four.



Write some code to help this lazy teacher out.



Details




  • Numbers may include a decimal point and a negative sign.

  • Numbers should be written in the short scale. (i.e., 1,000,000,000 is one billion)

  • Numbers can go up to 999,999,999,999,999,999 (nine hundred ninety nine quadrillion...nine hundred ninety nine).

  • Groups of zeros must be left out. e.g. 1,000,000 is one million not one million zero thousand zero hundred.

  • There can be arbitrarily many digits past the decimal point.

  • Digits after the decimal point must be listed digit by digit. e.g. 12.34 is twelve point three four not twelve point thirty four.

  • Two numbers are always separated by an operator.

  • The valid operators are plus (+), minus (-), times (*), and divided by (/).

  • There are no parentheses.

  • Numbers such as 1234 may optionally include an and in their output, as in one thousand two hundred *and* thirty four.

  • Commas and whitespace on the input may be ignored.


Examples



Input: 24 + 65

Output: twenty four plus sixty five



Input: 3.33333 - 0

Output: three point three three three three three minus zero



Input: 3.6 * 18.18 / 999.0

Output: three point six times eighteen point one eight divided by nine hundred ninety nine point zero



Input: 1-1

Output: one minus one



Input: 1+-1

Output: one plus negative one



Input: 1,000,000,000 + 0.2

Output: one billion plus zero point two



Input: 123,000,456,789,012,345.6789

Output: one hundred twenty three quadrillion four hundred fifty six billion seven hundred eighty nine million twelve thousand three hundred forty five point six seven eight nine



Input: -4.3 * 7

Output: negative four point three times seven



Input: -1-1--1

Output: negative one minus one minus negative one







code-golf string






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 5 hours ago

























asked 16 hours ago









Daffy

52849




52849








  • 1




    Could you add something like 123,456,789,012,345.6789 to the examples? It should cover a lot of test cases.
    – maxb
    15 hours ago






  • 2




    Can we use minus instead of negative?
    – Jo King
    15 hours ago






  • 1




    Can we assume that the input won't have whitespace in it? Alternatively, can the output have multiple spaces between words?
    – Jo King
    15 hours ago








  • 3




    For Mathematica: again there is a builtin, but / is over and negative number is minus, so it needs some manipulation.
    – user202729
    15 hours ago








  • 3




    Converting integers to English words
    – user202729
    15 hours ago














  • 1




    Could you add something like 123,456,789,012,345.6789 to the examples? It should cover a lot of test cases.
    – maxb
    15 hours ago






  • 2




    Can we use minus instead of negative?
    – Jo King
    15 hours ago






  • 1




    Can we assume that the input won't have whitespace in it? Alternatively, can the output have multiple spaces between words?
    – Jo King
    15 hours ago








  • 3




    For Mathematica: again there is a builtin, but / is over and negative number is minus, so it needs some manipulation.
    – user202729
    15 hours ago








  • 3




    Converting integers to English words
    – user202729
    15 hours ago








1




1




Could you add something like 123,456,789,012,345.6789 to the examples? It should cover a lot of test cases.
– maxb
15 hours ago




Could you add something like 123,456,789,012,345.6789 to the examples? It should cover a lot of test cases.
– maxb
15 hours ago




2




2




Can we use minus instead of negative?
– Jo King
15 hours ago




Can we use minus instead of negative?
– Jo King
15 hours ago




1




1




Can we assume that the input won't have whitespace in it? Alternatively, can the output have multiple spaces between words?
– Jo King
15 hours ago






Can we assume that the input won't have whitespace in it? Alternatively, can the output have multiple spaces between words?
– Jo King
15 hours ago






3




3




For Mathematica: again there is a builtin, but / is over and negative number is minus, so it needs some manipulation.
– user202729
15 hours ago






For Mathematica: again there is a builtin, but / is over and negative number is minus, so it needs some manipulation.
– user202729
15 hours ago






3




3




Converting integers to English words
– user202729
15 hours ago




Converting integers to English words
– user202729
15 hours ago










3 Answers
3






active

oldest

votes

















up vote
13
down vote













JavaScript (ES6), 552 532 bytes



This filthy monster comes straight from the depths of code-golfing hell.



Expects an input string without any whitespace.





S=>S[R='replace'](/[d.,]+|./g,s=>1/s[0]?a(+s[S=0]&&14)+s[R](/(D?)(d+)/g,(_,s,n)=>s>','?' point'+n[R](/./g,a):j--*n?(u=a(n%10||14),n>99?a(n[0])+' hundred':'')+((n%=100)<13?a(n||14):n<20?(a(n)||u)+'teen':(a(n/10+18)||a(n/10))+'ty'+u)+a(j+27)+(j>1?'illion':''):'',j=s.split`,`.length):a(S='+-*/'.indexOf(s=='-'&&S||s)+34),a=n=>(s='zero0one0two0three0four0five0six0seven0eight0nine0ten0eleven0twelve0thir00fif000eigh00twen0thir0for0fif000eigh00thousand0m0b0tr0quadr0negative0plus0minus0times0divided by'.split`0`[n|0])&&' '+s).trim()


Try it online!






share|improve this answer



















  • 2




    You can cut 18 bytes by replacing your giant string literal with btoa`ÍêèÒ‰ÞÒÜ(ÒØkyí¢êô~+ÞÒȱÒǯz}ŠmÒx§{K^ŸG¥z÷§ÒÜ–÷´¶«ÓGâM4z(!ÓKpz}-†*ô~Šô~'ôÓG¢‚4¶.±©ÝÒmÒÚôªæ�¯IÞ�«b½í)–ë4š)î³Kb™ë4v+âuçu×Vò`.replace(111,' ').
    – kamoroso94
    7 hours ago










  • I love responses that creatively compress string literals like this.
    – Daffy
    5 hours ago


















up vote
2
down vote














Clean, 766 736 702 bytes



import StdEnv,Text
z="zero"
r=reverse
l k=(!!)k o digitToInt
^s=l[s:split" ""one two three four five six seven eight nine"]
%s=l["","","twen","thir",s,"fif","six","seven","eigh","nine"]
~['0':t]= ~t
~[a,b,c]=(^""a)+" hundred "+ ~[b,c]
~[b,c]|b>'1'=(%"for"b)+"ty "+ ^""c|c>'2'=(%"four"c)+"teen"=["ten","eleven","twelve"]!!(digitToInt c)
~[c]= ^""c
~_=""
$=""
$[x:y]#(h,t)=span(e=isDigit e||e==',')if(x<'1')y[x:y]
=trim(join" "((case x of'0'=[z];'-'=["negative",$h];'.'=["point":map(^z)h];_=(r[u+v\u<-r(map~(split[',']h))&v<-[""," thousand":[" "+k+"illion"\k<-["m","b","tr","quadr"]]]|u>""]))++[?t]))
?['-':t]="minus "+ $t
?['+':t]="plus "+ $t
?['/':t]="divided by "+ $t
?['*':t]="times "+ $t
?t= $t


Try it online!



Expects a string without whitespace.






share|improve this answer






























    up vote
    0
    down vote














    sfk, 853 bytes



    xed -i
    "_*_ [part1]_"
    +xed
    _+_plus_
    _*_times_
    "_/_divided by_"
    "_- _minus _"
    "_-_negative _"
    +xed
    "_,[keep][19 chars of 0-9,]_quadr@ _"
    "_,[keep][15 chars of 0-9,]_tr@ _"
    "_,[keep][11 chars of 0-9,]_b@ _"
    "_,[keep][digits],[digits],_b@ _"
    "_,[keep][digits],_m@ _"
    "_,_ thousand _"
    +xed
    "_ 000[chars]@__"
    "_ 000__"
    "_ 00[keep][digit]_ _"
    "_ 0[keep][2 digits]_ @_"
    "_ [digit][keep][2 digits]_[part2]hundred @_"
    "_ [ortext] 0[digit]0_ @[part2]_"
    "_ [keep][2 digits]_ @_"
    "_@_illion _"
    +xed
    _@11_eleven_
    _@12_twelve_
    _@1[digit]_@[part2]teen_
    _@1_ten_
    _@4_forty_
    _@[digit]_@[part2]ty_
    +xed
    _@2_twen_
    _@3_thir_
    _@4_four_
    _@5_fif_
    _@6_six_
    _@7_seven_
    _@8_eigh_
    _@9_nine_
    +xed
    "_0_ zero _"
    "_1_ one _"
    "_2_ two _"
    "_3_ three _"
    "_4_ four _"
    "_5_ five _"
    "_6_ six _"
    "_7_ seven _"
    "_8_ eight _"
    "_9_ nine _"
    "_._ point _"
    +xed
    "_[white]_ _"
    +xed
    "_[lstart] __"



    Try it online!



    Requires operators and numbers be separated by at least one space character.






    share|improve this answer





















      Your Answer





      StackExchange.ifUsing("editor", function () {
      return StackExchange.using("mathjaxEditing", function () {
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
      });
      });
      }, "mathjax-editing");

      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "200"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














       

      draft saved


      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f176619%2flazy-word-problems%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      13
      down vote













      JavaScript (ES6), 552 532 bytes



      This filthy monster comes straight from the depths of code-golfing hell.



      Expects an input string without any whitespace.





      S=>S[R='replace'](/[d.,]+|./g,s=>1/s[0]?a(+s[S=0]&&14)+s[R](/(D?)(d+)/g,(_,s,n)=>s>','?' point'+n[R](/./g,a):j--*n?(u=a(n%10||14),n>99?a(n[0])+' hundred':'')+((n%=100)<13?a(n||14):n<20?(a(n)||u)+'teen':(a(n/10+18)||a(n/10))+'ty'+u)+a(j+27)+(j>1?'illion':''):'',j=s.split`,`.length):a(S='+-*/'.indexOf(s=='-'&&S||s)+34),a=n=>(s='zero0one0two0three0four0five0six0seven0eight0nine0ten0eleven0twelve0thir00fif000eigh00twen0thir0for0fif000eigh00thousand0m0b0tr0quadr0negative0plus0minus0times0divided by'.split`0`[n|0])&&' '+s).trim()


      Try it online!






      share|improve this answer



















      • 2




        You can cut 18 bytes by replacing your giant string literal with btoa`ÍêèÒ‰ÞÒÜ(ÒØkyí¢êô~+ÞÒȱÒǯz}ŠmÒx§{K^ŸG¥z÷§ÒÜ–÷´¶«ÓGâM4z(!ÓKpz}-†*ô~Šô~'ôÓG¢‚4¶.±©ÝÒmÒÚôªæ�¯IÞ�«b½í)–ë4š)î³Kb™ë4v+âuçu×Vò`.replace(111,' ').
        – kamoroso94
        7 hours ago










      • I love responses that creatively compress string literals like this.
        – Daffy
        5 hours ago















      up vote
      13
      down vote













      JavaScript (ES6), 552 532 bytes



      This filthy monster comes straight from the depths of code-golfing hell.



      Expects an input string without any whitespace.





      S=>S[R='replace'](/[d.,]+|./g,s=>1/s[0]?a(+s[S=0]&&14)+s[R](/(D?)(d+)/g,(_,s,n)=>s>','?' point'+n[R](/./g,a):j--*n?(u=a(n%10||14),n>99?a(n[0])+' hundred':'')+((n%=100)<13?a(n||14):n<20?(a(n)||u)+'teen':(a(n/10+18)||a(n/10))+'ty'+u)+a(j+27)+(j>1?'illion':''):'',j=s.split`,`.length):a(S='+-*/'.indexOf(s=='-'&&S||s)+34),a=n=>(s='zero0one0two0three0four0five0six0seven0eight0nine0ten0eleven0twelve0thir00fif000eigh00twen0thir0for0fif000eigh00thousand0m0b0tr0quadr0negative0plus0minus0times0divided by'.split`0`[n|0])&&' '+s).trim()


      Try it online!






      share|improve this answer



















      • 2




        You can cut 18 bytes by replacing your giant string literal with btoa`ÍêèÒ‰ÞÒÜ(ÒØkyí¢êô~+ÞÒȱÒǯz}ŠmÒx§{K^ŸG¥z÷§ÒÜ–÷´¶«ÓGâM4z(!ÓKpz}-†*ô~Šô~'ôÓG¢‚4¶.±©ÝÒmÒÚôªæ�¯IÞ�«b½í)–ë4š)î³Kb™ë4v+âuçu×Vò`.replace(111,' ').
        – kamoroso94
        7 hours ago










      • I love responses that creatively compress string literals like this.
        – Daffy
        5 hours ago













      up vote
      13
      down vote










      up vote
      13
      down vote









      JavaScript (ES6), 552 532 bytes



      This filthy monster comes straight from the depths of code-golfing hell.



      Expects an input string without any whitespace.





      S=>S[R='replace'](/[d.,]+|./g,s=>1/s[0]?a(+s[S=0]&&14)+s[R](/(D?)(d+)/g,(_,s,n)=>s>','?' point'+n[R](/./g,a):j--*n?(u=a(n%10||14),n>99?a(n[0])+' hundred':'')+((n%=100)<13?a(n||14):n<20?(a(n)||u)+'teen':(a(n/10+18)||a(n/10))+'ty'+u)+a(j+27)+(j>1?'illion':''):'',j=s.split`,`.length):a(S='+-*/'.indexOf(s=='-'&&S||s)+34),a=n=>(s='zero0one0two0three0four0five0six0seven0eight0nine0ten0eleven0twelve0thir00fif000eigh00twen0thir0for0fif000eigh00thousand0m0b0tr0quadr0negative0plus0minus0times0divided by'.split`0`[n|0])&&' '+s).trim()


      Try it online!






      share|improve this answer














      JavaScript (ES6), 552 532 bytes



      This filthy monster comes straight from the depths of code-golfing hell.



      Expects an input string without any whitespace.





      S=>S[R='replace'](/[d.,]+|./g,s=>1/s[0]?a(+s[S=0]&&14)+s[R](/(D?)(d+)/g,(_,s,n)=>s>','?' point'+n[R](/./g,a):j--*n?(u=a(n%10||14),n>99?a(n[0])+' hundred':'')+((n%=100)<13?a(n||14):n<20?(a(n)||u)+'teen':(a(n/10+18)||a(n/10))+'ty'+u)+a(j+27)+(j>1?'illion':''):'',j=s.split`,`.length):a(S='+-*/'.indexOf(s=='-'&&S||s)+34),a=n=>(s='zero0one0two0three0four0five0six0seven0eight0nine0ten0eleven0twelve0thir00fif000eigh00twen0thir0for0fif000eigh00thousand0m0b0tr0quadr0negative0plus0minus0times0divided by'.split`0`[n|0])&&' '+s).trim()


      Try it online!







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited 9 hours ago

























      answered 12 hours ago









      Arnauld

      69.9k686295




      69.9k686295








      • 2




        You can cut 18 bytes by replacing your giant string literal with btoa`ÍêèÒ‰ÞÒÜ(ÒØkyí¢êô~+ÞÒȱÒǯz}ŠmÒx§{K^ŸG¥z÷§ÒÜ–÷´¶«ÓGâM4z(!ÓKpz}-†*ô~Šô~'ôÓG¢‚4¶.±©ÝÒmÒÚôªæ�¯IÞ�«b½í)–ë4š)î³Kb™ë4v+âuçu×Vò`.replace(111,' ').
        – kamoroso94
        7 hours ago










      • I love responses that creatively compress string literals like this.
        – Daffy
        5 hours ago














      • 2




        You can cut 18 bytes by replacing your giant string literal with btoa`ÍêèÒ‰ÞÒÜ(ÒØkyí¢êô~+ÞÒȱÒǯz}ŠmÒx§{K^ŸG¥z÷§ÒÜ–÷´¶«ÓGâM4z(!ÓKpz}-†*ô~Šô~'ôÓG¢‚4¶.±©ÝÒmÒÚôªæ�¯IÞ�«b½í)–ë4š)î³Kb™ë4v+âuçu×Vò`.replace(111,' ').
        – kamoroso94
        7 hours ago










      • I love responses that creatively compress string literals like this.
        – Daffy
        5 hours ago








      2




      2




      You can cut 18 bytes by replacing your giant string literal with btoa`ÍêèÒ‰ÞÒÜ(ÒØkyí¢êô~+ÞÒȱÒǯz}ŠmÒx§{K^ŸG¥z÷§ÒÜ–÷´¶«ÓGâM4z(!ÓKpz}-†*ô~Šô~'ôÓG¢‚4¶.±©ÝÒmÒÚôªæ�¯IÞ�«b½í)–ë4š)î³Kb™ë4v+âuçu×Vò`.replace(111,' ').
      – kamoroso94
      7 hours ago




      You can cut 18 bytes by replacing your giant string literal with btoa`ÍêèÒ‰ÞÒÜ(ÒØkyí¢êô~+ÞÒȱÒǯz}ŠmÒx§{K^ŸG¥z÷§ÒÜ–÷´¶«ÓGâM4z(!ÓKpz}-†*ô~Šô~'ôÓG¢‚4¶.±©ÝÒmÒÚôªæ�¯IÞ�«b½í)–ë4š)î³Kb™ë4v+âuçu×Vò`.replace(111,' ').
      – kamoroso94
      7 hours ago












      I love responses that creatively compress string literals like this.
      – Daffy
      5 hours ago




      I love responses that creatively compress string literals like this.
      – Daffy
      5 hours ago










      up vote
      2
      down vote














      Clean, 766 736 702 bytes



      import StdEnv,Text
      z="zero"
      r=reverse
      l k=(!!)k o digitToInt
      ^s=l[s:split" ""one two three four five six seven eight nine"]
      %s=l["","","twen","thir",s,"fif","six","seven","eigh","nine"]
      ~['0':t]= ~t
      ~[a,b,c]=(^""a)+" hundred "+ ~[b,c]
      ~[b,c]|b>'1'=(%"for"b)+"ty "+ ^""c|c>'2'=(%"four"c)+"teen"=["ten","eleven","twelve"]!!(digitToInt c)
      ~[c]= ^""c
      ~_=""
      $=""
      $[x:y]#(h,t)=span(e=isDigit e||e==',')if(x<'1')y[x:y]
      =trim(join" "((case x of'0'=[z];'-'=["negative",$h];'.'=["point":map(^z)h];_=(r[u+v\u<-r(map~(split[',']h))&v<-[""," thousand":[" "+k+"illion"\k<-["m","b","tr","quadr"]]]|u>""]))++[?t]))
      ?['-':t]="minus "+ $t
      ?['+':t]="plus "+ $t
      ?['/':t]="divided by "+ $t
      ?['*':t]="times "+ $t
      ?t= $t


      Try it online!



      Expects a string without whitespace.






      share|improve this answer



























        up vote
        2
        down vote














        Clean, 766 736 702 bytes



        import StdEnv,Text
        z="zero"
        r=reverse
        l k=(!!)k o digitToInt
        ^s=l[s:split" ""one two three four five six seven eight nine"]
        %s=l["","","twen","thir",s,"fif","six","seven","eigh","nine"]
        ~['0':t]= ~t
        ~[a,b,c]=(^""a)+" hundred "+ ~[b,c]
        ~[b,c]|b>'1'=(%"for"b)+"ty "+ ^""c|c>'2'=(%"four"c)+"teen"=["ten","eleven","twelve"]!!(digitToInt c)
        ~[c]= ^""c
        ~_=""
        $=""
        $[x:y]#(h,t)=span(e=isDigit e||e==',')if(x<'1')y[x:y]
        =trim(join" "((case x of'0'=[z];'-'=["negative",$h];'.'=["point":map(^z)h];_=(r[u+v\u<-r(map~(split[',']h))&v<-[""," thousand":[" "+k+"illion"\k<-["m","b","tr","quadr"]]]|u>""]))++[?t]))
        ?['-':t]="minus "+ $t
        ?['+':t]="plus "+ $t
        ?['/':t]="divided by "+ $t
        ?['*':t]="times "+ $t
        ?t= $t


        Try it online!



        Expects a string without whitespace.






        share|improve this answer

























          up vote
          2
          down vote










          up vote
          2
          down vote










          Clean, 766 736 702 bytes



          import StdEnv,Text
          z="zero"
          r=reverse
          l k=(!!)k o digitToInt
          ^s=l[s:split" ""one two three four five six seven eight nine"]
          %s=l["","","twen","thir",s,"fif","six","seven","eigh","nine"]
          ~['0':t]= ~t
          ~[a,b,c]=(^""a)+" hundred "+ ~[b,c]
          ~[b,c]|b>'1'=(%"for"b)+"ty "+ ^""c|c>'2'=(%"four"c)+"teen"=["ten","eleven","twelve"]!!(digitToInt c)
          ~[c]= ^""c
          ~_=""
          $=""
          $[x:y]#(h,t)=span(e=isDigit e||e==',')if(x<'1')y[x:y]
          =trim(join" "((case x of'0'=[z];'-'=["negative",$h];'.'=["point":map(^z)h];_=(r[u+v\u<-r(map~(split[',']h))&v<-[""," thousand":[" "+k+"illion"\k<-["m","b","tr","quadr"]]]|u>""]))++[?t]))
          ?['-':t]="minus "+ $t
          ?['+':t]="plus "+ $t
          ?['/':t]="divided by "+ $t
          ?['*':t]="times "+ $t
          ?t= $t


          Try it online!



          Expects a string without whitespace.






          share|improve this answer















          Clean, 766 736 702 bytes



          import StdEnv,Text
          z="zero"
          r=reverse
          l k=(!!)k o digitToInt
          ^s=l[s:split" ""one two three four five six seven eight nine"]
          %s=l["","","twen","thir",s,"fif","six","seven","eigh","nine"]
          ~['0':t]= ~t
          ~[a,b,c]=(^""a)+" hundred "+ ~[b,c]
          ~[b,c]|b>'1'=(%"for"b)+"ty "+ ^""c|c>'2'=(%"four"c)+"teen"=["ten","eleven","twelve"]!!(digitToInt c)
          ~[c]= ^""c
          ~_=""
          $=""
          $[x:y]#(h,t)=span(e=isDigit e||e==',')if(x<'1')y[x:y]
          =trim(join" "((case x of'0'=[z];'-'=["negative",$h];'.'=["point":map(^z)h];_=(r[u+v\u<-r(map~(split[',']h))&v<-[""," thousand":[" "+k+"illion"\k<-["m","b","tr","quadr"]]]|u>""]))++[?t]))
          ?['-':t]="minus "+ $t
          ?['+':t]="plus "+ $t
          ?['/':t]="divided by "+ $t
          ?['*':t]="times "+ $t
          ?t= $t


          Try it online!



          Expects a string without whitespace.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 hours ago

























          answered 4 hours ago









          Οurous

          5,84311032




          5,84311032






















              up vote
              0
              down vote














              sfk, 853 bytes



              xed -i
              "_*_ [part1]_"
              +xed
              _+_plus_
              _*_times_
              "_/_divided by_"
              "_- _minus _"
              "_-_negative _"
              +xed
              "_,[keep][19 chars of 0-9,]_quadr@ _"
              "_,[keep][15 chars of 0-9,]_tr@ _"
              "_,[keep][11 chars of 0-9,]_b@ _"
              "_,[keep][digits],[digits],_b@ _"
              "_,[keep][digits],_m@ _"
              "_,_ thousand _"
              +xed
              "_ 000[chars]@__"
              "_ 000__"
              "_ 00[keep][digit]_ _"
              "_ 0[keep][2 digits]_ @_"
              "_ [digit][keep][2 digits]_[part2]hundred @_"
              "_ [ortext] 0[digit]0_ @[part2]_"
              "_ [keep][2 digits]_ @_"
              "_@_illion _"
              +xed
              _@11_eleven_
              _@12_twelve_
              _@1[digit]_@[part2]teen_
              _@1_ten_
              _@4_forty_
              _@[digit]_@[part2]ty_
              +xed
              _@2_twen_
              _@3_thir_
              _@4_four_
              _@5_fif_
              _@6_six_
              _@7_seven_
              _@8_eigh_
              _@9_nine_
              +xed
              "_0_ zero _"
              "_1_ one _"
              "_2_ two _"
              "_3_ three _"
              "_4_ four _"
              "_5_ five _"
              "_6_ six _"
              "_7_ seven _"
              "_8_ eight _"
              "_9_ nine _"
              "_._ point _"
              +xed
              "_[white]_ _"
              +xed
              "_[lstart] __"



              Try it online!



              Requires operators and numbers be separated by at least one space character.






              share|improve this answer

























                up vote
                0
                down vote














                sfk, 853 bytes



                xed -i
                "_*_ [part1]_"
                +xed
                _+_plus_
                _*_times_
                "_/_divided by_"
                "_- _minus _"
                "_-_negative _"
                +xed
                "_,[keep][19 chars of 0-9,]_quadr@ _"
                "_,[keep][15 chars of 0-9,]_tr@ _"
                "_,[keep][11 chars of 0-9,]_b@ _"
                "_,[keep][digits],[digits],_b@ _"
                "_,[keep][digits],_m@ _"
                "_,_ thousand _"
                +xed
                "_ 000[chars]@__"
                "_ 000__"
                "_ 00[keep][digit]_ _"
                "_ 0[keep][2 digits]_ @_"
                "_ [digit][keep][2 digits]_[part2]hundred @_"
                "_ [ortext] 0[digit]0_ @[part2]_"
                "_ [keep][2 digits]_ @_"
                "_@_illion _"
                +xed
                _@11_eleven_
                _@12_twelve_
                _@1[digit]_@[part2]teen_
                _@1_ten_
                _@4_forty_
                _@[digit]_@[part2]ty_
                +xed
                _@2_twen_
                _@3_thir_
                _@4_four_
                _@5_fif_
                _@6_six_
                _@7_seven_
                _@8_eigh_
                _@9_nine_
                +xed
                "_0_ zero _"
                "_1_ one _"
                "_2_ two _"
                "_3_ three _"
                "_4_ four _"
                "_5_ five _"
                "_6_ six _"
                "_7_ seven _"
                "_8_ eight _"
                "_9_ nine _"
                "_._ point _"
                +xed
                "_[white]_ _"
                +xed
                "_[lstart] __"



                Try it online!



                Requires operators and numbers be separated by at least one space character.






                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote










                  sfk, 853 bytes



                  xed -i
                  "_*_ [part1]_"
                  +xed
                  _+_plus_
                  _*_times_
                  "_/_divided by_"
                  "_- _minus _"
                  "_-_negative _"
                  +xed
                  "_,[keep][19 chars of 0-9,]_quadr@ _"
                  "_,[keep][15 chars of 0-9,]_tr@ _"
                  "_,[keep][11 chars of 0-9,]_b@ _"
                  "_,[keep][digits],[digits],_b@ _"
                  "_,[keep][digits],_m@ _"
                  "_,_ thousand _"
                  +xed
                  "_ 000[chars]@__"
                  "_ 000__"
                  "_ 00[keep][digit]_ _"
                  "_ 0[keep][2 digits]_ @_"
                  "_ [digit][keep][2 digits]_[part2]hundred @_"
                  "_ [ortext] 0[digit]0_ @[part2]_"
                  "_ [keep][2 digits]_ @_"
                  "_@_illion _"
                  +xed
                  _@11_eleven_
                  _@12_twelve_
                  _@1[digit]_@[part2]teen_
                  _@1_ten_
                  _@4_forty_
                  _@[digit]_@[part2]ty_
                  +xed
                  _@2_twen_
                  _@3_thir_
                  _@4_four_
                  _@5_fif_
                  _@6_six_
                  _@7_seven_
                  _@8_eigh_
                  _@9_nine_
                  +xed
                  "_0_ zero _"
                  "_1_ one _"
                  "_2_ two _"
                  "_3_ three _"
                  "_4_ four _"
                  "_5_ five _"
                  "_6_ six _"
                  "_7_ seven _"
                  "_8_ eight _"
                  "_9_ nine _"
                  "_._ point _"
                  +xed
                  "_[white]_ _"
                  +xed
                  "_[lstart] __"



                  Try it online!



                  Requires operators and numbers be separated by at least one space character.






                  share|improve this answer













                  sfk, 853 bytes



                  xed -i
                  "_*_ [part1]_"
                  +xed
                  _+_plus_
                  _*_times_
                  "_/_divided by_"
                  "_- _minus _"
                  "_-_negative _"
                  +xed
                  "_,[keep][19 chars of 0-9,]_quadr@ _"
                  "_,[keep][15 chars of 0-9,]_tr@ _"
                  "_,[keep][11 chars of 0-9,]_b@ _"
                  "_,[keep][digits],[digits],_b@ _"
                  "_,[keep][digits],_m@ _"
                  "_,_ thousand _"
                  +xed
                  "_ 000[chars]@__"
                  "_ 000__"
                  "_ 00[keep][digit]_ _"
                  "_ 0[keep][2 digits]_ @_"
                  "_ [digit][keep][2 digits]_[part2]hundred @_"
                  "_ [ortext] 0[digit]0_ @[part2]_"
                  "_ [keep][2 digits]_ @_"
                  "_@_illion _"
                  +xed
                  _@11_eleven_
                  _@12_twelve_
                  _@1[digit]_@[part2]teen_
                  _@1_ten_
                  _@4_forty_
                  _@[digit]_@[part2]ty_
                  +xed
                  _@2_twen_
                  _@3_thir_
                  _@4_four_
                  _@5_fif_
                  _@6_six_
                  _@7_seven_
                  _@8_eigh_
                  _@9_nine_
                  +xed
                  "_0_ zero _"
                  "_1_ one _"
                  "_2_ two _"
                  "_3_ three _"
                  "_4_ four _"
                  "_5_ five _"
                  "_6_ six _"
                  "_7_ seven _"
                  "_8_ eight _"
                  "_9_ nine _"
                  "_._ point _"
                  +xed
                  "_[white]_ _"
                  +xed
                  "_[lstart] __"



                  Try it online!



                  Requires operators and numbers be separated by at least one space character.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 25 mins ago









                  Οurous

                  5,84311032




                  5,84311032






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f176619%2flazy-word-problems%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Entries order in /etc/network/interfaces

                      新発田市

                      Grub takes very long (several minutes) to open Menu (in Multi-Boot-System)