Skip to main content

Posts

Math: Finding GCF and LCM Using Continuous Division (Translated to JavaScript)

Hi! In this, I'll show a method other than factorisation and clustering the factors to find GCF (Greatest Common Factor) and LCM (Least Common Multiple). I assume you're familiar with the first method. That is using factor tree and then grouping the results. I was taught to do this method in elementary school. The method has already been translated to an application on Port Raptor: GCFLCM.C . Let's start to implement the continuous division method. For example, we want to find GCF and LCM from: 8, 16, 18 Method: Create a table and write down those numbers as first row. Give some space for vertical column on the leftmost. The leftmost column will be used to list the divisor. The cells between the first row and first column are the division results (quotients). The division goes diagonally. Start with the division with 1, well... Then, divide starting from the lowest prime number → 2. If an element (or elements) can't be divided with current prime divis...

Suvi Teräsniska • Täydellinen Elämä

Magnificent. 🏆 Key It starts with B♭ minor or A# minor chord — it's within D♭ major or C# major scale. Beautifully arranged. Neat videography and audio engineering. Lyrics Finnish Täydellinen Elämä Mul on tapana ylös pistää Kokemukset vaikeat Pettymykset ja eron hetket haikeat Mul on tapana lauluun laittaa Myös ne hyvän muruset Joiden ohitse huomaamatta kävelet Mul on tapana mieltä purkaa Kertoo tosi juttuja Ja ne aiheet ovat kaikille tuttuja Mul on tapana lauluun laittaa Mitä kuulin, mitä näin Silloin kaikkea en kanna sisälläin [Kertosäe] Elämä on varjoa ja valoa Joskus se kyyneliin tiristää Silloin kun itkun kaulukset Kurkkua kiristää Elämä on sekoitus onnea Ja surullisia vaiheita Meil on täydellinen elämä Täynnä laulun aiheita Meil on täydellinen elämä ...

Chess: Sicilian Defense: Morphy Gambit

I played white side, against Sicilian Defense with a "Morphy gambit". The "gambit" is on my side. So, instead of right away capturing the d4 pawn, the g1 knight moved to f3, that's the "Morphy gambit" line. They call it knight, but it is abbreviated as "n" (English). Because "k" is already used for king. Back then it was "kt" — it was two letters, therefore, "n". You can use your left and right arrows on your keyboard or use the mouse scroll to see the moves back and forth on the chessboard. But first, click the board.

Chess: Sicilian Defense: French Variation

I played black. This was a 3 minutes game. Very sharp attack by the white. But at move 44 and forward, because my remaining time was only half of my opponent's (13 seconds left, he had remaining 27 seconds), so the surprising-confusing moves were executed. It is a common tactic in Blitz and (normal/hyper/ultra) Bullet. Usually, it was done when the player had little time remaining, for... glory, of course 😂 Unfortunately, I still had trustworthy focus to notice the utter confusion. You can use your left and right arrows on your keyboard or use the mouse scroll to see the moves back and forth on the chessboard. But first, click the board.

Chess: Russian Game: Cozio (Lasker) Attack

I played white side. This was a 3 minutes game of Blitz(krieg) at lichess.org as "Anonymous". The game was ended by resignation by black side. If continued, it would be checkmate in "impending doom". 😂 You can use your left and right arrows on your keyboard or use the mouse scroll to see the moves back and forth on the chessboard. But first, click the board. Look at the image above, the pieces are mostly offence side. 🤣 So, a bit about Russian Game: Cozio (Lasker) Attack . Russian Game Also called the Petrov Defence, it starts: 1.e4 e5 2.Nf3 Nf6 Symmetrical, solid, often heading into positional battles rather than wild tactics. It's called "Russian Game" because the first big theory work on it came from 19th-century Russian masters, notably from Alexander Petrov (hence Petrov Defence). Cozio Carlo Cozio was an 18th-century Italian nobleman and chess author. He'...

JavaScript and Python: Check if Property is in Object (or Dictionary)

JavaScript There are more than one method to check it. First, we can use hasOwnProperty method. let object = {"one": 2, "tree": "floor", 5: "socks"}; console.log(object.hasOwnProperty("tree")); // true console.log(object.hasOwnProperty(4)); // false // (Not in the object) We'll expect boolean output. Second, we can use in operator. let object = {"one": 2, "tree": "floor", 5: "socks"}; console.log("tree" in object); // true console.log(4 in object); // false // (Not in the object) We'll expect boolean output. Third, straight away access the property name we need to find out. let object = {"one": 2, "tree": "floor", 5: "socks"}; console.log(object.tree); // "floor" // (Value of that property) console.log(object[4]); // undefined // (Undefined value from that given property name in the object) We'll exp...

