Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Affin cipher fix #125

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Conversation

tintinthong
Copy link
Contributor

@tintinthong tintinthong commented Aug 6, 2019

This is my fix to the previous pull-request on #123.

Using GitKraken as GUI tool for Git, created new branch affin-cipher-fix. The problem was that my previous branch affine-cipher had excessive historical commits that was squashed on the upstream remote master(exercism/r/master). It is a mouthful and confusing but I basically, reset to the commit 73af394, pulled canges from upstream remote master and cherry picked my pull request commits 0ba2c4 and 950598 on affine-cipher branch. Hope I didn't change any history that has any conflicts.

In this new commit, I made code more readable by breaking it up into lines (also because lintr bot also said my line had too many characters).

Once everything is fine. I will do a squash myself.

@lintr-bot

This comment has been minimized.

2 similar comments
@lintr-bot
Copy link

exercises/affine-cipher/example.R:16:1: style: lines should not be more than 80 characters.

parsedMessage <- tolower(gsub(" ", "", message)) # removed whitespace & lower-cased
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

exercises/affine-cipher/example.R:16:3: style: Variable and function names should be all lowercase.

parsedMessage <- tolower(gsub(" ", "", message)) # removed whitespace & lower-cased
  ^~~~~~~~~~~~~

exercises/affine-cipher/example.R:17:25: style: Variable and function names should be all lowercase.

splitList <- strsplit(parsedMessage, "")[[1]] # list of letters
                        ^~~~~~~~~~~~~

exercises/affine-cipher/example.R:51:3: style: Variable and function names should be all lowercase.

parsedEncryption <- gsub(" ", "", encryption) # removed whitespace
  ^~~~~~~~~~~~~~~~

exercises/affine-cipher/example.R:52:25: style: Variable and function names should be all lowercase.

splitList <- strsplit(parsedEncryption, "")[[1]] # list of letters
                        ^~~~~~~~~~~~~~~~

exercises/affine-cipher/test_affine-cipher.R:24:1: style: lines should not be more than 80 characters.

​  expect_identical(decrypt("kqlfd jzvgy tpaet icdhm rtwly kqlon ubstx", 19, 13), "thequickbrownfoxjumpsoverthelazydog")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

exercises/affine-cipher/test_affine-cipher.R:29:1: style: lines should not be more than 80 characters.

​  expect_identical(decrypt("kqlfd jzvgy tpaet icdhm rtwly kqlon ubstx", 19, 13), "thequickbrownfoxjumpsoverthelazydog")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@lintr-bot
Copy link

exercises/affine-cipher/example.R:16:1: style: lines should not be more than 80 characters.

parsedMessage <- tolower(gsub(" ", "", message)) # removed whitespace & lower-cased
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

exercises/affine-cipher/example.R:16:3: style: Variable and function names should be all lowercase.

parsedMessage <- tolower(gsub(" ", "", message)) # removed whitespace & lower-cased
  ^~~~~~~~~~~~~

exercises/affine-cipher/example.R:17:25: style: Variable and function names should be all lowercase.

splitList <- strsplit(parsedMessage, "")[[1]] # list of letters
                        ^~~~~~~~~~~~~

exercises/affine-cipher/example.R:51:3: style: Variable and function names should be all lowercase.

parsedEncryption <- gsub(" ", "", encryption) # removed whitespace
  ^~~~~~~~~~~~~~~~

exercises/affine-cipher/example.R:52:25: style: Variable and function names should be all lowercase.

splitList <- strsplit(parsedEncryption, "")[[1]] # list of letters
                        ^~~~~~~~~~~~~~~~

exercises/affine-cipher/test_affine-cipher.R:24:1: style: lines should not be more than 80 characters.

​  expect_identical(decrypt("kqlfd jzvgy tpaet icdhm rtwly kqlon ubstx", 19, 13), "thequickbrownfoxjumpsoverthelazydog")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

exercises/affine-cipher/test_affine-cipher.R:29:1: style: lines should not be more than 80 characters.

​  expect_identical(decrypt("kqlfd jzvgy tpaet icdhm rtwly kqlon ubstx", 19, 13), "thequickbrownfoxjumpsoverthelazydog")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Weird. lintbot said all variable names must be lowercased but did not address all my cases (ie i used splitList but it did not detect it)
@lintr-bot

