This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%= form_for(@item) do |f| %> | |
| <% if @item.errors.any? %> | |
| <div id="error_explanation"> | |
| <h2><%= pluralize(@item.errors.count, "error") %> prohibited this item from being saved:</h2> | |
| <ul> | |
| <% @item.errors.full_messages.each do |msg| %> | |
| <li><%= msg %></li> | |
| <% end %> | |
| </ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def B(m,n) | |
| if(m==0 && n>0) | |
| return f(n) | |
| end | |
| if(m>0 && n==0 ) | |
| return B(m-1,1) | |
| end | |
| if(m>0 && n>0) | |
| return B(m-1,B(m,n-1)) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def B(string) #現在の計算式を後ろから見ていき最初に現れるB()を取得する関数 | |
| i = 1 | |
| num_n = 0 | |
| num_m = 0 | |
| while(string[-i] == ")") | |
| i += 1 | |
| end | |
| j = 0 | |
| while(string[-i] != ",")#数字が何桁になってもいいように数字を取得(すべて文字列で扱っているため) | |
| num_n += string[-i].to_i * (10**j) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| B(3,3) | |
| =B(2,B(3,2)) | |
| =B(2,B(2,B(3,1))) | |
| =B(2,B(2,B(2,B(3,0)))) | |
| =B(2,B(2,B(2,B(2,1)))) | |
| =B(2,B(2,B(2,B(1,B(2,0))))) | |
| =B(2,B(2,B(2,B(1,B(1,1))))) | |
| =B(2,B(2,B(2,B(1,B(0,B(1,0)))))) | |
| =B(2,B(2,B(2,B(1,B(0,B(0,1)))))) | |
| =B(2,B(2,B(2,B(1,B(0,2))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 実行前に下の設定が必要です | |
| # $ rbenv exec gem install heroku-api | |
| # $ export HEROKU_API_KEY=your_heroku_api_key | |
| require 'heroku-api' | |
| heroku = Heroku::API.new | |
| apps = heroku.get_apps.body | |
| apps.each do |app| | |
| puts app['name'] | |
| collaborators = heroku.get_collaborators(app['name']).body |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function steamrollArray(arr) { | |
| while (hasArrElement(arr)){ | |
| arr = expandArrElement(arr); | |
| } | |
| return arr; | |
| } | |
| function hasArrElement(arr) { | |
| for (var i = 0; i < arr.length; i++ ) { | |
| if (Array.isArray(arr[i])){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function steamrollArray(arr) { | |
| while (hasArrElement(arr)){ | |
| arr = expandArrElement(arr); | |
| } | |
| return arr; | |
| } | |
| function hasArrElement(arr){ | |
| return arr.filter(function(element) {return Array.isArray(element);}).length > 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function steamrollArray(arr) { | |
| return arr.reduce(function (prevVal, currentVal){ | |
| if (Array.isArray(currentVal)) { | |
| return [].concat.call( prevVal, steamrollArray(currentVal) ); | |
| } else { | |
| return [].concat.call( prevVal, currentVal ); | |
| } | |
| }, []); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function largestOfFour(arr) { | |
| return arr.map((numbers) => { | |
| return Math.max(...numbers); | |
| }); | |
| } | |
| largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function pairElement(str) { | |
| const DNA_PAIR = { | |
| 'A': 'T', | |
| 'T': 'A', | |
| 'C': 'G', | |
| 'G': 'C' | |
| }; | |
| return str.split('').map(function(char) { | |
| return [char, DNA_PAIR[char]]; |