How frustrating is my movie?











up vote
23
down vote

favorite












My parents have an home theater device. The remote is broken making it incredibly difficult to navigate rightwards in a menu. Most the time it doesn't work but when it does it moves rightwards incredibly quickly.



This is obviously frustrating but it is most frustrating when you want to enter a movie title which requires navigating a keyboard that looks like this:



a b c d e f
g h i j k l
m n o p q r
s t u v w x
y z 1 2 3 4
5 6 7 8 9 0


Your task is to take as input a movie title and calculate how "frustrating" it is to type that movie title. The frustration number of a particular string is the number of letters that require moving right from the letter before them. We don't care how far right they are, since if we start moving right we pretty much instantly go to the end of the line, and we don't care about up, down or leftwards movement because they are easy.



For example if we wanted to type in



keyboard



  • We start at k for free.


  • e is just above k so we don't need to move right.


  • y is all the way left so no need to move right.


  • b however is on the next column rightwards so we need to move right to get to it.


  • o is on the next column over so we have to move rightwards to get to it.


  • a is back in the first column so we move left to get to it.


  • r is all the way on the right so we move right to it.


  • d is two columns to the left of r's column.


The characters that need to move to the right are bor meaning that this is frustration 3.



Additional rules



This is a code-golf challenge so your answers will be scored in bytes with fewer bytes being better. The input will always consist of alphanumeric characters, you can support either capital or lowercase letters and you only need to support one. The input will never be empty.



Testcases



keyboard -> 3
2001aspaceodyssey -> 6
sorrytobotheryou -> 8
thinblueline -> 5
blast2 -> 3









share|improve this question




















  • 2




    Suggested test case: "blast2" -> 3 (not a real movie, but some answers have problems with such test cases)
    – Arnauld
    Nov 24 at 17:37










  • Suggested test case: one consisting of only digits, such as 5 -> 0
    – lirtosiast
    Nov 24 at 18:01












  • Suggested test case: 90 -> 1
    – nwellnhof
    Nov 24 at 20:46












  • Can we assume the input string will be non-empty?
    – Chas Brown
    Nov 25 at 4:06










  • @ChasBrown That is covered in the question.
    – Post Left Garf Hunter
    Nov 25 at 4:17















up vote
23
down vote

favorite












My parents have an home theater device. The remote is broken making it incredibly difficult to navigate rightwards in a menu. Most the time it doesn't work but when it does it moves rightwards incredibly quickly.



This is obviously frustrating but it is most frustrating when you want to enter a movie title which requires navigating a keyboard that looks like this:



a b c d e f
g h i j k l
m n o p q r
s t u v w x
y z 1 2 3 4
5 6 7 8 9 0


Your task is to take as input a movie title and calculate how "frustrating" it is to type that movie title. The frustration number of a particular string is the number of letters that require moving right from the letter before them. We don't care how far right they are, since if we start moving right we pretty much instantly go to the end of the line, and we don't care about up, down or leftwards movement because they are easy.



For example if we wanted to type in



keyboard



  • We start at k for free.


  • e is just above k so we don't need to move right.


  • y is all the way left so no need to move right.


  • b however is on the next column rightwards so we need to move right to get to it.


  • o is on the next column over so we have to move rightwards to get to it.


  • a is back in the first column so we move left to get to it.


  • r is all the way on the right so we move right to it.


  • d is two columns to the left of r's column.


The characters that need to move to the right are bor meaning that this is frustration 3.



Additional rules



This is a code-golf challenge so your answers will be scored in bytes with fewer bytes being better. The input will always consist of alphanumeric characters, you can support either capital or lowercase letters and you only need to support one. The input will never be empty.



Testcases



keyboard -> 3
2001aspaceodyssey -> 6
sorrytobotheryou -> 8
thinblueline -> 5
blast2 -> 3









share|improve this question




















  • 2




    Suggested test case: "blast2" -> 3 (not a real movie, but some answers have problems with such test cases)
    – Arnauld
    Nov 24 at 17:37










  • Suggested test case: one consisting of only digits, such as 5 -> 0
    – lirtosiast
    Nov 24 at 18:01












  • Suggested test case: 90 -> 1
    – nwellnhof
    Nov 24 at 20:46












  • Can we assume the input string will be non-empty?
    – Chas Brown
    Nov 25 at 4:06










  • @ChasBrown That is covered in the question.
    – Post Left Garf Hunter
    Nov 25 at 4:17













up vote
23
down vote

favorite









up vote
23
down vote

favorite











My parents have an home theater device. The remote is broken making it incredibly difficult to navigate rightwards in a menu. Most the time it doesn't work but when it does it moves rightwards incredibly quickly.



This is obviously frustrating but it is most frustrating when you want to enter a movie title which requires navigating a keyboard that looks like this:



a b c d e f
g h i j k l
m n o p q r
s t u v w x
y z 1 2 3 4
5 6 7 8 9 0


Your task is to take as input a movie title and calculate how "frustrating" it is to type that movie title. The frustration number of a particular string is the number of letters that require moving right from the letter before them. We don't care how far right they are, since if we start moving right we pretty much instantly go to the end of the line, and we don't care about up, down or leftwards movement because they are easy.



For example if we wanted to type in



keyboard



  • We start at k for free.


  • e is just above k so we don't need to move right.


  • y is all the way left so no need to move right.


  • b however is on the next column rightwards so we need to move right to get to it.


  • o is on the next column over so we have to move rightwards to get to it.


  • a is back in the first column so we move left to get to it.


  • r is all the way on the right so we move right to it.


  • d is two columns to the left of r's column.


The characters that need to move to the right are bor meaning that this is frustration 3.



Additional rules



This is a code-golf challenge so your answers will be scored in bytes with fewer bytes being better. The input will always consist of alphanumeric characters, you can support either capital or lowercase letters and you only need to support one. The input will never be empty.



Testcases



keyboard -> 3
2001aspaceodyssey -> 6
sorrytobotheryou -> 8
thinblueline -> 5
blast2 -> 3









share|improve this question















My parents have an home theater device. The remote is broken making it incredibly difficult to navigate rightwards in a menu. Most the time it doesn't work but when it does it moves rightwards incredibly quickly.



This is obviously frustrating but it is most frustrating when you want to enter a movie title which requires navigating a keyboard that looks like this:



a b c d e f
g h i j k l
m n o p q r
s t u v w x
y z 1 2 3 4
5 6 7 8 9 0


Your task is to take as input a movie title and calculate how "frustrating" it is to type that movie title. The frustration number of a particular string is the number of letters that require moving right from the letter before them. We don't care how far right they are, since if we start moving right we pretty much instantly go to the end of the line, and we don't care about up, down or leftwards movement because they are easy.



For example if we wanted to type in



keyboard



  • We start at k for free.


  • e is just above k so we don't need to move right.


  • y is all the way left so no need to move right.


  • b however is on the next column rightwards so we need to move right to get to it.


  • o is on the next column over so we have to move rightwards to get to it.


  • a is back in the first column so we move left to get to it.


  • r is all the way on the right so we move right to it.


  • d is two columns to the left of r's column.


The characters that need to move to the right are bor meaning that this is frustration 3.



Additional rules



This is a code-golf challenge so your answers will be scored in bytes with fewer bytes being better. The input will always consist of alphanumeric characters, you can support either capital or lowercase letters and you only need to support one. The input will never be empty.



Testcases



keyboard -> 3
2001aspaceodyssey -> 6
sorrytobotheryou -> 8
thinblueline -> 5
blast2 -> 3






code-golf string






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 at 17:38

























asked Nov 24 at 16:30









Post Left Garf Hunter

34.7k10154364




34.7k10154364








  • 2




    Suggested test case: "blast2" -> 3 (not a real movie, but some answers have problems with such test cases)
    – Arnauld
    Nov 24 at 17:37










  • Suggested test case: one consisting of only digits, such as 5 -> 0
    – lirtosiast
    Nov 24 at 18:01












  • Suggested test case: 90 -> 1
    – nwellnhof
    Nov 24 at 20:46












  • Can we assume the input string will be non-empty?
    – Chas Brown
    Nov 25 at 4:06










  • @ChasBrown That is covered in the question.
    – Post Left Garf Hunter
    Nov 25 at 4:17














  • 2




    Suggested test case: "blast2" -> 3 (not a real movie, but some answers have problems with such test cases)
    – Arnauld
    Nov 24 at 17:37










  • Suggested test case: one consisting of only digits, such as 5 -> 0
    – lirtosiast
    Nov 24 at 18:01












  • Suggested test case: 90 -> 1
    – nwellnhof
    Nov 24 at 20:46












  • Can we assume the input string will be non-empty?
    – Chas Brown
    Nov 25 at 4:06










  • @ChasBrown That is covered in the question.
    – Post Left Garf Hunter
    Nov 25 at 4:17








