This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Solution { | |
def backspaceCompare(left: String, right: String): Boolean = { | |
evaluate(left) == evaluate(right) | |
} | |
def evaluate(s: String, index: Int = 0, soFar: List[Char] = Nil): List[Char] = { | |
if (index >= s.length) { | |
soFar | |
} else { | |
val char = s.charAt(index) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Solution { | |
def backspaceCompare(left: String, right: String): Boolean = { | |
sealed trait Character {} | |
case object Nothing extends Character | |
case object Backspace extends Character | |
case object SkippedLetter extends Character | |
case class FinalLetter(c: Char) extends Character | |
case class State(string: String, pointer: Int, backspaces: Int) { | |
def charOption: Option[Char] = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Solution { | |
def backspaceCompare(left: String, right: String): Boolean = { | |
case class State(string: String, pointer: Int, backspaces: Int) { | |
def charOption: Option[Char] = { | |
if (pointer < 0 || pointer >= string.length) { | |
None | |
} else { | |
Some(string.charAt(pointer)) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const nPalindromes = length => | |
parseInt( | |
"4" + | |
"9".repeat(length - 1) + | |
"5" + | |
"0".repeat(Math.floor((length - 1) / 2)) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Option utils | |
type Some<T> = { | |
type: 'some'; | |
value: T; | |
}; | |
type None = { | |
type: 'none'; | |
}; | |
type Option<T> = Some<T> | None; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- ftp_test_suite_framework_update.py 2012-12-07 06:32:36.002404214 -0800 | |
+++ ftp_test_suite_framework_update_2.py 2012-12-07 07:13:16.474522327 -0800 | |
@@ -10,13 +10,13 @@ | |
1206_704pm | |
""" | |
-""" | |
+""" | |
Tests a variety of Passive FTP behaviors. | |
* --------------------------------------------- |