Sum Of Integers Between A And B
Sum of integers between a and b: `function sum(a, b) { if (a == b) return a; let min = Math.min(a,b), max = Math.max(a,b); return Array(max - min + 1).fill(0).map((_,i) => i + min).reduce((a,b) => a+b, 0); }
Sum of integers between a and b: `function sum(a, b) { if (a == b) return a; let min = Math.min(a,b), max = Math.max(a,b); return Array(max - min + 1).fill(0).map((_,i) => i + min).reduce((a,b) => a+b, 0); }
Reverse a string using Python: `'world' => 'dlrow', 'word' => 'drow'`. Convert to array, reverse with `reverse()`, then rejoin.
Correct digitized text errors: S -> 5, O -> 0, I -> 1. Used replaceAll() function to fix mistakes in character recognition software output.
Write code for car rental cost: $40/day. 7+ days: $50 off, 3+ days: $20 off. Example: 5 days = 200 + 30 = 230.