Skip to content

Commit

Permalink
Add mutex 2 challenge
Browse files Browse the repository at this point in the history
  • Loading branch information
rusinikita authored and Nikita Rusin committed Sep 19, 2023
1 parent 5f48508 commit 4f74e93
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
36 changes: 36 additions & 0 deletions challenge/files/mutex_2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name = "Mutex 2"
category = "concurrency"
default_code_snippet = """
type Map struct {
m map[int]int
sync.Mutex
}
func (m *Map) Get(key int) (value int, found bool) {
m.Lock()
defer m.Unlock()
i, ok := m.m[key]
return i, found
}
func (m *Map) Put(key, value int) {
m.Lock()
defer m.Unlock()
m.m[key] = value
}
func (m *Map) Len() int {
return len(m.m)
}
"""

[[questions]]
text = "This structure is used in other packages. Find issues."
type = "select_answers"
answers = [
{ text = "can't compile" },
{ text = "data race", code_line_ranges = [[19, 21]] },
{ text = "nil pointer exception", code_line_ranges = [[1, 16]] },
{ text = "wrong variable", code_line_ranges = [[10]] },
]
10 changes: 9 additions & 1 deletion docs/ADR3.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
## Future idea

### Question with modified code

Add ability to modify code sample by few code lines.
Allow questions with custom code: what if make(chan int)/remove/move
Allow questions with custom code: what if make(chan int)/remove/move

### Back to list button after challenge finished

### History

9 challenges now. Time to save completed

0 comments on commit 4f74e93

Please sign in to comment.