Skip to content

Instantly share code, notes, and snippets.

@torazuka
torazuka / calculator02.cpp
Created September 7, 2011 23:24
Chapter06_drill_PPPC++
//
// This is example code from Chapter 6.7 "Trying the second version" of
// "Software - Principles and Practice using C++" by Bjarne Stroustrup
//
/*
>This file is known as calculator02buggy.cpp
>
>I have inserted 5 errors that should cause this not to compile
@torazuka
torazuka / Main.java
Created June 24, 2012 12:50
鍋谷さんの参考問題: Java解答
package sample;
import java.util.ArrayList;
import java.util.List;
class Card {
char suit;
String rank;
Card() {
@torazuka
torazuka / plotnum.py
Last active April 28, 2022 03:13
To plot ternary numbers which do not contain 1
import matplotlib.pyplot as plt
import math as math
def get_exp(n):
if n <= 0:
return 0
return math.floor(math.log(n, 3))
def conv_to_deci(n):
s = str(n)
@torazuka
torazuka / ex1.rb
Last active January 12, 2016 11:30
オフラインリアルタイムどう書く#参考問題01 Ruby解答
#!/usr/bin/ruby
def is_fourcards (cs)
return cs.has_value?(4)
end
def is_threecards (cs)
return cs.has_value?(3)
end
@torazuka
torazuka / Scheherazade.java
Created January 9, 2014 16:14
第17回オフラインリアルタイムどう書く参考問題の解答
import static org.junit.Assert.assertEquals;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
/**
* Question: http://nabetani.sakura.ne.jp/hena/ord17scheherazade/
@torazuka
torazuka / Boseg.java
Created January 1, 2014 17:20
第16回オフラインリアルタイムどう書くのJava解答(nidouchiさんの解答の再実装)
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
/***
* Question: http://nabetani.sakura.ne.jp/hena/ord16boseg/ -- this answer is a
@torazuka
torazuka / file_colour.diag
Created November 10, 2013 17:51
The file include tree of memory directory in JVM HotSpot
blockdiag {
default_fontsize = 14;
allocation [color = "#ff0000"];
generation, heap, iterator, memRegion, resourceArea, space, watermark [color = "#ff9900"];
// include generation
generationSpec, compactPermGen, genCollectedHeap, "generation.inline", "genOopClosures.inline", permGen, sharedHeap, tenuredGeneration [color = "#ffff00"];
// include iterator
genOopClosures, permGen [color = "#ffff00"];
// include memRegion
@torazuka
torazuka / classes.diag
Created November 10, 2013 17:23
The class inheritance tree of memory directory in JVM HotSpot
blockdiag {
default_fontsize = 14;
ResourceObj -> AllocatedObj;
AllocStats, ReallocMark -> StackObj;
Chunk, Arena -> CHeapObj;
SharedHeap [color = "#FFFFFF"];
GenClosure -> StackObj;
GenCollectedHeap -> SharedHeap -> CollectedHeap -> CHeapObj;
@torazuka
torazuka / AllStatic_tree.diag
Created November 10, 2013 17:05
The important class inheritance trees of the allocation.hpp(JVM HotSpot)
blockdiag {
default_fontsize = 14;
AllStatic [color = "#FF9999"];
Universe -> AllStatic;
oopFactory -> AllStatic;
GenMarkSweep -> MarkSweep -> AllStatic;
HeapInspection -> AllStatic;
@torazuka
torazuka / Elebubo.java
Last active December 27, 2015 05:38
第15回オフラインリアルタイムどう書くのJava解答
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import org.junit.Test;
enum Rune {
U(3, new char[] { '1', '0', '1' }, new char[] { '1', '1', '1' }), N(3,
new char[] { '1', '1', '1' }, new char[] { '1', '0', '1' }), S(3,