Skip to content

Instantly share code, notes, and snippets.

@karan-ta
karan-ta / yahaan.dart
Last active September 19, 2020 06:38
main ()
{
var computer = 2;
var player = 3;
if (computer > player)
{
print ("my number is higher");
}
import 'dart:math';
import 'dart:io';
add (int first,int second,int playeranswer)
{
if (first + second == playeranswer)
{
print ("you got it!");
}
if (first + second != playeranswer)
@karan-ta
karan-ta / perceptron.py
Last active March 13, 2020 16:05
Perceptron neural network in python from scratch - Under 10 lines of code - works for and gate , or gate
#Read this first - https://jontysinai.github.io/jekyll/update/2017/09/24/the-mcp-neuron.html
#Set The inputs and the desired Outputs for and gate.
x1,x2,y = [0,0,1,1],[0,1,0,1], [0,0,0,1]
#Set Random values for weights w1,w2 and for the bias b. initialize all to 0
w1,w2,b = 0,0,0
#try 100 iterations to see if the perceptron can guess that we need a fucking and gate.
for _ in range(100):
#iterate for each input:
for i in [0,1,2,3]:
#just guess a y value based on our random weights and bias