Skip to content

Instantly share code, notes, and snippets.

@petrokoriakin
Created October 8, 2013 09:19
Show Gist options
  • Save petrokoriakin/6881990 to your computer and use it in GitHub Desktop.
Save petrokoriakin/6881990 to your computer and use it in GitHub Desktop.
Українські копійки - 1,2,5,10,25,50. 1 копійку можна розміняти 1 різним способом - {1} 2 - двома різними способами {1 + 1; 2} 5 - 4 {1 + 1 + 1 + 1 + 1; 1 + 1 + 1 + 2; 1 + 2 + 2; 5} …… Скількома різними способами можна розміняти гривню (100 копійок) ?
counter = 0
a = [0, 1, 2, 5, 10, 25, 50]
7.times do | i1 |
7.times do | i2 |
7.times do | i3 |
7.times do | i4 |
7.times do | i5 |
7.times do | i6 |
7.times do | i7 |
7.times do | i8 |
7.times do | i9 |
7.times do | i10 |
7.times do | i11 |
7.times do | i12 |
7.times do | i13 |
7.times do | i14 |
7.times do | i15 |
7.times do | i16 |
7.times do | i17 |
7.times do | i18 |
7.times do | i19 |
7.times do | i20 |
7.times do | i21 |
7.times do | i22 |
7.times do | i23 |
7.times do | i24 |
7.times do | i25 |
7.times do | i26 |
7.times do | i27 |
7.times do | i28 |
7.times do | i29 |
7.times do | i30 |
7.times do | i31 |
7.times do | i32 |
7.times do | i33 |
7.times do | i34 |
7.times do | i35 |
7.times do | i36 |
7.times do | i37 |
7.times do | i38 |
7.times do | i39 |
7.times do | i40 |
7.times do | i41 |
7.times do | i42 |
7.times do | i43 |
7.times do | i44 |
7.times do | i45 |
7.times do | i46 |
7.times do | i47 |
7.times do | i48 |
7.times do | i49 |
7.times do | i50 |
7.times do | i51 |
7.times do | i52 |
7.times do | i53 |
7.times do | i54 |
7.times do | i55 |
7.times do | i56 |
7.times do | i57 |
7.times do | i58 |
7.times do | i59 |
7.times do | i60 |
7.times do | i61 |
7.times do | i62 |
7.times do | i63 |
7.times do | i64 |
7.times do | i65 |
7.times do | i66 |
7.times do | i67 |
7.times do | i68 |
7.times do | i69 |
7.times do | i70 |
7.times do | i71 |
7.times do | i72 |
7.times do | i73 |
7.times do | i74 |
7.times do | i75 |
7.times do | i76 |
7.times do | i77 |
7.times do | i78 |
7.times do | i79 |
7.times do | i80 |
7.times do | i81 |
7.times do | i82 |
7.times do | i83 |
7.times do | i84 |
7.times do | i85 |
7.times do | i86 |
7.times do | i87 |
7.times do | i88 |
7.times do | i89 |
7.times do | i90 |
7.times do | i91 |
7.times do | i92 |
7.times do | i93 |
7.times do | i94 |
7.times do | i95 |
7.times do | i96 |
7.times do | i97 |
7.times do | i98 |
7.times do | i99 |
7.times do | i100 |
sum = a[i1]+a[i2]+a[i3]+a[i4]+a[i5]+a[i6]+a[i7]+a[i8]+a[i9]+a[i10]+a[i11]+a[i12]+a[i13]+a[i14]+a[i15]+a[i16]+a[i17]+a[i18]+a[i19]+a[i20]+a[i21]+a[i22]+a[i23]+a[i24]+a[i25]+a[i26]+a[i27]+a[i28]+a[i29]+a[i30]+a[i31]+a[i32]+a[i33]+a[i34]+a[i35]+a[i36]+a[i37]+a[i38]+a[i39]+a[i40]+a[i41]+a[i42]+a[i43]+a[i44]+a[i45]+a[i46]+a[i47]+a[i48]+a[i49]+a[i50]+a[i51]+a[i52]+a[i53]+a[i54]+a[i55]+a[i56]+a[i57]+a[i58]+a[i59]+a[i60]+a[i61]+a[i62]+a[i63]+a[i64]+a[i65]+a[i66]+a[i67]+a[i68]+a[i69]+a[i70]+a[i71]+a[i72]+a[i73]+a[i74]+a[i75]+a[i76]+a[i77]+a[i78]+a[i79]+a[i80]+a[i81]+a[i82]+a[i83]+a[i84]+a[i85]+a[i86]+a[i87]+a[i88]+a[i89]+a[i90]+a[i91]+a[i92]+a[i93]+a[i94]+a[i95]+a[i96]+a[i97]+a[i98]+a[i99]+a[i100]
сunter += 1 if sum == 100
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
puts count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment