计算波


26

我已经在这个网站上滚动了一段时间,但是最近才真正对尝试一些挑战很有兴趣。我本来打算尝试一些现有的代码高尔夫球主题,但是昨天我有一段时间没有互联网访问权限,与此同时,我考虑了自己的挑战。

您的任务是创建一个程序或函数,该程序或函数采用Floats数组a和一个整数n,然后将每个值设置a为旁边两个值的平均值n。当重复使用增大值时n,会产生类似波浪的运动:

波动

细节:

  • 如果碰巧中只有一项an或者等于或小于0,则程序应返回原始数组。
  • 输入和输出可以以所需的任何格式显示,只要它们在视觉上是分开的即可。

对于每个步骤:

  • 中的第一项a应成为其自身与下一项的平均值。
  • 中的最后一项a应成为其自身与上一项的平均值。
  • 中的任何其他项目a应成为上一项和下一项的平均值。
  • 确保您要计算的是上一步的数组,而不是当前的数组!

测试用例:注意:您的输入/输出不必采用这种格式!

[0, 0, 1, 0, 0], 1          -> [0, 0.5, 0, 0.5, 0]
[0, 0, 1, 0, 0], 2          -> [0.25, 0, 0.5, 0, 0.25]
[0, 0, 1, 0, 0], 0          -> [0, 0, 1, 0, 0]
[0, 0, 1, 0, 0], -39        -> [0, 0, 1, 0, 0]
[0, 16, 32, 16, 0], 1       -> [8, 16, 16, 16, 8]
[0, 1, 2, 3, 4, 5], 1       -> [0.5, 1, 2, 3, 4, 4.5]
[0, 64], 1                  -> [32, 32]
[0], 482                    -> [0]
[32, 32, 32, 16, 64, 16, 32, 32, 32], 4 -> [33, 27, 40, 22, 44, 22, 40, 27, 33]

这是,因此最短答案以字节为单位。获奖者将在一周内(8月1日)被选中。祝好运!

编辑:恭喜获胜者@issacg,其字节数高达18个!


2
我提出的改善此挑战的建议是,消除n没有提供和a没有提供的情况-它们并没有增加太多。
isaacg 2015年

我相信最终的测试用例是不正确的。n应该是4,而不是5
isaacg

@isaacg:是的,现在我再来看一遍,这些案例似乎并不那么重要。我已经更改了该错误,并修复了错误的示例。感谢您指出这些问题!
ETHproductions 2015年

1
如果您确实希望它处理空列表,则可能需要将其添加到测试用例列表中。我只是注意到我的解决方案在这种情况下失败了。就我个人而言,我不是很喜欢问题,因为解决方案的很大一部分用于处理特殊情况。
Reto Koradi 2015年

@RetoKoradi对不起,当我从示例中删除“空列表”案例时,我忘记了将其删除。感谢您的通知!
ETHproductions

Answers:


11

Pyth,46个 18字节

ucR2sV+hGGt+GeG.*Q

这段代码期望输入形式为iterations, [wave1, wave2, wave3 ...],如下面的第一个链接所示。

示范。 测试线束。

该程序通过将reduce(u)函数中的代码应用于输入列表来工作,其次数是迭代次数。

我将在列表中演示波传播函数,该函数[0, 1, 2, 3, 4, 5]位于G

+hGG预先考虑G的第一个元素G,从而形成[0, 0, 1, 2, 3, 4, 5]

t+GeGG最后一个元素追加到第一个元素G并将其删除,即形成[1, 2, 3, 4, 5, 5]

sV首先从列表中形成对,然后[[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 5]]将第一个列表的最后一个元素截断。然后,通过s函数将这些对相加,得到[1, 2, 4, 6, 8, 9]

cR2使用浮点除法将所有数字除以2,得到所需的结果[0.5, 1.0, 2.0, 3.0, 4.0, 4.5]


8

雪人1.0.0,219个字符

