diff --git a/exercises/practice/queen-attack/.approaches/config.json b/exercises/practice/queen-attack/.approaches/config.json index 20b951ff8..fbfa109a1 100644 --- a/exercises/practice/queen-attack/.approaches/config.json +++ b/exercises/practice/queen-attack/.approaches/config.json @@ -1,19 +1,18 @@ { - "introduction": { + "introduction": { + "authors": [ + "jagdish-15" + ] + }, + "approaches": [ + { + "uuid": "b2e474c8-b778-41e7-83c0-8e41cc84af9e", + "slug": "simple-comparison", + "title": "Simple Comparison Approach", + "blurb": "Use basic comparison checks to determine if queens can attack each other.", "authors": [ "jagdish-15" ] - }, - "approaches": [ - { - "uuid": "", - "slug": "simple-comparison", - "title": "Simple Comparison Approach", - "blurb": "Use basic comparison checks to determine if queens can attack each other.", - "authors": [ - "jagdish-15" - ] - } - ] - } - \ No newline at end of file + } + ] +} diff --git a/exercises/practice/queen-attack/.approaches/simple-comparison/snippet.txt b/exercises/practice/queen-attack/.approaches/simple-comparison/snippet.txt new file mode 100644 index 000000000..90f224025 --- /dev/null +++ b/exercises/practice/queen-attack/.approaches/simple-comparison/snippet.txt @@ -0,0 +1,5 @@ +boolean canQueensAttackOneAnother() { + int rowDifference = Math.abs(queen1.getRow() - queen2.getRow()); + int columnDifference = Math.abs(queen1.getColumn() - queen2.getColumn()); + return rowDifference == 0 || columnDifference == 0 || rowDifference == columnDifference; +} \ No newline at end of file