This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"strconv" | |
) | |
// CODE MAY NOT COMPILE WITHOUT REDIS API IMPLEMENTATION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newstore([]). | |
access(_,[],0). | |
access(I,[(I,V)|_],V). | |
access(I,[_|T],V) :- access(I,T,V). | |
update(I,NV,[],[(I,NV)]). | |
update(I,NV,[(I,_)|T],[(I,NV)|T]). | |
update(I,NV,[P|T],[P|T1]) :- update(I,NV,T,T1). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program(pprog(K)) --> k(K),[.]. | |
k(pblock(D,C)) --> [begin],d(D),[;],c(C),[end]. | |
d(D) --> d_d(D). | |
d(pdeclaration(D1,D2)) --> d_d(D1),[;],d(D2). | |
d_d(pconstant(I,N)) --> [const],i(I),[=],n(N). | |
d_d(pvar(I)) --> [var],i(I). | |
c(C) --> c_c(C). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
P ::= K. | |
K ::= begin D; C end | |
D ::= const I = N D' | var I D' | |
D' ::= ε | ; D D' | |
C ::= I := E C' | if B then C else C endif C' | while B do C endwhile C' | K C' | |
C' ::= ε | ; C C' | |
B ::= true | false | E = E | not B | |
E ::= I := E E' |I E' | N E' | |
E' ::= ε | + E E' | - E E' | * E E' | / E E' | |
I ::= x | y | z | u | v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean isAnagram(String str1, String str2) | |
{ | |
//To get the no of occurrences of each character and store it in their ASCII location | |
int[] strCountArr1=getASCIICountArr(str1); | |
int[] strCountArr2=getASCIICountArr(str2); | |
//To Test whether the two arrays have the same count of characters. Array size 256 since ASCII 256 unique values | |
for(int i=0;i<256;i++) | |
{ | |
if(strCountArr1[i]!=strCountArr2[i]) | |
return false; |