โจทย์ : http://expert-programming-tutor.com/tutorial/hyperhackathon.php
ป.ล. ไม่ได้ไปแข่ง
require 'prime'; Prime.find { |c| c > 1000000 } #=> 1000003
{ | |
"default_module": "powerline.segments.common", | |
"segment_data": { | |
"uptime": { | |
"before": "⇑ " | |
}, | |
"external_ip": { | |
"before": "ⓦ " | |
}, | |
"date": { |
{ | |
"name": "Default color scheme", | |
"groups": { | |
"background": { "fg": "white", "bg": "gray2" }, | |
"background:divider": { "fg": "gray6", "bg": "gray2" }, | |
"mode": { "fg": "darkestgreen", "bg": "brightgreen", "attr": ["bold"] }, | |
"modified_indicator": { "fg": "brightyellow", "bg": "gray4", "attr": ["bold"] }, | |
"paste_indicator": { "fg": "white", "bg": "mediumorange", "attr": ["bold"] }, | |
"readonly_indicator": { "fg": "gray6", "bg": "gray4" }, | |
"branch": { "fg": "gray9", "bg": "gray4" }, |
{ | |
"name": "Default color scheme for terminal prompts", | |
"groups": { | |
"background:divider": { "fg": "gray5", "bg": "gray0" }, | |
"session": { "fg": "black", "bg": "gray10", "attr": ["bold"] }, | |
"date": { "fg": "gray6", "bg": "gray1" }, | |
"time": { "fg": "gray10", "bg": "gray2", "attr": ["bold"] }, | |
"time:divider": { "fg": "gray5", "bg": "gray2" }, | |
"email_alert": { "fg": "white", "bg": "brightred", "attr": ["bold"] }, | |
"email_alert_gradient": { "fg": "white", "bg": "yellow_orange_red", "attr": ["bold"] }, |
โจทย์ : http://expert-programming-tutor.com/tutorial/hyperhackathon.php
ป.ล. ไม่ได้ไปแข่ง
require 'prime'; Prime.find { |c| c > 1000000 } #=> 1000003
access_token = "..." | |
j = JSON.parse(`curl "https://graph.facebook.com/PeaceandOrderMaintainingCommand/feed?access_token=#{access_token}&limit=1000"`); nil | |
-> times { times.length * 60 / (times.max - times.min) }[j['data'].map { |c| Time.parse(c['created_time']) }] | |
# => 20.285306704707562 |
มีวิธีทำหลายภาษา
/** | |
* INFINITELY DESCENDING CHORD PROGRESSION (v1.1) | |
* | |
* Enjoy this chord progression that loops forever.... | |
* By Thai Pangsakulyanont (https://github.com/dtinth) | |
* | |
* https://gist.github.com/dtinth/11371713 | |
*/ | |
var step = 0.1 |
### | |
# DO YOU HEAR THE PEOPLE SING? (Uplifting Mix) | |
# version 1.3 (clearer kick sound) | |
# | |
# Converted from CoffeeScript | |
# Source: https://gist.github.com/11080149 | |
# Usage: coffee -bcp file.coffee | |
# | |
# Original from Les Miserables |
สมมติว่าเรามีอาร์เรย์อยู่ เราสามารถแทรกข้อมูลที่ตำแหน่งใดก็ได้ใน Array โดยใช้เมธอด Array#insert
แบบนี้
arr = [6, 7, 2, 3]
arr.insert(0, "first")
#=> ["first", 6, 7, 2, 3]
arr.insert(3, "second")