{vg" "aS:10sB;aM0aa,AAg**-:|al|'NdE'0nRal@(%}{->:1*?{0AaG;:?{;bI:dUNiNwR'NdEwRaC;aM(~:?{(()1wR]0wRaC*))#'wRaC|*#|(()#aLNdEdUNdEwR]wR]aCwR*))#aC;:0wRdUaCwR*?{#aC;#bI:*#0aA'|aa|'!*+'(()#1aA*))#|,aa|'*`nA2nD;aM|*0*;bR|tSsP

带有换行符以实现“可读性”:

{vg" "aS:10sB;aM0aa,AAg**-:|al|'NdE'0nRal@(%}{->:1*?{0AaG;:?{;bI:dUNiNwR'NdEwRaC;
aM(~:?{(()1wR]0wRaC*))#'wRaC|*#|(()#aLNdEdUNdEwR]wR]aCwR*))#aC;:0wRdUaCwR*?{#aC;#
bI:*#0aA'|aa|'!*+'(()#1aA*))#|,aa|'*`nA2nD;aM|*0*;bR|tSsP

非高尔夫版/未缩小版:

{vg" "aS:10sB;aM  // input space-separated list of numbers
0aa,AAg           // get first element and array of all-but-first elements
**                // discard original input and the 0

// execute the following (input[0]) times
-:
    |al|'NdE'0nR               // get range from (0..input.length-1]
    al@(%}{->:1*?{0AaG;:?{;bI  // chop off first element if any
    :dUNiNwR'NdEwRaC;aM        // map n -> [n-1 n+1]
    // if the input consisted of a single element, append [0 0]
    // otherwise prepend [0 1] and append [len-2 len-1]
    (~:?{(()1wR]0wRaC*))#'wRaC|*#|(()#aLNdEdUNdEwR]wR]aCwR*))#aC;
        :0wRdUaCwR*?{#aC;#bI
    // map indeces to avg(input[i1], input[i2])
    :*#0aA'|aa|'!*+'(()#1aA*))#|,aa|'*`nA2nD;aM
    // replace old input, reset permavar
    |*0*
;bR

|tSsP  // output result

样本I / O格式:

llama@llama:...Code/snowman/ppcg53799waves$ snowman waves.snowman 
4 32 32 32 16 64 16 32 32 32
[33 27 40 22 44 22 40 27 33]

2
这真是太美了。
kirbyfan64sos


5

球拍, 164 145字节

(define(f a n)(if(< n 1)a(f(let([l(length a)][r list-ref])(for/list([i(in-range l)])(/(+(r a(max(- i 1)0))(r a(min(+ i 1)(- l 1))))2)))(- n 1))))

不打高尔夫球

(define (f a n)
  (if (< n 1)
      a
      (f (let ([l (length a)] [r list-ref])
           (for/list ([i (in-range l)])
             (/ (+ (r a (max (- i 1) 0))
                   (r a (min (+ i 1) (- l 1))))
                2))) (- n 1))))

注意,您可能需要#lang racket运行该行。


4

R,109字节

function(x,n){l=length(x);t=if(l>2)c(.5,0,.5)else if(l==2)c(.5,.5)else 1;for(i in 1:n)x=filter(x,t,c=T);c(x)}

这将创建一个未命名的函数,该函数接受一个向量和一个整数并返回一个向量。此处的方法是将输入视为单变量时间序列,并应用线性卷积滤波器。

取消+说明:

f <- function(x, n) {
    # Define filter coefficients
    t <- if (length(x) > 2)
        c(0.5, 0, 0.5)
    else if (length(x) == 2)
        c(0.5, 0.5)
    else
        1

    # Apply the filter n times
    for (i in 1:n) {
        # The circular option wraps the filter around the edges
        # of the series, otherwise the ends would be set to NA.
        x <- filter(x, t, circular = TRUE)
    }

    # Returned the modified input, stripped of the extraneous
    # properties that the filter function adds.
    c(x)
}

例子:

> f(c(32, 32, 32, 16, 64, 16, 32, 32, 32), 4)
[1] 33 27 40 22 44 22 40 27 33

> f(0, 482)
[1] 0

> f(c(0, 64), 1)
[1] 32 32

4

Haskell,76个字符

技巧是将第一个数字添加到列表的开头,将最后一个数字添加到列表的末尾,而不是处理边界条件。

f a@(x:s)=(/2)<$>zipWith(+)(x:a)(s++[last s])
f x=x
a#n|n<1=a|n>0=f a#(n-1)

测试:

λ: [0, 0, 1, 0, 0]#1  
[0.0,0.5,0.0,0.5,0.0]
λ: [0, 0, 1, 0, 0]#2
[0.25,0.0,0.5,0.0,0.25]
λ: [0, 0, 1, 0, 0]#0  
[0.0,0.0,1.0,0.0,0.0]
λ: [0, 0, 1, 0, 0]#(-39) 
[0.0,0.0,1.0,0.0,0.0]
λ: [0, 16, 32, 16, 0]#1
[8.0,16.0,16.0,16.0,8.0]
λ: [0, 1, 2, 3, 4, 5]#1
[0.5,1.0,2.0,3.0,4.0,4.5]
λ: [0, 64]#1
[32.0,32.0]
λ: [0]#482
[0.0]
λ: [32, 32, 32, 16, 64, 16, 32, 32, 32]#4
[33.0,27.0,40.0,22.0,44.0,22.0,40.0,27.0,33.0]

1
您可以使用2参数函数和后缀的infix运算符代替,从而节省一些字节if then else,即c成为a#n|n<1=a|1<2=iterate f a!!ns成为x!y=(x+y)/2(并称为...zipWith(!)(x:a)...)。
nimi 2015年

谢谢!不知道守卫如何在单行表达式中工作。
Keyran

另外2个字节:创建c一个中缀运算符,例如#a#n|n<1=a|1<2=iterate f a!!n。称它为[0, 0, 1, 0, 0] # 2
nimi

2

CJam,23 22字节

q~{_(@)@@+@@+.+.5f*}*`

在线尝试

输入采用CJam列表格式,例如上一个示例:

[32 32 32 16 64 16 32 32 32] 4

输出也是一个CJam列表:

[33.0 27.0 40.0 22.0 44.0 22.0 40.0 27.0 33.0]

基本方法是在每一步中,向量都向左移动一个位置,向右移动一个位置。两个向量中的每一个都填充有第一个/最后一个元素,然后计算两个向量的平均值。

说明:

q~    Get and interpret input.
{     Loop over repeat count.
  _     Copy list.
  (     Pop off left element.
  @     Get original list to top.
  )     Pop off right element.
  @@    Get first element and list with last element removed to top.
  +     Concatenate. This gives right-shifted list with first element repeated.
  @@    Get list with first element removed and last element to top.
  +     Concatenate. This gives left-shifted list with last element repeated.
  .+    Perform vector addition of two shifted lists.
  .5f*  Multiply sum by 0.5 to give average.
}*    End loop over repeat count.
`     Convert result array to string.

我不是OP,而是“如果a中恰好有零个或一项,或者n等于或小于0,则程序应返回原始数组。”
Maltysen

2

Java,181个字节

这是高尔夫球版:

float[]g(float[]i,int n){float[]c=i.clone();int l=c.length,s=1;if(n>0&&l>1){c[0]=(i[0]+i[1])/2f;c[--l]=(i[l]+i[l-1])/2f;while(s<l)c[s]=(i[s-1]+i[++s])/2f;return g(c,n-1);}return i;}

取消高尔夫:

float[] g(float[] i, int n) {
    float[] c = i.clone();
    int l = c.length,s=1;
    if(n>0&&l>1) {
        c[0] = (i[0]+i[1])/2f;
        c[--l] = (i[l]+i[l-1])/2f;
        while(s<l)
            c[s] = (i[s-1] + i[++s]) / 2f;
        return g(c, n-1);
    }
    return i;
}

我尝试使用Java尽可能缩短分配和条件。当然,欢迎改进。


2

JavaScript(ES6),153 132 67个字符

6个月后,我回到了第一个答案,该怎么办?打高尔夫球50%,就是这样。;)

s=(a,n)=>n<1?a:s(a.map((j,i)=>(a[i&&i-1]+a[a[i+1]+1?i+1:i])/2),n-1)

此版本反复调用自己,直到n小于1,n每次减1。

非递归溶液(151个 130 78字符):

(a,n)=>n<1?a:eval("while(n--)a=a.map((j,i)=>(a[i&&i-1]+a[a[i+1]+1?i+1:i])/2)")

取消高尔夫:(已过时)

递归:

s = function (a, n) {
  if (n < 1)
    return a;
  b = [];
  l = a.length;
  x = y = 0;
  for(var i = 0; i < l; i++) {
    x = a[(i < 1) ? 0 : i-1];
    y = a[(i > l-2) ? i : i+1];
    b[i] = (x + y)/2;
  }
  if (n > 2)
    return b;
  return s(b,n-1);
}

非递归:

s = function (a, n) {
  if (n < 1)
    return a;
  b = [];
  l = a.length;
  x = y = 0;
  while(n-- > 0) {
    for(var i = 0; i < l; i++) {
      x = a[(i < 1) ? 0 : i-1];
      y = a[(i > l-2) ? i : i+1];
      b[i] = (x + y)/2;
      a = b.slice(0);   // setting a to a copy of b, for copyright reasons
    }
  return b;
}

if(n<2)return b;return s(b,n-1)可以减少为return n<2?b:s(b,n-1)
Cyoce '16

@Cyoce谢谢,我已经考虑了这一点,然后考虑了一些……
ETHproductions 2016年

1

Java,203个字节

尝试我第一次使用Java。欢迎使用改进技巧:)

double[]f(double[]a,int n){int j,s,i=0;s=a.length-1;if(n<1||s<1)return a;double b[]=a;for(;i++<n;a=b.clone()){b[0]=.5*(a[0]+a[1]);b[s]=.5*(a[s]+a[s-1]);for(j=1;j<s;++j)b[j]=.5*(a[j-1]+a[j+1]);}return b;}

漂亮印刷:

double[] g(double[] a, int n) {
  int j, s, i = 0;
  s = a.length - 1;
  if (n < 1 || s < 1)
     return a;
  double b[] = a;
  for (; i++ < n; a = b.clone()) {
     b[0] = .5 * (a[0] + a[1]);
     b[s] = .5 * (a[s] + a[s - 1]);
     for (j = 1; j < s; ++j)
        b[j] = .5 * (a[j - 1] + a[j + 1]);
  }
  return b;
}

欢迎来到PPCG!我不太喜欢Java,但是可以将外部for循环中的三个赋值移动到循环的增量语句中吗?喜欢for(i=0;i<n;b[0]=...,b[s-1]=...,a=...,++i)for(...)b[j]=...;吗?然后,您应该可以摆脱括号。
Martin Ender

不幸的是,它们必须在每次迭代中重复,因此它们必须留在括号内。
盖尔,2015年

每次迭代也会重复递增,这就是为什么要将它们放在第三个位置(++i以逗号分隔,而不是用分号隔开的)的原因。试试看。:)
Martin Ender

我知道您要去的地方,但是在最后的迭代中我丢失了更新(除非有我不知道的窍门)。仍然可以通过做“丑陋的事情”在这里和那里剃一些字节:)
Geir

我认为您不会在最后一次迭代中丢失更新。f(a;b;c){d;e;}应该完全相同f{a;b;}{d;e;c;},因此也应该完全相同f(a;b;e,c)d;。但是,由于重新排列的代码不再起作用,因为您无法for在另一个内部移动代码for,所以我想所有这些都不再重要。;)
Martin Ender

1

Python 2,98字节

采取了直接方法,该方法过去exec是使用while循环。我认为有一种更好的逻辑来找出特殊情况,这是可行的。输入应采用格式[list], times

b,c=input()
k=~-len(b)
exec'b=[(b[x-(0<x<k)]+b[x+(x<k)-(x==k)])/2.for x in range(-~k)];'*c
print b

取消高尔夫:

BASE,TIME = input()
TEMP = [0]*len(BASE)                               # Temporary array as to not modify base.
while TIME:
    for x in xrange(len(BASE)):
        if x == 0:                                
            TEMP[x] = (BASE[x]   + BASE[x+1])/2.0  # First element special case.
        elif x == len(BASE)-1:                    
            TEMP[x] = (BASE[x]   + BASE[x-1])/2.0  # Last element special case.
        else:                                     
            TEMP[x] = (BASE[x-1] + BASE[x+1])/2.0  # Every other element.
    BASE = TEMP                                    # Set base to temporary array.
    TEMP = [0]*len(BASE)                           # Reset temporary array to 0s.
    TIME = TIME - 1
print BASE

1

Mathematica,81个字节

我有一种感觉,如果我想出一种更好的方法来应对积极的条件,那就可以打高尔夫了。

f[l_,_]:=l;f[l_,n_/;n>0]:=Nest[.5{1,0,1}~ListConvolve~ArrayPad[#,1,"Fixed"]&,l,n]

值得注意的是:Mathematica在其列表处理和过滤器功能以及的范围内提供了许多潜在的内置解决方案CellularAutomaton。我之所以选择Nest[... ListConvolve ...],是因为这是找出列表结尾处最简单的方法,但是其他角度可能会更短。


0

Matlab,109

function a=f(a,n)
if numel(a)>1&n>0
for k=1:n
a=[a(1)+a(2) conv(a,[1 0 1],'valid') a(end-1)+a(end)]/2;end
end

例子:

>> f([0, 0, 1, 0, 0], 1)
ans =
         0    0.5000         0    0.5000         0

>> f([0, 0, 1, 0, 0], 2)
ans =
    0.2500         0    0.5000         0    0.2500

>> f([0, 0, 1, 0, 0], 0)
ans =
     0     0     1     0     0

>> f([0, 0, 1, 0, 0], -39)
ans =
     0     0     1     0     0

>> f([0], 482)
ans =
     0

>> f([], 10)
ans =
     []

0

Scala,195个字符(186个带延迟输出,即Stream 187个字符

(t:Seq[Float],n:Int)⇒t.size match{case 0|1⇒t;case 2⇒{val a=t.sum/2;Seq(a,a)};case i⇒(t/:(1 to n)){(s,_)⇒(s.take(2).sum/2)+:s.sliding(3).map(l=>(l(0)+l(2))/2).toList:+(s.drop(i-2).sum/2)}}

可能不是最佳映射 sliding(3)在这种情况下非常有用。

测试:

scala> (t:Seq[Float],n:Int)⇒t.size match{case 0|1⇒t;case 2⇒{val a=t.sum/2;Seq(a,a)};case i⇒(t/:(1 to n)){(s,_)⇒(s.take(2).sum/2)+:s.sliding(3).map(l=>(l(0)+l(2))/2).toList:+(s.drop(i-2).sum/2)}}
res0: (Seq[Float], Int) => List[Float] = <function2>

scala> res0(Seq(0, 0, 1, 0, 0), 1)
res1: Seq[Float] = List(0.0, 0.5, 0.0, 0.5, 0.0)

scala> res0(Seq(0, 0, 1, 0, 0), 2)
res2: Seq[Float] = List(0.25, 0.0, 0.5, 0.0, 0.25)

scala> res0(Seq(0, 0, 1, 0, 0), 0)
res3: Seq[Float] = List(0.0, 0.0, 1.0, 0.0, 0.0)

scala> res0(Seq(0, 0, 1, 0, 0), -39)
res4: Seq[Float] = List(0.0, 0.0, 1.0, 0.0, 0.0)

scala> res0(Seq(0, 16, 32, 16, 0), 1)
res5: Seq[Float] = List(8.0, 16.0, 16.0, 16.0, 8.0)

scala> res0(Seq(1, 2, 3, 4, 5), 1)
res6: Seq[Float] = List(1.5, 2.0, 3.0, 4.0, 4.5)

scala> res0(Seq(0,64), 1)
res7: Seq[Float] = List(32.0, 32.0)

scala> res0(Seq(0), 482)
res8: Seq[Float] = List(0.0)

scala> res0(Seq(32, 32, 32, 16, 64, 16, 32, 32, 32), 4)
res9: Seq[Float] = List(33.0, 27.0, 40.0, 22.0, 44.0, 22.0, 40.0, 27.0, 33.0)

0

q(27个字符)

{avg x^/:1 -1 xprev\:x}/[;]

例子

q)f:{avg x^/:1 -1 xprev\:x}/[;]
q)f[4;32 32 32 16 64 16 32 32 32]
33 27 40 22 44 22 40 27 33f
//1-length input
q)f[10;enlist 1] 
,1f
//0-length input
q)f[10;`float$()]
`float$()

0

R,93字节

作为未命名的函数

function(a,n){l=length(a);while((n=n-1)>=0)a<-colMeans(rbind(c(a[-1],a[l]),c(a[1],a[-l])));a}

展开式

function(a,n){
    l=length(a);             # get the length of the vector
    while((n=n-1)>=0)        # repeat n times
        a<-colMeans(         # do the column means and assign to a
          rbind(             # create an array
            c(a[-1],a[l]),   # shift the vector left and duplicate last
            c(a[1],a[-l])    # shift the vector right and duplicate first
          )
        );
    a                        # return the vector
}

测验

> f=function(a,n){l=length(a);while((n=n-1)>=0)a<-colMeans(rbind(c(a[-1],a[l]),c(a[1],a[-l])));a}
> f(c(0, 0, 1, 0, 0), 1)
[1] 0.0 0.5 0.0 0.5 0.0
> f(c(0, 0, 1, 0, 0), 2)         
[1] 0.25 0.00 0.50 0.00 0.25
> f(c(0, 0, 1, 0, 0), 0)         
[1] 0 0 1 0 0
> f(c(0, 0, 1, 0, 0), -39)        
[1] 0 0 1 0 0
> f(c(0, 16, 32, 16, 0), 1)       
[1]  8 16 16 16  8
> f(c(0, 1, 2, 3, 4, 5), 1)      
[1] 0.5 1.0 2.0 3.0 4.0 4.5
> f(c(0, 64), 1)                  
[1] 32 32
> f(c(0), 482)                    
[1] 0
> f(c(32, 32, 32, 16, 64, 16, 32, 32, 32),4)
[1] 33 27 40 22 44 22 40 27 33
> 

0

Japt,39 37字节(非竞争)

这个答案是非竞争性的,因为这种语言比挑战性要新。我只是想看看我的高尔夫球语言如何应付我的第一个挑战。

Vm0 o r_£ZgY©Y-1 +ZgY>Zl -2?Y:°Y)/2}U

在线尝试!

Vm0 o r_£ZgY©Y-1 +ZgY>Zl -2?Y:°Y)/2}U
Vm0 o      // Generate the range of integers [0, max(V,0)).
r_     }U  // Reduce it with this function, with a starting value of U:
£          //  Return the argument, with each item X, index Y, and the full array Z mapped by this function:
ZgY©Y-1 +  //   Return (Z[max(Y-1,0)] plus
ZgY>Zl -2? //    Z[Y > Z.length-2?
Y:°Y)      //      Y:--Y],)
/2         //   divided by two.
           // Implicit: output last expression

0

C ++ 14,158个字节

#define D(a,b)d[i]=(c[a]+c[b])/2;
auto f(auto c,int n){while(n-->0&&c.size()>1){auto d{c};int i{};D(0,1)while(++i<c.size()-1)D(i-1,i+1)D(i,i-1)c=d;}return c;}

要求输入为容器value_type==double,例如vector<double>

取消高尔夫:

#define D(a,b) d[i] = (c[a]+c[b])/2;   //average
auto f(auto c, int n) {
  while(n-- > 0 && c.size() > 1) {     //breaks
    auto d{c};                         //copy container
    int i{};
    D(0,1)                             //left
    while(++i < c.size()-1)            //count up to right
      D(i-1,i+1)                       //interior
    D(i,i-1)                           //right
    c=d;                               //overwrite container
  }
  return c;
}

0

拍子223字节

(let p((l l)(m 0)(g list-ref))(cond[(> n m)(let*((j(length l))(k(for/list((i j))(cond[(= i 0)(/(+(g l 0)(g l 1))2)]
[(= i(- j 1))(/(+(g l(- j 2))(g l(- j 1)))2)][else(/(+(g l(+ i 1))(g l(- i 1)))2)]))))(p k(+ 1 m) g))][l]))

取消高尔夫:

(define(f l n)
  (let loop ((l l)
             (m 0)
             (lr list-ref))
    (cond
      [(> n m)
       (let* ((j (length l))
              (k (for/list ((i j))
                   (cond
                     [(= i 0)       (/ (+ (lr l 0)
                                          (lr l 1))
                                       2)]
                     [(= i (- j 1)) (/ (+ (lr l (- j 2))
                                          (lr l (- j 1)))
                                        2)]
                     [else          (/ (+ (lr l (+ i 1))
                                          (lr l (- i 1)))
                                       2)])
                   )))
         (loop k
               (+ 1 m)
               lr))]
      [else l]
      )))

测试:

(f '[32 32 32 16 64 16 32 32 32] 4)

输出:

'(33 27 40 22 44 22 40 27 33)


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.