0 Members and 1 Guest are viewing this topic.
allLetters = ['a'..'z']allWords = concat [wordsOfLen x | x<-[1..]] where wordsOfLen 1 = [[x] | x<-allLetters] wordsOfLen len = [x : y | x<-allLetters, y<-wordsOfLen (len - 1)]
void*GetPossibleWords(unsigned int amount) { unsigned int length=0; unsigned int char_length=1; unsigned int placeholder=amount; int placeholder2=1; while (placeholder) { length+=placeholder^26*placeholder2++; placeholder=(placeholder>=0)?(placeholder/26):(0); } void*memalloc=malloc(length); void*returnalloc=memalloc; *(memalloc)=length; memalloc+=sizeof(unsigned int); char*chars=malloc(placeholder2); *(chars)='a'; int k; for(int j=1;j<=char_length;j++) { memcop(chars,memalloc,char_length); k=char_length; while(k) { *(chars+k-1)++ if (*(chars+k-1)=='z') { *(chars+(k--)-1)='a'; } elseif (*(chars)=='z') { char_length++; for(int l=0;l<=char_length-1;l++) { *(chars+l)='a'; } } else { k=0; } } } return returnalloc;}
#include <stdio.h>unsigned long pow(unsigned long base, unsigned long exp){ if(exp == 1) return base; return base * pow(base, exp - 1);}char *GetString(int stringLength, unsigned long combination){ char* character = malloc(sizeof(char) * 2); *character = combination % 26 + 'a'; *(character + 1) = '\0'; if(stringLength == 1) return character; return strcat(GetString(stringLength - 1, combination / 26), character);}int main(int argc, int *argv[]){ const int MAX_LEN = 3; int len; unsigned long i; for(len = 1; len <= MAX_LEN; len++) { for(i = 0; i < pow(26, len); i++) { printf("%s\n", GetString(len, i)); } } return 0;}
:ClrHome:For(A,1,8:Disp ":End:For(A,1,1E99:" ->Str1:A->B:While B:round(26fPart(B/26->C:If C:Then:sub("ABCDEFGHIJKLMNOPQRSTUVWXY",C,1)+Str1->Str1:Else:"Z"+Str1->Str1:B-26->B:End:iPart(B/26->B:End:Output(8,1,Str1:Disp ":End
#include "iostream"#include "string"void allwords(string s, int i) { for(char j = 97; j <123; j++) { if(i > 1) allwords(s + j, i-1); else std::cout<<s+j<<'\n'; }}int main(void) { int i = 0; while(1) { allwords("", i); i++; }}
a="a"function increment(str) len = #str if len==0 then return "a" end bt = str:byte(len) if bt<122 then str = str:sub(1, len - 1) .. string.char(bt+1) else str = increment(str:sub(1, len - 1)) .. "a" end return strendprint(a)for i=1,100 do a=increment(a) print(a)end
def increment(x): """Increments the string x""" length_of_string = len(x) if length_of_string == 0: return "a" bt = ord(x) if bt < 122: x = x[1:-1] + chr(bt+1) else: x = increment(x[1:-1] + "a") return x def main(): """Displays all possible words using alphabet a-z""" a = "a" for i in range(1000): a = increment(a) print a if __name__ == "__main__": main()
import Levakdef main(): for words in Levak.dictionnary: print words
42
ephan, I'll give you a tip: Lua starts with 1, python with 0 (/me waits for the beating)@Levak, lol
def increment(x): """Increments the string x""" length_of_string = len(x) if length_of_string == 0: return "a" bt = ord(x) #The problem is that ord doesn't work for strings, only characters if bt < 122: x = x[-1] + chr(bt+1) else: x = increment(x[-1] + "a") return x def main(): """Displays all possible words using alphabet a-z""" a = "a" for i in range(1000): a = increment(a) print a if __name__ == "__main__": main()
def increment(x): """Increments the string x""" length_of_string = len(x) if length_of_string == 0: return "a" bt = x.encode("hex") if bt < 122: x = x + chr(bt+1) else: x = increment(x + "a") return x def main(): """Displays all possible words using alphabet a-z""" a = "a" for i in range(1000): a = increment(a) print a if __name__ == "__main__": main()
Slightly shorter than ztrumpet's? idk, but I think it's quite a bit faster
:ClrHome:For(A,-8,-1:Disp ":End:Repeat getKey:" ->Str1:A+1->A:Ans->B:While Ans:round(26fPart(Ans/26:If Ans:Then:sub("ABCDEFGHIJKLMNOPQRSTUVWXY",Ans,1)+Str1->Str1:B:Else:"Z"+Str1->Str1:B-26:End:int(Ans/26->B:End:Disp ":Output(8,1,Str1:End
Size comparisons ztrumpet? Nice either way