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
Show hidden characters
/** | |
* 果物の商品データをJSONCで記述したもの | |
* JSONCのサンプル | |
*/ | |
[ | |
// マンゴー | |
{"名称": "沖縄マンゴー", "値段": 3240, "産地": "沖縄"}, | |
// ミカン | |
{"名称": "愛媛ミカン", "値段": 3200, "産地": "愛媛"}, | |
// 梨 |
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> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>電卓アプリ</title> | |
<style> | |
input[type="text"] { | |
padding: 10px; | |
font-size: 24px; | |
border: 1px solid #ccc; |
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
use std::io::Write; | |
fn main() { // メイン処理 --- (*1) | |
let data = make_bitmap(8, 8); // 画像を作成 | |
let mut f = std::fs::File::create("test.bmp").unwrap(); // ファイル生成 | |
f.write(&data).unwrap(); // ファイルに書き出す | |
println!("画像を書き出しました。"); | |
} | |
// ビットマップ画像データを作成する --- (*2) | |
fn make_bitmap(width: u32, height: u32) -> Vec<u8> { | |
let mut data = vec![]; |
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
import random | |
import pygame | |
# 迷路をランダムに自動生成する | |
# - 迷路の壁は1、通路は0とする | |
# - 迷路のサイズはwidth * heightとする | |
# - 座標(1,1)をスタート地点とする | |
# - 座標(width-2,height-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
import random | |
import pygame | |
# 迷路をランダムに自動生成する | |
# - 迷路の壁は1、通路は0とする | |
# - 迷路のサイズはwidth * heightとする | |
# - 座標(1,1)をスタート地点とする | |
# - 座標(width-2,height-2)をゴール地点とする | |
# 次の手順で迷路を完成させる | |
# 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
use image::{imageops, ImageBuffer}; | |
const ROAD: u8 = 0; // 道を表す値 | |
const WALL: u8 = 1; // 壁を表す値 | |
// 迷路自動生成する関数 | |
fn make_maze(width: usize, height: usize) -> Vec<u8> { | |
// 迷路データを壁で初期化 | |
let mut maze = vec![]; | |
for _ in 0..(width * height) { |
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
import os, sys, re | |
# ファイルを分割する関数 --- (*1) | |
def split_file(file_path, chunk_size): | |
# ファイルを開く --- (*2) | |
with open(file_path, 'rb') as f: | |
fileno = 0 | |
chunk = f.read(chunk_size) # 分割サイズ分読み込む --- (*3) | |
while chunk: | |
# 出力ファイル名を決める --- (*4) |
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
--[[ | |
【お題】 | |
次のようなプログラムをLuaで作ってください。 | |
財布の中に硬貨があります。 | |
1640円を支払いたいのですが、最も少ない枚数で支払える組合せを求めたいです。 | |
なお、財布の中には次の枚数の硬貨があるものとし、値をテーブルで指定してください。 | |
・500円硬貨が5枚 | |
・100円硬貨が20枚 | |
・50円硬貨が8枚 |
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><html><head> | |
<meta name="viewport" content="width=device-width,initial-scale=1"> | |
<body style="background-color: black;"> | |
<!-- 花火を描画するキャンバス--> | |
<canvas id="fireworks" width="400" height="400" | |
style="border: 1px solid silver;"></canvas> | |
</body> | |
<script> | |
// HTMLの<canvas>要素を取得 | |
const canvas = document.getElementById('fireworks'); |
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
/* | |
file: Cargo.tml | |
[dependencies] | |
rustysynth = "1.2.0" | |
tinyaudio = "0.1.1" | |
*/ | |
use rustysynth::{SoundFont, Synthesizer, SynthesizerSettings}; | |
use std::fs::File; | |
use std::sync::Arc; |