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

d l mcbride solutions for day 2 to day 6 #380

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

d-l-mcbride
Copy link
Contributor

Please make sure you have done the following:

  • Created a folder with the name of language you code inside directory for the day you are making the contribution to
  • Added the source code file inside /Day<n>/<Language>/
  • Tested your code
  • Added credits (author and date) at the top of the code
  • Updated README.md for /Day <n>/
  • Added yourself as a contributor using all-contributors-cli

@d-l-mcbride
Copy link
Contributor Author

d-l-mcbride commented Nov 1, 2020

@aaditkamat or @MadhavBahl, sorry to bother you guys, but was trying to make the Hacktoberfest deadline for a couple of pull request. Could you add the "hacktoberfest-accepted" label to this. Thank you for your help! :)


fun hammingDistance(first: String, second: String ):Int {
var distance = 0
for(i in first.indices) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to verify that the two strings are of the same length before checking for the hamming distance between the two strings.

@aaditkamat aaditkamat changed the title d l mcbride day7 d l mcbride solutions for day 2 to day 6 Nov 1, 2020

val THREE_MID = "helllo"
val ONE_EACH = "abcd"
val FOUR_END = "byeeee"
Copy link
Contributor

Choose a reason for hiding this comment

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

You should ideally have test cases where the character appearing most frequently does not appear in consecutive positions.

println()
}
}
fun patterThree(longestLine: Int){
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fun patterThree(longestLine: Int){
fun patternThree(longestLine: Int){

}
patternOne(5)
patternTwo(lines = 4)
patterThree(5)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
patterThree(5)
patternThree(5)

}
fun patterThree(longestLine: Int){
(1..(longestLine*2-1)).forEach {line ->
if(line<=5) (1..line).forEach { pos ->print("${pos} ") } else (1..(2*longestLine-line)).forEach {less ->print("${less} ") }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if(line<=5) (1..line).forEach { pos ->print("${pos} ") } else (1..(2*longestLine-line)).forEach {less ->print("${less} ") }
if(line<=longestLine) (1..line).forEach { pos ->print("${pos} ") } else (1..(2*longestLine-line)).forEach {less ->print("${less} ") }

Copy link
Contributor

@aaditkamat aaditkamat left a comment

Choose a reason for hiding this comment

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

I have suggested some changes. Also, next time send a PR for each problem you solve instead of combining all the solutions under one PR.

@aaditkamat aaditkamat mentioned this pull request Nov 1, 2020
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants