Python Todoリスト

class TodoList:
def init(self):
self.tasks = []

def add_task(self, task):
    self.tasks.append(task)

def remove_task(self, task):
    if task in self.tasks:
        self.tasks.remove(task)
    else:
        print("タスクが見つかりません。")

def list_tasks(self):
    if not self.tasks:
        print("ToDoリストは空です。")
    else:
        print("ToDoリスト:")
        for idx, task in enumerate(self.tasks, start=1):
            print(f"{idx}. {task}")

def main():
todo_list = TodoList()
while True:
print(“\n操作を選択してください:”)
print(“1. タスクを追加”)
print(“2. タスクを削除”)
print(“3. タスク一覧を表示”)
print(“4. 終了”)
choice = input(“選択: “)

    if choice == '1':
        task = input("タスクを入力してください: ")
        todo_list.add_task(task)
        print("タスクが追加されました。")

    elif choice == '2':
        task_idx = int(input("削除するタスクの番号を入力してください: "))
        if 1 <= task_idx <= len(todo_list.tasks):
            task_to_remove = todo_list.tasks[task_idx - 1]
            todo_list.remove_task(task_to_remove)
            print("タスクが削除されました。")
        else:
            print("無効な番号です。")

    elif choice == '3':
        todo_list.list_tasks()

    elif choice == '4':
        print("プログラムを終了します。")
        break

    else:
        print("無効な選択です。")

if name == “main“:
main()

Python Webcrawler

import requests
from bs4 import BeautifulSoup

def crawl(url, max_depth=2):
if max_depth < 0:
return

try:
response = requests.get(url)
content = response.content
soup = BeautifulSoup(content, ‘html.parser’)

links = set()

for link in soup.find_all(‘a’):
href = link.get(‘href’)
if href and href.startswith(‘http’):
links.add(href)

print(f”Found {len(links)} links at {url}”)

for link in links:
crawl(link, max_depth – 1)

except requests.RequestException as e:
print(f”Error during requests to {url} : {str(e)}”)

# 使用例
start_url = “https://b.hatena.ne.jp/” # スタートするURL
crawl(start_url, max_depth=2) # 深さ2でクロール

C# interface

interface IPoint
{
int Px
{
get; set;
}
int Py
{
get; set;
}
}

class ReversePoint : IPoint
{
int x;
int y;

public ReversePoint(int x, int y)
{
    this.x = x;
    this.y = y;
}

public int Px
{
    get { return -x; }
    set { x = value; }
}

// Implementing Py similarly to Px
public int Py
{
    get { return -y; } // Return the negative of y
    set { y = value; } // Set y directly
}

}

class MainClass
{
public static void DisplayPoint( IPoint point)
{
Console.WriteLine(“x={0},y={1}”, point.Px, point.Py);
}

static void Main()
{
    ReversePoint p1 = new ReversePoint(-12, -300);

    Console.WriteLine(p1.Px);
    Console.WriteLine(p1.Py);

    ReversePoint p2 = new ReversePoint(12, 300);

    //プロパティの参照
    DisplayPoint(p2);
}

}

ポケモン

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
public float moveSpeed;
public LayerMask solidObjectsLayer;
public LayerMask grassLayer;

private bool isMoving;
private Vector2 input;

private Animator animator;

private void Awake()
{
    animator = GetComponent<Animator>();
}
private void Update()
{
       if (!isMoving)
        {
        input.x = Input.GetAxisRaw("Horizontal");
        input.y = Input.GetAxisRaw("Vertical");

        //remove diagonal movement
        if (input.x != 0) input.y = 0;

        if(input != Vector2.zero)
        {
            animator.SetFloat("moveX", input.x);
            animator.SetFloat("moveY", input.y);
            var targetPos = transform.position;
            targetPos.x += input.x;
            targetPos.y += input.y;

            if(IsWalkable(targetPos))
            StartCoroutine(Move(targetPos));
        }
    }

    animator.SetBool("isMoving", isMoving);
}
IEnumerator Move(Vector3 targetPos)
{
    isMoving = true;

    while ((targetPos - transform.position).sqrMagnitude > Mathf.Epsilon)
    {
        transform.position = Vector3.MoveTowards(transform.position, targetPos, moveSpeed * Time.deltaTime);
        yield return null;
    }
    transform.position = targetPos; // 目標位置に合わせて最終位置を設定

    isMoving = false;

    CheckForEncounters();
}

private bool IsWalkable(Vector3 tagetPos)
{
    if(Physics2D.OverlapCircle(tagetPos, 0.2f, solidObjectsLayer) != null)
    {
        return false;
    }

    return true;
}

private void CheckForEncounters()
{
    if(Physics2D.OverlapCircle(transform.position, 0.2f, grassLayer) != null)
    {
        if(Random.Range(1, 101) <= 10)
        {
            Debug.Log("野生のポケモンに遭遇した");
        }
   
}

}

PlayerController.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(fileName = “ポケモン”, menuName = “ポケモン/新しいポケモンを作成する”)]
public class PokemonBase : ScriptableObject
{
[SerializeField] string name;

[TextArea]
[SerializeField] string description;

[SerializeField] Sprite frontSprite;
[SerializeField] Sprite backSprite;

[SerializeField] PokemonType type1;
[SerializeField] PokemonType type2;

//Base Stats
[SerializeField] int maxHp;
[SerializeField] int attack;
[SerializeField] int defense;
[SerializeField] int spAttack;
[SerializeField] int spDefense;
[SerializeField] int speed;

}

public enum PokemonType
{
None,
Normal,
Fire,
Water,
Electric,
Grass,
Ice,
Fighting,
Poison,
Ground,
Flying,
Psychic,
Bug,
Rock,
Ghost,
Dragon
}

PokemonBase

C# Talk.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Talk : MonoBehaviour
{
public GameObject panel;
public Text txt;
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{

}

void OnTriggerEnter(Collider col)
{
    panel.SetActive(true);
}

}

UNIX コマンド

dotinstall:~ $ ls
dotinstall:~ $ touch index.html
dotinstall:~ $ ls -l
total 0
-rw-r–r– 1 dotinsta wheel 0 Sep 8 21:06 index.html
dotinstall:~ $ rm -index.html
rm: unrecognized option: n
BusyBox v1.31.1 () multi-call binary.

Usage: rm [-irf] FILE…

Remove (unlink) FILEs

    -i      Always prompt before removing
    -f      Never prompt
    -R,-r   Recurse

dotinstall:~ $ ls
index.html
dotinstall:~ $ rm – index.html
rm: can’t remove ‘-‘: No such file or directory
dotinstall:~ $ rm – index.html
rm: can’t remove ‘-‘: No such file or directory
rm: can’t remove ‘index.html’: No such file or directory
dotinstall:~ $ ls
dotinstall:~ $