2




2




Suggested test case: "blast2" -> 3 (not a real movie, but some answers have problems with such test cases)
– Arnauld
Nov 24 at 17:37




Suggested test case: "blast2" -> 3 (not a real movie, but some answers have problems with such test cases)
– Arnauld
Nov 24 at 17:37












Suggested test case: one consisting of only digits, such as 5 -> 0
– lirtosiast
Nov 24 at 18:01






Suggested test case: one consisting of only digits, such as 5 -> 0
– lirtosiast
Nov 24 at 18:01














Suggested test case: 90 -> 1
– nwellnhof
Nov 24 at 20:46






Suggested test case: 90 -> 1
– nwellnhof
Nov 24 at 20:46














Can we assume the input string will be non-empty?
– Chas Brown
Nov 25 at 4:06




Can we assume the input string will be non-empty?
– Chas Brown
Nov 25 at 4:06












@ChasBrown That is covered in the question.
– Post Left Garf Hunter
Nov 25 at 4:17




@ChasBrown That is covered in the question.
– Post Left Garf Hunter
Nov 25 at 4:17










13 Answers
13






active

oldest

votes

















up vote
8
down vote














JavaScript (Node.js), 61 55 54 bytes



Saved 1 byte thanks to @nwellnhof



Takes input as an array of characters.



s=>s.map(p=c=>r+=p>(p=(+c?~c:1-Buffer(c)[0])%6),r=0)|r


Try it online!



How?



For all characters but digits greater than $0$, the 0-indexed column $x$ is given by:



$$x=(c-1)bmod 6$$



where $c$ is the ASCII code of the character.



For positive digits $n$, we need to do instead:



$$x=(n+1)bmod 6$$



Examples:



"a" --> (97 - 1) mod 6 = 96 mod 6 = 0
"b" --> (98 - 1) mod 6 = 97 mod 6 = 1
"0" --> (48 - 1) mod 6 = 47 mod 6 = 5
"3" --> ( 3 + 1) mod 6 = 4 mod 6 = 4


Commented



s =>                       // s = input string (as array)
s.map(p = // initialize p to a non-numeric value
c => // for each character c in s:
r += // update the result r:
p > ( // compare p with
p = ( // the new value of p defined as:
+c ? // if c is a positive digit:
~c // -(int(c) + 1)
: // else:
1-Buffer(c)[0] // -(ord(c) - 1)
) % 6 // apply modulo 6
), // yields 1 if the previous value is greater than the new one
r = 0 // start with r = 0
) | r // end of map(); return r





share|improve this answer























  • It seems to work without the ternary for 46 bytes
    – Shaggy
    Nov 24 at 17:51






  • 1




    @Shaggy It won't. See my suggested test case "blast2".
    – Arnauld
    Nov 24 at 17:52










  • Ah. In that case: 53 bytes
    – Shaggy
    Nov 24 at 18:29






  • 1




    @Shaggy A bitwise OR would fail for, say, "234".
    – Arnauld
    Nov 24 at 18:33






  • 3




    Less whiskey is never the answer!
    – Shaggy
    Nov 24 at 18:58


















up vote
6
down vote














Jelly, 11 bytes



⁾04yO‘%6<ƝS


A monadic Link accepting a list of (uppercase) characters.



Try it online!



How?



First replaces any '0's with '4's (so the rest of the code treats them as being in the rightmost column). Then casts to ordinals, adds one and modulo's by 6 to get 0-based column indices. Then compares neighbours with is-less-than and sums the result.



⁾04yO‘%6<ƝS - Link: list of characters         e.g. "BLAST20"
⁾04 - list of characters = ['0', '4']
y - translate "BLAST24"
O - ordinals [66,76,65,83,84,50,52]
‘ - increment [67,77,66,84,85,51,53]
6 - literal six
% - modulo [ 1, 5, 0, 0, 1, 3, 5]
Ɲ - neighbourly:
< - less than? [ 1, 0, 0, 1, 1, 1 ]
S - sum 4





share|improve this answer























  • Oh my, this is art.
    – Erik the Outgolfer
    Nov 24 at 21:07


















up vote
3
down vote














Perl 6, 45 39 bytes





{sum .[1..*]Z<$_}o{(2 X-.ords)X%46 X%6}


Try it online!



Works with uppercase letters. (2-ord(c))%46%6 computes the reversed x coordinate.






