Hacking with a JavaScript Program

var drawCats = function (howManyTimes) { for (var i = 0; i < howManyTimes; i++) { console.log(i + " =^.^=); } }; drawCats(11); VM455:4 Uncaught SyntaxError: Unexpected token ILLEGALmessage: "Unexpected token ILLEGAL"stack: (…)get stack: function () { [native code] }arguments: nullcaller: nulllength: 0name: ""prototype: StackTraceGetter__proto__: function Empty() {}set stack: function () { [native code] }arguments: …

Looking into a few commands with python interactive shell

ABOUT PYTHON Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum and first released in 1991, Python has a design philosophy that emphasizes code readability, notably using significant whitespace. It provides constructs that enable clear programming on both small and large scales.[26] Van Rossum led the language community until stepping down …

How to write a program to solve project Euler problem 4

”’ This file is worked on from http://www.s-anand.net/euler.html , Solution of Problem 4 A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99. Find the largest palindrome made from the product of two 3-digit numbers. ”’ n = 0 for …

Hacking with runit and sv ( sv – control and manage services monitored by runsv(8) ) commands

ABOUT runit runit is a cross-platform Unix init scheme with service supervision, a replacement for sysvinit, and other init schemes. It runs on GNU/Linux, *BSD, MacOSX, Solaris, and can easily be adapted to other Unix operating systems ABOUT sv The sv program reports the current status and controls the state of services monitored by the …

Project Euler Problem 2, solution internals related using ruby debugger

$ruby -rdebug euler-two.rb Debug.rb Emacs support available. /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:57: RUBYGEMS_ACTIVATION_MONITOR.enter (rdb:1) r /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:57: RUBYGEMS_ACTIVATION_MONITOR.enter (rdb:1) r /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:57: RUBYGEMS_ACTIVATION_MONITOR.enter (rdb:1) next /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:143: RUBYGEMS_ACTIVATION_MONITOR.exit (rdb:1) next euler-two.rb:3:n1, n2 = 1, 2 (rdb:1) next euler-two.rb:4:sum = 0 (rdb:1) print n1 1nil (rdb:1) print n2 2nil (rdb:1) next euler-two.rb:6:while n2 < 4000000 (rdb:1) print n2 2nil (rdb:1) next euler-two.rb:7:sum += …

Project Euler Problem 3, solution internals using python debugger

$python -m pdb euler-three.py > /home/jeffrin/beautifulwork/lib/euler-three.py(7)() -> ”’ (Pdb) r 6857 –Return– > /home/jeffrin/beautifulwork/lib/euler-three.py(17)()->None -> print n (Pdb) next –Return– > (1)()->None (Pdb) next The program finished and will be restarted > /home/jeffrin/beautifulwork/lib/euler-three.py(7)() -> ”’ (Pdb) next > /home/jeffrin/beautifulwork/lib/euler-three.py(9)() -> n = 600851475143 (Pdb) next > /home/jeffrin/beautifulwork/lib/euler-three.py(11)() -> i = 2 (Pdb) next > /home/jeffrin/beautifulwork/lib/euler-three.py(12)() …

Project Euler Problem 2, solution internals using python debugger

$python -m pdb project-euler-2.py > /home/jeffrin/beautifulwork/lib/project-euler-2.py(13)() -> ”’ (Pdb) next > /home/jeffrin/beautifulwork/lib/project-euler-2.py(15)() -> cache = {} (Pdb) next > /home/jeffrin/beautifulwork/lib/project-euler-2.py(16)() -> def fib(n): (Pdb) next > /home/jeffrin/beautifulwork/lib/project-euler-2.py(20)() -> n = 0 (Pdb) next > /home/jeffrin/beautifulwork/lib/project-euler-2.py(21)() -> i = 0 (Pdb) next > /home/jeffrin/beautifulwork/lib/project-euler-2.py(22)() -> while fib(i) /home/jeffrin/beautifulwork/lib/project-euler-2.py(23)() -> if not fib(i) % 2: n = …

How to write an algorithm to find among natural numbers the sum of multiples of 3 and 5 below 1000 ?

/* This program has been worked on from http://www.s-anand.net/euler.html */ #include <stdio.h> sofmul() { int n, i; n = 0; for (i = 0 ; i < 1000 ; i++) { if ( !(i % 5) || !(i % 3) ) n = n + i; } printf(“Sum of the multiples of 3 and 5 …

How to write a program to multiply a number by 4 using a bitwise operator ?

/* Part of this program copied from http://www.sanfoundry.com/c-program-multiply-number-4-using-bitwise-operators/ */ #include <stdio.h> multbitwise() { long number; printf(“Enter an integer: “); scanf(“%ld”,&number); number = number << 2; printf(“Result is %ld \n”,number); } /* http://stackoverflow.com/questions/4456442/interview-multiplication-of-2-integers-using-bitwise-operators */ /* http://www.geeksforgeeks.org/multiply-two-numbers-without-using-multiply-division-bitwise-operators-and-no-loops/ */ /* http://en.wikipedia.org/wiki/Bitwise_operation */

Hacking with conversions of decimal and binary

$./app Sign detection [1] Power of two [2] Counting No. of bits set [3] Set or clear bits without branching[4] Find maximum value[5] Finding least common multiple[6] Finding the greatest commom divisor[7] Finding if a number is an Armstrong number or not[8] Finding if a given number is prime number[9] Finding the number of twin …