This comment has been minimized.

2 similar comments
@lintr-bot
Copy link

exercises/affine-cipher/example.R:16:1: style: lines should not be more than 80 characters.

parsedmessage <- tolower(gsub(" ", "", message)) # removed whitespace & lower-cased
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@lintr-bot
Copy link

exercises/affine-cipher/example.R:16:1: style: lines should not be more than 80 characters.

parsedmessage <- tolower(gsub(" ", "", message)) # removed whitespace & lower-cased
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@katrinleinweber
Copy link
Contributor

katrinleinweber commented Aug 8, 2019

Nicely done :-) I'll review on the weekend.

config.json Outdated
"slug": "affine-cipher",
"uuid": "9bc3f040-9e4b-4ed0-b23c-3ae565e83a59",
"core": false,
"difficulty": 5,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you consider this substantially more difficult than crypto-square or tournament? Those are 4s, so we should have an argument here to introduce 5.

Copy link
Contributor

@katrinleinweber katrinleinweber Aug 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: I use https://jonmcalder.shinyapps.io/exercism-config-viz/ BTW to visualise where a new exercise might fit into the track structure. Please feel free to suggest an unlocked_by ;-)

Copy link
Contributor Author

@tintinthong tintinthong Aug 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@katrinleinweber (For me) I do not necessarily feel that affine-cipher is difficult at all (tournament is more difficult tho). However, I do feel that the reader contends with a high overhead of needing to find out gcd and MMI as pre-requisites of solving the question. As expected I checked in python and crypto-square was 1 whereas tournament and affine-cipher was 5. The rust track does not have affine-cipher but rates tournament and crypto-square both as 4. I am happy to rate affine-cipher at 4, however, to the non-mathematically inclined will experience it to be a bit harder than normal.

Copy link
Contributor Author

@tintinthong tintinthong Aug 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally. for the student. We would want to break it up into smaller pieces and make each piece as pre-requisite. These are the unlocked_by tree; in brackets it is difficulty.

  1. Ideal Option
prime-factors (3)-> gcd (3) -> mmi (2) --> affine-cipher(3)
crypto-square (4) -> affine-cipher(3) 

If these pre-requisites exist for affine-cipher, it's difficulty should dampen. And the true task of affine cipher is just to put gcd and mmi together and also handle the normalisation-- that's all.

  1. Practical Option
prime-factors (3) ->affine-cipher(4)

The reason I include the practical option is because. 1) unlocked_by cannot have a many-to-one dependence (correct me if I am wrong). 2) Do not want to add too many new exercises just for the sake of affine-cipher.

In addition, I should add the pre-requisite of being able to solve a gcd function in the README.md. I noticed I have not made it as clear as how I have done for the MMI.

}


decrypt <- function(encryption, a, b) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does encryption mean the ciphertext here? If yes, please consider renaming it. message -> plaintext might also be a good idea then, because those are the domain terms.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Agreed.

