Skip to content

Instantly share code, notes, and snippets.

@RQN
RQN / BinarySearch.cs
Last active November 11, 2018 16:39
二分探索がしたい
// using System;
// using System.Collections.Generic;
// using System.Linq;
public static class BinarySearch
{
/// <summary>
/// 指定された範囲の中央位置を取得します。小数点以下は切り上げます。
/// </summary>
private static int GetCenterIndex(int start, int last)
@RQN
RQN / CharacterArt.cs
Last active November 11, 2018 16:32
ちろちろのパクり
// using System.Collections.Generic;
public static class CharacterArt
{
public static IEnumerable<Item> Diamond(int size)
{
for (int i = 0; i < size; i++)
{
yield return new Item
{
@RQN
RQN / RepeatedPermutation.cs
Last active August 28, 2016 09:58
重複順列
using System;
using System.Collections.Generic;
namespace RQN
{
public static class RepeatedPermutation
{
/// <summary>
/// 指定した文字を使用して、指定した長さの重複順列を生成します。
/// </summary>
@RQN
RQN / Random.cs
Last active November 11, 2018 16:34
乱数生成
// using System;
// using System.Security.Cryptography;
public static class Random
{
/// <summary>
/// 指定された最大値より小さい 0 以上のランダムな整数を返します。
/// </summary>
public static int GetRandomNumber(int maxValue = int.MaxValue)
{
@RQN
RQN / Generate.cs
Last active November 11, 2018 16:38
重複順列(再帰)
// using System.Collections.Generic;
static IEnumerable<string> Generate(string[] keyword, int length)
{
if (length > 1)
{
foreach (var key in keyword)
{
foreach (var key2 in Generate(keyword, length - 1))
{