share|improve this answer






























    up vote
    1
    down vote














    K (ngn/k), 32 31 bytes



    +/>':(+6 6#,/"a10"+!'26 9 1)?0+


    Try it online!






    share|improve this answer






























      up vote
      1
      down vote














      Clean, 85 bytes



      import StdEnv
      (s=sum[1\a<-s&b<-tl s|b>a])o map(e=(toInt e+if(e-'1'>'/')1 -1)rem 6)


      Try it online!






      share|improve this answer




























        up vote
        1
        down vote














        Ruby, 56 bytes





        ->s{w=9;s.count{|c|w<w=[*?a..?z,*?1..?9,?0].index(c)%6}}


        Try it online!



        Preliminary naive version, will be golfed.






        share|improve this answer




























          up vote
          1
          down vote














          Japt -x, 14 bytes



          ®rT4 c Ä u6Ãä<


          Try it online!



          Port of this Jelly answer. Takes input as an array of characters, with letters uppercase.



          Explanation:



          ®rT4 c Ä u6Ãä<    :
          ® Ã :Map each character through:
          rT4 : Replace 0 with 4
          c : Get the char-code
          Ä : Increment it
          u6 : Modulo 6
          ä< :Replace with 1 if you had to move right, 0 otherwise
          :Implicitly sum and output





          share|improve this answer























          • Unfortunately this fails for the last test case.
            – Shaggy
            2 days ago










          • I was working on a solution last night that I've now golfed down to 12 bytes if you want to try for it. Hint: It takes input as an array and uses a flag.
            – Shaggy
            2 days ago










          • Actually, it looks like you just need to take input in uppercase to get yours working.
            – Shaggy
            2 days ago


















          up vote
          1
          down vote














          Java (OpenJDK 8), 73 bytes



          Not a bad solution for Java! That zero being on the right-hand side cost me several bytes.





          t->{int a=9,c=0;for(int d:t)c+=a<(a=(--d+(d/48==1?2:0))%6)?1:0;return c;}


          Try it online!



          Explained



          t -> {                          // Lambda taking a char array as input
          int a=9, // Initialise last column value
          c=0; // Initialise frustration count
          for(int d:t) // Loop through all chars in title
          c+= // increment the frustration count if...
          a< // The last column is smaller than the current column
          (a= // Set last column to current column
          (--d+ // Decrement ascii value of char
          (d/48==1 // If ascii decremented ascii value is between 48 and 95
          ?2:0) // increment by 2 (1 total) or 0 (-1 total)
          )%6) // Mod 6 to retrieve column index
          ?1:0; // Increment if to right hand side
          return c; // return calculated frustration count
          }





          share|improve this answer




























            up vote
            1
            down vote














            05AB1E, 12 11 bytes



            -1 byte thanks to @Kevin Cruijssen



            ¾4:Ç>6%¥1@O


            Another port of Jonathan Allan's Jelly answer. Takes input in uppercase.



            Explanation:



            ¾4:Ç>6%¥1@O   //full program
            ¾4: //replace all '0's with '4's
            Ç //get ASCII code points
            > //increment
            6% //modulo 6
            ¥ //get deltas
            1@ //is >= 1
            O //sum


            Try it online!






            share|improve this answer



















            • 1




              0'4 can be ¾4 to save a byte (relevant 05AB1E tip).
              – Kevin Cruijssen
              16 hours ago




















            up vote
            0
            down vote














            Retina 0.8.2, 46 bytes



            T`l1-90`1-61-61-61-61-61-6
            .
            ;$&$*
            &`;(1+);11


            Try it online! Link includes test cases. Explanation:



            T`l1-90`1-61-61-61-61-61-6


            List the alphabet and digits in the order on the OSK and map each one to a (1-indexed) column number.



            .
            ;$&$*


            Convert each column number to unary.



            &`;(1+);11


            Count the number of columns that are followed by a larger (i.e. rightwards) column. The &` allows the matches to overlap.






            share|improve this answer




























              up vote
              0
              down vote














              Python 2, 84 bytes





              def f(s,k=6):j=(ord(s[0])+('0'<s[0]<':')*2-1)%6;return(j>k)+(~-len(s)and f(s[1:],j))


              Try it online!






              share|improve this answer






























                up vote
                0
                down vote













                Mathematica, 102 bytes



                Differences[Last@@Join[Alphabet,ToString/@Range@9,{"0"}]~Partition~6~Position~#&/@#]~Count~_?(#>0&)&


                Pure function. Takes a list of characters as input and returns a number as output. This is a pretty naive solution, golfing suggestions welcome.






                share|improve this answer




























                  up vote
                  0
                  down vote














                  C (gcc),  82  79 bytes





                  o;c(i){i+=i<60&&i>48?1:5;i%=6;}f(char*s){for(o=0;*++s;o+=c(*s)>c(*(s-1)));o=o;}


                  Try it online!



                  This function will only support lowercase inputs





                  Ungolfed and commented:





                  o; //Used for output
                  c(i){ //Calculates the column of given character
                  i+= //Correct i to get the correct column
                  i<60 //If i is a digit...
                  && i>48 //... but not '0'
                  ?1 //Then move it one column on the right
                  :5; //Else move it five columns on the right
                  i%=6; //Get the column number
                  }
                  f(char*s){ // The actual "frustrating" function
                  for( //Loop for each character
                  o=0; //reinitialize output
                  *++s; //move to next character / while this is not ''
                  o+=c(*s)>c(*(s-1)) //Increment if current character is on the right of the previous one
                  );
                  o=o; // Outputs result
                  }




                  If my function is allowed to accept wide character strings, it can be reduced to 78 bytes with:





                  o;c(i){i+=i<60&&i>48?1:5;i%=6;}f(int*s){for(o=0;*++s;o+=c(*s)>c(*(s-1)));o=o;}


                  Try it online!



                  This version just accept input as int* instead of char*





                  Edits:




                  • Golfed 3 bytes in the calculation of the column (function c)






                  share|improve this answer























                  • And there, 77 bytes
                    – Rogem
                    2 days ago











                  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%2f176492%2fhow-frustrating-is-my-movie%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  13 Answers
                  13






                  active

                  oldest

                  votes








                  13 Answers
                  13






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes








                  up vote
                  8
                  down vote














                  JavaScript (Node.js), 61 55 54 bytes



                  Saved 1 byte thanks to @nwellnhof



                  Takes input as an array of characters.



                  s=>s.map(p=c=>r+=p>(p=(+c?~c:1-Buffer(c)[0])%6),r=0)|r


                  Try it online!



                  How?



                  For all characters but digits greater than $0$, the 0-indexed column $x$ is given by:



                  $$x=(c-1)bmod 6$$



                  where $c$ is the ASCII code of the character.



                  For positive digits $n$, we need to do instead:



                  $$x=(n+1)bmod 6$$



                  Examples:



                  "a" --> (97 - 1) mod 6 = 96 mod 6 = 0
                  "b" --> (98 - 1) mod 6 = 97 mod 6 = 1
                  "0" --> (48 - 1) mod 6 = 47 mod 6 = 5
                  "3" --> ( 3 + 1) mod 6 = 4 mod 6 = 4


                  Commented



                  s =>                       // s = input string (as array)
                  s.map(p = // initialize p to a non-numeric value
                  c => // for each character c in s:
                  r += // update the result r:
                  p > ( // compare p with
                  p = ( // the new value of p defined as:
                  +c ? // if c is a positive digit:
                  ~c // -(int(c) + 1)
                  : // else:
                  1-Buffer(c)[0] // -(ord(c) - 1)
                  ) % 6 // apply modulo 6
                  ), // yields 1 if the previous value is greater than the new one
                  r = 0 // start with r = 0
                  ) | r // end of map(); return r





                  share|improve this answer























                  • It seems to work without the ternary for 46 bytes
                    – Shaggy
                    Nov 24 at 17:51






                  • 1




                    @Shaggy It won't. See my suggested test case "blast2".
                    – Arnauld
                    Nov 24 at 17:52










                  • Ah. In that case: 53 bytes
                    – Shaggy
                    Nov 24 at 18:29






                  • 1




                    @Shaggy A bitwise OR would fail for, say, "234".
                    – Arnauld
                    Nov 24 at 18:33






                  • 3




                    Less whiskey is never the answer!
                    – Shaggy
                    Nov 24 at 18:58















                  up vote
                  8
                  down vote














                  JavaScript (Node.js), 61 55 54 bytes



                  Saved 1 byte thanks to @nwellnhof



                  Takes input as an array of characters.



                  s=>s.map(p=c=>r+=p>(p=(+c?~c:1-Buffer(c)[0])%6),r=0)|r


                  Try it online!



                  How?



                  For all characters but digits greater than $0$, the 0-indexed column $x$ is given by:



                  $$x=(c-1)bmod 6$$



                  where $c$ is the ASCII code of the character.



                  For positive digits $n$, we need to do instead:



                  $$x=(n+1)bmod 6$$



                  Examples:



                  "a" --> (97 - 1) mod 6 = 96 mod 6 = 0
                  "b" --> (98 - 1) mod 6 = 97 mod 6 = 1
                  "0" --> (48 - 1) mod 6 = 47 mod 6 = 5
                  "3" --> ( 3 + 1) mod 6 = 4 mod 6 = 4


                  Commented



                  s =>                       // s = input string (as array)
                  s.map(p = // initialize p to a non-numeric value
                  c => // for each character c in s:
                  r += // update the result r:
                  p > ( // compare p with
                  p = ( // the new value of p defined as:
                  +c ? // if c is a positive digit:
                  ~c // -(int(c) + 1)
                  : // else:
                  1-Buffer(c)[0] // -(ord(c) - 1)
                  ) % 6 // apply modulo 6
                  ), // yields 1 if the previous value is greater than the new one
                  r = 0 // start with r = 0
                  ) | r // end of map(); return r





                  share|improve this answer























                  • It seems to work without the ternary for 46 bytes
                    – Shaggy
                    Nov 24 at 17:51






                  • 1




                    @Shaggy It won't. See my suggested test case "blast2".
                    – Arnauld
                    Nov 24 at 17:52










                  • Ah. In that case: 53 bytes
                    – Shaggy
                    Nov 24 at 18:29






                  • 1




                    @Shaggy A bitwise OR would fail for, say, "234".
                    – Arnauld
                    Nov 24 at 18:33






                  • 3




                    Less whiskey is never the answer!
                    – Shaggy
                    Nov 24 at 18:58













                  up vote
                  8
                  down vote










                  up vote
                  8
                  down vote










                  JavaScript (Node.js), 61 55 54 bytes



                  Saved 1 byte thanks to @nwellnhof



                  Takes input as an array of characters.



                  s=>s.map(p=c=>r+=p>(p=(+c?~c:1-Buffer(c)[0])%6),r=0)|r


                  Try it online!



                  How?



                  For all characters but digits greater than $0$, the 0-indexed column $x$ is given by:



                  $$x=(c-1)bmod 6$$



                  where $c$ is the ASCII code of the character.



                  For positive digits $n$, we need to do instead:



                  $$x=(n+1)bmod 6$$



                  Examples:



                  "a" --> (97 - 1) mod 6 = 96 mod 6 = 0
                  "b" --> (98 - 1) mod 6 = 97 mod 6 = 1
                  "0" --> (48 - 1) mod 6 = 47 mod 6 = 5
                  "3" --> ( 3 + 1) mod 6 = 4 mod 6 = 4


                  Commented



                  s =>                       // s = input string (as array)
                  s.map(p = // initialize p to a non-numeric value
                  c => // for each character c in s:
                  r += // update the result r:
                  p > ( // compare p with
                  p = ( // the new value of p defined as:
                  +c ? // if c is a positive digit:
                  ~c // -(int(c) + 1)
                  : // else:
                  1-Buffer(c)[0] // -(ord(c) - 1)
                  ) % 6 // apply modulo 6
                  ), // yields 1 if the previous value is greater than the new one
                  r = 0 // start with r = 0
                  ) | r // end of map(); return r





                  share|improve this answer















                  JavaScript (Node.js), 61 55 54 bytes



                  Saved 1 byte thanks to @nwellnhof



                  Takes input as an array of characters.



                  s=>s.map(p=c=>r+=p>(p=(+c?~c:1-Buffer(c)[0])%6),r=0)|r


                  Try it online!



                  How?



                  For all characters but digits greater than $0$, the 0-indexed column $x$ is given by:



                  $$x=(c-1)bmod 6$$



                  where $c$ is the ASCII code of the character.



                  For positive digits $n$, we need to do instead:



                  $$x=(n+1)bmod 6$$



                  Examples:



                  "a" --> (97 - 1) mod 6 = 96 mod 6 = 0
                  "b" --> (98 - 1) mod 6 = 97 mod 6 = 1
                  "0" --> (48 - 1) mod 6 = 47 mod 6 = 5
                  "3" --> ( 3 + 1) mod 6 = 4 mod 6 = 4


                  Commented



                  s =>                       // s = input string (as array)
                  s.map(p = // initialize p to a non-numeric value
                  c => // for each character c in s:
                  r += // update the result r:
                  p > ( // compare p with
                  p = ( // the new value of p defined as:
                  +c ? // if c is a positive digit:
                  ~c // -(int(c) + 1)
                  : // else:
                  1-Buffer(c)[0] // -(ord(c) - 1)
                  ) % 6 // apply modulo 6
                  ), // yields 1 if the previous value is greater than the new one
                  r = 0 // start with r = 0
                  ) | r // end of map(); return r






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 24 at 20:55

























                  answered Nov 24 at 16:47









                  Arnauld

                  70.1k686295




                  70.1k686295












                  • It seems to work without the ternary for 46 bytes
                    – Shaggy
                    Nov 24 at 17:51






                  • 1




                    @Shaggy It won't. See my suggested test case "blast2".
                    – Arnauld
                    Nov 24 at 17:52










                  • Ah. In that case: 53 bytes
                    – Shaggy
                    Nov 24 at 18:29






                  • 1




                    @Shaggy A bitwise OR would fail for, say, "234".
                    – Arnauld
                    Nov 24 at 18:33






                  • 3




                    Less whiskey is never the answer!
                    – Shaggy
                    Nov 24 at 18:58


















                  • It seems to work without the ternary for 46 bytes
                    – Shaggy
                    Nov 24 at 17:51






                  • 1




                    @Shaggy It won't. See my suggested test case "blast2".
                    – Arnauld
                    Nov 24 at 17:52










                  • Ah. In that case: 53 bytes
                    – Shaggy
                    Nov 24 at 18:29






                  • 1




                    @Shaggy A bitwise OR would fail for, say, "234".
                    – Arnauld
                    Nov 24 at 18:33






                  • 3




                    Less whiskey is never the answer!
                    – Shaggy
                    Nov 24 at 18:58
















                  It seems to work without the ternary for 46 bytes
                  – Shaggy
                  Nov 24 at 17:51




                  It seems to work without the ternary for 46 bytes
                  – Shaggy
                  Nov 24 at 17:51




                  1




                  1




                  @Shaggy It won't. See my suggested test case "blast2".
                  – Arnauld
                  Nov 24 at 17:52




                  @Shaggy It won't. See my suggested test case "blast2".
                  – Arnauld
                  Nov 24 at 17:52












                  Ah. In that case: 53 bytes
                  – Shaggy
                  Nov 24 at 18:29




                  Ah. In that case: 53 bytes
                  – Shaggy
                  Nov 24 at 18:29




                  1




                  1




                  @Shaggy A bitwise OR would fail for, say, "234".
                  – Arnauld
                  Nov 24 at 18:33




                  @Shaggy A bitwise OR would fail for, say, "234".
                  – Arnauld
                  Nov 24 at 18:33




                  3




                  3




                  Less whiskey is never the answer!
                  – Shaggy
                  Nov 24 at 18:58




                  Less whiskey is never the answer!
                  – Shaggy
                  Nov 24 at 18:58










                  up vote
                  6
                  down vote














                  Jelly, 11 bytes



                  ⁾04yO‘%6<ƝS


                  A monadic Link accepting a list of (uppercase) characters.



                  Try it online!



                  How?



                  First replaces any '0's with '4's (so the rest of the code treats them as being in the rightmost column). Then casts to ordinals, adds one and modulo's by 6 to get 0-based column indices. Then compares neighbours with is-less-than and sums the result.



                  ⁾04yO‘%6<ƝS - Link: list of characters         e.g. "BLAST20"
                  ⁾04 - list of characters = ['0', '4']
                  y - translate "BLAST24"
                  O - ordinals [66,76,65,83,84,50,52]
                  ‘ - increment [67,77,66,84,85,51,53]
                  6 - literal six
                  % - modulo [ 1, 5, 0, 0, 1, 3, 5]
                  Ɲ - neighbourly:
                  < - less than? [ 1, 0, 0, 1, 1, 1 ]
                  S - sum 4





                  share|improve this answer























                  • Oh my, this is art.
                    – Erik the Outgolfer
                    Nov 24 at 21:07















                  up vote
                  6
                  down vote














                  Jelly, 11 bytes



                  ⁾04yO‘%6<ƝS


                  A monadic Link accepting a list of (uppercase) characters.



                  Try it online!



                  How?



                  First replaces any '0's with '4's (so the rest of the code treats them as being in the rightmost column). Then casts to ordinals, adds one and modulo's by 6 to get 0-based column indices. Then compares neighbours with is-less-than and sums the result.



                  ⁾04yO‘%6<ƝS - Link: list of characters         e.g. "BLAST20"
                  ⁾04 - list of characters = ['0', '4']
                  y - translate "BLAST24"
                  O - ordinals [66,76,65,83,84,50,52]
                  ‘ - increment [67,77,66,84,85,51,53]
                  6 - literal six
                  % - modulo [ 1, 5, 0, 0, 1, 3, 5]
                  Ɲ - neighbourly:
                  < - less than? [ 1, 0, 0, 1, 1, 1 ]
                  S - sum 4





                  share|improve this answer























                  • Oh my, this is art.
                    – Erik the Outgolfer
                    Nov 24 at 21:07













                  up vote
                  6
                  down vote










                  up vote
                  6
                  down vote










                  Jelly, 11 bytes



                  ⁾04yO‘%6<ƝS


                  A monadic Link accepting a list of (uppercase) characters.



                  Try it online!



                  How?



                  First replaces any '0's with '4's (so the rest of the code treats them as being in the rightmost column). Then casts to ordinals, adds one and modulo's by 6 to get 0-based column indices. Then compares neighbours with is-less-than and sums the result.



                  ⁾04yO‘%6<ƝS - Link: list of characters         e.g. "BLAST20"
                  ⁾04 - list of characters = ['0', '4']
                  y - translate "BLAST24"
                  O - ordinals [66,76,65,83,84,50,52]
                  ‘ - increment [67,77,66,84,85,51,53]
                  6 - literal six
                  % - modulo [ 1, 5, 0, 0, 1, 3, 5]
                  Ɲ - neighbourly:
                  < - less than? [ 1, 0, 0, 1, 1, 1 ]
                  S - sum 4





                  share|improve this answer















                  Jelly, 11 bytes



                  ⁾04yO‘%6<ƝS


                  A monadic Link accepting a list of (uppercase) characters.



                  Try it online!



                  How?



                  First replaces any '0's with '4's (so the rest of the code treats them as being in the rightmost column). Then casts to ordinals, adds one and modulo's by 6 to get 0-based column indices. Then compares neighbours with is-less-than and sums the result.



                  ⁾04yO‘%6<ƝS - Link: list of characters         e.g. "BLAST20"
                  ⁾04 - list of characters = ['0', '4']
                  y - translate "BLAST24"
                  O - ordinals [66,76,65,83,84,50,52]
                  ‘ - increment [67,77,66,84,85,51,53]
                  6 - literal six
                  % - modulo [ 1, 5, 0, 0, 1, 3, 5]
                  Ɲ - neighbourly:
                  < - less than? [ 1, 0, 0, 1, 1, 1 ]
                  S - sum 4






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 24 at 18:05

























                  answered Nov 24 at 17:21









                  Jonathan Allan

                  50.3k534165




                  50.3k534165












                  • Oh my, this is art.
                    – Erik the Outgolfer
                    Nov 24 at 21:07


















                  • Oh my, this is art.
                    – Erik the Outgolfer
                    Nov 24 at 21:07
















                  Oh my, this is art.
                  – Erik the Outgolfer
                  Nov 24 at 21:07




                  Oh my, this is art.
                  – Erik the Outgolfer
                  Nov 24 at 21:07










                  up vote
                  3
                  down vote














                  Perl 6, 45 39 bytes





                  {sum .[1..*]Z<$_}o{(2 X-.ords)X%46 X%6}


                  Try it online!



                  Works with uppercase letters. (2-ord(c))%46%6 computes the reversed x coordinate.






                  share|improve this answer



























                    up vote
                    3
                    down vote














                    Perl 6, 45 39 bytes





                    {sum .[1..*]Z<$_}o{(2 X-.ords)X%46 X%6}


                    Try it online!



                    Works with uppercase letters. (2-ord(c))%46%6 computes the reversed x coordinate.






                    share|improve this answer

























                      up vote
                      3
                      down vote










                      up vote
                      3
                      down vote










                      Perl 6, 45 39 bytes





                      {sum .[1..*]Z<$_}o{(2 X-.ords)X%46 X%6}


                      Try it online!



                      Works with uppercase letters. (2-ord(c))%46%6 computes the reversed x coordinate.






                      share|improve this answer















                      Perl 6, 45 39 bytes





                      {sum .[1..*]Z<$_}o{(2 X-.ords)X%46 X%6}


                      Try it online!



                      Works with uppercase letters. (2-ord(c))%46%6 computes the reversed x coordinate.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Nov 25 at 11:13

























                      answered Nov 24 at 20:13









                      nwellnhof

                      6,3131125




                      6,3131125






















                          up vote
                          1
                          down vote














                          K (ngn/k), 32 31 bytes



                          +/>':(+6 6#,/"a10"+!'26 9 1)?0+


                          Try it online!






                          share|improve this answer



























                            up vote
                            1
                            down vote














                            K (ngn/k), 32 31 bytes



                            +/>':(+6 6#,/"a10"+!'26 9 1)?0+


                            Try it online!






                            share|improve this answer

























                              up vote
                              1
                              down vote










                              up vote
                              1
                              down vote










                              K (ngn/k), 32 31 bytes



                              +/>':(+6 6#,/"a10"+!'26 9 1)?0+


                              Try it online!






                              share|improve this answer















                              K (ngn/k), 32 31 bytes



                              +/>':(+6 6#,/"a10"+!'26 9 1)?0+


                              Try it online!







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Nov 24 at 20:53

























                              answered Nov 24 at 20:44









                              ngn

                              6,49312459




                              6,49312459






















                                  up vote
                                  1
                                  down vote














                                  Clean, 85 bytes



                                  import StdEnv
                                  (s=sum[1\a<-s&b<-tl s|b>a])o map(e=(toInt e+if(e-'1'>'/')1 -1)rem 6)


                                  Try it online!






                                  share|improve this answer

























                                    up vote
                                    1
                                    down vote














                                    Clean, 85 bytes



                                    import StdEnv
                                    (s=sum[1\a<-s&b<-tl s|b>a])o map(e=(toInt e+if(e-'1'>'/')1 -1)rem 6)


                                    Try it online!






                                    share|improve this answer























                                      up vote
                                      1
                                      down vote










                                      up vote
                                      1
                                      down vote










                                      Clean, 85 bytes



                                      import StdEnv
                                      (s=sum[1\a<-s&b<-tl s|b>a])o map(e=(toInt e+if(e-'1'>'/')1 -1)rem 6)


                                      Try it online!






                                      share|improve this answer













                                      Clean, 85 bytes



                                      import StdEnv
                                      (s=sum[1\a<-s&b<-tl s|b>a])o map(e=(toInt e+if(e-'1'>'/')1 -1)rem 6)


                                      Try it online!







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Nov 25 at 21:26









                                      Οurous

                                      5,94311032




                                      5,94311032






















                                          up vote
                                          1
                                          down vote














                                          Ruby, 56 bytes





                                          ->s{w=9;s.count{|c|w<w=[*?a..?z,*?1..?9,?0].index(c)%6}}


                                          Try it online!



                                          Preliminary naive version, will be golfed.






                                          share|improve this answer

























                                            up vote
                                            1
                                            down vote














                                            Ruby, 56 bytes





                                            ->s{w=9;s.count{|c|w<w=[*?a..?z,*?1..?9,?0].index(c)%6}}


                                            Try it online!



                                            Preliminary naive version, will be golfed.






                                            share|improve this answer























                                              up vote
                                              1
                                              down vote










                                              up vote
                                              1
                                              down vote










                                              Ruby, 56 bytes





                                              ->s{w=9;s.count{|c|w<w=[*?a..?z,*?1..?9,?0].index(c)%6}}


                                              Try it online!



                                              Preliminary naive version, will be golfed.






                                              share|improve this answer













                                              Ruby, 56 bytes





                                              ->s{w=9;s.count{|c|w<w=[*?a..?z,*?1..?9,?0].index(c)%6}}


                                              Try it online!



                                              Preliminary naive version, will be golfed.







                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered 2 days ago









                                              G B

                                              7,5761328




                                              7,5761328






















                                                  up vote
                                                  1
                                                  down vote














                                                  Japt -x, 14 bytes



                                                  ®rT4 c Ä u6Ãä<


                                                  Try it online!



                                                  Port of this Jelly answer. Takes input as an array of characters, with letters uppercase.



                                                  Explanation:



                                                  ®rT4 c Ä u6Ãä<    :
                                                  ® Ã :Map each character through:
                                                  rT4 : Replace 0 with 4
                                                  c : Get the char-code
                                                  Ä : Increment it
                                                  u6 : Modulo 6
                                                  ä< :Replace with 1 if you had to move right, 0 otherwise
                                                  :Implicitly sum and output





                                                  share|improve this answer























                                                  • Unfortunately this fails for the last test case.
                                                    – Shaggy
                                                    2 days ago










                                                  • I was working on a solution last night that I've now golfed down to 12 bytes if you want to try for it. Hint: It takes input as an array and uses a flag.
                                                    – Shaggy
                                                    2 days ago










                                                  • Actually, it looks like you just need to take input in uppercase to get yours working.
                                                    – Shaggy
                                                    2 days ago















                                                  up vote
                                                  1
                                                  down vote














                                                  Japt -x, 14 bytes



                                                  ®rT4 c Ä u6Ãä<


                                                  Try it online!



                                                  Port of this Jelly answer. Takes input as an array of characters, with letters uppercase.



                                                  Explanation:



                                                  ®rT4 c Ä u6Ãä<    :
                                                  ® Ã :Map each character through:
                                                  rT4 : Replace 0 with 4
                                                  c : Get the char-code
                                                  Ä : Increment it
                                                  u6 : Modulo 6
                                                  ä< :Replace with 1 if you had to move right, 0 otherwise
                                                  :Implicitly sum and output





                                                  share|improve this answer























                                                  • Unfortunately this fails for the last test case.
                                                    – Shaggy
                                                    2 days ago










                                                  • I was working on a solution last night that I've now golfed down to 12 bytes if you want to try for it. Hint: It takes input as an array and uses a flag.
                                                    – Shaggy
                                                    2 days ago










                                                  • Actually, it looks like you just need to take input in uppercase to get yours working.
                                                    – Shaggy
                                                    2 days ago













                                                  up vote
                                                  1
                                                  down vote










                                                  up vote
                                                  1
                                                  down vote










                                                  Japt -x, 14 bytes



                                                  ®rT4 c Ä u6Ãä<


                                                  Try it online!



                                                  Port of this Jelly answer. Takes input as an array of characters, with letters uppercase.



                                                  Explanation:



                                                  ®rT4 c Ä u6Ãä<    :
                                                  ® Ã :Map each character through:
                                                  rT4 : Replace 0 with 4
                                                  c : Get the char-code
                                                  Ä : Increment it
                                                  u6 : Modulo 6
                                                  ä< :Replace with 1 if you had to move right, 0 otherwise
                                                  :Implicitly sum and output





                                                  share|improve this answer















                                                  Japt -x, 14 bytes



                                                  ®rT4 c Ä u6Ãä<


                                                  Try it online!



                                                  Port of this Jelly answer. Takes input as an array of characters, with letters uppercase.



                                                  Explanation:



                                                  ®rT4 c Ä u6Ãä<    :
                                                  ® Ã :Map each character through:
                                                  rT4 : Replace 0 with 4
                                                  c : Get the char-code
                                                  Ä : Increment it
                                                  u6 : Modulo 6
                                                  ä< :Replace with 1 if you had to move right, 0 otherwise
                                                  :Implicitly sum and output






                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited 2 days ago

























                                                  answered Nov 25 at 19:36









                                                  Kamil Drakari

                                                  2,601416




                                                  2,601416












                                                  • Unfortunately this fails for the last test case.
                                                    – Shaggy
                                                    2 days ago










                                                  • I was working on a solution last night that I've now golfed down to 12 bytes if you want to try for it. Hint: It takes input as an array and uses a flag.
                                                    – Shaggy
                                                    2 days ago










                                                  • Actually, it looks like you just need to take input in uppercase to get yours working.
                                                    – Shaggy
                                                    2 days ago


















                                                  • Unfortunately this fails for the last test case.
                                                    – Shaggy
                                                    2 days ago










                                                  • I was working on a solution last night that I've now golfed down to 12 bytes if you want to try for it. Hint: It takes input as an array and uses a flag.
                                                    – Shaggy
                                                    2 days ago










                                                  • Actually, it looks like you just need to take input in uppercase to get yours working.
                                                    – Shaggy
                                                    2 days ago
















                                                  Unfortunately this fails for the last test case.
                                                  – Shaggy
                                                  2 days ago




                                                  Unfortunately this fails for the last test case.
                                                  – Shaggy
                                                  2 days ago












                                                  I was working on a solution last night that I've now golfed down to 12 bytes if you want to try for it. Hint: It takes input as an array and uses a flag.
                                                  – Shaggy
                                                  2 days ago




                                                  I was working on a solution last night that I've now golfed down to 12 bytes if you want to try for it. Hint: It takes input as an array and uses a flag.
                                                  – Shaggy
                                                  2 days ago












                                                  Actually, it looks like you just need to take input in uppercase to get yours working.
                                                  – Shaggy
                                                  2 days ago




                                                  Actually, it looks like you just need to take input in uppercase to get yours working.
                                                  – Shaggy
                                                  2 days ago










                                                  up vote
                                                  1
                                                  down vote














                                                  Java (OpenJDK 8), 73 bytes



                                                  Not a bad solution for Java! That zero being on the right-hand side cost me several bytes.





                                                  t->{int a=9,c=0;for(int d:t)c+=a<(a=(--d+(d/48==1?2:0))%6)?1:0;return c;}


                                                  Try it online!



                                                  Explained



                                                  t -> {                          // Lambda taking a char array as input
                                                  int a=9, // Initialise last column value
                                                  c=0; // Initialise frustration count
                                                  for(int d:t) // Loop through all chars in title
                                                  c+= // increment the frustration count if...
                                                  a< // The last column is smaller than the current column
                                                  (a= // Set last column to current column
                                                  (--d+ // Decrement ascii value of char
                                                  (d/48==1 // If ascii decremented ascii value is between 48 and 95
                                                  ?2:0) // increment by 2 (1 total) or 0 (-1 total)
                                                  )%6) // Mod 6 to retrieve column index
                                                  ?1:0; // Increment if to right hand side
                                                  return c; // return calculated frustration count
                                                  }





                                                  share|improve this answer

























                                                    up vote
                                                    1
                                                    down vote














                                                    Java (OpenJDK 8), 73 bytes



                                                    Not a bad solution for Java! That zero being on the right-hand side cost me several bytes.





                                                    t->{int a=9,c=0;for(int d:t)c+=a<(a=(--d+(d/48==1?2:0))%6)?1:0;return c;}


                                                    Try it online!



                                                    Explained



                                                    t -> {                          // Lambda taking a char array as input
                                                    int a=9, // Initialise last column value
                                                    c=0; // Initialise frustration count
                                                    for(int d:t) // Loop through all chars in title
                                                    c+= // increment the frustration count if...
                                                    a< // The last column is smaller than the current column
                                                    (a= // Set last column to current column
                                                    (--d+ // Decrement ascii value of char
                                                    (d/48==1 // If ascii decremented ascii value is between 48 and 95
                                                    ?2:0) // increment by 2 (1 total) or 0 (-1 total)
                                                    )%6) // Mod 6 to retrieve column index
                                                    ?1:0; // Increment if to right hand side
                                                    return c; // return calculated frustration count
                                                    }





                                                    share|improve this answer























                                                      up vote
                                                      1
                                                      down vote










                                                      up vote
                                                      1
                                                      down vote










                                                      Java (OpenJDK 8), 73 bytes



                                                      Not a bad solution for Java! That zero being on the right-hand side cost me several bytes.





                                                      t->{int a=9,c=0;for(int d:t)c+=a<(a=(--d+(d/48==1?2:0))%6)?1:0;return c;}


                                                      Try it online!



                                                      Explained



                                                      t -> {                          // Lambda taking a char array as input
                                                      int a=9, // Initialise last column value
                                                      c=0; // Initialise frustration count
                                                      for(int d:t) // Loop through all chars in title
                                                      c+= // increment the frustration count if...
                                                      a< // The last column is smaller than the current column
                                                      (a= // Set last column to current column
                                                      (--d+ // Decrement ascii value of char
                                                      (d/48==1 // If ascii decremented ascii value is between 48 and 95
                                                      ?2:0) // increment by 2 (1 total) or 0 (-1 total)
                                                      )%6) // Mod 6 to retrieve column index
                                                      ?1:0; // Increment if to right hand side
                                                      return c; // return calculated frustration count
                                                      }





                                                      share|improve this answer













                                                      Java (OpenJDK 8), 73 bytes



                                                      Not a bad solution for Java! That zero being on the right-hand side cost me several bytes.





                                                      t->{int a=9,c=0;for(int d:t)c+=a<(a=(--d+(d/48==1?2:0))%6)?1:0;return c;}


                                                      Try it online!



                                                      Explained



                                                      t -> {                          // Lambda taking a char array as input
                                                      int a=9, // Initialise last column value
                                                      c=0; // Initialise frustration count
                                                      for(int d:t) // Loop through all chars in title
                                                      c+= // increment the frustration count if...
                                                      a< // The last column is smaller than the current column
                                                      (a= // Set last column to current column
                                                      (--d+ // Decrement ascii value of char
                                                      (d/48==1 // If ascii decremented ascii value is between 48 and 95
                                                      ?2:0) // increment by 2 (1 total) or 0 (-1 total)
                                                      )%6) // Mod 6 to retrieve column index
                                                      ?1:0; // Increment if to right hand side
                                                      return c; // return calculated frustration count
                                                      }






                                                      share|improve this answer












                                                      share|improve this answer



                                                      share|improve this answer










                                                      answered 2 days ago









                                                      Luke Stevens

                                                      684214




                                                      684214






















                                                          up vote
                                                          1
                                                          down vote














                                                          05AB1E, 12 11 bytes



                                                          -1 byte thanks to @Kevin Cruijssen



                                                          ¾4:Ç>6%¥1@O


                                                          Another port of Jonathan Allan's Jelly answer. Takes input in uppercase.



                                                          Explanation:



                                                          ¾4:Ç>6%¥1@O   //full program
                                                          ¾4: //replace all '0's with '4's
                                                          Ç //get ASCII code points
                                                          > //increment
                                                          6% //modulo 6
                                                          ¥ //get deltas
                                                          1@ //is >= 1
                                                          O //sum


                                                          Try it online!






                                                          share|improve this answer



















                                                          • 1




                                                            0'4 can be ¾4 to save a byte (relevant 05AB1E tip).
                                                            – Kevin Cruijssen
                                                            16 hours ago

















                                                          up vote
                                                          1
                                                          down vote














                                                          05AB1E, 12 11 bytes



                                                          -1 byte thanks to @Kevin Cruijssen



                                                          ¾4:Ç>6%¥1@O


                                                          Another port of Jonathan Allan's Jelly answer. Takes input in uppercase.



                                                          Explanation:



                                                          ¾4:Ç>6%¥1@O   //full program
                                                          ¾4: //replace all '0's with '4's
                                                          Ç //get ASCII code points
                                                          > //increment
                                                          6% //modulo 6
                                                          ¥ //get deltas
                                                          1@ //is >= 1
                                                          O //sum


                                                          Try it online!






                                                          share|improve this answer



















                                                          • 1




                                                            0'4 can be ¾4 to save a byte (relevant 05AB1E tip).
                                                            – Kevin Cruijssen
                                                            16 hours ago















                                                          up vote
                                                          1
                                                          down vote










                                                          up vote
                                                          1
                                                          down vote










                                                          05AB1E, 12 11 bytes



                                                          -1 byte thanks to @Kevin Cruijssen



                                                          ¾4:Ç>6%¥1@O


                                                          Another port of Jonathan Allan's Jelly answer. Takes input in uppercase.



                                                          Explanation:



                                                          ¾4:Ç>6%¥1@O   //full program
                                                          ¾4: //replace all '0's with '4's
                                                          Ç //get ASCII code points
                                                          > //increment
                                                          6% //modulo 6
                                                          ¥ //get deltas
                                                          1@ //is >= 1
                                                          O //sum


                                                          Try it online!






                                                          share|improve this answer















                                                          05AB1E, 12 11 bytes



                                                          -1 byte thanks to @Kevin Cruijssen



                                                          ¾4:Ç>6%¥1@O


                                                          Another port of Jonathan Allan's Jelly answer. Takes input in uppercase.



                                                          Explanation:



                                                          ¾4:Ç>6%¥1@O   //full program
                                                          ¾4: //replace all '0's with '4's
                                                          Ç //get ASCII code points
                                                          > //increment
                                                          6% //modulo 6
                                                          ¥ //get deltas
                                                          1@ //is >= 1
                                                          O //sum


                                                          Try it online!







                                                          share|improve this answer














                                                          share|improve this answer



                                                          share|improve this answer








                                                          edited 11 hours ago

























                                                          answered 2 days ago









                                                          Cowabunghole

                                                          1,010418




                                                          1,010418








                                                          • 1




                                                            0'4 can be ¾4 to save a byte (relevant 05AB1E tip).
                                                            – Kevin Cruijssen
                                                            16 hours ago
















                                                          • 1




                                                            0'4 can be ¾4 to save a byte (relevant 05AB1E tip).
                                                            – Kevin Cruijssen
                                                            16 hours ago










                                                          1




                                                          1




                                                          0'4 can be ¾4 to save a byte (relevant 05AB1E tip).
                                                          – Kevin Cruijssen
                                                          16 hours ago






                                                          0'4 can be ¾4 to save a byte (relevant 05AB1E tip).
                                                          – Kevin Cruijssen
                                                          16 hours ago












                                                          up vote
                                                          0
                                                          down vote














                                                          Retina 0.8.2, 46 bytes



                                                          T`l1-90`1-61-61-61-61-61-6
                                                          .
                                                          ;$&$*
                                                          &`;(1+);11


                                                          Try it online! Link includes test cases. Explanation:



                                                          T`l1-90`1-61-61-61-61-61-6


                                                          List the alphabet and digits in the order on the OSK and map each one to a (1-indexed) column number.



                                                          .
                                                          ;$&$*


                                                          Convert each column number to unary.



                                                          &`;(1+);11


                                                          Count the number of columns that are followed by a larger (i.e. rightwards) column. The &` allows the matches to overlap.






                                                          share|improve this answer

























                                                            up vote
                                                            0
                                                            down vote














                                                            Retina 0.8.2, 46 bytes



                                                            T`l1-90`1-61-61-61-61-61-6
                                                            .
                                                            ;$&$*
                                                            &`;(1+);11


                                                            Try it online! Link includes test cases. Explanation:



                                                            T`l1-90`1-61-61-61-61-61-6


                                                            List the alphabet and digits in the order on the OSK and map each one to a (1-indexed) column number.



                                                            .
                                                            ;$&$*


                                                            Convert each column number to unary.



                                                            &`;(1+);11


                                                            Count the number of columns that are followed by a larger (i.e. rightwards) column. The &` allows the matches to overlap.






                                                            share|improve this answer























                                                              up vote
                                                              0
                                                              down vote










                                                              up vote
                                                              0
                                                              down vote










                                                              Retina 0.8.2, 46 bytes



                                                              T`l1-90`1-61-61-61-61-61-6
                                                              .
                                                              ;$&$*
                                                              &`;(1+);11


                                                              Try it online! Link includes test cases. Explanation:



                                                              T`l1-90`1-61-61-61-61-61-6


                                                              List the alphabet and digits in the order on the OSK and map each one to a (1-indexed) column number.



                                                              .
                                                              ;$&$*


                                                              Convert each column number to unary.



                                                              &`;(1+);11


                                                              Count the number of columns that are followed by a larger (i.e. rightwards) column. The &` allows the matches to overlap.






                                                              share|improve this answer













                                                              Retina 0.8.2, 46 bytes



                                                              T`l1-90`1-61-61-61-61-61-6
                                                              .
                                                              ;$&$*
                                                              &`;(1+);11


                                                              Try it online! Link includes test cases. Explanation:



                                                              T`l1-90`1-61-61-61-61-61-6


                                                              List the alphabet and digits in the order on the OSK and map each one to a (1-indexed) column number.



                                                              .
                                                              ;$&$*


                                                              Convert each column number to unary.



                                                              &`;(1+);11


                                                              Count the number of columns that are followed by a larger (i.e. rightwards) column. The &` allows the matches to overlap.







                                                              share|improve this answer












                                                              share|improve this answer



                                                              share|improve this answer










                                                              answered Nov 24 at 20:49









                                                              Neil

                                                              78.3k744175




                                                              78.3k744175






















                                                                  up vote
                                                                  0
                                                                  down vote














                                                                  Python 2, 84 bytes





                                                                  def f(s,k=6):j=(ord(s[0])+('0'<s[0]<':')*2-1)%6;return(j>k)+(~-len(s)and f(s[1:],j))


                                                                  Try it online!






                                                                  share|improve this answer



























                                                                    up vote
                                                                    0
                                                                    down vote














                                                                    Python 2, 84 bytes





                                                                    def f(s,k=6):j=(ord(s[0])+('0'<s[0]<':')*2-1)%6;return(j>k)+(~-len(s)and f(s[1:],j))


                                                                    Try it online!






                                                                    share|improve this answer

























                                                                      up vote
                                                                      0
                                                                      down vote










                                                                      up vote
                                                                      0
                                                                      down vote










                                                                      Python 2, 84 bytes





                                                                      def f(s,k=6):j=(ord(s[0])+('0'<s[0]<':')*2-1)%6;return(j>k)+(~-len(s)and f(s[1:],j))


                                                                      Try it online!






                                                                      share|improve this answer















                                                                      Python 2, 84 bytes





                                                                      def f(s,k=6):j=(ord(s[0])+('0'<s[0]<':')*2-1)%6;return(j>k)+(~-len(s)and f(s[1:],j))


                                                                      Try it online!







                                                                      share|improve this answer














                                                                      share|improve this answer



                                                                      share|improve this answer








                                                                      edited Nov 25 at 6:20

























                                                                      answered Nov 25 at 4:42









                                                                      Chas Brown

                                                                      4,7491522




                                                                      4,7491522






















                                                                          up vote
                                                                          0
                                                                          down vote













                                                                          Mathematica, 102 bytes



                                                                          Differences[Last@@Join[Alphabet,ToString/@Range@9,{"0"}]~Partition~6~Position~#&/@#]~Count~_?(#>0&)&


                                                                          Pure function. Takes a list of characters as input and returns a number as output. This is a pretty naive solution, golfing suggestions welcome.






                                                                          share|improve this answer

























                                                                            up vote
                                                                            0
                                                                            down vote













                                                                            Mathematica, 102 bytes



                                                                            Differences[Last@@Join[Alphabet,ToString/@Range@9,{"0"}]~Partition~6~Position~#&/@#]~Count~_?(#>0&)&


                                                                            Pure function. Takes a list of characters as input and returns a number as output. This is a pretty naive solution, golfing suggestions welcome.






                                                                            share|improve this answer























                                                                              up vote
                                                                              0
                                                                              down vote










                                                                              up vote
                                                                              0
                                                                              down vote









                                                                              Mathematica, 102 bytes



                                                                              Differences[Last@@Join[Alphabet,ToString/@Range@9,{"0"}]~Partition~6~Position~#&/@#]~Count~_?(#>0&)&


                                                                              Pure function. Takes a list of characters as input and returns a number as output. This is a pretty naive solution, golfing suggestions welcome.






                                                                              share|improve this answer












                                                                              Mathematica, 102 bytes



                                                                              Differences[Last@@Join[Alphabet,ToString/@Range@9,{"0"}]~Partition~6~Position~#&/@#]~Count~_?(#>0&)&


                                                                              Pure function. Takes a list of characters as input and returns a number as output. This is a pretty naive solution, golfing suggestions welcome.







                                                                              share|improve this answer












                                                                              share|improve this answer



                                                                              share|improve this answer










                                                                              answered Nov 25 at 15:24









                                                                              LegionMammal978

                                                                              15k41752




                                                                              15k41752






















                                                                                  up vote
                                                                                  0
                                                                                  down vote














                                                                                  C (gcc),  82  79 bytes





                                                                                  o;c(i){i+=i<60&&i>48?1:5;i%=6;}f(char*s){for(o=0;*++s;o+=c(*s)>c(*(s-1)));o=o;}


                                                                                  Try it online!



                                                                                  This function will only support lowercase inputs





                                                                                  Ungolfed and commented:





                                                                                  o; //Used for output
                                                                                  c(i){ //Calculates the column of given character
                                                                                  i+= //Correct i to get the correct column
                                                                                  i<60 //If i is a digit...
                                                                                  && i>48 //... but not '0'
                                                                                  ?1 //Then move it one column on the right
                                                                                  :5; //Else move it five columns on the right
                                                                                  i%=6; //Get the column number
                                                                                  }
                                                                                  f(char*s){ // The actual "frustrating" function
                                                                                  for( //Loop for each character
                                                                                  o=0; //reinitialize output
                                                                                  *++s; //move to next character / while this is not ''
                                                                                  o+=c(*s)>c(*(s-1)) //Increment if current character is on the right of the previous one
                                                                                  );
                                                                                  o=o; // Outputs result
                                                                                  }




                                                                                  If my function is allowed to accept wide character strings, it can be reduced to 78 bytes with:





                                                                                  o;c(i){i+=i<60&&i>48?1:5;i%=6;}f(int*s){for(o=0;*++s;o+=c(*s)>c(*(s-1)));o=o;}


                                                                                  Try it online!



                                                                                  This version just accept input as int* instead of char*





                                                                                  Edits:




                                                                                  • Golfed 3 bytes in the calculation of the column (function c)






                                                                                  share|improve this answer























                                                                                  • And there, 77 bytes
                                                                                    – Rogem
                                                                                    2 days ago















                                                                                  up vote
                                                                                  0
                                                                                  down vote














                                                                                  C (gcc),  82  79 bytes





                                                                                  o;c(i){i+=i<60&&i>48?1:5;i%=6;}f(char*s){for(o=0;*++s;o+=c(*s)>c(*(s-1)));o=o;}


                                                                                  Try it online!



                                                                                  This function will only support lowercase inputs





                                                                                  Ungolfed and commented:





                                                                                  o; //Used for output
                                                                                  c(i){ //Calculates the column of given character
                                                                                  i+= //Correct i to get the correct column
                                                                                  i<60 //If i is a digit...
                                                                                  && i>48 //... but not '0'
                                                                                  ?1 //Then move it one column on the right
                                                                                  :5; //Else move it five columns on the right
                                                                                  i%=6; //Get the column number
                                                                                  }
                                                                                  f(char*s){ // The actual "frustrating" function
                                                                                  for( //Loop for each character
                                                                                  o=0; //reinitialize output
                                                                                  *++s; //move to next character / while this is not ''
                                                                                  o+=c(*s)>c(*(s-1)) //Increment if current character is on the right of the previous one
                                                                                  );
                                                                                  o=o; // Outputs result
                                                                                  }




                                                                                  If my function is allowed to accept wide character strings, it can be reduced to 78 bytes with:





                                                                                  o;c(i){i+=i<60&&i>48?1:5;i%=6;}f(int*s){for(o=0;*++s;o+=c(*s)>c(*(s-1)));o=o;}


                                                                                  Try it online!



                                                                                  This version just accept input as int* instead of char*





                                                                                  Edits:




                                                                                  • Golfed 3 bytes in the calculation of the column (function c)






                                                                                  share|improve this answer























                                                                                  • And there, 77 bytes
                                                                                    – Rogem
                                                                                    2 days ago













                                                                                  up vote
                                                                                  0
                                                                                  down vote










                                                                                  up vote
                                                                                  0
                                                                                  down vote










                                                                                  C (gcc),  82  79 bytes





                                                                                  o;c(i){i+=i<60&&i>48?1:5;i%=6;}f(char*s){for(o=0;*++s;o+=c(*s)>c(*(s-1)));o=o;}


                                                                                  Try it online!



                                                                                  This function will only support lowercase inputs





                                                                                  Ungolfed and commented:





                                                                                  o; //Used for output
                                                                                  c(i){ //Calculates the column of given character
                                                                                  i+= //Correct i to get the correct column
                                                                                  i<60 //If i is a digit...
                                                                                  && i>48 //... but not '0'
                                                                                  ?1 //Then move it one column on the right
                                                                                  :5; //Else move it five columns on the right
                                                                                  i%=6; //Get the column number
                                                                                  }
                                                                                  f(char*s){ // The actual "frustrating" function
                                                                                  for( //Loop for each character
                                                                                  o=0; //reinitialize output
                                                                                  *++s; //move to next character / while this is not ''
                                                                                  o+=c(*s)>c(*(s-1)) //Increment if current character is on the right of the previous one
                                                                                  );
                                                                                  o=o; // Outputs result
                                                                                  }




                                                                                  If my function is allowed to accept wide character strings, it can be reduced to 78 bytes with:





                                                                                  o;c(i){i+=i<60&&i>48?1:5;i%=6;}f(int*s){for(o=0;*++s;o+=c(*s)>c(*(s-1)));o=o;}


                                                                                  Try it online!



                                                                                  This version just accept input as int* instead of char*





                                                                                  Edits:




                                                                                  • Golfed 3 bytes in the calculation of the column (function c)






                                                                                  share|improve this answer















                                                                                  C (gcc),  82  79 bytes





                                                                                  o;c(i){i+=i<60&&i>48?1:5;i%=6;}f(char*s){for(o=0;*++s;o+=c(*s)>c(*(s-1)));o=o;}


                                                                                  Try it online!



                                                                                  This function will only support lowercase inputs





                                                                                  Ungolfed and commented:





                                                                                  o; //Used for output
                                                                                  c(i){ //Calculates the column of given character
                                                                                  i+= //Correct i to get the correct column
                                                                                  i<60 //If i is a digit...
                                                                                  && i>48 //... but not '0'
                                                                                  ?1 //Then move it one column on the right
                                                                                  :5; //Else move it five columns on the right
                                                                                  i%=6; //Get the column number
                                                                                  }
                                                                                  f(char*s){ // The actual "frustrating" function
                                                                                  for( //Loop for each character
                                                                                  o=0; //reinitialize output
                                                                                  *++s; //move to next character / while this is not ''
                                                                                  o+=c(*s)>c(*(s-1)) //Increment if current character is on the right of the previous one
                                                                                  );
                                                                                  o=o; // Outputs result
                                                                                  }




                                                                                  If my function is allowed to accept wide character strings, it can be reduced to 78 bytes with:





                                                                                  o;c(i){i+=i<60&&i>48?1:5;i%=6;}f(int*s){for(o=0;*++s;o+=c(*s)>c(*(s-1)));o=o;}


                                                                                  Try it online!



                                                                                  This version just accept input as int* instead of char*





                                                                                  Edits:




                                                                                  • Golfed 3 bytes in the calculation of the column (function c)







                                                                                  share|improve this answer














                                                                                  share|improve this answer



                                                                                  share|improve this answer








                                                                                  edited 2 days ago

























                                                                                  answered 2 days ago









                                                                                  Annyo

                                                                                  1313




                                                                                  1313












                                                                                  • And there, 77 bytes
                                                                                    – Rogem
                                                                                    2 days ago


















                                                                                  • And there, 77 bytes
                                                                                    – Rogem
                                                                                    2 days ago
















                                                                                  And there, 77 bytes
                                                                                  – Rogem
                                                                                  2 days ago




                                                                                  And there, 77 bytes
                                                                                  – Rogem
                                                                                  2 days ago


















                                                                                   

                                                                                  draft saved


                                                                                  draft discarded



















































                                                                                   


                                                                                  draft saved


                                                                                  draft discarded














                                                                                  StackExchange.ready(
                                                                                  function () {
                                                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f176492%2fhow-frustrating-is-my-movie%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

                                                                                  AnyDesk - Fatal Program Failure

                                                                                  How to calibrate 16:9 built-in touch-screen to a 4:3 resolution?

                                                                                  QoS: MAC-Priority for clients behind a repeater