# must check a and m are coprime
if (gcd(a, m) != 1) {
stop("a and 26 must be co-prime")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gcd <- function(x, y) {
r <- x %% y
return(ifelse(r, gcd(y, r), y))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# must check a and m are coprime
if (gcd(a, m) != 1) {
stop("a and 26 must be co-prime")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should 26 be hard-coded here? I think stop can act like paste in that m could be inserted dynamically here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes okay

# removed whitespace & lower-cased
parsedmessage <- tolower(gsub(" ", "", message))
# list of letters
splitlist <- strsplit(parsedmessage, "")[[1]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be variables names here, that don't require a comment above them?

@lintr-bot

This comment has been minimized.

2 similar comments
@lintr-bot
Copy link

exercises/affine-cipher/affine-cipher.R:5:10: style: Put spaces around all infix operators.

normalise<-function(text){
        ~^~~

exercises/affine-cipher/affine-cipher.R:10:1: style: Variable and function names should be all lowercase.

lookupIndex<-function(normalisedtext){
^~~~~~~~~~~

exercises/affine-cipher/affine-cipher.R:10:12: style: Put spaces around all infix operators.

lookupIndex<-function(normalisedtext){
          ~^~~

exercises/affine-cipher/affine-cipher.R:41:21: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                    ^

exercises/affine-cipher/affine-cipher.R:41:23: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                      ^

exercises/affine-cipher/affine-cipher.R:41:33: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                                ^

exercises/affine-cipher/affine-cipher.R:41:35: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                                  ^

exercises/affine-cipher/affine-cipher.R:45:22: style: Put spaces around all infix operators.

normalisedplaintext<-normalise(plaintext) 
                    ~^~~

exercises/affine-cipher/affine-cipher.R:46:4: style: Put spaces around all infix operators.

x<-lookupIndex(normalisedplaintext)
  ~^~~

exercises/affine-cipher/affine-cipher.R:46:6: style: Variable and function names should be all lowercase.

x<-lookupIndex(normalisedplaintext)
     ^~~~~~~~~~~

exercises/affine-cipher/affine-cipher.R:62:23: style: Put spaces around all infix operators.

normalisedencryption<-normalise(encryption)
                     ~^~~

exercises/affine-cipher/affine-cipher.R:63:4: style: Put spaces around all infix operators.

y<-lookupIndex(normalisedencryption)
  ~^~~

exercises/affine-cipher/affine-cipher.R:63:6: style: Variable and function names should be all lowercase.

y<-lookupIndex(normalisedencryption)
     ^~~~~~~~~~~

exercises/affine-cipher/example.R:5:10: style: Put spaces around all infix operators.

normalise<-function(text){
        ~^~~

exercises/affine-cipher/example.R:10:1: style: Variable and function names should be all lowercase.

lookupIndex<-function(normalisedtext){
^~~~~~~~~~~

exercises/affine-cipher/example.R:10:12: style: Put spaces around all infix operators.

lookupIndex<-function(normalisedtext){
          ~^~~

exercises/affine-cipher/example.R:41:21: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                    ^

exercises/affine-cipher/example.R:41:23: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                      ^

exercises/affine-cipher/example.R:41:33: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                                ^

exercises/affine-cipher/example.R:41:35: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                                  ^

exercises/affine-cipher/example.R:45:22: style: Put spaces around all infix operators.

normalisedplaintext<-normalise(plaintext) 
                    ~^~~

exercises/affine-cipher/example.R:46:4: style: Put spaces around all infix operators.

x<-lookupIndex(normalisedencryption)
  ~^~~

exercises/affine-cipher/example.R:46:6: style: Variable and function names should be all lowercase.

x<-lookupIndex(normalisedencryption)
     ^~~~~~~~~~~

exercises/affine-cipher/example.R:62:23: style: Put spaces around all infix operators.

normalisedencryption<-normalise(plaintext)
                     ~^~~

exercises/affine-cipher/example.R:63:4: style: Put spaces around all infix operators.

y<-lookupIndex(normalisedencryption)
  ~^~~

exercises/affine-cipher/example.R:63:6: style: Variable and function names should be all lowercase.

y<-lookupIndex(normalisedencryption)
     ^~~~~~~~~~~

@lintr-bot
Copy link

exercises/affine-cipher/affine-cipher.R:5:10: style: Put spaces around all infix operators.

normalise<-function(text){
        ~^~~

exercises/affine-cipher/affine-cipher.R:10:1: style: Variable and function names should be all lowercase.

lookupIndex<-function(normalisedtext){
^~~~~~~~~~~

exercises/affine-cipher/affine-cipher.R:10:12: style: Put spaces around all infix operators.

lookupIndex<-function(normalisedtext){
          ~^~~

exercises/affine-cipher/affine-cipher.R:41:21: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                    ^

exercises/affine-cipher/affine-cipher.R:41:23: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                      ^

exercises/affine-cipher/affine-cipher.R:41:33: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                                ^

exercises/affine-cipher/affine-cipher.R:41:35: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                                  ^

exercises/affine-cipher/affine-cipher.R:45:22: style: Put spaces around all infix operators.

normalisedplaintext<-normalise(plaintext) 
                    ~^~~

exercises/affine-cipher/affine-cipher.R:46:4: style: Put spaces around all infix operators.

x<-lookupIndex(normalisedplaintext)
  ~^~~

exercises/affine-cipher/affine-cipher.R:46:6: style: Variable and function names should be all lowercase.

x<-lookupIndex(normalisedplaintext)
     ^~~~~~~~~~~

exercises/affine-cipher/affine-cipher.R:62:23: style: Put spaces around all infix operators.

normalisedencryption<-normalise(encryption)
                     ~^~~

exercises/affine-cipher/affine-cipher.R:63:4: style: Put spaces around all infix operators.

y<-lookupIndex(normalisedencryption)
  ~^~~

exercises/affine-cipher/affine-cipher.R:63:6: style: Variable and function names should be all lowercase.

y<-lookupIndex(normalisedencryption)
     ^~~~~~~~~~~

exercises/affine-cipher/example.R:5:10: style: Put spaces around all infix operators.

normalise<-function(text){
        ~^~~

exercises/affine-cipher/example.R:10:1: style: Variable and function names should be all lowercase.

lookupIndex<-function(normalisedtext){
^~~~~~~~~~~

exercises/affine-cipher/example.R:10:12: style: Put spaces around all infix operators.

lookupIndex<-function(normalisedtext){
          ~^~~

exercises/affine-cipher/example.R:41:21: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                    ^

exercises/affine-cipher/example.R:41:23: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                      ^

exercises/affine-cipher/example.R:41:33: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                                ^

exercises/affine-cipher/example.R:41:35: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                                  ^

exercises/affine-cipher/example.R:45:22: style: Put spaces around all infix operators.

normalisedplaintext<-normalise(plaintext) 
                    ~^~~

exercises/affine-cipher/example.R:46:4: style: Put spaces around all infix operators.

x<-lookupIndex(normalisedencryption)
  ~^~~

exercises/affine-cipher/example.R:46:6: style: Variable and function names should be all lowercase.

x<-lookupIndex(normalisedencryption)
     ^~~~~~~~~~~

exercises/affine-cipher/example.R:62:23: style: Put spaces around all infix operators.

normalisedencryption<-normalise(plaintext)
                     ~^~~

exercises/affine-cipher/example.R:63:4: style: Put spaces around all infix operators.

y<-lookupIndex(normalisedencryption)
  ~^~~

exercises/affine-cipher/example.R:63:6: style: Variable and function names should be all lowercase.

y<-lookupIndex(normalisedencryption)
     ^~~~~~~~~~~

@lintr-bot

This comment has been minimized.

2 similar comments
@lintr-bot
Copy link

exercises/affine-cipher/affine-cipher.R:1:10: style: Put spaces around all infix operators.

normalise<-function(text){
        ~^~~

exercises/affine-cipher/affine-cipher.R:4:12: style: Put spaces around all infix operators.

lookupindex<-function(normalisedtext){
          ~^~~

exercises/affine-cipher/affine-cipher.R:7:4: style: Put spaces around all infix operators.

gcd<-function(x,y){
  ~^~~

exercises/affine-cipher/affine-cipher.R:7:17: style: Commas should always have a space after.

gcd<-function(x,y){
                ^

exercises/affine-cipher/affine-cipher.R:10:4: style: Put spaces around all infix operators.

mmi<-function(a,m){
  ~^~~

exercises/affine-cipher/affine-cipher.R:10:17: style: Commas should always have a space after.

mmi<-function(a,m){
                ^

exercises/affine-cipher/affine-cipher.R:13:8: style: Put spaces around all infix operators.

encrypt<-function(plaintext,a,b){
      ~^~~

exercises/affine-cipher/affine-cipher.R:13:29: style: Commas should always have a space after.

encrypt<-function(plaintext,a,b){
                            ^

exercises/affine-cipher/affine-cipher.R:13:31: style: Commas should always have a space after.

encrypt<-function(plaintext,a,b){
                              ^

exercises/affine-cipher/affine-cipher.R:16:8: style: Put spaces around all infix operators.

decrypt<-function(encryption,a,b){
      ~^~~

exercises/affine-cipher/affine-cipher.R:16:30: style: Commas should always have a space after.

decrypt<-function(encryption,a,b){
                             ^

exercises/affine-cipher/affine-cipher.R:16:32: style: Commas should always have a space after.

decrypt<-function(encryption,a,b){
                               ^

exercises/affine-cipher/example.R:1:10: style: Put spaces around all infix operators.

normalise<-function(text){
        ~^~~

exercises/affine-cipher/example.R:5:12: style: Put spaces around all infix operators.

lookupindex<-function(normalisedtext){
          ~^~~

exercises/affine-cipher/example.R:29:21: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                    ^

exercises/affine-cipher/example.R:29:23: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                      ^

exercises/affine-cipher/example.R:29:33: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                                ^

exercises/affine-cipher/example.R:29:35: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                                  ^

exercises/affine-cipher/example.R:32:22: style: Put spaces around all infix operators.

normalisedplaintext<-normalise(plaintext) 
                    ~^~~

exercises/affine-cipher/example.R:33:4: style: Put spaces around all infix operators.

x<-lookupindex(normalisedplaintext)
  ~^~~

exercises/affine-cipher/example.R:45:23: style: Put spaces around all infix operators.

normalisedencryption<-normalise(encryption)
                     ~^~~

exercises/affine-cipher/example.R:46:4: style: Put spaces around all infix operators.

y<-lookupindex(normalisedencryption)
  ~^~~

@lintr-bot
Copy link

exercises/affine-cipher/affine-cipher.R:1:10: style: Put spaces around all infix operators.

normalise<-function(text){
        ~^~~

exercises/affine-cipher/affine-cipher.R:4:12: style: Put spaces around all infix operators.

lookupindex<-function(normalisedtext){
          ~^~~

exercises/affine-cipher/affine-cipher.R:7:4: style: Put spaces around all infix operators.

gcd<-function(x,y){
  ~^~~

exercises/affine-cipher/affine-cipher.R:7:17: style: Commas should always have a space after.

gcd<-function(x,y){
                ^

exercises/affine-cipher/affine-cipher.R:10:4: style: Put spaces around all infix operators.

mmi<-function(a,m){
  ~^~~

exercises/affine-cipher/affine-cipher.R:10:17: style: Commas should always have a space after.

mmi<-function(a,m){
                ^

exercises/affine-cipher/affine-cipher.R:13:8: style: Put spaces around all infix operators.

encrypt<-function(plaintext,a,b){
      ~^~~

exercises/affine-cipher/affine-cipher.R:13:29: style: Commas should always have a space after.

encrypt<-function(plaintext,a,b){
                            ^

exercises/affine-cipher/affine-cipher.R:13:31: style: Commas should always have a space after.

encrypt<-function(plaintext,a,b){
                              ^

exercises/affine-cipher/affine-cipher.R:16:8: style: Put spaces around all infix operators.

decrypt<-function(encryption,a,b){
      ~^~~

exercises/affine-cipher/affine-cipher.R:16:30: style: Commas should always have a space after.

decrypt<-function(encryption,a,b){
                             ^

exercises/affine-cipher/affine-cipher.R:16:32: style: Commas should always have a space after.

decrypt<-function(encryption,a,b){
                               ^

exercises/affine-cipher/example.R:1:10: style: Put spaces around all infix operators.

normalise<-function(text){
        ~^~~

exercises/affine-cipher/example.R:5:12: style: Put spaces around all infix operators.

lookupindex<-function(normalisedtext){
          ~^~~

exercises/affine-cipher/example.R:29:21: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                    ^

exercises/affine-cipher/example.R:29:23: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                      ^

exercises/affine-cipher/example.R:29:33: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                                ^

exercises/affine-cipher/example.R:29:35: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                                  ^

exercises/affine-cipher/example.R:32:22: style: Put spaces around all infix operators.

normalisedplaintext<-normalise(plaintext) 
                    ~^~~

exercises/affine-cipher/example.R:33:4: style: Put spaces around all infix operators.

x<-lookupindex(normalisedplaintext)
  ~^~~

exercises/affine-cipher/example.R:45:23: style: Put spaces around all infix operators.

normalisedencryption<-normalise(encryption)
                     ~^~~

exercises/affine-cipher/example.R:46:4: style: Put spaces around all infix operators.

y<-lookupindex(normalisedencryption)
  ~^~~

@tintinthong
Copy link
Contributor Author

@katrinleinweber I made all changes mentioned. I made affine cipher of difficulty 4 and unlocked_by prime-factors

@lintr-bot

This comment has been minimized.

2 similar comments
@lintr-bot
Copy link

exercises/affine-cipher/affine-cipher.R:1:10: style: Put spaces around all infix operators.

normalise<-function(text){
        ~^~~

exercises/affine-cipher/affine-cipher.R:4:12: style: Put spaces around all infix operators.

lookupindex<-function(normalisedtext){
          ~^~~

exercises/affine-cipher/affine-cipher.R:7:4: style: Put spaces around all infix operators.

gcd<-function(x,y){
  ~^~~

exercises/affine-cipher/affine-cipher.R:7:17: style: Commas should always have a space after.

gcd<-function(x,y){
                ^

exercises/affine-cipher/affine-cipher.R:10:4: style: Put spaces around all infix operators.

mmi<-function(a,m){
  ~^~~

exercises/affine-cipher/affine-cipher.R:10:17: style: Commas should always have a space after.

mmi<-function(a,m){
                ^

exercises/affine-cipher/affine-cipher.R:13:8: style: Put spaces around all infix operators.

encrypt<-function(plaintext,a,b){
      ~^~~

exercises/affine-cipher/affine-cipher.R:13:29: style: Commas should always have a space after.

encrypt<-function(plaintext,a,b){
                            ^

exercises/affine-cipher/affine-cipher.R:13:31: style: Commas should always have a space after.

encrypt<-function(plaintext,a,b){
                              ^

exercises/affine-cipher/affine-cipher.R:16:8: style: Put spaces around all infix operators.

decrypt<-function(encryption,a,b){
      ~^~~

exercises/affine-cipher/affine-cipher.R:16:30: style: Commas should always have a space after.

decrypt<-function(encryption,a,b){
                             ^

exercises/affine-cipher/affine-cipher.R:16:32: style: Commas should always have a space after.

decrypt<-function(encryption,a,b){
                               ^

exercises/affine-cipher/example.R:1:10: style: Put spaces around all infix operators.

normalise<-function(text){
        ~^~~

exercises/affine-cipher/example.R:5:12: style: Put spaces around all infix operators.

lookupindex<-function(normalisedtext){
          ~^~~

exercises/affine-cipher/example.R:29:21: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                    ^

exercises/affine-cipher/example.R:29:23: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                      ^

exercises/affine-cipher/example.R:29:33: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                                ^

exercises/affine-cipher/example.R:29:35: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                                  ^

exercises/affine-cipher/example.R:32:22: style: Put spaces around all infix operators.

normalisedplaintext<-normalise(plaintext) 
                    ~^~~

exercises/affine-cipher/example.R:33:4: style: Put spaces around all infix operators.

x<-lookupindex(normalisedplaintext)
  ~^~~

exercises/affine-cipher/example.R:45:23: style: Put spaces around all infix operators.

normalisedencryption<-normalise(encryption)
                     ~^~~

exercises/affine-cipher/example.R:46:4: style: Put spaces around all infix operators.

y<-lookupindex(normalisedencryption)
  ~^~~

@lintr-bot
Copy link

exercises/affine-cipher/affine-cipher.R:1:10: style: Put spaces around all infix operators.

normalise<-function(text){
        ~^~~

exercises/affine-cipher/affine-cipher.R:4:12: style: Put spaces around all infix operators.

lookupindex<-function(normalisedtext){
          ~^~~

exercises/affine-cipher/affine-cipher.R:7:4: style: Put spaces around all infix operators.

gcd<-function(x,y){
  ~^~~

exercises/affine-cipher/affine-cipher.R:7:17: style: Commas should always have a space after.

gcd<-function(x,y){
                ^

exercises/affine-cipher/affine-cipher.R:10:4: style: Put spaces around all infix operators.

mmi<-function(a,m){
  ~^~~

exercises/affine-cipher/affine-cipher.R:10:17: style: Commas should always have a space after.

mmi<-function(a,m){
                ^

exercises/affine-cipher/affine-cipher.R:13:8: style: Put spaces around all infix operators.

encrypt<-function(plaintext,a,b){
      ~^~~

exercises/affine-cipher/affine-cipher.R:13:29: style: Commas should always have a space after.

encrypt<-function(plaintext,a,b){
                            ^

exercises/affine-cipher/affine-cipher.R:13:31: style: Commas should always have a space after.

encrypt<-function(plaintext,a,b){
                              ^

exercises/affine-cipher/affine-cipher.R:16:8: style: Put spaces around all infix operators.

decrypt<-function(encryption,a,b){
      ~^~~

exercises/affine-cipher/affine-cipher.R:16:30: style: Commas should always have a space after.

decrypt<-function(encryption,a,b){
                             ^

exercises/affine-cipher/affine-cipher.R:16:32: style: Commas should always have a space after.

decrypt<-function(encryption,a,b){
                               ^

exercises/affine-cipher/example.R:1:10: style: Put spaces around all infix operators.

normalise<-function(text){
        ~^~~

exercises/affine-cipher/example.R:5:12: style: Put spaces around all infix operators.

lookupindex<-function(normalisedtext){
          ~^~~

exercises/affine-cipher/example.R:29:21: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                    ^

exercises/affine-cipher/example.R:29:23: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                      ^

exercises/affine-cipher/example.R:29:33: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                                ^

exercises/affine-cipher/example.R:29:35: style: Commas should always have a space after.

​    stop(paste('a=',a,' and m=',m,'is coprime'))
                                  ^

exercises/affine-cipher/example.R:32:22: style: Put spaces around all infix operators.

normalisedplaintext<-normalise(plaintext) 
                    ~^~~

exercises/affine-cipher/example.R:33:4: style: Put spaces around all infix operators.

x<-lookupindex(normalisedplaintext)
  ~^~~

exercises/affine-cipher/example.R:45:23: style: Put spaces around all infix operators.

normalisedencryption<-normalise(encryption)
                     ~^~~

exercises/affine-cipher/example.R:46:4: style: Put spaces around all infix operators.

y<-lookupindex(normalisedencryption)
  ~^~~

@katrinleinweber

This comment has been minimized.

@tintinthong
Copy link
Contributor Author

Thanks for the updates :-) Aabout the linter bot: I forgot to point you to the styler addin for RStudio & its "Style active file" function before, sorry! It should prevent at least 90% of those minor issues.

I am aware of this. Sometimes I forget to run it :P

@jonmcalder
Copy link
Member

I am aware of this. Sometimes I forget to run it :P

Thanks again for this PR and for your other contributions so far Justin. I'll leave the review to @katrinleinweber, just wanted to mention that we recently merged in config & installation instructions for a pre-commit hook (because it's easy to forget to run styler). Please feel free to try that out and let us know if you have any issues (or suggest updates to the README instructions for contributors).

@tintinthong
Copy link
Contributor Author

I am aware of this. Sometimes I forget to run it :P

Thanks again for this PR and for your other contributions so far Justin. I'll leave the review to @katrinleinweber, just wanted to mention that we recently merged in config & installation instructions for a pre-commit hook (because it's easy to forget to run styler). Please feel free to try that out and let us know if you have any issues (or suggest updates to the README instructions for contributors).

@jonmcalder thats really useful. Thanks!

@tintinthong
Copy link
Contributor Author

tintinthong commented Aug 16, 2019

@katrinleinweber I thought I would update(pull) your recent commits and also jonmcalders commits in master and push back to my branch so that everything is in-sync but I am having some build issues. Do you know what might be the problem?

Here is a link to my git tree

You are represented in two icons. One shown as in the sidebar and the other as a yellow circle

@katrinleinweber
Copy link
Contributor

Right now, I can only say that there seem to be linting issues, still. I don't have time in the next few days for this, apologies!

@tintinthong
Copy link
Contributor Author

@katrinleinweber no worries ahhh thank u. sorry did not know how to see the errors. seems alright now. thanks for the help!!

@katrinleinweber katrinleinweber self-requested a review August 24, 2019 11:07
Base automatically changed from master to main January 28, 2021 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants