# Search Results

Results tagged with Search options user 7231
5 results

The challenge involves mathematics. Also consider using more specific tags: [number] [number-theory] [arithmetic] [combinatorics] [graph-theory] [geometry] [abstract-algebra].

Smalltalk Squeak 4.x flavour, 91 char in the form of a block: [:p||b|b:=Bag new.p do:[:x|p do:[:y|b add:(x dist:y)]].b valuesAndCounts asSet={4. 8}asSet] Test it with: { "Example squares:" {0@ …
answered May 3 '13 by aka.nice
Smalltalk (Pharo 2.0) (41 ln) 3.713572066704308 Pharo -headless Pharo-2.0.image eval "FileStream stdin nextLine asNumber log:41" No syntactic sugar is Smalltalk's pride, just regular sentence ;)
answered Apr 20 '13 by aka.nice
Squeak Smalltalk, fast version 111 octets - 25 bonus: 86 In class String, define method: d|h s t|h:=self first:1.(s:=self size-1)>0or:[^h+1*h/2].t:=self last:s.^s*9+h-1*(5 raisedTo:s)<<(s-1)+t+1*h+t …
answered Jan 16 '14 by aka.nice
C #include "stdio.h" int main() {{ int i,j,s,d; /* auto test */ for(i=1;i<=2;i++) {{ j=i; d=diff(i,j); s=sum(j,j); if( d != 0 || s != 2*i ) ab …
answered Nov 25 '15 by aka.nice
C, 56 bytes c=1;f(char*a){c=-c;*a&16?c+=1-*a-1[a],c&=2,c/=2:f(a+1);} Hint: only the last two bits count. The basic idea was to use least significant bit for storing result of factorial, and next …
answered Feb 10 '17 by aka.nice