JavaScript and Python: Check if Item is in Array (or List)

JavaScript We can use indexOf method to do that. let a = ["one", 2, "tree", "floor", 5, "socks"]; console.log(a.indexOf("floor")); // 3 console.log(a.indexOf(4)); // -1 // (Not in the array) Using indexOf , we'll expect integer output. Returned value -1 (negative one) is to tell that the item isn't present in the array. In latest version of ECMA (latest browsers), we can use includes method. let a = ["one", 2, "tree", "floor", 5, "socks"]; console.log(a.includes("floor")); // true console.log(a.includes(4)); // false Using includes , we'll expect boolean output (true / false). Python Well, the phrase itself, "check if item in list", then we can use in operator to do that. list = ["one", 2, "tree", "floor", 5, "socks"] print 1 in list # False print "tree" in list # True Using that method, we'll ...

JavaScript: Generating Random Text with Letters and Numbers

Good day. This is a JavaScript snippet to generate random text with letters and numbers. It can receive a positive integer input optionally. If the input isn't that type, it will be ignored. The default length for the generated text is 6. Demonstration How many characters to generate? GENERATE CLEAR Thank you for visiting. 🙂

JavaScript: How to Convert One Number Base (Radix) to Another

Decimal to Binary For instance, we have number 7 , which is base-10 number. Then, we need to convert to base-2 (binary) system. The base-2 system uses the addition of power of 2's to get the number we have in another radix system. So to get the value from the other base system (base-10 for example), we continuously divide that number with 2, and take the remainder of each division . In paper and pen scribbling, we do this: 7 ÷ 2 ➡️ closest multiplier is 3, remainder 1 3 ÷ 2 ➡️ closest multiplier is 1, remainder 1 1 ÷ 2 ➡️ the only multiplier is 0, remainder 1 Put all remainders as a number . Take each from the BOTTOM : 1 ➡️ 1 ➡️ 1 . Meaning 7 in binary system is 111. $7_10 = 111_2$ Or, we could use the addition method of power of 2: $$ 7 = (\bo1 × 2^2) + (\bo1 × 2^1) + (\bo1 × 2^0)$$ Look at the multiplier (1), read it from the LEFT : 1 ➡️ 1 ➡️ 1 . Similar to prior method, 7 in base-10 is equal to 111 in base-2 system. $7_10 = 111_2$ JavaSc...

JavaScript: Copy Object

For example, we have this Object : const myObject = { a: 1, b: 2, 3: 3 } And we want to clone it without affecting the original Object . We do not directly assign it. ⚠️ const clonedObject = myObject Because every time the original myObject changes, the clonedObject will also follow the change and vice versa. It also applies to Array . We need to construct new Object and put the cloned content into it . Methods Deep Copy const myObject = { a: 1, b: 2, 3: 3 } const myClonedObject = JSON.parse(JSON.stringify(myObject)) This will work for nested-structured original Object . const myObject = { name: "Dilly the Photocopier", location: "Riverbank", specs: { status: "short circuited", model: "Xerox Aqua 3000" }, tags: ["office", "waterproof", "legend"] } // Deep clone using JSON method. const myClonedObject = JSON.parse(JSON.stringify(myOb...

Python: How to Unescape String (DecodeURI in JavaScript)

Decoding We can use urllib module to do this. This is on Python 2.7x and Python 3+ (added). #!/usr/bin/env python2 """urllib module - Python 2.7x""" import urllib # ENCODED STRING THE_ENCODED_STRING = "https%3A%2F%2Flalala.com%2Flalala%3Fla%3Dla%26lala%3Dlala" # DECODED STRING THE_DECODED_STRING = urllib.unquote(THE_ENCODED_STRING) print(THE_DECODED_STRING) """ Python 3+ """ import urllib.parse # ENCODED STRING THE_ENCODED_STRING = "https%3A%2F%2Flalala.com%2Flalala%3Fla%3Dla%26lala%3Dlala" # DECODED STRING THE_DECODED_STRING = urllib.parse.unquote(THE_ENCODED_STRING) print(THE_DECODED_STRING) Documentation for urllib.unquote Python 2 utility . Documentation for urllib.parse.unquote Python 3 utility . Encoding The opposite of that function is urllib.quote(string) (Python 2) with additional argument to create a custom safe characters list. This is the documentation . For Pytho...
Monkey Raptor uses biscuits. More info on Privacy Policy