└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # Backend Test Case 2 | 3 | ## Requirements 4 | 5 | - [ ] it should be use [NestJS](https://nestjs.com/) Framework Or [ExpressJS](https://expressjs.com/) With **TypeScript** 6 | - [ ] it should be use Swagger as API Documentation 7 | - [ ] it should be use Database (SQL/NoSQL) 8 | - [ ] it should be open sourced on your github repo 9 | 10 | ## Extras 11 | 12 | - [ ] Implement [DDD Pattern]([https://khalilstemmler.com/articles/categories/domain-driven-design/](https://khalilstemmler.com/articles/categories/domain-driven-design/)) 13 | - [ ] Implement Unit Testing 14 | 15 | ## Notes 16 | - Feel free to add some structure or plugins 17 | 18 | ## Entities 19 | 20 | - Member 21 | - Book 22 | 23 | ## Use Case 24 | 25 | - Members can borrow books with conditions 26 | - [ ] Members may not borrow more than 2 books 27 | - [ ] Borrowed books are not borrowed by other members 28 | - [ ] Member is currently not being penalized 29 | - Member returns the book with conditions 30 | - [ ] The returned book is a book that the member has borrowed 31 | - [ ] If the book is returned after more than 7 days, the member will be subject to a penalty. Member with penalty cannot able to borrow the book for 3 days 32 | - Check the book 33 | - [ ] Shows all existing books and quantities 34 | - [ ] Books that are being borrowed are not counted 35 | - Member check 36 | - [ ] Shows all existing members 37 | - [ ] The number of books being borrowed by each member 38 | 39 | ## Mock Data 40 | 41 | - Books 42 | 43 | ```tsx 44 | [ 45 | { 46 | code: "JK-45", 47 | title: "Harry Potter", 48 | author: "J.K Rowling", 49 | stock: 1 50 | }, 51 | { 52 | code: "SHR-1", 53 | title: "A Study in Scarlet", 54 | author: "Arthur Conan Doyle", 55 | stock: 1 56 | }, 57 | { 58 | code: "TW-11", 59 | title: "Twilight", 60 | author: "Stephenie Meyer", 61 | stock: 1 62 | }, 63 | { 64 | code: "HOB-83", 65 | title: "The Hobbit, or There and Back Again", 66 | author: "J.R.R. Tolkien", 67 | stock: 1 68 | }, 69 | { 70 | code: "NRN-7", 71 | title: "The Lion, the Witch and the Wardrobe", 72 | author: "C.S. Lewis", 73 | stock: 1 74 | }, 75 | ] 76 | ``` 77 | 78 | - Members 79 | 80 | ```tsx 81 | [ 82 | { 83 | code: "M001", 84 | name: "Angga", 85 | }, 86 | { 87 | code: "M002", 88 | name: "Ferry", 89 | }, 90 | { 91 | code: "M003", 92 | name: "Putri", 93 | }, 94 | ] 95 | ``` 96 | 97 | 98 | ------ 99 | 100 | # ALGORITMA 101 | Kerjakan dengan menggunakan bahasa pemograman yg anda kuasai, buat folder terpisah untuk soal ini 102 | 103 | 1. Terdapat string "NEGIE1", silahkan reverse alphabet nya dengan angka tetap diakhir kata Hasil = "EIGEN1" 104 | 105 | 2. Diberikan contoh sebuah kalimat, silahkan cari kata terpanjang dari kalimat tersebut, jika ada kata dengan panjang yang sama silahkan ambil salah satu 106 | 107 | Contoh: 108 | ``` 109 | const sentence = "Saya sangat senang mengerjakan soal algoritma" 110 | 111 | longest(sentence) 112 | // mengerjakan: 11 character 113 | ``` 114 | 3. Terdapat dua buah array yaitu array INPUT dan array QUERY, silahkan tentukan berapa kali kata dalam QUERY terdapat pada array INPUT 115 | 116 | Contoh: 117 | ``` 118 | INPUT = ['xc', 'dz', 'bbb', 'dz'] 119 | QUERY = ['bbb', 'ac', 'dz'] 120 | 121 | OUTPUT = [1, 0, 2] karena kata 'bbb' terdapat 1 pada INPUT, kata 'ac' tidak ada pada INPUT, dan kata 'dz' terdapat 2 pada INPUT 122 | ``` 123 | 124 | 4. Silahkan cari hasil dari pengurangan dari jumlah diagonal sebuah matrik NxN Contoh: 125 | 126 | Contoh: 127 | ``` 128 | Matrix = [[1, 2, 0], [4, 5, 6], [7, 8, 9]] 129 | 130 | diagonal pertama = 1 + 5 + 9 = 15 131 | diagonal kedua = 0 + 5 + 7 = 12 132 | 133 | maka hasilnya adalah 15 - 12 = 3 134 | ``` 135 | 136 | --------------------------------------------------------------------------------