-
Notifications
You must be signed in to change notification settings - Fork 153
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
base: master
Are you sure you want to change the base?
Conversation
@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) { |
There was a problem hiding this comment.
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.
|
||
val THREE_MID = "helllo" | ||
val ONE_EACH = "abcd" | ||
val FOUR_END = "byeeee" |
There was a problem hiding this comment.
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){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fun patterThree(longestLine: Int){ | |
fun patternThree(longestLine: Int){ |
} | ||
patternOne(5) | ||
patternTwo(lines = 4) | ||
patterThree(5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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} ") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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} ") } |
There was a problem hiding this 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.
Please make sure you have done the following:
/Day<n>/<Language>/
/Day <n>/
all-contributors-cli