Skip to main content
added 6 characters in body
Source Link
Zeta
  • 701
  • 4
  • 12

C++11C++, (63 6060 57 bytes)

void s(int*f,int*e){for(int c=*f;++f!=e;c=*f)*f+=c=e;c=*f+=c/ *f**f;*f**f);} 

Works inplace given a range [first, last). Originally written as template variant, but that was longer:

template <classtemplate<class T>void s(T f,T e){for(auto c=*f;++f!=e;c=*f)*f+=c=e;c=*f+=c/ *f**f;*f**f);} 

Extended version

template <class ForwardIterator> void sort(ForwardIterator first, ForwardIterator last){ auto previous = *first; for(++first; first != last; ++first){ auto & current = *first; current += current * (current / previous); previous = current; } } 

C++11 (63 60 bytes)

void s(int*f,int*e){for(int c=*f;++f!=e;c=*f)*f+=c/ *f**f;} 

Works inplace given a range [first, last). Originally written as template variant, but that was longer:

template <class T>void s(T f,T e){for(auto c=*f;++f!=e;c=*f)*f+=c/ *f**f;} 

Extended version

template <class ForwardIterator> void sort(ForwardIterator first, ForwardIterator last){ auto previous = *first; for(++first; first != last; ++first){ auto & current = *first; current += current * (current / previous); previous = current; } } 

C++, 63 60 57 bytes

void s(int*f,int*e){for(int c=*f;++f!=e;c=*f+=c/ *f**f);} 

Works inplace given a range [first, last). Originally written as template variant, but that was longer:

template<class T>void s(T f,T e){for(auto c=*f;++f!=e;c=*f+=c/ *f**f);} 

Extended version

template <class ForwardIterator> void sort(ForwardIterator first, ForwardIterator last){ auto previous = *first; for(++first; first != last; ++first){ auto & current = *first; current += current * (current / previous); previous = current; } } 
added 11 characters in body
Source Link
Zeta
  • 701
  • 4
  • 12

C++11 (6363 60 bytes)

void s(int* fint*f,int* eint*e){for(autoint c=*f;++f!=e;c=*f)*f+=c/ *f**f;} 

Works inplace given a range [first, last). Originally written as template variant, but that was longer:

template <class T>void s(T f,T e){for(auto c=*f;++f!=e;c=*f)*f+=c/ *f**f;} 

Extended version

template <class ForwardIterator> void sort(ForwardIterator first, ForwardIterator last){ auto previous = *first; for(++first; first != last; ++first){ auto & current = *first; current += current * (current / previous); previous = current; } } 

C++11 (63 bytes)

void s(int* f,int* e){for(auto c=*f;++f!=e;c=*f)*f+=c/ *f**f;} 

Works inplace given a range [first, last). Originally written as template variant, but that was longer:

template <class T>void s(T f,T e){for(auto c=*f;++f!=e;c=*f)*f+=c/ *f**f;} 

Extended version

template <class ForwardIterator> void sort(ForwardIterator first, ForwardIterator last){ auto previous = *first; for(++first; first != last; ++first){ auto & current = *first; current += current * (current / previous) previous = current; } } 

C++11 (63 60 bytes)

void s(int*f,int*e){for(int c=*f;++f!=e;c=*f)*f+=c/ *f**f;} 

Works inplace given a range [first, last). Originally written as template variant, but that was longer:

template <class T>void s(T f,T e){for(auto c=*f;++f!=e;c=*f)*f+=c/ *f**f;} 

Extended version

template <class ForwardIterator> void sort(ForwardIterator first, ForwardIterator last){ auto previous = *first; for(++first; first != last; ++first){ auto & current = *first; current += current * (current / previous); previous = current; } } 
Source Link
Zeta
  • 701
  • 4
  • 12

C++11 (63 bytes)

void s(int* f,int* e){for(auto c=*f;++f!=e;c=*f)*f+=c/ *f**f;} 

Works inplace given a range [first, last). Originally written as template variant, but that was longer:

template <class T>void s(T f,T e){for(auto c=*f;++f!=e;c=*f)*f+=c/ *f**f;} 

Extended version

template <class ForwardIterator> void sort(ForwardIterator first, ForwardIterator last){ auto previous = *first; for(++first; first != last; ++first){ auto & current = *first; current += current * (current / previous) previous = current; } }