Skip to content

Instantly share code, notes, and snippets.

View linkin-park's full-sized avatar
🏠
Working from home

linkin-park

🏠
Working from home
View GitHub Profile
-module(solution).
-export([main/0]).
%R-Repeat,L-actual List ,
main() ->
[R|L] = read_input([]),
foo(R,L).
foo(_,[]) -> [];
foo(R,[X|Xs]) -> repeat(X,R), foo(R,Xs).
@linkin-park
linkin-park / HackerRank
Created August 31, 2017 17:35
Erlang SUCKS!
-module(solution).
-export([main/0]).
%R-Repeat,L-actual List ,
main() ->
[R|L] = read_input([]),
foo(R,L,[]).
foo(_,[],NL)-> NL;
foo(R,[X|Xs],NL)->foo(R,Xs,NL++repeat(X,R)).
@linkin-park
linkin-park / Erlang Error
Created August 29, 2017 10:54
Erlang Error input ouput
-module(solution).
-export([start/0]).
start() ->
{ok,X}=io:fread(">","~d"),
io:fwrite("~w~n",[X*2]).
Error
** exception error: an error occurred when evaluating an arithmetic expression
in function solution:start/0 (solution.erl, line 6)
-module(wf_1).%week 1 final
-export([bits/1,bitsT/1,bitsST/1]).
-author("Erlang").
-version(".1").
bits(0)->0;
bits(1)->1;
bits(N) -> bits(N div 2)+ (N rem 2).
%-----7
-module(wf_1_peri).%week 1 final
-export([perimeter/1,area/1]).
-author("Erlang").
-version(".1").
% passing width and height of triangle
perimeter({rectangle,W,H}) -> 2*(W+H);
% passing Radius of Circle
perimeter({circle,R}) -> 2*(math:pi())*R;
%passing base,sides length , height
@linkin-park
linkin-park / Sheet 1 tested
Created November 3, 2016 13:56
Update 1 - VBA , update the logic
Function generateObject() As RowCell
Set rfirst = Selection.Rows.Item(1) ' initialized to first row
Dim cell As Variant
Dim count As Integer
Dim dict As Variant
Set dict = CreateObject("Scripting.Dictionary") ': dict.CompareMode = vbTextCompare
count = 0
Debug.Print "total Rows in Selection " & Selection.Rows.count
Dim tempRowCell As RowCell, theParentRowCell As RowCell
@linkin-park
linkin-park / Tail Recursion Excercise
Last active August 11, 2017 08:40
Erlang Class - 2nd Recursion - Assignment
%tail Recursion
-module(recursion_1_3_4).
-export([sum/1,fib/1,perfect/1,perfect1/1]).
% Try 1
%
% Sum of numbers
% F(0)+F(1)+....F(N-1)+F(N)
sum(N) -> sum(N-1,N).
@linkin-park
linkin-park / 1st Recursion Assignment
Created August 5, 2017 11:51
Erlang Class - Recursion- 1
-module(recursion_1_3_1).
-export([fib/1,dim/2]).
%fibonnaci
%0,1,2,3,4,5...
%0,1,1,2,3,5,...
fib(0)->io:fwrite([0," "]),0;
fib(1)->io:fwrite([1," "]),1;
fib(N) when N>1->K=fib(N-1)+fib(N-2),io:fwrite([K," "]),K.
46> XOr=fun(true,X)->not(X);
(false,X)->X end.
-module(pat_assignment).
-export([xOr1/2,xOr2/2,xOr3/2,xOr5/2,maxThree/3,test/0]).
xOr1(true,false)->true;
xOr1(false,true)->true;
xOr1(X,Y)->false.
xOr2(true,false)->true;