Skip to content

Instantly share code, notes, and snippets.

@BonfaceKilz
Last active March 18, 2021 13:06
Show Gist options
  • Select an option

  • Save BonfaceKilz/26e36c39a4a0d0dcaa71e2edc3b4b5fa to your computer and use it in GitHub Desktop.

Select an option

Save BonfaceKilz/26e36c39a4a0d0dcaa71e2edc3b4b5fa to your computer and use it in GitHub Desktop.
000. Monchoka! Weekly Algos by your neighbourly scheme-r ;)

Prelude

Hi folks! This one took a while to post; but nevertheless, here we are!

Last week, Perserverance(a.k.a Percy) landed on Mars; which saw Linux on Mars! One small win(?) for Linux(?) \o/ \o/

Earlier this week, I picked up (again) "The Philosophy of Software Design by John Ousterhout" and I found myself nerding about it with some fellas at the office-- poor souls ;)!. The particularly interesting thing was the book's discussion of what our role is (as SWEs) wrt work; with an opinionated view that it all boils down to tackling "complexity". Without getting into much detail, I particularly found the books discussion of "causes of complexity" interesting: Dependencies and obscurity. For anyone getting into the field, I'd strongly recommend that read(albeit pore through it with a critical eye).

Last Week's Challenge

Issue 1: https://is.gd/HK0jFF

Mailing List discussion: https://is.gd/xrHZmY

If you get the bandwidth, hack at the problems at the submission links above-- It's a nice way to get comments on your code \m/\m/.

This Week's Challenge

Source: https://is.gd/HwTL9E

Given an integer as a function, test to see if it's a palindrome

Constraints: You may not cast the number to a string!

Examples:
Input: n = 9229
Output: True

input: n = 1234
Output: False

Post your answers here as comments.

@BonfaceKilz
Copy link
Copy Markdown
Author

BonfaceKilz commented Feb 25, 2021 via email

@BonfaceKilz
Copy link
Copy Markdown
Author

BonfaceKilz commented Feb 25, 2021 via email

@DMGithinji
Copy link
Copy Markdown

DMGithinji commented Mar 1, 2021

`
function isPalindrome(x: number): boolean {
let rev = 0;
let copy = x;

    while(copy > 0) {
        const rem = copy%10;
        rev = rem + (rev * 10);
        copy = Math.floor(copy/10);
    }
    return rev === x;

}
`

@BonfaceKilz
Copy link
Copy Markdown
Author

BonfaceKilz commented Mar 1, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment