-
Notifications
You must be signed in to change notification settings - Fork 0
feat: implement a wikiracer #1
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
base: main
Are you sure you want to change the base?
Conversation
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.
Feel free to fix your program — it currently produces incorrect results for the input:
https://en.wikipedia.org/wiki/Arithmetic_shift, https://en.wikipedia.org/wiki/Adolf_Hitler
There is a path of 2 pages between them.
You’re welcome to update your solution, and I will update the mark.
The current mark is 4 (maximum is 14).
} | ||
|
||
override suspend fun getReferences(page: String): List<String> { | ||
val url = if (page.startsWith("https://")) page else "https://$page" |
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.
This is not necessarily
@@ -25,8 +27,8 @@ internal class ParsingTest { | |||
fun referencesData() = listOf( | |||
Arguments.of( | |||
"https://en.wikipedia.org/wiki/Kotlin_(programming_language)aaaaa", | |||
emptyList<String>(), |
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.
Why did you change it? It was correct answer
val searchDepth: Int by option("-d", "--depth", help = "Search depth").int().default(4) | ||
val threads: Int by option("-t", "--threads", help = "Number of threads").int().default(8) | ||
|
||
override fun run() { |
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 like this approach!
val dispatcher = Dispatchers.IO.limitedParallelism(maxThreads) | ||
val client = HttpClient() | ||
|
||
override fun race( |
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.
In the search method, all arguments are on one line; in the race method, all arguments are on the next line; and in processLevels, each argument is on a separate line. It would be better to follow a consistent formatting style across all methods. Consider configuring a static analyzer to enforce and automate this structure.
} | ||
|
||
@OptIn(ExperimentalCoroutinesApi::class) | ||
class AsyncRacer(maxThreads: Int) : WikiRacer { |
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.
The AsyncRacer class contains two methods that are too large and complex. It would be helpful to break them down into smaller, well-named methods to improve readability and make it easier for others to understand what each part of the code does.
No description provided.