This file contains 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
// wordpressの投稿の一括変換の依頼が来たので変換のスクリプトを書いた。 | |
var fs = require('fs') | |
// 行をまたいで置換を行うために、対象があるかぎり再帰的に置換する関数 | |
function rereg(str, reg, newStr) { | |
if(!reg.test(str)) return str; | |
return rereg(str.replace(reg, newStr), reg, newStr); | |
} | |
fs.readFile('input.txt', 'utf8', function (err,data) { |
This file contains 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
3.times{|i| | |
p i | |
} | |
# out => | |
# 0 | |
# 1 | |
# 2 |
This file contains 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
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> | |
<script type="text/javascript"> | |
function calcPayment(loan, termRate, numberOfTerms, loanType, count){ | |
if (count < 1) return 0; | |
if (loanType == "payment_equal") { | |
return calcPaymentEqual(loan, termRate, numberOfTerms) * count; | |
}else{ | |
return calcPrincipalEqual(loan, termRate, numberOfTerms) | |
+ calcPayment(loan * (numberOfTerms - 1) / numberOfTerms, termRate, numberOfTerms - 1, loanType, count - 1); |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
public static class Extension{ | |
// var list = new char[] {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}; | |
// 1.To(5).Select(i => list[i]).ToList().ForEach(c => Console.Write(c)); | |
// out => bcdef | |
public static IEnumerable<int> To(this int from, int to){ | |
return Enumerable.Range(from, to - from + 1); |
This file contains 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
public class Scanner{ | |
private string line; | |
private string[] token; | |
private int cursole = 0; | |
public string ReadLine(){ | |
line = Console.ReadLine(); | |
token = line.Split(' '); | |
cursole = 0; | |
return line; |
This file contains 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
<!DOCTYPE> | |
<html lang="ja"> | |
<head> | |
<meta charset="utf-8"> | |
<title>TextQuest</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> | |
<script type="text/javascript" > | |
// これ見てて作りたくなった。 | |
// https://teratail.com/questions/13308 | |
// fieldの定義はうまく言ったと思うが、コードは汚い |
This file contains 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
using System; | |
static class Heapsort{ | |
struct Node{ | |
public int[] List; | |
public int Root_i; | |
public int Bottom_i; | |
public int Root{ | |
get{return this.List[this.Root_i];} | |
} |
This file contains 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
using System; | |
static class MargeSort{ | |
static int[] Sort(this int[] list){ | |
InnerMargesort(list,new int[list.Length], 0, list.Length - 1); | |
return list; | |
} | |
static void InnerMargesort(int[] list, int[] temp, int lh, int rh){ | |
if (rh <= lh) return; | |
var mid = (lh + rh)/2; |
This file contains 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
using System; | |
static class selectSort{ | |
static int[] Sort(this int[] list){ | |
for(var i = 0; i < list.Length - 1; ++i){ | |
int min = i + 1; | |
for(var j = i; j < list.Length; ++j) | |
if (list[j] < list[min]) min = j; | |
list.Swap(min, i); | |
} |
This file contains 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
using System; | |
static class ShellSort{ | |
static int[] Sort(this int[] list){ | |
list.InnerSort(list.Length / 2); | |
return list; | |
} | |
static void InnerSort(this int[] list, int gap){ | |
if(gap < 1) return; |
NewerOlder