Tenebriusness
Saturday, September 19, 2020
Monday, August 14, 2017
Gradient Descent Implementation in 3 core lines of Python
import matplotlib.pyplot as plt import random import numpy as np from mpl_toolkits.mplot3d import Axes3D x = np.array([np.array([1,j]) for j in range(5,)]) y = [j*j for j in range(5,)] p=np.ones(len(x[0]));
#We start here for k in range(20000): for i,xi in enumerate(x): p = p - (0.001 * (((xi.dot(p)) - y[i]) * xi))/len(x) #3 lines
print(p)
Project Euler 11-15
#Problem 11
In scala.
/** * Created by Administrator on 6/6/2017. */object Problem11 { //find the sum of primes below 2 million def main(args: Array[String]): Unit = { var stringGrid: String = """08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 0849 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 0081 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 6552 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 9122 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 8024 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 5032 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 7067 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 2124 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 7221 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 9578 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 9216 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 5786 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 5819 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 4004 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 6688 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 6904 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 3620 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 1620 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 5401 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48"""; var grid = Array.ofDim[Int](20, 20); val lines: Array[String] = stringGrid.split("\r\n") { var lineNo: Int = 0; for (line <- lines) { val chars: Array[String] = line.split("\\s") var charNo: Int = 0; for (char <- chars) { grid(lineNo)(charNo) = char.toInt; charNo += 1; } lineNo += 1; } } var max: Long = 0; for (line <- (0 to 19)) { for (char <- (0 to 19)) { //horizontal if (char <= 16) { val horz = grid(line)(char) * grid(line)(char + 1) * grid(line)(char + 2) * grid(line)(char + 3) if (horz > max) { max = horz; } } if (line <= 16) { val vertical = grid(line)(char) * grid(line + 1)(char) * grid(line + 2)(char) * grid(line + 3)(char) if (vertical > max) { max = vertical; } } if (line <= 16 && char <= 16) { val diagonal = grid(line)(char) * grid(line + 1)(char + 1) * grid(line + 2)(char + 2) * grid(line + 3)(char + 3) if (diagonal > max) { max = diagonal; } } if (line <= 16 && char >= 3) { val diagonalRight = grid(line)(char) * grid(line + 1)(char - 1) * grid(line + 2)(char - 2) * grid(line + 3)(char - 3) if (diagonalRight > max) { max = diagonalRight; } } } } println(s"Max : $max"); } }
#Problem 12
import scala.collection.mutable.ArrayBuffer /** * Created by Administrator on 6/6/2017. */object Problem12 { //find the sum of primes below 2 million def main(args: Array[String]): Unit = { var max = 0; var break = false; for {x <- (1 to 99999999) if (!break)} { //calculate triangle number var tot = 0; for (n <- (1 to x)) { tot += n; } //starting to find factors var n = math.sqrt(tot.toDouble).toInt; var factors = 0; if (n*n==tot){ factors = -1; } var i = 1 while (i <= n) { if (tot % (i) == 0) { factors += 2; } i += 1; } println(x + ": \t\t" + tot + " : \t\t" + factors); if (factors >= 500) { break = true; } } } }
Friday, October 4, 2013
Project Euler Answer Codes 6-10
# Problem 6
# Problem 7
# Problem 8
# Problem 9
No idea when this went
# Problem 10
Sum square difference
I luckily came across the formula for sum of the squares of consecutive numbers which goes like this
1^2 + 2^2 + 3^2 + ... + (2n)^2 = (n(2n+1) (4n+1))/3
Then using the equation for fo sum of a series, you can get the equation for square of the sum
1 + 2 + .... + m = (m/2)(1+m)
(1 + 2 + .. + m)^2 = ((m/2)(1=m))^2
Since m=2n, we can substitute and write down the difference of the 2 equations as
difference = (12(n^4) + 4(n^3) - 3(n^2) - n)/3
and here n = 50
# Problem 7
10001st prime
In matlab just run factor(n) on a loop of odd numbers and increment a counter everytime you find a number with only one factor(i.e. it is a prime number). Stop when 10001st prime number is found(counter reaches 10001).
Largest product in a series
Simplest and laziest way
y = ['73167176531330624919225119674426574742355349194934' ...
'96983520312774506326239578318016984801869478851843' ...
'85861560789112949495459501737958331952853208805511' ...
'12540698747158523863050715693290963295227443043557' ...
'66896648950445244523161731856403098711121722383113' ...
'62229893423380308135336276614282806444486645238749' ...
'30358907296290491560440772390713810515859307960866' ...
'70172427121883998797908792274921901699720888093776' ...
'65727333001053367881220235421809751254540594752243' ...
'52584907711670556013604839586446706324415722155397' ...
'53697817977846174064955149290862569321978468622482' ...
'83972241375657056057490261407972968652414535100474' ...
'82166370484403199890008895243450658541227588666881' ...
'16427171479924442928230863465674813919123162824586' ...
'17866458359124566529476545682848912883142607690042' ...
'24219022671055626321111109370544217506941658960408' ...
'07198403850962455444362981230987879927244284909188' ...
'84580156166097919133875499200524063689912560717606' ...
'05886116467109405077541002256983155200055935729725' ...
'71636269561882670428252483600823257530420752963450' ];
n = 1;
length(y)
max = 1;
while n < 997
prod = str2num(y(n)) * str2num(y(n+1)) * str2num(y(n+2)) * str2num(y(n+3)) * str2num(y(n+4));
if max < prod
max = prod;
end
n = n +1;
end
max
# Problem 9
No idea when this went
# Problem 10
Sum of primes below 2e6
Scala code:/** * Created by Administrator on 6/6/2017. */object Problem10 { //find the sum of primes below 2 million def main(args: Array[String]): Unit = { var total:Long = 0; var n = 0; var break: Boolean = false; for (x <- (2 to 2000000)) { n = (math.sqrt(x.toDouble)).toInt; break = false; while (n > 1 && !break) { if (x % (n) == 0) { break = true; } n -= 1; } if (!break) { total += x; } } println(s"total : $total") } }
Saturday, September 28, 2013
Project Euler Answer Codes 1-5
Solutions for problems at http://projecteuler.net/problems written using the online compiler http://py-ide-online.appspot.com/
# Problem 1 :
Multiples of 3 and 5
tot5 = 0
x = 0
print "start"
print "fives"
while x <= 1000:
tot5= tot5 + x
print x
x=x+5
x=0
print "threes"
while x <= 1000:
if x % 5 <> 0:
tot5=tot5+x
print x
x= x+3
print tot5
# Problem 2
Even Fibonacci numbers
tot5 = 0
x = 0
y = 1
temp = 0
temp1 = 0
print "start"
while y < 4000000:
if y % 2 == 0:
tot5= tot5 + y
temp = y
temp1 = x
x = y
y = temp1 + temp
print tot5
# Problem 3
Largest prime factor
I think i found the shortest way to do that. Written in Matlabtarget = 600851475143;
f = factor(target);
max(f)
# Problem 4
Largest palindrome product
My solution in matlab. One of the slowest method but also one of the most basic method to understand and implement. Most cpu time is spent on the num2str function though. Not my fault. Took 50 seconds to process.a = 999;
b = 999;
pal = 0;
max = 0;
while a > 100
found = 0;
b = 999;
while (b > 100) && (found == 0)
inta = a * b;
stra = int2str(inta);
if (fliplr(stra) == stra)
found = 1;
end
b = b -1;
end
if pal > max
max = inta
a
b
end
a = a - 1;
end
# Problem 5
Smallest multiple
No programming solution went like this 19 * 18 * 17 * 16 * 15 * 14 * 13 * 11 and the rest would be divisible since the rest are already multiples of these. now 18, 16, 15, 14 are not prime numbers so they are adding multiples useless to the product. We need to remove these multiples. There's 3 hanging in both 18 and 15, remove them/ likewise we have a 2 hanging in 14 and 18. remove them. multiply by the 3 and 2 you removed. 19*3*17*4*5*7*13*11*3*2 Now we cant't remove anything else without loosing our higher multiples.436 problems to go
Sunday, September 8, 2013
Applying for Jobs online in Mauritius
Having just completed my undergraduate studies, I returned to my country looking for jobs. First I started looking websites with job postings. Here are some websites with offer engineering and IT jobs. Usually you create an online CV and apply for the different jobs available.
www.ceridian.mu - mainly IT jobs, mainly outsourced jobs
www.myjobs.mu - all types of jobs
www.adecco.mu - all types of jobs
www.careers.accenture.com
www.careers.accenture.com
I shall update the list as I find more.
Here is a sample of my CV I created in word. I am copy pasting the text saved as html here.
Here is a sample of my CV I created in word. I am copy pasting the text saved as html here.
SHAMLOLL
DIVISH
DoB :20/11/1990 Email : divish007@gmail.com
Address : Shamloll
Lane, Royal Road, Laventure
Mobile : 9232830 Home : 4187604
EDUCATION
<![if !supportLists]>l <![endif]>B. Eng in Telecommunication Engineering
2009-2013
Huazhong University of Science and Technology, Wuhan, China
<![if !supportLists]>l <![endif]>Cisco Certified Network Assistant (CCNA) 2009
Infoclub, Rue Desforge, Mauritius
<![if !supportLists]>l <![endif]>Computing and Mathematics 2001-2008
Royal College Curepipe, Curepipe, Mauritius
PROFESSIONAL WORK EXPERIENCE
<![if !supportLists]>l <![endif]>Maintenace officer at SICA Waterpark (jul 2012) Mauritius
Operating and
supervising machinery and guide tourists around the park.
<![if !supportLists]>l <![endif]>IT Support at Synohydro Ltd Mauritius(Jul 2012-Aug 2012)
Assist the network engineer to troubleshoot
office network mainly in chinese language
<![if !supportLists]>l <![endif]>Trainee Effect Box Designer at Joyo Ltd Shenzhen, China (July 2013)
Design a sound card-audio-DSP hybrid as a new product for the company.
<![if !supportLists]>l <![endif]>Part-time primary school English teacher Wuhan, China(2010-2013)
Teach 25-30 students from ages 5-15. Received
good reviews from parents and students.
PROJECTS EXPERIENCE
Atmel AVR projects on Arduino - Bluetooth comm,
simple 4-wheel, portable mp3 player (self)
Xbee Wireless mesh networks - Lights automation,
Water tank control , Misc remote controls
Android apps - Wrote a Sound/voice analysis
engine, P2P communications system
PHP/MySQL/Django/GoogleApp Engine - Web accessible
database system (part of thesis)
Mobile networks research - Measuring smartphone
3G performance of China Carriers(thesis)
C++/OpenGL project - Designed a user-customizable
graphing software (school work)
Cortex-M3 programming - Audio and DSP programming
at Joyo Ltd(work experience)
Graphic design - Lead graphic designer for Royal
College Curepipe annual magazine - 2009
RELEVANT STUDIES AND SKILLS
Network
setup, administration
Network performance
evaluation
Modern Telecommunication
Systems
Electronic Circuits of Communication
Microcontroller
programming
Matlab and
Simulations
Computer
and mobile phone repairs
Possess high analytic and diagnostic skill
Understand advanced programming concepts
Able to program in large number of languages
Extensive Android development experience
Work independently within a team
framework
Ability to write and converse in Chinese
Excellent oral and written
communication skills.
References will be provided upon request.
Subscribe to:
Posts (Atom)
